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[8]; /**< 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");
26 viewdefs[7] = _("Calendar List");
30 * \brief Determine which views are allowed as the default for creating a new room.
32 * \param which_view The view ID being queried.
34 int is_view_allowed_as_default(int which_view)
37 case VIEW_BBS: return(1);
38 case VIEW_MAILBOX: return(1);
39 case VIEW_ADDRESSBOOK: return(1);
40 case VIEW_CALENDAR: return(1);
41 case VIEW_TASKS: return(1);
42 case VIEW_NOTES: return(1);
43 case VIEW_WIKI: return(0); /**< because it isn't finished yet */
44 case VIEW_CALBRIEF: return(0);
45 default: return(0); /**< should never get here */
51 * \brief load the list of floors
53 void load_floorlist(void)
58 for (a = 0; a < 128; ++a)
62 serv_getln(buf, sizeof buf);
64 strcpy(floorlist[0], "Main Floor");
67 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
68 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
74 * \brief Free a session's march list
76 * \param wcf Pointer to session being cleared
78 void free_march_list(struct wcsession *wcf)
82 while (wcf->march != NULL) {
83 mptr = wcf->march->next;
93 * \brief remove a room from the march list
95 void remove_march(char *aaa)
97 struct march *mptr, *mptr2;
99 if (WC->march == NULL)
102 if (!strcasecmp(WC->march->march_name, aaa)) {
103 mptr = WC->march->next;
109 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
110 if (!strcasecmp(mptr->march_name, aaa)) {
111 mptr2->next = mptr->next;
124 * \brief display rooms in tree structure???
125 * \param rp the roomlist to build a tree from
127 void room_tree_list(struct roomlisting *rp)
136 room_tree_list(rp->lnext);
138 strcpy(rmname, rp->rlname);
141 wprintf("<a href=\"dotgoto&room=");
145 escputs1(rmname, 1, 1);
146 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
148 else if (f & QR_DIRECTORY)
150 else if (f & QR_NETWORK)
154 wprintf("</A><TT> </TT>\n");
156 room_tree_list(rp->rnext);
162 * \brief Room ordering stuff (compare first by floor, then by order)
163 * \param r1 first roomlist to compare
164 * \param r2 second roomlist co compare
165 * \return are they the same???
167 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
169 if ((r1 == NULL) && (r2 == NULL))
175 if (r1->rlfloor < r2->rlfloor)
177 if (r1->rlfloor > r2->rlfloor)
179 if (r1->rlorder < r2->rlorder)
181 if (r1->rlorder > r2->rlorder)
188 * \brief Common code for all room listings
189 * \param variety what???
191 void listrms(char *variety)
196 struct roomlisting *rl = NULL;
197 struct roomlisting *rp;
198 struct roomlisting *rs;
201 /** Ask the server for a room list */
203 serv_getln(buf, sizeof buf);
208 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
210 rp = malloc(sizeof(struct roomlisting));
211 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
212 rp->rlflags = extract_int(buf, 1);
213 rp->rlfloor = extract_int(buf, 2);
214 rp->rlorder = extract_int(buf, 3);
223 if (rordercmp(rp, rs) < 0) {
224 if (rs->lnext == NULL) {
231 if (rs->rnext == NULL) {
244 * If no rooms were listed, print an nbsp to make the cell
245 * borders show up anyway.
247 if (num_rooms == 0) wprintf(" ");
252 * \brief list all forgotten rooms
254 void zapped_list(void)
256 output_headers(1, 1, 0, 0, 0, 0);
258 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
259 do_template("beginbox");
263 wprintf("<br /><br />\n");
264 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
265 do_template("endbox");
271 * \brief read this room's info file (set v to 1 for verbose mode)
278 serv_getln(buf, sizeof buf);
291 * \brief Display room banner icon.
292 * The server doesn't actually
293 * need the room name, but we supply it in order to
294 * keep the browser from using a cached icon from
297 void embed_room_graphic(void) {
300 serv_puts("OIMG _roompic_");
301 serv_getln(buf, sizeof buf);
303 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
304 urlescputs(WC->wc_roomname);
307 serv_getln(buf, sizeof buf);
309 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
310 wprintf("<img height=48 width=48 src=\""
311 "static/viewcontacts_48x.gif"
315 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
316 wprintf("<img height=48 width=48 src=\""
317 "static/calarea_48x.gif"
321 else if (WC->wc_view == VIEW_TASKS) {
322 wprintf("<img height=48 width=48 src=\""
323 "static/taskmanag_48x.gif"
327 else if (WC->wc_view == VIEW_NOTES) {
328 wprintf("<img height=48 width=48 src=\""
329 "static/storenotes_48x.gif"
333 else if (WC->wc_view == VIEW_MAILBOX) {
334 wprintf("<img height=48 width=48 src=\""
335 "static/privatemess_48x.gif"
340 wprintf("<img height=48 width=48 src=\""
341 "static/chatrooms_48x.gif"
351 * \brief Display the current view and offer an option to change it
353 void embed_view_o_matic(void) {
356 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
357 "<span class=\"room_banner_new_messages\">");
358 wprintf(_("View as:"));
360 "<SELECT NAME=\"newview\" SIZE=\"1\" "
361 "STYLE=\"font-size: 7pt; background: #444455; color: #ddddcc;\" "
362 "OnChange=\"location.href=viewomatic.newview.options"
363 "[selectedIndex].value\">\n");
365 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
367 * Only offer the views that make sense, given the default
368 * view for the room. For example, don't offer a Calendar
369 * view in a non-Calendar room.
373 || (i == WC->wc_default_view) /**< default */
374 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
375 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
376 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
379 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
380 ((i == WC->wc_view) ? "SELECTED" : ""),
382 escputs(viewdefs[i]);
383 wprintf("</OPTION>\n");
386 wprintf("</select></span></form>\n");
391 * \brief Display a search box
393 void embed_search_o_matic(void) {
394 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n"
395 "<span class=\"room_banner_new_messages\">");
396 wprintf(_("Search: "));
398 "type=\"text\" name=\"query\" size=\"20\" maxlength=\"128\" "
399 "style=\"font-size: 7pt; background: #444455; color: #ddddcc;\">\n"
401 wprintf("</select></span></form>\n");
406 * \brief Embed the room banner
408 * \param got The information returned from a GOTO server command
409 * \param navbar_style Determines which navigation buttons to display
412 void embed_room_banner(char *got, int navbar_style) {
416 * We need to have the information returned by a GOTO server command.
417 * If it isn't supplied, we fake it by issuing our own GOTO.
420 serv_printf("GOTO %s", WC->wc_roomname);
421 serv_getln(buf, sizeof buf);
425 /** The browser needs some information for its own use */
426 wprintf("<script type=\"text/javascript\"> \n"
427 " room_is_trash = %d; \n"
433 * If the user happens to select the "make this my start page" link,
434 * we want it to remember the URL as a "/dotskip" one instead of
435 * a "skip" or "gotonext" or something like that.
437 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
440 /** Check for new mail. */
441 WC->new_mail = extract_int(&got[4], 9);
442 WC->wc_view = extract_int(&got[4], 11);
444 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
445 svprintf("NUMMSGS", WCS_STRING,
446 _("%d new of %d messages"),
447 extract_int(&got[4], 1),
448 extract_int(&got[4], 2)
450 svcallback("ROOMPIC", embed_room_graphic);
451 svcallback("ROOMINFO", readinfo);
452 svcallback("VIEWOMATIC", embed_view_o_matic);
453 svcallback("SEARCHOMATIC", embed_search_o_matic);
454 svcallback("START", offer_start_page);
456 do_template("roombanner");
457 if (navbar_style != navbar_none) {
459 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
460 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
463 if (navbar_style == navbar_default) wprintf(
465 "<a href=\"ungoto\">"
466 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
467 "<span class=\"navbar_link\">%s</span></A>"
468 "</td>\n", _("Ungoto")
471 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
474 "<a href=\"readnew\">"
475 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
476 "<span class=\"navbar_link\">%s</span></A>"
477 "</td>\n", _("Read new messages")
481 if (navbar_style == navbar_default) {
482 switch(WC->wc_view) {
483 case VIEW_ADDRESSBOOK:
486 "<a href=\"readfwd\">"
487 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
489 "<span class=\"navbar_link\">"
491 "</span></a></td>\n", _("View contacts")
497 "<a href=\"readfwd?calview=day\">"
498 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
500 "<span class=\"navbar_link\">"
502 "</span></a></td>\n", _("Day view")
506 "<a href=\"readfwd?calview=month\">"
507 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
509 "<span class=\"navbar_link\">"
511 "</span></a></td>\n", _("Month view")
517 "<a href=\"readfwd?calview=month\">"
518 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
520 "<span class=\"navbar_link\">"
522 "</span></a></td>\n", _("Calendar list")
528 "<a href=\"readfwd\">"
529 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
531 "<span class=\"navbar_link\">"
533 "</span></a></td>\n", _("View tasks")
539 "<a href=\"readfwd\">"
540 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
542 "<span class=\"navbar_link\">"
544 "</span></a></td>\n", _("View notes")
550 "<a href=\"readfwd\">"
551 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
553 "<span class=\"navbar_link\">"
555 "</span></a></td>\n", _("View message list")
561 "<a href=\"readfwd\">"
562 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
564 "<span class=\"navbar_link\">"
566 "</span></a></td>\n", _("Wiki home")
572 "<a href=\"readfwd\">"
573 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
575 "<span class=\"navbar_link\">"
577 "</span></a></td>\n", _("Read all messages")
583 if (navbar_style == navbar_default) {
584 switch(WC->wc_view) {
585 case VIEW_ADDRESSBOOK:
587 "<td><a href=\"display_enter\">"
588 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
589 "border=\"0\"><span class=\"navbar_link\">"
591 "</span></a></td>\n", _("Add new contact")
596 wprintf("<td><a href=\"display_enter");
597 if (strlen(bstr("year")) > 0) wprintf("?year=%s", bstr("year"));
598 if (strlen(bstr("month")) > 0) wprintf("?month=%s", bstr("month"));
599 if (strlen(bstr("day")) > 0) wprintf("?day=%s", bstr("day"));
601 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
602 "border=\"0\"><span class=\"navbar_link\">"
604 "</span></a></td>\n", _("Add new event")
609 "<td><a href=\"display_enter\">"
610 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
611 "border=\"0\"><span class=\"navbar_link\">"
613 "</span></a></td>\n", _("Add new task")
618 "<td><a href=\"javascript:add_new_note();\">"
619 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
620 "border=\"0\"><span class=\"navbar_link\">"
622 "</span></a></td>\n", _("Add new note")
626 safestrncpy(buf, bstr("page"), sizeof buf);
629 "<td><a href=\"display_enter?wikipage=%s\">"
630 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
631 "border=\"0\"><span class=\"navbar_link\">"
633 "</span></a></td>\n", buf, _("Edit this page")
638 "<td><a href=\"display_enter\">"
639 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
640 "border=\"0\"><span class=\"navbar_link\">"
642 "</span></a></td>\n", _("Enter a message")
648 if (navbar_style == navbar_default) wprintf(
652 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
653 "<span class=\"navbar_link\">%s</span></a>"
655 _("Leave all messages marked as unread, go to next room with unread messages"),
659 if (navbar_style == navbar_default) wprintf(
661 "<a href=\"gotonext\" "
663 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
664 "<span class=\"navbar_link\">%s</span></a>"
666 _("Mark all messages as read, go to next room with unread messages"),
670 wprintf("</tr></table></div>\n");
680 * \brief back end routine to take the session to a new room
681 * \param gname room to go to
684 int gotoroom(char *gname)
687 static long ls = (-1L);
690 /** store ungoto information */
691 strcpy(WC->ugname, WC->wc_roomname);
694 /** move to the new room */
695 serv_printf("GOTO %s", gname);
696 serv_getln(buf, sizeof buf);
700 serv_puts("GOTO _BASEROOM_");
701 serv_getln(buf, sizeof buf);
708 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
709 WC->room_flags = extract_int(&buf[4], 4);
710 /* highest_msg_read = extract_int(&buf[4],6);
711 maxmsgnum = extract_int(&buf[4],5);
713 WC->is_mailbox = extract_int(&buf[4],7);
714 ls = extract_long(&buf[4], 6);
715 WC->wc_floor = extract_int(&buf[4], 10);
716 WC->wc_view = extract_int(&buf[4], 11);
717 WC->wc_default_view = extract_int(&buf[4], 12);
718 WC->wc_is_trash = extract_int(&buf[4], 13);
721 WC->is_room_aide = WC->is_aide;
723 WC->is_room_aide = (char) extract_int(&buf[4], 8);
725 remove_march(WC->wc_roomname);
726 if (!strcasecmp(gname, "_BASEROOM_"))
734 * \brief Locate the room on the march list which we most want to go to.
736 * is measured given a "weight" of preference based on various factors.
737 * \param desired_floor the room number on the citadel server
738 * \return the roomname
740 char *pop_march(int desired_floor)
742 static char TheRoom[128];
744 int TheOrder = 32767;
747 struct march *mptr = NULL;
749 strcpy(TheRoom, "_BASEROOM_");
750 if (WC->march == NULL)
753 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
755 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
756 weight = weight + 10000;
757 if (mptr->march_floor == desired_floor)
758 weight = weight + 5000;
760 weight = weight + ((128 - (mptr->march_floor)) * 128);
761 weight = weight + (128 - (mptr->march_order));
763 if (weight > TheWeight) {
765 strcpy(TheRoom, mptr->march_name);
766 TheFloor = mptr->march_floor;
767 TheOrder = mptr->march_order;
776 *\brief Goto next room having unread messages.
777 * We want to skip over rooms that the user has already been to, and take the
778 * user back to the lobby when done. The room we end up in is placed in
779 * newroom - which is set to 0 (the lobby) initially.
780 * We start the search in the current room rather than the beginning to prevent
781 * two or more concurrent users from dragging each other back to the same room.
786 struct march *mptr, *mptr2;
790 * First check to see if the march-mode list is already allocated.
791 * If it is, pop the first room off the list and go there.
794 if (WC->march == NULL) {
796 serv_getln(buf, sizeof buf);
798 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
799 mptr = (struct march *) malloc(sizeof(struct march));
801 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
802 mptr->march_floor = extract_int(buf, 2);
803 mptr->march_order = extract_int(buf, 3);
804 if (WC->march == NULL) {
808 while (mptr2->next != NULL)
814 * add _BASEROOM_ to the end of the march list, so the user will end up
815 * in the system base room (usually the Lobby>) at the end of the loop
817 mptr = (struct march *) malloc(sizeof(struct march));
819 strcpy(mptr->march_name, "_BASEROOM_");
820 if (WC->march == NULL) {
824 while (mptr2->next != NULL)
829 * ...and remove the room we're currently in, so a <G>oto doesn't make us
830 * walk around in circles
832 remove_march(WC->wc_roomname);
834 if (WC->march != NULL) {
835 strcpy(next_room, pop_march(-1));
837 strcpy(next_room, "_BASEROOM_");
841 smart_goto(next_room);
846 * \brief goto next room
847 * \param next_room next room to go to
849 void smart_goto(char *next_room) {
857 * \brief mark all messages in current room as having been read
859 void slrp_highest(void)
863 serv_puts("SLRP HIGHEST");
864 serv_getln(buf, sizeof buf);
869 * \brief un-goto the previous room
875 if (!strcmp(WC->ugname, "")) {
876 smart_goto(WC->wc_roomname);
879 serv_printf("GOTO %s", WC->ugname);
880 serv_getln(buf, sizeof buf);
882 smart_goto(WC->wc_roomname);
885 if (WC->uglsn >= 0L) {
886 serv_printf("SLRP %ld", WC->uglsn);
887 serv_getln(buf, sizeof buf);
889 strcpy(buf, WC->ugname);
890 strcpy(WC->ugname, "");
899 * \brief Set/clear/read the "self-service list subscribe" flag for a room
901 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
902 * \return return the new value.
905 int self_service(int newval) {
906 int current_value = 0;
912 int flags, floor, order, view, flags2;
915 serv_getln(buf, sizeof buf);
916 if (buf[0] != '2') return(0);
918 extract_token(name, &buf[4], 0, '|', sizeof name);
919 extract_token(password, &buf[4], 1, '|', sizeof password);
920 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
921 flags = extract_int(&buf[4], 3);
922 floor = extract_int(&buf[4], 4);
923 order = extract_int(&buf[4], 5);
924 view = extract_int(&buf[4], 6);
925 flags2 = extract_int(&buf[4], 7);
927 if (flags2 & QR2_SELFLIST) {
935 flags2 = flags2 | QR2_SELFLIST;
937 else if (newval == 0) {
938 flags2 = flags2 & ~QR2_SELFLIST;
941 return(current_value);
944 if (newval != current_value) {
945 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
946 name, password, dirname, flags,
947 floor, order, view, flags2);
948 serv_getln(buf, sizeof buf);
961 * \brief display the form for editing a room
963 void display_editroom(void)
968 char remote_room[SIZ];
971 char er_password[10];
973 char er_roomaide[26];
979 char *not_shared_with;
986 if (strlen(tab) == 0) tab = "admin";
990 serv_getln(buf, sizeof buf);
993 strcpy(WC->ImportantMessage, &buf[4]);
997 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
998 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
999 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1000 er_flags = extract_int(&buf[4], 3);
1001 er_floor = extract_int(&buf[4], 4);
1003 output_headers(1, 1, 1, 0, 0, 0);
1005 /** print the tabbed dialog */
1007 "<div class=\"fix_scrollbar_bug\">"
1008 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
1010 "<TD> </TD>\n");
1012 if (!strcmp(tab, "admin")) {
1013 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1016 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1018 wprintf(_("Administration"));
1019 if (!strcmp(tab, "admin")) {
1020 wprintf("</SPAN></TD>\n");
1023 wprintf("</A></TD>\n");
1026 wprintf("<TD> </TD>\n");
1028 if (!strcmp(tab, "config")) {
1029 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1032 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=config\">");
1034 wprintf(_("Configuration"));
1035 if (!strcmp(tab, "config")) {
1036 wprintf("</SPAN></TD>\n");
1039 wprintf("</A></TD>\n");
1042 wprintf("<TD> </TD>\n");
1044 if (!strcmp(tab, "expire")) {
1045 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1048 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1050 wprintf(_("Message expire policy"));
1051 if (!strcmp(tab, "expire")) {
1052 wprintf("</SPAN></TD>\n");
1055 wprintf("</A></TD>\n");
1058 wprintf("<TD> </TD>\n");
1060 if (!strcmp(tab, "access")) {
1061 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1064 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=access\">");
1066 wprintf(_("Access controls"));
1067 if (!strcmp(tab, "access")) {
1068 wprintf("</SPAN></TD>\n");
1071 wprintf("</A></TD>\n");
1074 wprintf("<TD> </TD>\n");
1076 if (!strcmp(tab, "sharing")) {
1077 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1080 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1082 wprintf(_("Sharing"));
1083 if (!strcmp(tab, "sharing")) {
1084 wprintf("</SPAN></TD>\n");
1087 wprintf("</A></TD>\n");
1090 wprintf("<TD> </TD>\n");
1092 if (!strcmp(tab, "listserv")) {
1093 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1096 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1098 wprintf(_("Mailing list service"));
1099 if (!strcmp(tab, "listserv")) {
1100 wprintf("</SPAN></TD>\n");
1103 wprintf("</A></TD>\n");
1106 wprintf("<TD> </TD>\n");
1108 wprintf("</TR></TABLE></div>\n");
1109 /** end tabbed dialog */
1111 /** begin content of whatever tab is open now */
1112 wprintf("<div class=\"fix_scrollbar_bug\">"
1113 "<TABLE class=\"roomops_background\">\n"
1116 if (!strcmp(tab, "admin")) {
1118 "<LI><a href=\"delete_room\" "
1119 "onClick=\"return confirm('");
1120 wprintf(_("Are you sure you want to delete this room?"));
1121 wprintf("');\">\n");
1122 wprintf(_("Delete this room"));
1124 "<LI><a href=\"display_editroompic\">\n");
1125 wprintf(_("Set or change the icon for this room's banner"));
1127 "<LI><a href=\"display_editinfo\">\n");
1128 wprintf(_("Edit this room's Info file"));
1133 if (!strcmp(tab, "config")) {
1134 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1136 wprintf("<UL><LI>");
1137 wprintf(_("Name of room: "));
1138 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1144 wprintf(_("Resides on floor: "));
1145 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1146 for (i = 0; i < 128; ++i)
1147 if (strlen(floorlist[i]) > 0) {
1148 wprintf("<OPTION ");
1150 wprintf("SELECTED ");
1151 wprintf("VALUE=\"%d\">", i);
1152 escputs(floorlist[i]);
1153 wprintf("</OPTION>\n");
1155 wprintf("</SELECT>\n");
1158 wprintf(_("Type of room:"));
1161 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1162 if ((er_flags & QR_PRIVATE) == 0)
1163 wprintf("CHECKED ");
1165 wprintf(_("Public room"));
1168 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1169 if ((er_flags & QR_PRIVATE) &&
1170 (er_flags & QR_GUESSNAME))
1171 wprintf("CHECKED ");
1173 wprintf(_("Private - guess name"));
1175 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1176 if ((er_flags & QR_PRIVATE) &&
1177 (er_flags & QR_PASSWORDED))
1178 wprintf("CHECKED ");
1180 wprintf(_("Private - require password:"));
1181 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1184 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1185 if ((er_flags & QR_PRIVATE)
1186 && ((er_flags & QR_GUESSNAME) == 0)
1187 && ((er_flags & QR_PASSWORDED) == 0))
1188 wprintf("CHECKED ");
1190 wprintf(_("Private - invitation only"));
1192 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1194 wprintf(_("If private, cause current users to forget room"));
1196 wprintf("\n</UL>\n");
1198 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1199 if (er_flags & QR_PREFONLY)
1200 wprintf("CHECKED ");
1202 wprintf(_("Preferred users only"));
1204 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1205 if (er_flags & QR_READONLY)
1206 wprintf("CHECKED ");
1208 wprintf(_("Read-only room"));
1210 /** directory stuff */
1211 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1212 if (er_flags & QR_DIRECTORY)
1213 wprintf("CHECKED ");
1215 wprintf(_("File directory room"));
1217 wprintf("\n<UL><LI>");
1218 wprintf(_("Directory name: "));
1219 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1222 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1223 if (er_flags & QR_UPLOAD)
1224 wprintf("CHECKED ");
1226 wprintf(_("Uploading allowed"));
1228 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1229 if (er_flags & QR_DOWNLOAD)
1230 wprintf("CHECKED ");
1232 wprintf(_("Downloading allowed"));
1234 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1235 if (er_flags & QR_VISDIR)
1236 wprintf("CHECKED ");
1238 wprintf(_("Visible directory"));
1241 /** end of directory stuff */
1243 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1244 if (er_flags & QR_NETWORK)
1245 wprintf("CHECKED ");
1247 wprintf(_("Network shared room"));
1249 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1250 if (er_flags & QR_PERMANENT)
1251 wprintf("CHECKED ");
1253 wprintf(_("Permanent (does not auto-purge)"));
1255 /** start of anon options */
1258 wprintf(_("Anonymous messages"));
1261 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1262 if (((er_flags & QR_ANONONLY) == 0)
1263 && ((er_flags & QR_ANONOPT) == 0))
1264 wprintf("CHECKED ");
1266 wprintf(_("No anonymous messages"));
1268 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1269 if (er_flags & QR_ANONONLY)
1270 wprintf("CHECKED ");
1272 wprintf(_("All messages are anonymous"));
1274 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1275 if (er_flags & QR_ANONOPT)
1276 wprintf("CHECKED ");
1278 wprintf(_("Prompt user when entering messages"));
1281 /* end of anon options */
1284 wprintf(_("Room aide: "));
1286 serv_getln(buf, sizeof buf);
1287 if (buf[0] != '2') {
1288 wprintf("<em>%s</em>\n", &buf[4]);
1290 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1291 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1294 wprintf("</UL><CENTER>\n");
1295 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1296 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1298 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1306 /** Sharing the room with other Citadel nodes... */
1307 if (!strcmp(tab, "sharing")) {
1309 shared_with = strdup("");
1310 not_shared_with = strdup("");
1312 /** Learn the current configuration */
1313 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1314 serv_getln(buf, sizeof buf);
1315 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1316 extract_token(node, buf, 0, '|', sizeof node);
1317 not_shared_with = realloc(not_shared_with,
1318 strlen(not_shared_with) + 32);
1319 strcat(not_shared_with, node);
1320 strcat(not_shared_with, "\n");
1324 serv_getln(buf, sizeof buf);
1325 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1326 extract_token(cmd, buf, 0, '|', sizeof cmd);
1327 extract_token(node, buf, 1, '|', sizeof node);
1328 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1329 if (!strcasecmp(cmd, "ignet_push_share")) {
1330 shared_with = realloc(shared_with,
1331 strlen(shared_with) + 32);
1332 strcat(shared_with, node);
1333 if (strlen(remote_room) > 0) {
1334 strcat(shared_with, "|");
1335 strcat(shared_with, remote_room);
1337 strcat(shared_with, "\n");
1341 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1342 extract_token(buf, shared_with, i, '\n', sizeof buf);
1343 extract_token(node, buf, 0, '|', sizeof node);
1344 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1345 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1346 if (!strcasecmp(node, cmd)) {
1347 remove_token(not_shared_with, j, '\n');
1352 /** Display the stuff */
1353 wprintf("<CENTER><br />"
1354 "<TABLE border=1 cellpadding=5><TR>"
1356 wprintf(_("Shared with"));
1357 wprintf("</I></B></TD>"
1359 wprintf(_("Not shared with"));
1360 wprintf("</I></B></TD></TR>\n"
1361 "<TR><TD VALIGN=TOP>\n");
1363 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1364 wprintf(_("Remote node name"));
1365 wprintf("</TD><TD>");
1366 wprintf(_("Remote room name"));
1367 wprintf("</TD><TD>");
1368 wprintf(_("Actions"));
1369 wprintf("</TD></TR>\n");
1371 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1372 extract_token(buf, shared_with, i, '\n', sizeof buf);
1373 extract_token(node, buf, 0, '|', sizeof node);
1374 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1375 if (strlen(node) > 0) {
1376 wprintf("<FORM METHOD=\"POST\" "
1377 "action=\"netedit\">"
1378 "<TR><TD>%s</TD>\n", node);
1381 if (strlen(remote_room) > 0) {
1382 escputs(remote_room);
1388 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1389 "VALUE=\"ignet_push_share|");
1391 if (strlen(remote_room) > 0) {
1393 urlescputs(remote_room);
1396 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1397 "VALUE=\"sharing\">\n");
1398 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1399 "VALUE=\"remove\">\n");
1400 wprintf("<INPUT TYPE=\"submit\" "
1401 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1402 wprintf("</TD></TR></FORM>\n");
1406 wprintf("</TABLE>\n");
1407 wprintf("</TD><TD VALIGN=TOP>\n");
1408 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1409 wprintf(_("Remote node name"));
1410 wprintf("</TD><TD>");
1411 wprintf(_("Remote room name"));
1412 wprintf("</TD><TD>");
1413 wprintf(_("Actions"));
1414 wprintf("</TD></TR>\n");
1416 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1417 extract_token(node, not_shared_with, i, '\n', sizeof node);
1418 if (strlen(node) > 0) {
1419 wprintf("<FORM METHOD=\"POST\" "
1420 "action=\"netedit\">"
1424 "<INPUT TYPE=\"INPUT\" "
1428 wprintf("<INPUT TYPE=\"hidden\" "
1430 "VALUE=\"ignet_push_share|");
1433 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1434 "VALUE=\"sharing\">\n");
1435 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1436 "VALUE=\"add\">\n");
1437 wprintf("<INPUT TYPE=\"submit\" "
1438 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1439 wprintf("</TD></TR></FORM>\n");
1443 wprintf("</TABLE>\n");
1444 wprintf("</TD></TR>"
1445 "</TABLE></CENTER><br />\n"
1446 "<I><B>%s</B><UL><LI>", _("Notes:"));
1447 wprintf(_("When sharing a room, "
1448 "it must be shared from both ends. Adding a node to "
1449 "the 'shared' list sends messages out, but in order to"
1450 " receive messages, the other nodes must be configured"
1451 " to send messages out to your system as well. "
1452 "<LI>If the remote room name is blank, it is assumed "
1453 "that the room name is identical on the remote node."
1454 "<LI>If the remote room name is different, the remote "
1455 "node must also configure the name of the room here."
1461 /** Mailing list management */
1462 if (!strcmp(tab, "listserv")) {
1464 wprintf("<br /><center>"
1465 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1466 "<TR><TD VALIGN=TOP>");
1468 wprintf(_("<i>The contents of this room are being "
1469 "mailed <b>as individual messages</b> "
1470 "to the following list recipients:"
1471 "</i><br /><br />\n"));
1474 serv_getln(buf, sizeof buf);
1475 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1476 extract_token(cmd, buf, 0, '|', sizeof cmd);
1477 if (!strcasecmp(cmd, "listrecp")) {
1478 extract_token(recp, buf, 1, '|', sizeof recp);
1481 wprintf(" <a href=\"netedit&cmd=remove&line="
1484 wprintf("&tab=listserv\">");
1485 wprintf(_("(remove)"));
1486 wprintf("</A><br />");
1489 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1490 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1491 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1492 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1493 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1494 wprintf("</FORM>\n");
1496 wprintf("</TD><TD VALIGN=TOP>\n");
1498 wprintf(_("<i>The contents of this room are being "
1499 "mailed <b>in digest form</b> "
1500 "to the following list recipients:"
1501 "</i><br /><br />\n"));
1504 serv_getln(buf, sizeof buf);
1505 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1506 extract_token(cmd, buf, 0, '|', sizeof cmd);
1507 if (!strcasecmp(cmd, "digestrecp")) {
1508 extract_token(recp, buf, 1, '|', sizeof recp);
1511 wprintf(" <a href=\"netedit&cmd=remove&line="
1514 wprintf("&tab=listserv\">");
1515 wprintf(_("(remove)"));
1516 wprintf("</A><br />");
1519 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1520 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1521 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1522 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1523 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1524 wprintf("</FORM>\n");
1526 wprintf("</TD></TR></TABLE><hr />\n");
1528 if (self_service(999) == 1) {
1529 wprintf(_("This room is configured to allow "
1530 "self-service subscribe/unsubscribe requests."));
1531 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1532 wprintf(_("Click to disable."));
1533 wprintf("</A><br />\n");
1534 wprintf(_("The URL for subscribe/unsubscribe is: "));
1535 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1536 (is_https ? "https" : "http"),
1540 wprintf(_("This room is <i>not</i> configured to allow "
1541 "self-service subscribe/unsubscribe requests."));
1542 wprintf(" <a href=\"toggle_self_service?newval=1&"
1544 wprintf(_("Click to enable."));
1545 wprintf("</A><br />\n");
1549 wprintf("</CENTER>\n");
1553 /** Mailing list management */
1554 if (!strcmp(tab, "expire")) {
1556 serv_puts("GPEX room");
1557 serv_getln(buf, sizeof buf);
1558 if (buf[0] == '2') {
1559 roompolicy = extract_int(&buf[4], 0);
1560 roomvalue = extract_int(&buf[4], 1);
1563 serv_puts("GPEX floor");
1564 serv_getln(buf, sizeof buf);
1565 if (buf[0] == '2') {
1566 floorpolicy = extract_int(&buf[4], 0);
1567 floorvalue = extract_int(&buf[4], 1);
1570 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1571 wprintf("<TABLE border=0 cellspacing=5>\n");
1572 wprintf("<TR><TD>");
1573 wprintf(_("Message expire policy for this room"));
1575 escputs(WC->wc_roomname);
1576 wprintf(")</TD><TD>");
1577 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1578 ((roompolicy == 0) ? "CHECKED" : "") );
1579 wprintf(_("Use the default policy for this floor"));
1580 wprintf("<br />\n");
1581 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1582 ((roompolicy == 1) ? "CHECKED" : "") );
1583 wprintf(_("Never automatically expire messages"));
1584 wprintf("<br />\n");
1585 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1586 ((roompolicy == 2) ? "CHECKED" : "") );
1587 wprintf(_("Expire by message count"));
1588 wprintf("<br />\n");
1589 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1590 ((roompolicy == 3) ? "CHECKED" : "") );
1591 wprintf(_("Expire by message age"));
1593 wprintf(_("Number of messages or days: "));
1594 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1595 wprintf("</TD></TR>\n");
1597 if (WC->axlevel >= 6) {
1598 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1599 wprintf("<TR><TD>");
1600 wprintf(_("Message expire policy for this floor"));
1602 escputs(floorlist[WC->wc_floor]);
1603 wprintf(")</TD><TD>");
1604 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1605 ((floorpolicy == 0) ? "CHECKED" : "") );
1606 wprintf(_("Use the system default"));
1607 wprintf("<br />\n");
1608 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1609 ((floorpolicy == 1) ? "CHECKED" : "") );
1610 wprintf(_("Never automatically expire messages"));
1611 wprintf("<br />\n");
1612 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1613 ((floorpolicy == 2) ? "CHECKED" : "") );
1614 wprintf(_("Expire by message count"));
1615 wprintf("<br />\n");
1616 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1617 ((floorpolicy == 3) ? "CHECKED" : "") );
1618 wprintf(_("Expire by message age"));
1620 wprintf(_("Number of messages or days: "));
1621 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1625 wprintf("<CENTER>\n");
1626 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1627 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1629 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1630 wprintf("</CENTER></TD><TR>\n");
1632 wprintf("</TABLE>\n"
1633 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1639 /** Mailing list management */
1640 if (!strcmp(tab, "access")) {
1644 /** end content of whatever tab is open now */
1645 wprintf("</TD></TR></TABLE></div>\n");
1652 * \brief Toggle self-service list subscription
1654 void toggle_self_service(void) {
1657 newval = atoi(bstr("newval"));
1658 self_service(newval);
1665 * \brief save new parameters for a room
1671 char er_password[10];
1672 char er_dirname[15];
1673 char er_roomaide[26];
1679 if (strlen(bstr("ok_button")) == 0) {
1680 strcpy(WC->ImportantMessage,
1681 _("Cancelled. Changes were not saved."));
1686 serv_getln(buf, sizeof buf);
1688 if (buf[0] != '2') {
1689 strcpy(WC->ImportantMessage, &buf[4]);
1693 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1694 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1695 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1696 er_flags = extract_int(&buf[4], 3);
1698 strcpy(er_roomaide, bstr("er_roomaide"));
1699 if (strlen(er_roomaide) == 0) {
1701 serv_getln(buf, sizeof buf);
1702 if (buf[0] != '2') {
1703 strcpy(er_roomaide, "");
1705 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1708 strcpy(buf, bstr("er_name"));
1710 if (strlen(buf) > 0) {
1711 strcpy(er_name, buf);
1714 strcpy(buf, bstr("er_password"));
1716 if (strlen(buf) > 0)
1717 strcpy(er_password, buf);
1719 strcpy(buf, bstr("er_dirname"));
1721 if (strlen(buf) > 0)
1722 strcpy(er_dirname, buf);
1724 strcpy(buf, bstr("type"));
1725 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1727 if (!strcmp(buf, "invonly")) {
1728 er_flags |= (QR_PRIVATE);
1730 if (!strcmp(buf, "hidden")) {
1731 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1733 if (!strcmp(buf, "passworded")) {
1734 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1736 if (!strcmp(bstr("prefonly"), "yes")) {
1737 er_flags |= QR_PREFONLY;
1739 er_flags &= ~QR_PREFONLY;
1742 if (!strcmp(bstr("readonly"), "yes")) {
1743 er_flags |= QR_READONLY;
1745 er_flags &= ~QR_READONLY;
1748 if (!strcmp(bstr("permanent"), "yes")) {
1749 er_flags |= QR_PERMANENT;
1751 er_flags &= ~QR_PERMANENT;
1754 if (!strcmp(bstr("network"), "yes")) {
1755 er_flags |= QR_NETWORK;
1757 er_flags &= ~QR_NETWORK;
1760 if (!strcmp(bstr("directory"), "yes")) {
1761 er_flags |= QR_DIRECTORY;
1763 er_flags &= ~QR_DIRECTORY;
1766 if (!strcmp(bstr("ulallowed"), "yes")) {
1767 er_flags |= QR_UPLOAD;
1769 er_flags &= ~QR_UPLOAD;
1772 if (!strcmp(bstr("dlallowed"), "yes")) {
1773 er_flags |= QR_DOWNLOAD;
1775 er_flags &= ~QR_DOWNLOAD;
1778 if (!strcmp(bstr("visdir"), "yes")) {
1779 er_flags |= QR_VISDIR;
1781 er_flags &= ~QR_VISDIR;
1784 strcpy(buf, bstr("anon"));
1786 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1787 if (!strcmp(buf, "anononly"))
1788 er_flags |= QR_ANONONLY;
1789 if (!strcmp(buf, "anon2"))
1790 er_flags |= QR_ANONOPT;
1793 if (!strcmp(bstr("bump"), "yes"))
1796 er_floor = atoi(bstr("er_floor"));
1798 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1799 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1801 serv_getln(buf, sizeof buf);
1802 if (buf[0] != '2') {
1803 strcpy(WC->ImportantMessage, &buf[4]);
1809 if (strlen(er_roomaide) > 0) {
1810 sprintf(buf, "SETA %s", er_roomaide);
1812 serv_getln(buf, sizeof buf);
1813 if (buf[0] != '2') {
1814 strcpy(WC->ImportantMessage, &buf[4]);
1815 display_main_menu();
1820 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1827 * \brief Display form for Invite, Kick, and show Who Knows a room
1829 void do_invt_kick(void) {
1830 char buf[SIZ], room[SIZ], username[SIZ];
1833 serv_getln(buf, sizeof buf);
1835 if (buf[0] != '2') {
1839 extract_token(room, &buf[4], 0, '|', sizeof room);
1841 strcpy(username, bstr("username"));
1843 if (strlen(bstr("kick_button")) > 0) {
1844 sprintf(buf, "KICK %s", username);
1846 serv_getln(buf, sizeof buf);
1848 if (buf[0] != '2') {
1849 strcpy(WC->ImportantMessage, &buf[4]);
1851 sprintf(WC->ImportantMessage,
1852 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1857 if (strlen(bstr("invite_button")) > 0) {
1858 sprintf(buf, "INVT %s", username);
1860 serv_getln(buf, sizeof buf);
1862 if (buf[0] != '2') {
1863 strcpy(WC->ImportantMessage, &buf[4]);
1865 sprintf(WC->ImportantMessage,
1866 _("<B><I>User %s invited to room %s.</I></B>\n"),
1877 * \brief Display form for Invite, Kick, and show Who Knows a room
1879 void display_whok(void)
1881 char buf[SIZ], room[SIZ], username[SIZ];
1884 serv_getln(buf, sizeof buf);
1886 if (buf[0] != '2') {
1890 extract_token(room, &buf[4], 0, '|', sizeof room);
1893 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1894 wprintf(_("The users listed below have access to this room. "
1895 "To remove a user from the access list, select the user "
1896 "name from the list and click 'Kick'."));
1897 wprintf("<br /><br />");
1899 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1900 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1901 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1903 serv_getln(buf, sizeof buf);
1904 if (buf[0] == '1') {
1905 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1906 extract_token(username, buf, 0, '|', sizeof username);
1907 wprintf("<OPTION>");
1912 wprintf("</SELECT><br />\n");
1914 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1915 wprintf("</FORM></CENTER>\n");
1917 wprintf("</TD><TD>");
1918 wprintf(_("To grant another user access to this room, enter the "
1919 "user name in the box below and click 'Invite'."));
1920 wprintf("<br /><br />");
1922 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1923 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1924 wprintf(_("Invite:"));
1926 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1927 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1928 "<input type=\"submit\" value=\"%s\">"
1929 "</FORM></CENTER>\n", _("Invite"));
1931 wprintf("</TD></TR></TABLE>\n");
1938 * \brief display the form for entering a new room
1940 void display_entroom(void)
1945 serv_puts("CRE8 0");
1946 serv_getln(buf, sizeof buf);
1948 if (buf[0] != '2') {
1949 strcpy(WC->ImportantMessage, &buf[4]);
1950 display_main_menu();
1954 output_headers(1, 1, 2, 0, 0, 0);
1955 wprintf("<div id=\"banner\">\n"
1956 "<TABLE class=\"roomops_banner\"><TR><TD>"
1957 "<SPAN CLASS=\"titlebar\">");
1958 wprintf(_("Create a new room"));
1960 "</TD></TR></TABLE>\n"
1961 "</div>\n<div id=\"content\">\n"
1964 wprintf("<div class=\"fix_scrollbar_bug\">"
1965 "<table class=\"roomops_background\"><tr><td>\n");
1967 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1969 wprintf("<UL><LI>");
1970 wprintf(_("Name of room: "));
1971 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1974 wprintf(_("Resides on floor: "));
1976 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1977 for (i = 0; i < 128; ++i)
1978 if (strlen(floorlist[i]) > 0) {
1979 wprintf("<OPTION ");
1980 wprintf("VALUE=\"%d\">", i);
1981 escputs(floorlist[i]);
1982 wprintf("</OPTION>\n");
1984 wprintf("</SELECT>\n");
1987 * Our clever little snippet of JavaScript automatically selects
1988 * a public room if the view is set to Bulletin Board or wiki, and
1989 * it selects a mailbox room otherwise. The user can override this,
1990 * of course. We also disable the floor selector for mailboxes.
1993 wprintf(_("Default view for room: "));
1994 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1995 " if ( (this.form.er_view.value == 0) "
1996 " || (this.form.er_view.value == 6) ) { "
1997 " this.form.type[0].checked=true; "
1998 " this.form.er_floor.disabled = false; "
2001 " this.form.type[4].checked=true; "
2002 " this.form.er_floor.disabled = true; "
2005 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2006 if (is_view_allowed_as_default(i)) {
2007 wprintf("<OPTION %s VALUE=\"%d\">",
2008 ((i == 0) ? "SELECTED" : ""), i );
2009 escputs(viewdefs[i]);
2010 wprintf("</OPTION>\n");
2013 wprintf("</SELECT>\n");
2016 wprintf(_("Type of room:"));
2019 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2020 wprintf("CHECKED OnChange=\""
2021 " if (this.form.type[0].checked == true) { "
2022 " this.form.er_floor.disabled = false; "
2025 wprintf(_("Public (automatically appears to everyone)"));
2027 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2028 " if (this.form.type[1].checked == true) { "
2029 " this.form.er_floor.disabled = false; "
2032 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2034 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2035 " if (this.form.type[2].checked == true) { "
2036 " this.form.er_floor.disabled = false; "
2039 wprintf(_("Private - require password: "));
2040 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2042 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2043 " if (this.form.type[3].checked == true) { "
2044 " this.form.er_floor.disabled = false; "
2047 wprintf(_("Private - invitation only"));
2049 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2051 " if (this.form.type[4].checked == true) { "
2052 " this.form.er_floor.disabled = true; "
2055 wprintf(_("Personal (mailbox for you only)"));
2057 wprintf("\n</UL>\n");
2059 wprintf("<CENTER>\n");
2060 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2062 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2063 wprintf("</CENTER>\n");
2064 wprintf("</FORM>\n<hr />");
2065 serv_printf("MESG roomaccess");
2066 serv_getln(buf, sizeof buf);
2067 if (buf[0] == '1') {
2070 wprintf("</td></tr></table></div>\n");
2078 * \brief support function for entroom() -- sets the default view
2080 void er_set_default_view(int newview) {
2093 serv_getln(buf, sizeof buf);
2094 if (buf[0] != '2') return;
2096 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2097 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2098 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2099 rm_bits1 = extract_int(&buf[4], 3);
2100 rm_floor = extract_int(&buf[4], 4);
2101 rm_listorder = extract_int(&buf[4], 5);
2102 rm_bits2 = extract_int(&buf[4], 7);
2104 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2105 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2106 rm_listorder, newview, rm_bits2
2108 serv_getln(buf, sizeof buf);
2114 * \brief enter a new room
2121 char er_password[SIZ];
2126 if (strlen(bstr("ok_button")) == 0) {
2127 strcpy(WC->ImportantMessage,
2128 _("Cancelled. No new room was created."));
2129 display_main_menu();
2132 strcpy(er_name, bstr("er_name"));
2133 strcpy(er_type, bstr("type"));
2134 strcpy(er_password, bstr("er_password"));
2135 er_floor = atoi(bstr("er_floor"));
2136 er_view = atoi(bstr("er_view"));
2139 if (!strcmp(er_type, "hidden"))
2141 if (!strcmp(er_type, "passworded"))
2143 if (!strcmp(er_type, "invonly"))
2145 if (!strcmp(er_type, "personal"))
2148 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2149 er_name, er_num_type, er_password, er_floor, 0, er_view);
2151 serv_getln(buf, sizeof buf);
2152 if (buf[0] != '2') {
2153 strcpy(WC->ImportantMessage, &buf[4]);
2154 display_main_menu();
2158 do_change_view(er_view); /* Now go there */
2163 * \brief display the screen to enter a private room
2165 void display_private(char *rname, int req_pass)
2167 output_headers(1, 1, 2, 0, 0, 0);
2168 wprintf("<div id=\"banner\">\n"
2169 "<TABLE class=\"roomops_banner\"><TR><TD>"
2170 "<SPAN CLASS=\"titlebar\">");
2171 wprintf(_("Go to a hidden room"));
2173 "</TD></TR></TABLE>\n"
2174 "</div>\n<div id=\"content\">\n"
2177 wprintf("<div class=\"fix_scrollbar_bug\">"
2178 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2180 wprintf("<CENTER>\n");
2182 wprintf(_("If you know the name of a hidden (guess-name) or "
2183 "passworded room, you can enter that room by typing "
2184 "its name below. Once you gain access to a private "
2185 "room, it will appear in your regular room listings "
2186 "so you don't have to keep returning here."));
2187 wprintf("\n<br /><br />");
2189 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2191 wprintf("<table border=\"0\" cellspacing=\"5\" "
2192 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2194 wprintf(_("Enter room name:"));
2196 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2197 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2200 wprintf("</TD></TR><TR><TD>");
2201 wprintf(_("Enter room password:"));
2202 wprintf("</TD><TD>");
2203 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2205 wprintf("</TD></TR></TABLE><br />\n");
2207 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2209 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2213 wprintf("</FORM>\n");
2214 wprintf("</td></tr></table></div>\n");
2219 * \brief goto a private room
2221 void goto_private(void)
2226 if (strlen(bstr("ok_button")) == 0) {
2227 display_main_menu();
2230 strcpy(hold_rm, WC->wc_roomname);
2231 strcpy(buf, "GOTO ");
2232 strcat(buf, bstr("gr_name"));
2234 strcat(buf, bstr("gr_pass"));
2236 serv_getln(buf, sizeof buf);
2238 if (buf[0] == '2') {
2239 smart_goto(bstr("gr_name"));
2242 if (!strncmp(buf, "540", 3)) {
2243 display_private(bstr("gr_name"), 1);
2246 output_headers(1, 1, 1, 0, 0, 0);
2247 wprintf("%s\n", &buf[4]);
2254 * \brief display the screen to zap a room
2256 void display_zap(void)
2258 output_headers(1, 1, 2, 0, 0, 0);
2260 wprintf("<div id=\"banner\">\n");
2261 wprintf("<TABLE class=\"roomops_zap\"><TR><TD>");
2262 wprintf("<SPAN CLASS=\"titlebar\">");
2263 wprintf(_("Zap (forget/unsubscribe) the current room"));
2264 wprintf("</SPAN>\n");
2265 wprintf("</TD></TR></TABLE>\n");
2266 wprintf("</div>\n<div id=\"content\">\n");
2268 wprintf(_("If you select this option, <em>%s</em> will "
2269 "disappear from your room list. Is this what you wish "
2270 "to do?<br />\n"), WC->wc_roomname);
2272 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2273 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2275 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2276 wprintf("</FORM>\n");
2287 char final_destination[SIZ];
2290 * If the forget-room routine fails for any reason, we fall back
2291 * to the current room; otherwise, we go to the Lobby
2293 strcpy(final_destination, WC->wc_roomname);
2295 if (strlen(bstr("ok_button")) > 0) {
2296 serv_printf("GOTO %s", WC->wc_roomname);
2297 serv_getln(buf, sizeof buf);
2298 if (buf[0] == '2') {
2300 serv_getln(buf, sizeof buf);
2301 if (buf[0] == '2') {
2302 strcpy(final_destination, "_BASEROOM_");
2306 smart_goto(final_destination);
2312 * \brief Delete the current room
2314 void delete_room(void)
2318 serv_puts("KILL 1");
2319 serv_getln(buf, sizeof buf);
2320 if (buf[0] != '2') {
2321 strcpy(WC->ImportantMessage, &buf[4]);
2322 display_main_menu();
2325 smart_goto("_BASEROOM_");
2332 * \brief Perform changes to a room's network configuration
2334 void netedit(void) {
2343 if (strlen(bstr("line"))==0) {
2348 strcpy(line, bstr("prefix"));
2349 strcat(line, bstr("line"));
2350 strcat(line, bstr("suffix"));
2359 serv_getln(buf, sizeof buf);
2360 if (buf[0] != '1') {
2366 /** This loop works for add *or* remove. Spiffy, eh? */
2367 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2368 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2369 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2370 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2371 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2372 if ( (strcasecmp(cmpa0, cmpb0))
2373 || (strcasecmp(cmpa1, cmpb1)) ) {
2374 fprintf(fp, "%s\n", buf);
2380 serv_getln(buf, sizeof buf);
2381 if (buf[0] != '4') {
2387 while (fgets(buf, sizeof buf, fp) != NULL) {
2388 buf[strlen(buf)-1] = 0;
2392 if (strlen(bstr("add_button")) > 0) {
2404 * \brief Convert a room name to a folder-ish-looking name.
2405 * \param folder the folderish name
2406 * \param room the room name
2407 * \param floor the floor name
2408 * \param is_mailbox is it a mailbox?
2410 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2415 * For mailboxes, just do it straight...
2418 sprintf(folder, "My folders|%s", room);
2422 * Otherwise, prefix the floor name as a "public folders" moniker
2425 sprintf(folder, "%s|%s", floorlist[floor], room);
2429 * Replace "\" characters with "|" for pseudo-folder-delimiting
2431 for (i=0; i<strlen(folder); ++i) {
2432 if (folder[i] == '\\') folder[i] = '|';
2440 * \brief Back end for change_view()
2441 * \param newview set newview???
2443 void do_change_view(int newview) {
2446 serv_printf("VIEW %d", newview);
2447 serv_getln(buf, sizeof buf);
2448 WC->wc_view = newview;
2449 smart_goto(WC->wc_roomname);
2455 * \brief Change the view for this room
2457 void change_view(void) {
2460 view = atol(bstr("view"));
2461 do_change_view(view);
2466 * \brief One big expanded tree list view --- like a folder list
2467 * \param fold the folder to view
2468 * \param max_folders how many folders???
2469 * \param num_floors hom many floors???
2471 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2475 int has_subfolders = 0;
2478 parents = malloc(max_folders * sizeof(int));
2480 /** BEGIN TREE MENU */
2481 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2483 /** include NanoTree */
2484 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2486 /** initialize NanoTree */
2487 wprintf("<script type=\"text/javascript\"> \n"
2488 " showRootNode = false; \n"
2489 " sortNodes = false; \n"
2490 " dragable = false; \n"
2492 " function standardClick(treeNode) { \n"
2495 " var closedGif = 'static/folder_closed.gif'; \n"
2496 " var openGif = 'static/folder_open.gif'; \n"
2498 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2502 for (i=0; i<max_folders; ++i) {
2505 if ((i+1) < max_folders) {
2506 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2507 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2512 levels = num_tokens(fold[i].name, '|');
2513 parents[levels] = i;
2515 wprintf("var node%d = new TreeNode(%d, '", i, i);
2517 if (fold[i].selectable) {
2518 wprintf("<a href=\"dotgoto?room=");
2519 urlescputs(fold[i].room);
2524 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2526 else if (fold[i].hasnewmsgs) {
2527 wprintf("<SPAN CLASS=\"roomlist_new\">");
2530 wprintf("<SPAN CLASS=\"roomlist_old\">");
2532 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2537 if (has_subfolders) {
2538 wprintf("new Array(closedGif, openGif)");
2540 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2541 wprintf("'static/viewcontacts_16x.gif'");
2543 else if (fold[i].view == VIEW_CALENDAR) {
2544 wprintf("'static/calarea_16x.gif'");
2546 else if (fold[i].view == VIEW_CALBRIEF) {
2547 wprintf("'static/calarea_16x.gif'");
2549 else if (fold[i].view == VIEW_TASKS) {
2550 wprintf("'static/taskmanag_16x.gif'");
2552 else if (fold[i].view == VIEW_NOTES) {
2553 wprintf("'static/storenotes_16x.gif'");
2555 else if (fold[i].view == VIEW_MAILBOX) {
2556 wprintf("'static/privatemess_16x.gif'");
2559 wprintf("'static/chatrooms_16x.gif'");
2562 urlescputs(fold[i].name);
2566 wprintf("rootNode.addChild(node%d);\n", i);
2569 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2573 wprintf("container = document.getElementById('roomlist_div'); \n"
2579 /** END TREE MENU */
2583 * \brief Boxes and rooms and lists ... oh my!
2584 * \param fold the folder to view
2585 * \param max_folders how many folders???
2586 * \param num_floors hom many floors???
2588 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2590 char floor_name[256];
2591 char old_floor_name[256];
2593 int levels, oldlevels;
2596 static int columns = 3;
2597 int boxes_per_column = 0;
2598 int current_column = 0;
2601 strcpy(floor_name, "");
2602 strcpy(old_floor_name, "");
2605 while (nf % columns != 0) ++nf;
2606 boxes_per_column = (nf / columns);
2607 if (boxes_per_column < 1) boxes_per_column = 1;
2609 /** Outer table (for columnization) */
2610 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2611 "<tr><td valign=top>");
2615 for (i=0; i<max_folders; ++i) {
2617 levels = num_tokens(fold[i].name, '|');
2618 extract_token(floor_name, fold[i].name, 0,
2619 '|', sizeof floor_name);
2621 if ( (strcasecmp(floor_name, old_floor_name))
2622 && (strlen(old_floor_name) > 0) ) {
2624 do_template("endbox");
2627 if ((num_boxes % boxes_per_column) == 0) {
2629 if (current_column < columns) {
2630 wprintf("</td><td valign=top>\n");
2634 strcpy(old_floor_name, floor_name);
2637 /** Begin inner box */
2638 stresc(boxtitle, floor_name, 1, 0);
2639 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2640 do_template("beginbox");
2647 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2648 if (fold[i].selectable) {
2649 wprintf("<a href=\"dotgoto?room=");
2650 urlescputs(fold[i].room);
2656 if (fold[i].hasnewmsgs) {
2657 wprintf("<SPAN CLASS=\"roomlist_new\">");
2660 wprintf("<SPAN CLASS=\"roomlist_old\">");
2662 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2665 if (fold[i].selectable) {
2671 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2672 wprintf(" (INBOX)");
2674 wprintf("<br />\n");
2677 /** End the final inner box */
2678 do_template("endbox");
2680 wprintf("</TD></TR></TABLE>\n");
2684 * \brief print a floor div???
2685 * \param which_floordiv name of the floordiv???
2687 void set_floordiv_expanded(char *which_floordiv) {
2688 begin_ajax_response();
2689 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2690 end_ajax_response();
2694 * \brief view the iconbar
2695 * \param fold the folder to view
2696 * \param max_folders how many folders???
2697 * \param num_floors hom many floors???
2699 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2701 char floor_name[256];
2702 char old_floor_name[256];
2703 char floordivtitle[256];
2704 char floordiv_id[32];
2705 int levels, oldlevels;
2707 int num_drop_targets = 0;
2710 strcpy(floor_name, "");
2711 strcpy(old_floor_name, "");
2715 for (i=0; i<max_folders; ++i) {
2717 levels = num_tokens(fold[i].name, '|');
2718 extract_token(floor_name, fold[i].name, 0,
2719 '|', sizeof floor_name);
2721 if ( (strcasecmp(floor_name, old_floor_name))
2722 && (strlen(old_floor_name) > 0) ) {
2723 /** End inner box */
2725 wprintf("</div>\n"); /** floordiv */
2727 strcpy(old_floor_name, floor_name);
2731 stresc(floordivtitle, floor_name, 0, 0);
2732 sprintf(floordiv_id, "floordiv%d", i);
2733 wprintf("<span class=\"ib_roomlist_floor\" "
2734 "onClick=\"expand_floor('%s')\">"
2735 "%s</span><br>\n", floordiv_id, floordivtitle);
2736 wprintf("<div id=\"%s\" style=\"display:%s\">",
2738 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2745 wprintf("<div id=\"roomdiv%d\">", i);
2747 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2749 /** choose the icon */
2750 if (fold[i].view == VIEW_ADDRESSBOOK) {
2751 icon = "viewcontacts_16x.gif" ;
2753 else if (fold[i].view == VIEW_CALENDAR) {
2754 icon = "calarea_16x.gif" ;
2756 else if (fold[i].view == VIEW_CALBRIEF) {
2757 icon = "calarea_16x.gif" ;
2759 else if (fold[i].view == VIEW_TASKS) {
2760 icon = "taskmanag_16x.gif" ;
2762 else if (fold[i].view == VIEW_NOTES) {
2763 icon = "storenotes_16x.gif" ;
2765 else if (fold[i].view == VIEW_MAILBOX) {
2766 icon = "privatemess_16x.gif" ;
2769 icon = "chatrooms_16x.gif" ;
2772 if (fold[i].selectable) {
2773 wprintf("<a href=\"dotgoto?room=");
2774 urlescputs(fold[i].room);
2776 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2781 if (fold[i].hasnewmsgs) {
2782 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2785 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2787 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2789 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2790 wprintf(" (INBOX)");
2793 if (fold[i].selectable) {
2800 wprintf("</div>\n"); /** roomdiv */
2803 wprintf("</div>\n"); /** floordiv */
2806 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2807 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2809 num_drop_targets = 0;
2811 for (i=0; i<max_folders; ++i) {
2812 levels = num_tokens(fold[i].name, '|');
2814 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2815 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2816 jsescputs(fold[i].room);
2822 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2823 if (strlen(WC->floordiv_expanded) > 1) {
2824 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2828 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2834 * \brief Show the room list.
2835 * (only should get called by
2836 * knrooms() because that's where output_headers() is called from)
2837 * \param viewpref the view preferences???
2840 void list_all_rooms_by_floor(char *viewpref) {
2843 struct folder *fold = NULL;
2845 int max_folders = 0;
2846 int alloc_folders = 0;
2850 int num_floors = 1; /** add an extra one for private folders */
2852 /** If our cached folder list is very old, burn it. */
2853 if (WC->cache_fold != NULL) {
2854 if ((time(NULL) - WC->cache_timestamp) > 300) {
2855 free(WC->cache_fold);
2856 WC->cache_fold = NULL;
2860 /** Can we do the iconbar roomlist from cache? */
2861 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2862 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2866 /** Grab the floor table so we know how to build the list... */
2869 /** Start with the mailboxes */
2872 fold = malloc(sizeof(struct folder));
2873 memset(fold, 0, sizeof(struct folder));
2874 strcpy(fold[0].name, "My folders");
2875 fold[0].is_mailbox = 1;
2877 /** Then add floors */
2879 serv_getln(buf, sizeof buf);
2880 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2881 if (max_folders >= alloc_folders) {
2882 alloc_folders = max_folders + 100;
2883 fold = realloc(fold,
2884 alloc_folders * sizeof(struct folder));
2886 memset(&fold[max_folders], 0, sizeof(struct folder));
2887 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2892 /** Now add rooms */
2894 serv_getln(buf, sizeof buf);
2895 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2896 if (max_folders >= alloc_folders) {
2897 alloc_folders = max_folders + 100;
2898 fold = realloc(fold,
2899 alloc_folders * sizeof(struct folder));
2901 memset(&fold[max_folders], 0, sizeof(struct folder));
2902 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2903 ra_flags = extract_int(buf, 5);
2904 flags = extract_int(buf, 1);
2905 fold[max_folders].floor = extract_int(buf, 2);
2906 fold[max_folders].hasnewmsgs =
2907 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2908 if (flags & QR_MAILBOX) {
2909 fold[max_folders].is_mailbox = 1;
2911 fold[max_folders].view = extract_int(buf, 6);
2912 room_to_folder(fold[max_folders].name,
2913 fold[max_folders].room,
2914 fold[max_folders].floor,
2915 fold[max_folders].is_mailbox);
2916 fold[max_folders].selectable = 1;
2920 /** Bubble-sort the folder list */
2921 for (i=0; i<max_folders; ++i) {
2922 for (j=0; j<(max_folders-1)-i; ++j) {
2923 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2924 swap = strcasecmp(fold[j].name, fold[j+1].name);
2927 if ( (fold[j+1].is_mailbox)
2928 && (!fold[j].is_mailbox)) {
2936 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2937 memcpy(&fold[j], &fold[j+1],
2938 sizeof(struct folder));
2939 memcpy(&fold[j+1], &ftmp,
2940 sizeof(struct folder));
2946 if (!strcasecmp(viewpref, "folders")) {
2947 do_folder_view(fold, max_folders, num_floors);
2949 else if (!strcasecmp(viewpref, "hackish_view")) {
2950 for (i=0; i<max_folders; ++i) {
2951 escputs(fold[i].name);
2952 wprintf("<br />\n");
2955 else if (!strcasecmp(viewpref, "iconbar")) {
2956 do_iconbar_view(fold, max_folders, num_floors);
2959 do_rooms_view(fold, max_folders, num_floors);
2962 /* Don't free the folder list ... cache it for future use! */
2963 if (WC->cache_fold != NULL) {
2964 free(WC->cache_fold);
2966 WC->cache_fold = fold;
2967 WC->cache_max_folders = max_folders;
2968 WC->cache_num_floors = num_floors;
2969 WC->cache_timestamp = time(NULL);
2974 * \brief Do either a known rooms list or a folders list, depending on the
2979 char listviewpref[SIZ];
2981 output_headers(1, 1, 2, 0, 0, 0);
2983 /** Determine whether the user is trying to change views */
2984 if (bstr("view") != NULL) {
2985 if (strlen(bstr("view")) > 0) {
2986 set_preference("roomlistview", bstr("view"), 1);
2990 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2992 if ( (strcasecmp(listviewpref, "folders"))
2993 && (strcasecmp(listviewpref, "table")) ) {
2994 strcpy(listviewpref, "rooms");
2998 wprintf("<div id=\"banner\">\n"
2999 "<TABLE class=\"roomops_banner\"><TR><TD>"
3000 "<SPAN CLASS=\"titlebar\">"
3002 if (!strcasecmp(listviewpref, "rooms")) {
3003 wprintf(_("Room list"));
3005 if (!strcasecmp(listviewpref, "folders")) {
3006 wprintf(_("Folder list"));
3008 if (!strcasecmp(listviewpref, "table")) {
3009 wprintf(_("Room list"));
3011 wprintf("</SPAN></TD>\n");
3013 /** offer the ability to switch views */
3014 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
3015 "<SELECT NAME=\"newview\" SIZE=\"1\" "
3016 "OnChange=\"location.href=roomlistomatic.newview.options"
3017 "[selectedIndex].value\">\n");
3019 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3022 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3025 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3026 "View as folder list"
3028 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3031 wprintf("</SELECT><br />");
3033 wprintf("</FORM></TD></TR></TABLE>\n");
3036 "<div id=\"content\">\n");
3038 /** Display the room list in the user's preferred format */
3039 list_all_rooms_by_floor(listviewpref);
3046 * \brief Set the message expire policy for this room and/or floor
3048 void set_room_policy(void) {
3051 if (strlen(bstr("ok_button")) == 0) {
3052 strcpy(WC->ImportantMessage,
3053 _("Cancelled. Changes were not saved."));
3058 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3059 serv_getln(buf, sizeof buf);
3060 strcpy(WC->ImportantMessage, &buf[4]);
3062 if (WC->axlevel >= 6) {
3063 strcat(WC->ImportantMessage, "<br />\n");
3064 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3065 serv_getln(buf, sizeof buf);
3066 strcat(WC->ImportantMessage, &buf[4]);