5 * \defgroup RoomOps Lots of different room-related operations.
6 * \ingroup CitadelCommunitacion
11 char floorlist[128][SIZ]; /**< list of our floor names */
13 char *viewdefs[7]; /**< the different kinds of available views */
16 * \brief initialize the viewdefs with localized strings
18 void initialize_viewdefs(void) {
19 viewdefs[0] = _("Bulletin Board");
20 viewdefs[1] = _("Mail Folder");
21 viewdefs[2] = _("Address Book");
22 viewdefs[3] = _("Calendar");
23 viewdefs[4] = _("Task List");
24 viewdefs[5] = _("Notes List");
25 viewdefs[6] = _("Wiki");
30 * \brief load the list of floors
32 void load_floorlist(void)
37 for (a = 0; a < 128; ++a)
41 serv_getln(buf, sizeof buf);
43 strcpy(floorlist[0], "Main Floor");
46 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
47 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
53 * \brief remove a room from the march list
55 void remove_march(char *aaa)
57 struct march *mptr, *mptr2;
59 if (WC->march == NULL)
62 if (!strcasecmp(WC->march->march_name, aaa)) {
63 mptr = WC->march->next;
69 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
70 if (!strcasecmp(mptr->march_name, aaa)) {
71 mptr2->next = mptr->next;
84 * \brief display rooms in tree structure???
85 * \param rp the roomlist to build a tree from
87 void room_tree_list(struct roomlisting *rp)
96 room_tree_list(rp->lnext);
98 strcpy(rmname, rp->rlname);
101 wprintf("<a href=\"dotgoto&room=");
105 escputs1(rmname, 1, 1);
106 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
108 else if (f & QR_DIRECTORY)
110 else if (f & QR_NETWORK)
114 wprintf("</A><TT> </TT>\n");
116 room_tree_list(rp->rnext);
122 * \brief Room ordering stuff (compare first by floor, then by order)
123 * \param r1 first roomlist to compare
124 * \param r2 second roomlist co compare
125 * \return are they the same???
127 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
129 if ((r1 == NULL) && (r2 == NULL))
135 if (r1->rlfloor < r2->rlfloor)
137 if (r1->rlfloor > r2->rlfloor)
139 if (r1->rlorder < r2->rlorder)
141 if (r1->rlorder > r2->rlorder)
148 * \brief Common code for all room listings
149 * \param variety what???
151 void listrms(char *variety)
156 struct roomlisting *rl = NULL;
157 struct roomlisting *rp;
158 struct roomlisting *rs;
161 /** Ask the server for a room list */
163 serv_getln(buf, sizeof buf);
168 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
170 rp = malloc(sizeof(struct roomlisting));
171 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
172 rp->rlflags = extract_int(buf, 1);
173 rp->rlfloor = extract_int(buf, 2);
174 rp->rlorder = extract_int(buf, 3);
183 if (rordercmp(rp, rs) < 0) {
184 if (rs->lnext == NULL) {
191 if (rs->rnext == NULL) {
204 * If no rooms were listed, print an nbsp to make the cell
205 * borders show up anyway.
207 if (num_rooms == 0) wprintf(" ");
212 * \brief list all forgotten rooms
214 void zapped_list(void)
216 output_headers(1, 1, 0, 0, 0, 0);
218 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
219 do_template("beginbox");
223 wprintf("<br /><br />\n");
224 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
225 do_template("endbox");
231 * \brief read this room's info file (set v to 1 for verbose mode)
238 serv_getln(buf, sizeof buf);
251 * \brief Display room banner icon.
252 * The server doesn't actually
253 * need the room name, but we supply it in order to
254 * keep the browser from using a cached icon from
257 void embed_room_graphic(void) {
260 serv_puts("OIMG _roompic_");
261 serv_getln(buf, sizeof buf);
263 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
264 urlescputs(WC->wc_roomname);
267 serv_getln(buf, sizeof buf);
269 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
270 wprintf("<img height=48 width=48 src=\""
271 "static/viewcontacts_48x.gif"
275 else if (WC->wc_view == VIEW_CALENDAR) {
276 wprintf("<img height=48 width=48 src=\""
277 "static/calarea_48x.gif"
281 else if (WC->wc_view == VIEW_TASKS) {
282 wprintf("<img height=48 width=48 src=\""
283 "static/taskmanag_48x.gif"
287 else if (WC->wc_view == VIEW_NOTES) {
288 wprintf("<img height=48 width=48 src=\""
289 "static/storenotes_48x.gif"
293 else if (WC->wc_view == VIEW_MAILBOX) {
294 wprintf("<img height=48 width=48 src=\""
295 "static/privatemess_48x.gif"
300 wprintf("<img height=48 width=48 src=\""
301 "static/chatrooms_48x.gif"
311 * \brief Display the current view and offer an option to change it
313 void embed_view_o_matic(void) {
316 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
317 "<span class=\"room_banner_new_messages\">");
318 wprintf(_("View as:"));
320 "<SELECT NAME=\"newview\" SIZE=\"1\" "
321 "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif;"
322 " font-size: 7pt; background: #444455; color: #ddddcc;\" "
323 "OnChange=\"location.href=viewomatic.newview.options"
324 "[selectedIndex].value\">\n");
326 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
328 * Only offer the views that make sense, given the default
329 * view for the room. For example, don't offer a Calendar
330 * view in a non-Calendar room.
334 || (i == WC->wc_default_view)
335 || ( (i == 0) && (WC->wc_default_view == 1) )
336 || ( (i == 1) && (WC->wc_default_view == 0) )
339 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
340 ((i == WC->wc_view) ? "SELECTED" : ""),
342 escputs(viewdefs[i]);
343 wprintf("</OPTION>\n");
346 wprintf("</select></span></form>\n");
351 * \brief view room banner
353 * \param navbar_style
355 void embed_room_banner(char *got, int navbar_style) {
359 * We need to have the information returned by a GOTO server command.
360 * If it isn't supplied, we fake it by issuing our own GOTO.
363 serv_printf("GOTO %s", WC->wc_roomname);
364 serv_getln(buf, sizeof buf);
368 /** The browser needs some information for its own use */
369 wprintf("<script type=\"text/javascript\"> \n"
370 " room_is_trash = %d; \n"
376 * If the user happens to select the "make this my start page" link,
377 * we want it to remember the URL as a "/dotskip" one instead of
378 * a "skip" or "gotonext" or something like that.
380 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
383 /** Check for new mail. */
384 WC->new_mail = extract_int(&got[4], 9);
385 WC->wc_view = extract_int(&got[4], 11);
387 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
388 svprintf("NUMMSGS", WCS_STRING,
389 _("%d new of %d messages"),
390 extract_int(&got[4], 1),
391 extract_int(&got[4], 2)
393 svcallback("ROOMPIC", embed_room_graphic);
394 svcallback("ROOMINFO", readinfo);
395 svcallback("VIEWOMATIC", embed_view_o_matic);
396 svcallback("START", offer_start_page);
398 do_template("roombanner");
399 if (navbar_style != navbar_none) {
401 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
402 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
405 if (navbar_style == navbar_default) wprintf(
407 "<a href=\"ungoto\">"
408 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
409 "<span class=\"navbar_link\">%s</span></A>"
410 "</td>\n", _("Ungoto")
413 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
416 "<a href=\"readnew\">"
417 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
418 "<span class=\"navbar_link\">%s</span></A>"
419 "</td>\n", _("Read new messages")
423 if (navbar_style == navbar_default) {
424 switch(WC->wc_view) {
425 case VIEW_ADDRESSBOOK:
428 "<a href=\"readfwd\">"
429 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
431 "<span class=\"navbar_link\">"
433 "</span></a></td>\n", _("View contacts")
439 "<a href=\"readfwd?calview=day\">"
440 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
442 "<span class=\"navbar_link\">"
444 "</span></a></td>\n", _("Day view")
448 "<a href=\"readfwd?calview=month\">"
449 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
451 "<span class=\"navbar_link\">"
453 "</span></a></td>\n", _("Month view")
459 "<a href=\"readfwd\">"
460 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
462 "<span class=\"navbar_link\">"
464 "</span></a></td>\n", _("View tasks")
470 "<a href=\"readfwd\">"
471 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
473 "<span class=\"navbar_link\">"
475 "</span></a></td>\n", _("View notes")
481 "<a href=\"readfwd\">"
482 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
484 "<span class=\"navbar_link\">"
486 "</span></a></td>\n", _("View message list")
492 "<a href=\"readfwd\">"
493 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
495 "<span class=\"navbar_link\">"
497 "</span></a></td>\n", _("Wiki home")
503 "<a href=\"readfwd\">"
504 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
506 "<span class=\"navbar_link\">"
508 "</span></a></td>\n", _("Read all messages")
514 if (navbar_style == navbar_default) {
515 switch(WC->wc_view) {
516 case VIEW_ADDRESSBOOK:
518 "<td><a href=\"display_enter\">"
519 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
520 "border=\"0\"><span class=\"navbar_link\">"
522 "</span></a></td>\n", _("Add new contact")
527 "<td><a href=\"display_enter\">"
528 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
529 "border=\"0\"><span class=\"navbar_link\">"
531 "</span></a></td>\n", _("Add new event")
536 "<td><a href=\"display_enter\">"
537 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
538 "border=\"0\"><span class=\"navbar_link\">"
540 "</span></a></td>\n", _("Add new task")
545 "<td><a href=\"javascript:add_new_note();\">"
546 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
547 "border=\"0\"><span class=\"navbar_link\">"
549 "</span></a></td>\n", _("Add new note")
553 safestrncpy(buf, bstr("page"), sizeof buf);
556 "<td><a href=\"display_enter?wikipage=%s\">"
557 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
558 "border=\"0\"><span class=\"navbar_link\">"
560 "</span></a></td>\n", buf, _("Edit this page")
565 "<td><a href=\"display_enter\">"
566 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
567 "border=\"0\"><span class=\"navbar_link\">"
569 "</span></a></td>\n", _("Enter a message")
575 if (navbar_style == navbar_default) wprintf(
579 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
580 "<span class=\"navbar_link\">%s</span></a>"
582 _("Leave all messages marked as unread, go to next room with unread messages"),
586 if (navbar_style == navbar_default) wprintf(
588 "<a href=\"gotonext\" "
590 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
591 "<span class=\"navbar_link\">%s</span></a>"
593 _("Mark all messages as read, go to next room with unread messages"),
597 wprintf("</tr></table></div>\n");
607 * \brief back end routine to take the session to a new room
608 * \param gname room to go to
611 int gotoroom(char *gname)
614 static long ls = (-1L);
617 /** store ungoto information */
618 strcpy(WC->ugname, WC->wc_roomname);
621 /** move to the new room */
622 serv_printf("GOTO %s", gname);
623 serv_getln(buf, sizeof buf);
627 serv_puts("GOTO _BASEROOM_");
628 serv_getln(buf, sizeof buf);
635 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
636 WC->room_flags = extract_int(&buf[4], 4);
637 /* highest_msg_read = extract_int(&buf[4],6);
638 maxmsgnum = extract_int(&buf[4],5);
640 WC->is_mailbox = extract_int(&buf[4],7);
641 ls = extract_long(&buf[4], 6);
642 WC->wc_floor = extract_int(&buf[4], 10);
643 WC->wc_view = extract_int(&buf[4], 11);
644 WC->wc_default_view = extract_int(&buf[4], 12);
645 WC->wc_is_trash = extract_int(&buf[4], 13);
648 WC->is_room_aide = WC->is_aide;
650 WC->is_room_aide = (char) extract_int(&buf[4], 8);
652 remove_march(WC->wc_roomname);
653 if (!strcasecmp(gname, "_BASEROOM_"))
661 * \brief Locate the room on the march list which we most want to go to.
663 * is measured given a "weight" of preference based on various factors.
664 * \param desired_floor the room number on the citadel server
665 * \return the roomname
667 char *pop_march(int desired_floor)
669 static char TheRoom[128];
671 int TheOrder = 32767;
674 struct march *mptr = NULL;
676 strcpy(TheRoom, "_BASEROOM_");
677 if (WC->march == NULL)
680 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
682 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
683 weight = weight + 10000;
684 if (mptr->march_floor == desired_floor)
685 weight = weight + 5000;
687 weight = weight + ((128 - (mptr->march_floor)) * 128);
688 weight = weight + (128 - (mptr->march_order));
690 if (weight > TheWeight) {
692 strcpy(TheRoom, mptr->march_name);
693 TheFloor = mptr->march_floor;
694 TheOrder = mptr->march_order;
703 *\brief Goto next room having unread messages.
704 * We want to skip over rooms that the user has already been to, and take the
705 * user back to the lobby when done. The room we end up in is placed in
706 * newroom - which is set to 0 (the lobby) initially.
707 * We start the search in the current room rather than the beginning to prevent
708 * two or more concurrent users from dragging each other back to the same room.
713 struct march *mptr, *mptr2;
717 * First check to see if the march-mode list is already allocated.
718 * If it is, pop the first room off the list and go there.
721 if (WC->march == NULL) {
723 serv_getln(buf, sizeof buf);
725 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
726 mptr = (struct march *) malloc(sizeof(struct march));
728 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
729 mptr->march_floor = extract_int(buf, 2);
730 mptr->march_order = extract_int(buf, 3);
731 if (WC->march == NULL) {
735 while (mptr2->next != NULL)
741 * add _BASEROOM_ to the end of the march list, so the user will end up
742 * in the system base room (usually the Lobby>) at the end of the loop
744 mptr = (struct march *) malloc(sizeof(struct march));
746 strcpy(mptr->march_name, "_BASEROOM_");
747 if (WC->march == NULL) {
751 while (mptr2->next != NULL)
756 * ...and remove the room we're currently in, so a <G>oto doesn't make us
757 * walk around in circles
759 remove_march(WC->wc_roomname);
761 if (WC->march != NULL) {
762 strcpy(next_room, pop_march(-1));
764 strcpy(next_room, "_BASEROOM_");
768 smart_goto(next_room);
773 * \brief goto next room
774 * \param next_room next room to go to
776 void smart_goto(char *next_room) {
784 * \brief mark all messages in current room as having been read
786 void slrp_highest(void)
791 serv_puts("SLRP HIGHEST");
792 serv_getln(buf, sizeof buf);
794 wprintf("<EM>%s</EM><br />\n", &buf[4]);
801 * \brief un-goto the previous room
807 if (!strcmp(WC->ugname, "")) {
808 smart_goto(WC->wc_roomname);
811 serv_printf("GOTO %s", WC->ugname);
812 serv_getln(buf, sizeof buf);
814 smart_goto(WC->wc_roomname);
817 if (WC->uglsn >= 0L) {
818 serv_printf("SLRP %ld", WC->uglsn);
819 serv_getln(buf, sizeof buf);
821 strcpy(buf, WC->ugname);
822 strcpy(WC->ugname, "");
831 * \brief Set/clear/read the "self-service list subscribe" flag for a room
833 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
834 * \return return the new value.
837 int self_service(int newval) {
838 int current_value = 0;
844 int flags, floor, order, view, flags2;
847 serv_getln(buf, sizeof buf);
848 if (buf[0] != '2') return(0);
850 extract_token(name, &buf[4], 0, '|', sizeof name);
851 extract_token(password, &buf[4], 1, '|', sizeof password);
852 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
853 flags = extract_int(&buf[4], 3);
854 floor = extract_int(&buf[4], 4);
855 order = extract_int(&buf[4], 5);
856 view = extract_int(&buf[4], 6);
857 flags2 = extract_int(&buf[4], 7);
859 if (flags2 & QR2_SELFLIST) {
867 flags2 = flags2 | QR2_SELFLIST;
869 else if (newval == 0) {
870 flags2 = flags2 & ~QR2_SELFLIST;
873 return(current_value);
876 if (newval != current_value) {
877 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
878 name, password, dirname, flags,
879 floor, order, view, flags2);
880 serv_getln(buf, sizeof buf);
893 * \brief display the form for editing a room
895 void display_editroom(void)
900 char remote_room[SIZ];
903 char er_password[10];
905 char er_roomaide[26];
911 char *not_shared_with;
918 if (strlen(tab) == 0) tab = "admin";
922 serv_getln(buf, sizeof buf);
925 strcpy(WC->ImportantMessage, &buf[4]);
929 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
930 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
931 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
932 er_flags = extract_int(&buf[4], 3);
933 er_floor = extract_int(&buf[4], 4);
935 output_headers(1, 1, 1, 0, 0, 0);
937 /** print the tabbed dialog */
939 "<div class=\"fix_scrollbar_bug\">"
940 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
942 "<TD> </TD>\n");
944 if (!strcmp(tab, "admin")) {
945 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
948 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
950 wprintf(_("Administration"));
951 if (!strcmp(tab, "admin")) {
952 wprintf("</SPAN></TD>\n");
955 wprintf("</A></TD>\n");
958 wprintf("<TD> </TD>\n");
960 if (!strcmp(tab, "config")) {
961 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
964 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
966 wprintf(_("Configuration"));
967 if (!strcmp(tab, "config")) {
968 wprintf("</SPAN></TD>\n");
971 wprintf("</A></TD>\n");
974 wprintf("<TD> </TD>\n");
976 if (!strcmp(tab, "expire")) {
977 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
980 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
982 wprintf(_("Message expire policy"));
983 if (!strcmp(tab, "expire")) {
984 wprintf("</SPAN></TD>\n");
987 wprintf("</A></TD>\n");
990 wprintf("<TD> </TD>\n");
992 if (!strcmp(tab, "access")) {
993 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
996 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
998 wprintf(_("Access controls"));
999 if (!strcmp(tab, "access")) {
1000 wprintf("</SPAN></TD>\n");
1003 wprintf("</A></TD>\n");
1006 wprintf("<TD> </TD>\n");
1008 if (!strcmp(tab, "sharing")) {
1009 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1012 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
1014 wprintf(_("Sharing"));
1015 if (!strcmp(tab, "sharing")) {
1016 wprintf("</SPAN></TD>\n");
1019 wprintf("</A></TD>\n");
1022 wprintf("<TD> </TD>\n");
1024 if (!strcmp(tab, "listserv")) {
1025 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1028 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
1030 wprintf(_("Mailing list service"));
1031 if (!strcmp(tab, "listserv")) {
1032 wprintf("</SPAN></TD>\n");
1035 wprintf("</A></TD>\n");
1038 wprintf("<TD> </TD>\n");
1040 wprintf("</TR></TABLE></div>\n");
1041 /** end tabbed dialog */
1043 /** begin content of whatever tab is open now */
1044 wprintf("<div class=\"fix_scrollbar_bug\">"
1045 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
1048 if (!strcmp(tab, "admin")) {
1050 "<LI><a href=\"delete_room\" "
1051 "onClick=\"return confirm('");
1052 wprintf(_("Are you sure you want to delete this room?"));
1053 wprintf("');\">\n");
1054 wprintf(_("Delete this room"));
1056 "<LI><a href=\"display_editroompic\">\n");
1057 wprintf(_("Set or change the icon for this room's banner"));
1059 "<LI><a href=\"display_editinfo\">\n");
1060 wprintf(_("Edit this room's Info file"));
1065 if (!strcmp(tab, "config")) {
1066 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1068 wprintf("<UL><LI>");
1069 wprintf(_("Name of room: "));
1070 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1076 wprintf(_("Resides on floor: "));
1077 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1078 for (i = 0; i < 128; ++i)
1079 if (strlen(floorlist[i]) > 0) {
1080 wprintf("<OPTION ");
1082 wprintf("SELECTED ");
1083 wprintf("VALUE=\"%d\">", i);
1084 escputs(floorlist[i]);
1085 wprintf("</OPTION>\n");
1087 wprintf("</SELECT>\n");
1090 wprintf(_("Type of room:"));
1093 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1094 if ((er_flags & QR_PRIVATE) == 0)
1095 wprintf("CHECKED ");
1097 wprintf(_("Public room"));
1100 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1101 if ((er_flags & QR_PRIVATE) &&
1102 (er_flags & QR_GUESSNAME))
1103 wprintf("CHECKED ");
1105 wprintf(_("Private - guess name"));
1107 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1108 if ((er_flags & QR_PRIVATE) &&
1109 (er_flags & QR_PASSWORDED))
1110 wprintf("CHECKED ");
1112 wprintf(_("Private - require password:"));
1113 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1116 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1117 if ((er_flags & QR_PRIVATE)
1118 && ((er_flags & QR_GUESSNAME) == 0)
1119 && ((er_flags & QR_PASSWORDED) == 0))
1120 wprintf("CHECKED ");
1122 wprintf(_("Private - invitation only"));
1124 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1126 wprintf(_("If private, cause current users to forget room"));
1128 wprintf("\n</UL>\n");
1130 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1131 if (er_flags & QR_PREFONLY)
1132 wprintf("CHECKED ");
1134 wprintf(_("Preferred users only"));
1136 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1137 if (er_flags & QR_READONLY)
1138 wprintf("CHECKED ");
1140 wprintf(_("Read-only room"));
1142 /** directory stuff */
1143 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1144 if (er_flags & QR_DIRECTORY)
1145 wprintf("CHECKED ");
1147 wprintf(_("File directory room"));
1149 wprintf("\n<UL><LI>");
1150 wprintf(_("Directory name: "));
1151 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1154 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1155 if (er_flags & QR_UPLOAD)
1156 wprintf("CHECKED ");
1158 wprintf(_("Uploading allowed"));
1160 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1161 if (er_flags & QR_DOWNLOAD)
1162 wprintf("CHECKED ");
1164 wprintf(_("Downloading allowed"));
1166 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1167 if (er_flags & QR_VISDIR)
1168 wprintf("CHECKED ");
1170 wprintf(_("Visible directory"));
1173 /** end of directory stuff */
1175 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1176 if (er_flags & QR_NETWORK)
1177 wprintf("CHECKED ");
1179 wprintf(_("Network shared room"));
1181 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1182 if (er_flags & QR_PERMANENT)
1183 wprintf("CHECKED ");
1185 wprintf(_("Permanent (does not auto-purge)"));
1187 /** start of anon options */
1190 wprintf(_("Anonymous messages"));
1193 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1194 if (((er_flags & QR_ANONONLY) == 0)
1195 && ((er_flags & QR_ANONOPT) == 0))
1196 wprintf("CHECKED ");
1198 wprintf(_("No anonymous messages"));
1200 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1201 if (er_flags & QR_ANONONLY)
1202 wprintf("CHECKED ");
1204 wprintf(_("All messages are anonymous"));
1206 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1207 if (er_flags & QR_ANONOPT)
1208 wprintf("CHECKED ");
1210 wprintf(_("Prompt user when entering messages"));
1213 /* end of anon options */
1216 wprintf(_("Room aide: "));
1218 serv_getln(buf, sizeof buf);
1219 if (buf[0] != '2') {
1220 wprintf("<EM>%s</EM>\n", &buf[4]);
1222 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1223 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1226 wprintf("</UL><CENTER>\n");
1227 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1228 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1230 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1238 /** Sharing the room with other Citadel nodes... */
1239 if (!strcmp(tab, "sharing")) {
1241 shared_with = strdup("");
1242 not_shared_with = strdup("");
1244 /** Learn the current configuration */
1245 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1246 serv_getln(buf, sizeof buf);
1247 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1248 extract_token(node, buf, 0, '|', sizeof node);
1249 not_shared_with = realloc(not_shared_with,
1250 strlen(not_shared_with) + 32);
1251 strcat(not_shared_with, node);
1252 strcat(not_shared_with, "\n");
1256 serv_getln(buf, sizeof buf);
1257 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1258 extract_token(cmd, buf, 0, '|', sizeof cmd);
1259 extract_token(node, buf, 1, '|', sizeof node);
1260 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1261 if (!strcasecmp(cmd, "ignet_push_share")) {
1262 shared_with = realloc(shared_with,
1263 strlen(shared_with) + 32);
1264 strcat(shared_with, node);
1265 if (strlen(remote_room) > 0) {
1266 strcat(shared_with, "|");
1267 strcat(shared_with, remote_room);
1269 strcat(shared_with, "\n");
1273 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1274 extract_token(buf, shared_with, i, '\n', sizeof buf);
1275 extract_token(node, buf, 0, '|', sizeof node);
1276 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1277 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1278 if (!strcasecmp(node, cmd)) {
1279 remove_token(not_shared_with, j, '\n');
1284 /** Display the stuff */
1285 wprintf("<CENTER><br />"
1286 "<TABLE border=1 cellpadding=5><TR>"
1288 wprintf(_("Shared with"));
1289 wprintf("</I></B></TD>"
1291 wprintf(_("Not shared with"));
1292 wprintf("</I></B></TD></TR>\n"
1293 "<TR><TD VALIGN=TOP>\n");
1295 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1296 wprintf(_("Remote node name"));
1297 wprintf("</TD><TD>");
1298 wprintf(_("Remote room name"));
1299 wprintf("</TD><TD>");
1300 wprintf(_("Actions"));
1301 wprintf("</TD></TR>\n");
1303 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1304 extract_token(buf, shared_with, i, '\n', sizeof buf);
1305 extract_token(node, buf, 0, '|', sizeof node);
1306 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1307 if (strlen(node) > 0) {
1308 wprintf("<FORM METHOD=\"POST\" "
1309 "action=\"netedit\">"
1310 "<TR><TD>%s</TD>\n", node);
1313 if (strlen(remote_room) > 0) {
1314 escputs(remote_room);
1320 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1321 "VALUE=\"ignet_push_share|");
1323 if (strlen(remote_room) > 0) {
1325 urlescputs(remote_room);
1328 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1329 "VALUE=\"sharing\">\n");
1330 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1331 "VALUE=\"remove\">\n");
1332 wprintf("<INPUT TYPE=\"submit\" "
1333 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1334 wprintf("</TD></TR></FORM>\n");
1338 wprintf("</TABLE>\n");
1339 wprintf("</TD><TD VALIGN=TOP>\n");
1340 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1341 wprintf(_("Remote node name"));
1342 wprintf("</TD><TD>");
1343 wprintf(_("Remote room name"));
1344 wprintf("</TD><TD>");
1345 wprintf(_("Actions"));
1346 wprintf("</TD></TR>\n");
1348 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1349 extract_token(node, not_shared_with, i, '\n', sizeof node);
1350 if (strlen(node) > 0) {
1351 wprintf("<FORM METHOD=\"POST\" "
1352 "action=\"netedit\">"
1356 "<INPUT TYPE=\"INPUT\" "
1360 wprintf("<INPUT TYPE=\"hidden\" "
1362 "VALUE=\"ignet_push_share|");
1365 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1366 "VALUE=\"sharing\">\n");
1367 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1368 "VALUE=\"add\">\n");
1369 wprintf("<INPUT TYPE=\"submit\" "
1370 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1371 wprintf("</TD></TR></FORM>\n");
1375 wprintf("</TABLE>\n");
1376 wprintf("</TD></TR>"
1377 "</TABLE></CENTER><br />\n"
1378 "<I><B>%s</B><UL><LI>", _("Notes:"));
1379 wprintf(_("When sharing a room, "
1380 "it must be shared from both ends. Adding a node to "
1381 "the 'shared' list sends messages out, but in order to"
1382 " receive messages, the other nodes must be configured"
1383 " to send messages out to your system as well. "
1384 "<LI>If the remote room name is blank, it is assumed "
1385 "that the room name is identical on the remote node."
1386 "<LI>If the remote room name is different, the remote "
1387 "node must also configure the name of the room here."
1393 /** Mailing list management */
1394 if (!strcmp(tab, "listserv")) {
1396 wprintf("<br /><center>"
1397 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1398 "<TR><TD VALIGN=TOP>");
1400 wprintf(_("<i>The contents of this room are being "
1401 "mailed <b>as individual messages</b> "
1402 "to the following list recipients:"
1403 "</i><br /><br />\n"));
1406 serv_getln(buf, sizeof buf);
1407 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1408 extract_token(cmd, buf, 0, '|', sizeof cmd);
1409 if (!strcasecmp(cmd, "listrecp")) {
1410 extract_token(recp, buf, 1, '|', sizeof recp);
1413 wprintf(" <a href=\"netedit&cmd=remove&line="
1416 wprintf("&tab=listserv\">");
1417 wprintf(_("(remove)"));
1418 wprintf("</A><br />");
1421 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1422 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1423 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1424 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1425 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1426 wprintf("</FORM>\n");
1428 wprintf("</TD><TD VALIGN=TOP>\n");
1430 wprintf(_("<i>The contents of this room are being "
1431 "mailed <b>in digest form</b> "
1432 "to the following list recipients:"
1433 "</i><br /><br />\n"));
1436 serv_getln(buf, sizeof buf);
1437 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1438 extract_token(cmd, buf, 0, '|', sizeof cmd);
1439 if (!strcasecmp(cmd, "digestrecp")) {
1440 extract_token(recp, buf, 1, '|', sizeof recp);
1443 wprintf(" <a href=\"netedit&cmd=remove&line="
1446 wprintf("&tab=listserv\">");
1447 wprintf(_("(remove)"));
1448 wprintf("</A><br />");
1451 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1452 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1453 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1454 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1455 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1456 wprintf("</FORM>\n");
1458 wprintf("</TD></TR></TABLE><hr />\n");
1460 if (self_service(999) == 1) {
1461 wprintf(_("This room is configured to allow "
1462 "self-service subscribe/unsubscribe requests."));
1463 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1464 wprintf(_("Click to disable."));
1465 wprintf("</A><br />\n");
1466 wprintf(_("The URL for subscribe/unsubscribe is: "));
1467 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1468 (is_https ? "https" : "http"),
1472 wprintf(_("This room is <i>not</i> configured to allow "
1473 "self-service subscribe/unsubscribe requests."));
1474 wprintf(" <a href=\"toggle_self_service?newval=1&"
1476 wprintf(_("Click to enable."));
1477 wprintf("</A><br />\n");
1481 wprintf("</CENTER>\n");
1485 /** Mailing list management */
1486 if (!strcmp(tab, "expire")) {
1488 serv_puts("GPEX room");
1489 serv_getln(buf, sizeof buf);
1490 if (buf[0] == '2') {
1491 roompolicy = extract_int(&buf[4], 0);
1492 roomvalue = extract_int(&buf[4], 1);
1495 serv_puts("GPEX floor");
1496 serv_getln(buf, sizeof buf);
1497 if (buf[0] == '2') {
1498 floorpolicy = extract_int(&buf[4], 0);
1499 floorvalue = extract_int(&buf[4], 1);
1502 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1503 wprintf("<TABLE border=0 cellspacing=5>\n");
1504 wprintf("<TR><TD>");
1505 wprintf(_("Message expire policy for this room"));
1507 escputs(WC->wc_roomname);
1508 wprintf(")</TD><TD>");
1509 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1510 ((roompolicy == 0) ? "CHECKED" : "") );
1511 wprintf(_("Use the default policy for this floor"));
1512 wprintf("<br />\n");
1513 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1514 ((roompolicy == 1) ? "CHECKED" : "") );
1515 wprintf(_("Never automatically expire messages"));
1516 wprintf("<br />\n");
1517 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1518 ((roompolicy == 2) ? "CHECKED" : "") );
1519 wprintf(_("Expire by message count"));
1520 wprintf("<br />\n");
1521 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1522 ((roompolicy == 3) ? "CHECKED" : "") );
1523 wprintf(_("Expire by message age"));
1525 wprintf(_("Number of messages or days: "));
1526 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1527 wprintf("</TD></TR>\n");
1529 if (WC->axlevel >= 6) {
1530 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1531 wprintf("<TR><TD>");
1532 wprintf(_("Message expire policy for this floor"));
1534 escputs(floorlist[WC->wc_floor]);
1535 wprintf(")</TD><TD>");
1536 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1537 ((floorpolicy == 0) ? "CHECKED" : "") );
1538 wprintf(_("Use the system default"));
1539 wprintf("<br />\n");
1540 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1541 ((floorpolicy == 1) ? "CHECKED" : "") );
1542 wprintf(_("Never automatically expire messages"));
1543 wprintf("<br />\n");
1544 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1545 ((floorpolicy == 2) ? "CHECKED" : "") );
1546 wprintf(_("Expire by message count"));
1547 wprintf("<br />\n");
1548 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1549 ((floorpolicy == 3) ? "CHECKED" : "") );
1550 wprintf(_("Expire by message age"));
1552 wprintf(_("Number of messages or days: "));
1553 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1557 wprintf("<CENTER>\n");
1558 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1559 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1561 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1562 wprintf("</CENTER></TD><TR>\n");
1564 wprintf("</TABLE>\n"
1565 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1571 /** Mailing list management */
1572 if (!strcmp(tab, "access")) {
1576 /** end content of whatever tab is open now */
1577 wprintf("</TD></TR></TABLE></div>\n");
1584 * \brief Toggle self-service list subscription
1586 void toggle_self_service(void) {
1589 newval = atoi(bstr("newval"));
1590 self_service(newval);
1597 * \brief save new parameters for a room
1603 char er_password[10];
1604 char er_dirname[15];
1605 char er_roomaide[26];
1611 if (strlen(bstr("ok_button")) == 0) {
1612 strcpy(WC->ImportantMessage,
1613 _("Cancelled. Changes were not saved."));
1618 serv_getln(buf, sizeof buf);
1620 if (buf[0] != '2') {
1621 strcpy(WC->ImportantMessage, &buf[4]);
1625 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1626 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1627 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1628 er_flags = extract_int(&buf[4], 3);
1630 strcpy(er_roomaide, bstr("er_roomaide"));
1631 if (strlen(er_roomaide) == 0) {
1633 serv_getln(buf, sizeof buf);
1634 if (buf[0] != '2') {
1635 strcpy(er_roomaide, "");
1637 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1640 strcpy(buf, bstr("er_name"));
1642 if (strlen(buf) > 0) {
1643 strcpy(er_name, buf);
1646 strcpy(buf, bstr("er_password"));
1648 if (strlen(buf) > 0)
1649 strcpy(er_password, buf);
1651 strcpy(buf, bstr("er_dirname"));
1653 if (strlen(buf) > 0)
1654 strcpy(er_dirname, buf);
1656 strcpy(buf, bstr("type"));
1657 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1659 if (!strcmp(buf, "invonly")) {
1660 er_flags |= (QR_PRIVATE);
1662 if (!strcmp(buf, "hidden")) {
1663 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1665 if (!strcmp(buf, "passworded")) {
1666 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1668 if (!strcmp(bstr("prefonly"), "yes")) {
1669 er_flags |= QR_PREFONLY;
1671 er_flags &= ~QR_PREFONLY;
1674 if (!strcmp(bstr("readonly"), "yes")) {
1675 er_flags |= QR_READONLY;
1677 er_flags &= ~QR_READONLY;
1680 if (!strcmp(bstr("permanent"), "yes")) {
1681 er_flags |= QR_PERMANENT;
1683 er_flags &= ~QR_PERMANENT;
1686 if (!strcmp(bstr("network"), "yes")) {
1687 er_flags |= QR_NETWORK;
1689 er_flags &= ~QR_NETWORK;
1692 if (!strcmp(bstr("directory"), "yes")) {
1693 er_flags |= QR_DIRECTORY;
1695 er_flags &= ~QR_DIRECTORY;
1698 if (!strcmp(bstr("ulallowed"), "yes")) {
1699 er_flags |= QR_UPLOAD;
1701 er_flags &= ~QR_UPLOAD;
1704 if (!strcmp(bstr("dlallowed"), "yes")) {
1705 er_flags |= QR_DOWNLOAD;
1707 er_flags &= ~QR_DOWNLOAD;
1710 if (!strcmp(bstr("visdir"), "yes")) {
1711 er_flags |= QR_VISDIR;
1713 er_flags &= ~QR_VISDIR;
1716 strcpy(buf, bstr("anon"));
1718 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1719 if (!strcmp(buf, "anononly"))
1720 er_flags |= QR_ANONONLY;
1721 if (!strcmp(buf, "anon2"))
1722 er_flags |= QR_ANONOPT;
1725 if (!strcmp(bstr("bump"), "yes"))
1728 er_floor = atoi(bstr("er_floor"));
1730 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1731 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1733 serv_getln(buf, sizeof buf);
1734 if (buf[0] != '2') {
1735 strcpy(WC->ImportantMessage, &buf[4]);
1741 if (strlen(er_roomaide) > 0) {
1742 sprintf(buf, "SETA %s", er_roomaide);
1744 serv_getln(buf, sizeof buf);
1745 if (buf[0] != '2') {
1746 strcpy(WC->ImportantMessage, &buf[4]);
1747 display_main_menu();
1752 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1759 * \brief Display form for Invite, Kick, and show Who Knows a room
1761 void do_invt_kick(void) {
1762 char buf[SIZ], room[SIZ], username[SIZ];
1765 serv_getln(buf, sizeof buf);
1767 if (buf[0] != '2') {
1771 extract_token(room, &buf[4], 0, '|', sizeof room);
1773 strcpy(username, bstr("username"));
1775 if (strlen(bstr("kick_button")) > 0) {
1776 sprintf(buf, "KICK %s", username);
1778 serv_getln(buf, sizeof buf);
1780 if (buf[0] != '2') {
1781 strcpy(WC->ImportantMessage, &buf[4]);
1783 sprintf(WC->ImportantMessage,
1784 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1789 if (strlen(bstr("invite_button")) > 0) {
1790 sprintf(buf, "INVT %s", username);
1792 serv_getln(buf, sizeof buf);
1794 if (buf[0] != '2') {
1795 strcpy(WC->ImportantMessage, &buf[4]);
1797 sprintf(WC->ImportantMessage,
1798 _("<B><I>User %s invited to room %s.</I></B>\n"),
1809 * \brief Display form for Invite, Kick, and show Who Knows a room
1811 void display_whok(void)
1813 char buf[SIZ], room[SIZ], username[SIZ];
1816 serv_getln(buf, sizeof buf);
1818 if (buf[0] != '2') {
1822 extract_token(room, &buf[4], 0, '|', sizeof room);
1825 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1826 wprintf(_("The users listed below have access to this room. "
1827 "To remove a user from the access list, select the user "
1828 "name from the list and click 'Kick'."));
1829 wprintf("<br /><br />");
1831 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1832 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1833 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1835 serv_getln(buf, sizeof buf);
1836 if (buf[0] == '1') {
1837 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1838 extract_token(username, buf, 0, '|', sizeof username);
1839 wprintf("<OPTION>");
1844 wprintf("</SELECT><br />\n");
1846 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1847 wprintf("</FORM></CENTER>\n");
1849 wprintf("</TD><TD>");
1850 wprintf(_("To grant another user access to this room, enter the "
1851 "user name in the box below and click 'Invite'."));
1852 wprintf("<br /><br />");
1854 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1855 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1856 wprintf(_("Invite:"));
1858 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1859 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1860 "<input type=\"submit\" value=\"%s\">"
1861 "</FORM></CENTER>\n", _("Invite"));
1863 wprintf("</TD></TR></TABLE>\n");
1870 * \brief display the form for entering a new room
1872 void display_entroom(void)
1877 serv_puts("CRE8 0");
1878 serv_getln(buf, sizeof buf);
1880 if (buf[0] != '2') {
1881 strcpy(WC->ImportantMessage, &buf[4]);
1882 display_main_menu();
1886 output_headers(1, 1, 2, 0, 0, 0);
1887 wprintf("<div id=\"banner\">\n"
1888 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1889 "<SPAN CLASS=\"titlebar\">");
1890 wprintf(_("Create a new room"));
1892 "</TD></TR></TABLE>\n"
1893 "</div>\n<div id=\"content\">\n"
1896 wprintf("<div class=\"fix_scrollbar_bug\">"
1897 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1899 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1901 wprintf("<UL><LI>");
1902 wprintf(_("Name of room: "));
1903 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1906 wprintf(_("Resides on floor: "));
1908 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1909 for (i = 0; i < 128; ++i)
1910 if (strlen(floorlist[i]) > 0) {
1911 wprintf("<OPTION ");
1912 wprintf("VALUE=\"%d\">", i);
1913 escputs(floorlist[i]);
1914 wprintf("</OPTION>\n");
1916 wprintf("</SELECT>\n");
1919 * Our clever little snippet of JavaScript automatically selects
1920 * a public room if the view is set to Bulletin Board or wiki, and
1921 * it selects a mailbox room otherwise. The user can override this,
1922 * of course. We also disable the floor selector for mailboxes.
1925 wprintf(_("Default view for room: "));
1926 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1927 " if ( (this.form.er_view.value == 0) "
1928 " || (this.form.er_view.value == 6) ) { "
1929 " this.form.type[0].checked=true; "
1930 " this.form.er_floor.disabled = false; "
1933 " this.form.type[4].checked=true; "
1934 " this.form.er_floor.disabled = true; "
1937 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1938 wprintf("<OPTION %s VALUE=\"%d\">",
1939 ((i == 0) ? "SELECTED" : ""), i );
1940 escputs(viewdefs[i]);
1941 wprintf("</OPTION>\n");
1943 wprintf("</SELECT>\n");
1946 wprintf(_("Type of room:"));
1949 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1950 wprintf("CHECKED OnChange=\""
1951 " if (this.form.type[0].checked == true) { "
1952 " this.form.er_floor.disabled = false; "
1955 wprintf(_("Public (automatically appears to everyone)"));
1957 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1958 " if (this.form.type[1].checked == true) { "
1959 " this.form.er_floor.disabled = false; "
1962 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1964 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1965 " if (this.form.type[2].checked == true) { "
1966 " this.form.er_floor.disabled = false; "
1969 wprintf(_("Private - require password: "));
1970 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1972 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1973 " if (this.form.type[3].checked == true) { "
1974 " this.form.er_floor.disabled = false; "
1977 wprintf(_("Private - invitation only"));
1979 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1981 " if (this.form.type[4].checked == true) { "
1982 " this.form.er_floor.disabled = true; "
1985 wprintf(_("Personal (mailbox for you only)"));
1987 wprintf("\n</UL>\n");
1989 wprintf("<CENTER>\n");
1990 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1992 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1993 wprintf("</CENTER>\n");
1994 wprintf("</FORM>\n<hr />");
1995 serv_printf("MESG roomaccess");
1996 serv_getln(buf, sizeof buf);
1997 if (buf[0] == '1') {
2000 wprintf("</td></tr></table></div>\n");
2008 * \brief support function for entroom() -- sets the default view
2010 void er_set_default_view(int newview) {
2023 serv_getln(buf, sizeof buf);
2024 if (buf[0] != '2') return;
2026 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2027 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2028 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2029 rm_bits1 = extract_int(&buf[4], 3);
2030 rm_floor = extract_int(&buf[4], 4);
2031 rm_listorder = extract_int(&buf[4], 5);
2032 rm_bits2 = extract_int(&buf[4], 7);
2034 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2035 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2036 rm_listorder, newview, rm_bits2
2038 serv_getln(buf, sizeof buf);
2044 * \brief enter a new room
2051 char er_password[SIZ];
2056 if (strlen(bstr("ok_button")) == 0) {
2057 strcpy(WC->ImportantMessage,
2058 _("Cancelled. No new room was created."));
2059 display_main_menu();
2062 strcpy(er_name, bstr("er_name"));
2063 strcpy(er_type, bstr("type"));
2064 strcpy(er_password, bstr("er_password"));
2065 er_floor = atoi(bstr("er_floor"));
2066 er_view = atoi(bstr("er_view"));
2069 if (!strcmp(er_type, "hidden"))
2071 if (!strcmp(er_type, "passworded"))
2073 if (!strcmp(er_type, "invonly"))
2075 if (!strcmp(er_type, "personal"))
2078 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2079 er_name, er_num_type, er_password, er_floor, 0, er_view);
2081 serv_getln(buf, sizeof buf);
2082 if (buf[0] != '2') {
2083 strcpy(WC->ImportantMessage, &buf[4]);
2084 display_main_menu();
2088 do_change_view(er_view); /* Now go there */
2093 * \brief display the screen to enter a private room
2095 void display_private(char *rname, int req_pass)
2097 output_headers(1, 1, 2, 0, 0, 0);
2098 wprintf("<div id=\"banner\">\n"
2099 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2100 "<SPAN CLASS=\"titlebar\">");
2101 wprintf(_("Go to a hidden room"));
2103 "</TD></TR></TABLE>\n"
2104 "</div>\n<div id=\"content\">\n"
2107 wprintf("<div class=\"fix_scrollbar_bug\">"
2108 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2110 wprintf("<CENTER>\n");
2112 wprintf(_("If you know the name of a hidden (guess-name) or "
2113 "passworded room, you can enter that room by typing "
2114 "its name below. Once you gain access to a private "
2115 "room, it will appear in your regular room listings "
2116 "so you don't have to keep returning here."));
2117 wprintf("\n<br /><br />");
2119 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2121 wprintf("<table border=\"0\" cellspacing=\"5\" "
2122 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2124 wprintf(_("Enter room name:"));
2126 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2127 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2130 wprintf("</TD></TR><TR><TD>");
2131 wprintf(_("Enter room password:"));
2132 wprintf("</TD><TD>");
2133 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2135 wprintf("</TD></TR></TABLE><br />\n");
2137 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2139 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2143 wprintf("</FORM>\n");
2144 wprintf("</td></tr></table></div>\n");
2149 * \brief goto a private room
2151 void goto_private(void)
2156 if (strlen(bstr("ok_button")) == 0) {
2157 display_main_menu();
2160 strcpy(hold_rm, WC->wc_roomname);
2161 strcpy(buf, "GOTO ");
2162 strcat(buf, bstr("gr_name"));
2164 strcat(buf, bstr("gr_pass"));
2166 serv_getln(buf, sizeof buf);
2168 if (buf[0] == '2') {
2169 smart_goto(bstr("gr_name"));
2172 if (!strncmp(buf, "540", 3)) {
2173 display_private(bstr("gr_name"), 1);
2176 output_headers(1, 1, 1, 0, 0, 0);
2177 wprintf("%s\n", &buf[4]);
2184 * \brief display the screen to zap a room
2186 void display_zap(void)
2188 output_headers(1, 1, 2, 0, 0, 0);
2190 wprintf("<div id=\"banner\">\n");
2191 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2192 wprintf("<SPAN CLASS=\"titlebar\">");
2193 wprintf(_("Zap (forget/unsubscribe) the current room"));
2194 wprintf("</SPAN>\n");
2195 wprintf("</TD></TR></TABLE>\n");
2196 wprintf("</div>\n<div id=\"content\">\n");
2198 wprintf(_("If you select this option, <em>%s</em> will "
2199 "disappear from your room list. Is this what you wish "
2200 "to do?<br />\n"), WC->wc_roomname);
2202 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2203 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2205 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2206 wprintf("</FORM>\n");
2217 char final_destination[SIZ];
2220 * If the forget-room routine fails for any reason, we fall back
2221 * to the current room; otherwise, we go to the Lobby
2223 strcpy(final_destination, WC->wc_roomname);
2225 if (strlen(bstr("ok_button")) > 0) {
2226 serv_printf("GOTO %s", WC->wc_roomname);
2227 serv_getln(buf, sizeof buf);
2228 if (buf[0] == '2') {
2230 serv_getln(buf, sizeof buf);
2231 if (buf[0] == '2') {
2232 strcpy(final_destination, "_BASEROOM_");
2236 smart_goto(final_destination);
2242 * \brief Delete the current room
2244 void delete_room(void)
2248 serv_puts("KILL 1");
2249 serv_getln(buf, sizeof buf);
2250 if (buf[0] != '2') {
2251 strcpy(WC->ImportantMessage, &buf[4]);
2252 display_main_menu();
2255 smart_goto("_BASEROOM_");
2262 * \brief Perform changes to a room's network configuration
2264 void netedit(void) {
2273 if (strlen(bstr("line"))==0) {
2278 strcpy(line, bstr("prefix"));
2279 strcat(line, bstr("line"));
2280 strcat(line, bstr("suffix"));
2289 serv_getln(buf, sizeof buf);
2290 if (buf[0] != '1') {
2296 /** This loop works for add *or* remove. Spiffy, eh? */
2297 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2298 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2299 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2300 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2301 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2302 if ( (strcasecmp(cmpa0, cmpb0))
2303 || (strcasecmp(cmpa1, cmpb1)) ) {
2304 fprintf(fp, "%s\n", buf);
2310 serv_getln(buf, sizeof buf);
2311 if (buf[0] != '4') {
2317 while (fgets(buf, sizeof buf, fp) != NULL) {
2318 buf[strlen(buf)-1] = 0;
2322 if (strlen(bstr("add_button")) > 0) {
2334 * \brief Convert a room name to a folder-ish-looking name.
2335 * \param folder the folderish name
2336 * \param room the room name
2337 * \param floor the floor name
2338 * \param is_mailbox is it a mailbox?
2340 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2345 * For mailboxes, just do it straight...
2348 sprintf(folder, "My folders|%s", room);
2352 * Otherwise, prefix the floor name as a "public folders" moniker
2355 sprintf(folder, "%s|%s", floorlist[floor], room);
2359 * Replace "\" characters with "|" for pseudo-folder-delimiting
2361 for (i=0; i<strlen(folder); ++i) {
2362 if (folder[i] == '\\') folder[i] = '|';
2370 * \brief Back end for change_view()
2371 * \param newview set newview???
2373 void do_change_view(int newview) {
2376 serv_printf("VIEW %d", newview);
2377 serv_getln(buf, sizeof buf);
2378 WC->wc_view = newview;
2379 smart_goto(WC->wc_roomname);
2385 * \brief Change the view for this room
2387 void change_view(void) {
2390 view = atol(bstr("view"));
2391 do_change_view(view);
2396 * \brief One big expanded tree list view --- like a folder list
2397 * \param fold the folder to view
2398 * \param max_folders how many folders???
2399 * \param num_floors hom many floors???
2401 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2405 int has_subfolders = 0;
2408 parents = malloc(max_folders * sizeof(int));
2410 /** BEGIN TREE MENU */
2411 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2413 /** include NanoTree */
2414 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2416 /** initialize NanoTree */
2417 wprintf("<script type=\"text/javascript\"> \n"
2418 " showRootNode = false; \n"
2419 " sortNodes = false; \n"
2420 " dragable = false; \n"
2422 " function standardClick(treeNode) { \n"
2425 " var closedGif = 'static/folder_closed.gif'; \n"
2426 " var openGif = 'static/folder_open.gif'; \n"
2428 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2432 for (i=0; i<max_folders; ++i) {
2435 if ((i+1) < max_folders) {
2436 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2437 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2442 levels = num_tokens(fold[i].name, '|');
2443 parents[levels] = i;
2445 wprintf("var node%d = new TreeNode(%d, '", i, i);
2447 if (fold[i].selectable) {
2448 wprintf("<a href=\"dotgoto?room=");
2449 urlescputs(fold[i].room);
2454 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2456 else if (fold[i].hasnewmsgs) {
2457 wprintf("<SPAN CLASS=\"roomlist_new\">");
2460 wprintf("<SPAN CLASS=\"roomlist_old\">");
2462 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2467 if (has_subfolders) {
2468 wprintf("new Array(closedGif, openGif)");
2470 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2471 wprintf("'static/viewcontacts_16x.gif'");
2473 else if (fold[i].view == VIEW_CALENDAR) {
2474 wprintf("'static/calarea_16x.gif'");
2476 else if (fold[i].view == VIEW_TASKS) {
2477 wprintf("'static/taskmanag_16x.gif'");
2479 else if (fold[i].view == VIEW_NOTES) {
2480 wprintf("'static/storenotes_16x.gif'");
2482 else if (fold[i].view == VIEW_MAILBOX) {
2483 wprintf("'static/privatemess_16x.gif'");
2486 wprintf("'static/chatrooms_16x.gif'");
2489 urlescputs(fold[i].name);
2493 wprintf("rootNode.addChild(node%d);\n", i);
2496 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2500 wprintf("container = document.getElementById('roomlist_div'); \n"
2506 /** END TREE MENU */
2510 * \brief Boxes and rooms and lists ... oh my!
2511 * \param fold the folder to view
2512 * \param max_folders how many folders???
2513 * \param num_floors hom many floors???
2515 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2517 char floor_name[256];
2518 char old_floor_name[256];
2520 int levels, oldlevels;
2523 static int columns = 3;
2524 int boxes_per_column = 0;
2525 int current_column = 0;
2528 strcpy(floor_name, "");
2529 strcpy(old_floor_name, "");
2532 while (nf % columns != 0) ++nf;
2533 boxes_per_column = (nf / columns);
2534 if (boxes_per_column < 1) boxes_per_column = 1;
2536 /** Outer table (for columnization) */
2537 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2538 "<tr><td valign=top>");
2542 for (i=0; i<max_folders; ++i) {
2544 levels = num_tokens(fold[i].name, '|');
2545 extract_token(floor_name, fold[i].name, 0,
2546 '|', sizeof floor_name);
2548 if ( (strcasecmp(floor_name, old_floor_name))
2549 && (strlen(old_floor_name) > 0) ) {
2551 do_template("endbox");
2554 if ((num_boxes % boxes_per_column) == 0) {
2556 if (current_column < columns) {
2557 wprintf("</td><td valign=top>\n");
2561 strcpy(old_floor_name, floor_name);
2564 /** Begin inner box */
2565 stresc(boxtitle, floor_name, 1, 0);
2566 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2567 do_template("beginbox");
2574 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2575 if (fold[i].selectable) {
2576 wprintf("<a href=\"dotgoto?room=");
2577 urlescputs(fold[i].room);
2583 if (fold[i].hasnewmsgs) {
2584 wprintf("<SPAN CLASS=\"roomlist_new\">");
2587 wprintf("<SPAN CLASS=\"roomlist_old\">");
2589 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2592 if (fold[i].selectable) {
2598 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2599 wprintf(" (INBOX)");
2601 wprintf("<br />\n");
2604 /** End the final inner box */
2605 do_template("endbox");
2607 wprintf("</TD></TR></TABLE>\n");
2611 * \brief print a floor div???
2612 * \param which_floordiv name of the floordiv???
2614 void set_floordiv_expanded(char *which_floordiv) {
2615 begin_ajax_response();
2616 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2617 end_ajax_response();
2621 * \brief view the iconbar
2622 * \param fold the folder to view
2623 * \param max_folders how many folders???
2624 * \param num_floors hom many floors???
2626 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2628 char floor_name[256];
2629 char old_floor_name[256];
2630 char floordivtitle[256];
2631 char floordiv_id[32];
2632 int levels, oldlevels;
2634 int num_drop_targets = 0;
2637 strcpy(floor_name, "");
2638 strcpy(old_floor_name, "");
2642 for (i=0; i<max_folders; ++i) {
2644 levels = num_tokens(fold[i].name, '|');
2645 extract_token(floor_name, fold[i].name, 0,
2646 '|', sizeof floor_name);
2648 if ( (strcasecmp(floor_name, old_floor_name))
2649 && (strlen(old_floor_name) > 0) ) {
2650 /** End inner box */
2652 wprintf("</div>\n"); /** floordiv */
2654 strcpy(old_floor_name, floor_name);
2658 stresc(floordivtitle, floor_name, 0, 0);
2659 sprintf(floordiv_id, "floordiv%d", i);
2660 wprintf("<span class=\"ib_roomlist_floor\" "
2661 "onClick=\"expand_floor('%s')\">"
2662 "%s</span><br>\n", floordiv_id, floordivtitle);
2663 wprintf("<div id=\"%s\" style=\"display:%s\">",
2665 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2672 wprintf("<div id=\"roomdiv%d\">", i);
2674 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2676 /** choose the icon */
2677 if (fold[i].view == VIEW_ADDRESSBOOK) {
2678 icon = "viewcontacts_16x.gif" ;
2680 else if (fold[i].view == VIEW_CALENDAR) {
2681 icon = "calarea_16x.gif" ;
2683 else if (fold[i].view == VIEW_TASKS) {
2684 icon = "taskmanag_16x.gif" ;
2686 else if (fold[i].view == VIEW_NOTES) {
2687 icon = "storenotes_16x.gif" ;
2689 else if (fold[i].view == VIEW_MAILBOX) {
2690 icon = "privatemess_16x.gif" ;
2693 icon = "chatrooms_16x.gif" ;
2696 if (fold[i].selectable) {
2697 wprintf("<a href=\"dotgoto?room=");
2698 urlescputs(fold[i].room);
2700 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2705 if (fold[i].hasnewmsgs) {
2706 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2709 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2711 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2713 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2714 wprintf(" (INBOX)");
2717 if (fold[i].selectable) {
2724 wprintf("</div>\n"); /** roomdiv */
2727 wprintf("</div>\n"); /** floordiv */
2730 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2731 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2733 num_drop_targets = 0;
2735 for (i=0; i<max_folders; ++i) {
2736 levels = num_tokens(fold[i].name, '|');
2738 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2739 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2740 jsescputs(fold[i].room);
2746 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2747 if (strlen(WC->floordiv_expanded) > 1) {
2748 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2752 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2758 * \brief Show the room list.
2759 * (only should get called by
2760 * knrooms() because that's where output_headers() is called from)
2761 * \param viewpref the view preferences???
2764 void list_all_rooms_by_floor(char *viewpref) {
2767 struct folder *fold = NULL;
2769 int max_folders = 0;
2770 int alloc_folders = 0;
2774 int num_floors = 1; /** add an extra one for private folders */
2776 /** If our cached folder list is very old, burn it. */
2777 if (WC->cache_fold != NULL) {
2778 if ((time(NULL) - WC->cache_timestamp) > 300) {
2779 free(WC->cache_fold);
2780 WC->cache_fold = NULL;
2784 /** Can we do the iconbar roomlist from cache? */
2785 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2786 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2790 /** Grab the floor table so we know how to build the list... */
2793 /** Start with the mailboxes */
2796 fold = malloc(sizeof(struct folder));
2797 memset(fold, 0, sizeof(struct folder));
2798 strcpy(fold[0].name, "My folders");
2799 fold[0].is_mailbox = 1;
2801 /** Then add floors */
2803 serv_getln(buf, sizeof buf);
2804 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2805 if (max_folders >= alloc_folders) {
2806 alloc_folders = max_folders + 100;
2807 fold = realloc(fold,
2808 alloc_folders * sizeof(struct folder));
2810 memset(&fold[max_folders], 0, sizeof(struct folder));
2811 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2816 /** Now add rooms */
2818 serv_getln(buf, sizeof buf);
2819 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2820 if (max_folders >= alloc_folders) {
2821 alloc_folders = max_folders + 100;
2822 fold = realloc(fold,
2823 alloc_folders * sizeof(struct folder));
2825 memset(&fold[max_folders], 0, sizeof(struct folder));
2826 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2827 ra_flags = extract_int(buf, 5);
2828 flags = extract_int(buf, 1);
2829 fold[max_folders].floor = extract_int(buf, 2);
2830 fold[max_folders].hasnewmsgs =
2831 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2832 if (flags & QR_MAILBOX) {
2833 fold[max_folders].is_mailbox = 1;
2835 fold[max_folders].view = extract_int(buf, 6);
2836 room_to_folder(fold[max_folders].name,
2837 fold[max_folders].room,
2838 fold[max_folders].floor,
2839 fold[max_folders].is_mailbox);
2840 fold[max_folders].selectable = 1;
2844 /** Bubble-sort the folder list */
2845 for (i=0; i<max_folders; ++i) {
2846 for (j=0; j<(max_folders-1)-i; ++j) {
2847 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2848 swap = strcasecmp(fold[j].name, fold[j+1].name);
2851 if ( (fold[j+1].is_mailbox)
2852 && (!fold[j].is_mailbox)) {
2860 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2861 memcpy(&fold[j], &fold[j+1],
2862 sizeof(struct folder));
2863 memcpy(&fold[j+1], &ftmp,
2864 sizeof(struct folder));
2870 if (!strcasecmp(viewpref, "folders")) {
2871 do_folder_view(fold, max_folders, num_floors);
2873 else if (!strcasecmp(viewpref, "hackish_view")) {
2874 for (i=0; i<max_folders; ++i) {
2875 escputs(fold[i].name);
2876 wprintf("<br />\n");
2879 else if (!strcasecmp(viewpref, "iconbar")) {
2880 do_iconbar_view(fold, max_folders, num_floors);
2883 do_rooms_view(fold, max_folders, num_floors);
2886 /* Don't free the folder list ... cache it for future use! */
2887 if (WC->cache_fold != NULL) {
2888 free(WC->cache_fold);
2890 WC->cache_fold = fold;
2891 WC->cache_max_folders = max_folders;
2892 WC->cache_num_floors = num_floors;
2893 WC->cache_timestamp = time(NULL);
2898 * \brief Do either a known rooms list or a folders list, depending on the
2903 char listviewpref[SIZ];
2905 output_headers(1, 1, 2, 0, 0, 0);
2907 /** Determine whether the user is trying to change views */
2908 if (bstr("view") != NULL) {
2909 if (strlen(bstr("view")) > 0) {
2910 set_preference("roomlistview", bstr("view"), 1);
2914 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2916 if ( (strcasecmp(listviewpref, "folders"))
2917 && (strcasecmp(listviewpref, "table")) ) {
2918 strcpy(listviewpref, "rooms");
2922 wprintf("<div id=\"banner\">\n"
2923 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2924 "<SPAN CLASS=\"titlebar\">"
2926 if (!strcasecmp(listviewpref, "rooms")) {
2927 wprintf(_("Room list"));
2929 if (!strcasecmp(listviewpref, "folders")) {
2930 wprintf(_("Folder list"));
2932 if (!strcasecmp(listviewpref, "table")) {
2933 wprintf(_("Room list"));
2935 wprintf("</SPAN></TD>\n");
2937 /** offer the ability to switch views */
2938 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2939 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2940 "OnChange=\"location.href=roomlistomatic.newview.options"
2941 "[selectedIndex].value\">\n");
2943 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
2946 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2949 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
2950 "View as folder list"
2952 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2955 wprintf("</SELECT><br />");
2957 wprintf("</FORM></TD></TR></TABLE>\n");
2960 "<div id=\"content\">\n");
2962 /** Display the room list in the user's preferred format */
2963 list_all_rooms_by_floor(listviewpref);
2970 * \brief Set the message expire policy for this room and/or floor
2972 void set_room_policy(void) {
2975 if (strlen(bstr("ok_button")) == 0) {
2976 strcpy(WC->ImportantMessage,
2977 _("Cancelled. Changes were not saved."));
2982 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2983 serv_getln(buf, sizeof buf);
2984 strcpy(WC->ImportantMessage, &buf[4]);
2986 if (WC->axlevel >= 6) {
2987 strcat(WC->ImportantMessage, "<br />\n");
2988 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2989 serv_getln(buf, sizeof buf);
2990 strcat(WC->ImportantMessage, &buf[4]);