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[9]; /**< 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");
27 viewdefs[8] = _("Journal");
31 * \brief Determine which views are allowed as the default for creating a new room.
33 * \param which_view The view ID being queried.
35 int is_view_allowed_as_default(int which_view)
38 case VIEW_BBS: return(1);
39 case VIEW_MAILBOX: return(1);
40 case VIEW_ADDRESSBOOK: return(1);
41 case VIEW_CALENDAR: return(1);
42 case VIEW_TASKS: return(1);
43 case VIEW_NOTES: return(1);
44 case VIEW_WIKI: return(0); /**< because it isn't finished yet */
45 case VIEW_CALBRIEF: return(0);
46 case VIEW_JOURNAL: return(0);
47 default: return(0); /**< should never get here */
53 * \brief load the list of floors
55 void load_floorlist(void)
60 for (a = 0; a < 128; ++a)
64 serv_getln(buf, sizeof buf);
66 strcpy(floorlist[0], "Main Floor");
69 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
70 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
76 * \brief Free a session's march list
78 * \param wcf Pointer to session being cleared
80 void free_march_list(struct wcsession *wcf)
84 while (wcf->march != NULL) {
85 mptr = wcf->march->next;
95 * \brief remove a room from the march list
97 void remove_march(char *aaa)
99 struct march *mptr, *mptr2;
101 if (WC->march == NULL)
104 if (!strcasecmp(WC->march->march_name, aaa)) {
105 mptr = WC->march->next;
111 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
112 if (!strcasecmp(mptr->march_name, aaa)) {
113 mptr2->next = mptr->next;
126 * \brief display rooms in tree structure???
127 * \param rp the roomlist to build a tree from
129 void room_tree_list(struct roomlisting *rp)
138 room_tree_list(rp->lnext);
140 strcpy(rmname, rp->rlname);
143 wprintf("<a href=\"dotgoto&room=");
147 escputs1(rmname, 1, 1);
148 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
150 else if (f & QR_DIRECTORY)
152 else if (f & QR_NETWORK)
156 wprintf("</A><TT> </TT>\n");
158 room_tree_list(rp->rnext);
164 * \brief Room ordering stuff (compare first by floor, then by order)
165 * \param r1 first roomlist to compare
166 * \param r2 second roomlist co compare
167 * \return are they the same???
169 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
171 if ((r1 == NULL) && (r2 == NULL))
177 if (r1->rlfloor < r2->rlfloor)
179 if (r1->rlfloor > r2->rlfloor)
181 if (r1->rlorder < r2->rlorder)
183 if (r1->rlorder > r2->rlorder)
190 * \brief Common code for all room listings
191 * \param variety what???
193 void listrms(char *variety)
198 struct roomlisting *rl = NULL;
199 struct roomlisting *rp;
200 struct roomlisting *rs;
202 /** Ask the server for a room list */
204 serv_getln(buf, sizeof buf);
210 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
212 rp = malloc(sizeof(struct roomlisting));
213 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
214 rp->rlflags = extract_int(buf, 1);
215 rp->rlfloor = extract_int(buf, 2);
216 rp->rlorder = extract_int(buf, 3);
225 if (rordercmp(rp, rs) < 0) {
226 if (rs->lnext == NULL) {
233 if (rs->rnext == NULL) {
246 * If no rooms were listed, print an nbsp to make the cell
247 * borders show up anyway.
249 if (num_rooms == 0) wprintf(" ");
254 * \brief list all forgotten rooms
256 void zapped_list(void)
258 output_headers(1, 1, 0, 0, 0, 0);
260 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
261 do_template("beginbox");
265 wprintf("<br /><br />\n");
266 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
267 do_template("endbox");
273 * \brief read this room's info file (set v to 1 for verbose mode)
280 int fullinfo_len = 0;
283 serv_getln(buf, sizeof buf);
286 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
287 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
288 strcpy(&fullinfo[fullinfo_len], buf);
289 fullinfo_len += strlen(buf);
293 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
294 strcpy(&briefinfo[50], "...");
296 wprintf("<div class=\"infos\" "
297 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
300 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
301 wprintf("<img class=\"close_infos\" "
302 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
303 "src=\"static/closewindow.gif\" alt=\"%s\">",
318 * \brief Display room banner icon.
319 * The server doesn't actually
320 * need the room name, but we supply it in order to
321 * keep the browser from using a cached icon from
324 void embed_room_graphic(void) {
327 serv_puts("OIMG _roompic_");
328 serv_getln(buf, sizeof buf);
330 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
331 urlescputs(WC->wc_roomname);
334 serv_getln(buf, sizeof buf);
336 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
337 wprintf("<img height=48 width=48 src=\""
338 "static/viewcontacts_48x.gif"
342 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
343 wprintf("<img height=48 width=48 src=\""
344 "static/calarea_48x.gif"
348 else if (WC->wc_view == VIEW_TASKS) {
349 wprintf("<img height=48 width=48 src=\""
350 "static/taskmanag_48x.gif"
354 else if (WC->wc_view == VIEW_NOTES) {
355 wprintf("<img height=48 width=48 src=\""
356 "static/storenotes_48x.gif"
360 else if (WC->wc_view == VIEW_MAILBOX) {
361 wprintf("<img height=48 width=48 src=\""
362 "static/privatemess_48x.gif"
367 wprintf("<img height=48 width=48 src=\""
368 "static/chatrooms_48x.gif"
378 * \brief Display the current view and offer an option to change it
380 void embed_view_o_matic(void) {
383 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
384 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
385 wprintf("<label for=\"view_name\">");
386 wprintf(_("View as:"));
388 "<select name=\"newview\" size=\"1\" "
389 "id=\"view_name\" class=\"selectbox\" "
390 "OnChange=\"location.href=viewomatic.newview.options"
391 "[selectedIndex].value\">\n");
393 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
395 * Only offer the views that make sense, given the default
396 * view for the room. For example, don't offer a Calendar
397 * view in a non-Calendar room.
401 || (i == WC->wc_default_view) /**< default */
402 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
403 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
404 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
407 wprintf("<option %s value=\"changeview?view=%d\">",
408 ((i == WC->wc_view) ? "selected" : ""),
410 escputs(viewdefs[i]);
411 wprintf("</option>\n");
414 wprintf("</select></form>\n");
419 * \brief Display a search box
421 void embed_search_o_matic(void) {
422 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
423 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
424 wprintf("<label for=\"search_name\">");
425 wprintf(_("Search: "));
426 wprintf("</label> <input "
427 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
428 "id=\"search_name\" class=\"inputbox\">\n"
430 wprintf("</select></form>\n");
435 * \brief Embed the room banner
437 * \param got The information returned from a GOTO server command
438 * \param navbar_style Determines which navigation buttons to display
442 void embed_room_banner(char *got, int navbar_style) {
444 char sanitized_roomname[256];
447 * We need to have the information returned by a GOTO server command.
448 * If it isn't supplied, we fake it by issuing our own GOTO.
451 serv_printf("GOTO %s", WC->wc_roomname);
452 serv_getln(buf, sizeof buf);
456 /** The browser needs some information for its own use */
457 wprintf("<script type=\"text/javascript\"> \n"
458 " room_is_trash = %d; \n"
464 * If the user happens to select the "make this my start page" link,
465 * we want it to remember the URL as a "/dotskip" one instead of
466 * a "skip" or "gotonext" or something like that.
468 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
471 /** Check for new mail. */
472 WC->new_mail = extract_int(&got[4], 9);
473 WC->wc_view = extract_int(&got[4], 11);
475 stresc(sanitized_roomname, WC->wc_roomname, 1, 1);
476 svprintf("ROOMNAME", WCS_STRING, "%s", sanitized_roomname);
477 svprintf("NUMMSGS", WCS_STRING,
478 _("%d new of %d messages"),
479 extract_int(&got[4], 1),
480 extract_int(&got[4], 2)
482 svcallback("ROOMPIC", embed_room_graphic);
483 svcallback("ROOMINFO", readinfo);
484 svcallback("VIEWOMATIC", embed_view_o_matic);
485 svcallback("SEARCHOMATIC", embed_search_o_matic);
486 svcallback("START", offer_start_page);
488 do_template("roombanner");
489 if (navbar_style != navbar_none) {
491 wprintf("<div id=\"navbar\"><ul>");
493 if (navbar_style == navbar_default) wprintf(
494 "<li class=\"ungoto\">"
495 "<a href=\"ungoto\">"
496 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
497 "<span class=\"navbar_link\">%s</span></A>"
498 "</li>\n", _("Ungoto")
501 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
503 "<li class=\"newmess\">"
504 "<a href=\"readnew\">"
505 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
506 "<span class=\"navbar_link\">%s</span></A>"
507 "</li>\n", _("Read new messages")
511 if (navbar_style == navbar_default) {
512 switch(WC->wc_view) {
513 case VIEW_ADDRESSBOOK:
515 "<li class=\"viewcontacts\">"
516 "<a href=\"readfwd\">"
517 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
519 "<span class=\"navbar_link\">"
521 "</span></a></li>\n", _("View contacts")
526 "<li class=\"staskday\">"
527 "<a href=\"readfwd?calview=day\">"
528 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
530 "<span class=\"navbar_link\">"
532 "</span></a></li>\n", _("Day view")
535 "<li class=\"monthview\">"
536 "<a href=\"readfwd?calview=month\">"
537 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
539 "<span class=\"navbar_link\">"
541 "</span></a></li>\n", _("Month view")
546 "<li class=\"monthview\">"
547 "<a href=\"readfwd?calview=month\">"
548 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
550 "<span class=\"navbar_link\">"
552 "</span></a></li>\n", _("Calendar list")
557 "<li class=\"taskmanag\">"
558 "<a href=\"readfwd\">"
559 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
561 "<span class=\"navbar_link\">"
563 "</span></a></li>\n", _("View tasks")
568 "<li class=\"viewnotes\">"
569 "<a href=\"readfwd\">"
570 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
572 "<span class=\"navbar_link\">"
574 "</span></a></li>\n", _("View notes")
579 "<li class=\"readallmess\">"
580 "<a href=\"readfwd\">"
581 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
583 "<span class=\"navbar_link\">"
585 "</span></a></li>\n", _("View message list")
590 "<li class=\"readallmess\">"
591 "<a href=\"readfwd\">"
592 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
594 "<span class=\"navbar_link\">"
596 "</span></a></li>\n", _("Wiki home")
601 "<li class=\"readallmess\">"
602 "<a href=\"readfwd\">"
603 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
605 "<span class=\"navbar_link\">"
607 "</span></a></li>\n", _("Read all messages")
613 if (navbar_style == navbar_default) {
614 switch(WC->wc_view) {
615 case VIEW_ADDRESSBOOK:
617 "<li class=\"addnewcontact\">"
618 "<a href=\"display_enter\">"
619 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
620 "border=\"0\"><span class=\"navbar_link\">"
622 "</span></a></li>\n", _("Add new contact")
627 wprintf("<li class=\"addevent\"><a href=\"display_enter");
628 if (!IsEmptyStr(bstr("year" ))) wprintf("?year=%s", bstr("year"));
629 if (!IsEmptyStr(bstr("month"))) wprintf("?month=%s", bstr("month"));
630 if (!IsEmptyStr(bstr("day" ))) wprintf("?day=%s", bstr("day"));
632 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
633 "border=\"0\"><span class=\"navbar_link\">"
635 "</span></a></li>\n", _("Add new event")
640 "<li class=\"newmess\">"
641 "<a href=\"display_enter\">"
642 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
643 "border=\"0\"><span class=\"navbar_link\">"
645 "</span></a></li>\n", _("Add new task")
650 "<li class=\"enternewnote\">"
651 "<a href=\"javascript:add_new_note();\">"
652 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
653 "border=\"0\"><span class=\"navbar_link\">"
655 "</span></a></li>\n", _("Add new note")
659 safestrncpy(buf, bstr("page"), sizeof buf);
662 "<li class=\"newmess\">"
663 "<a href=\"display_enter?wikipage=%s\">"
664 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
665 "border=\"0\"><span class=\"navbar_link\">"
667 "</span></a></li>\n", buf, _("Edit this page")
672 "<li class=\"newmess\">"
673 "<a href=\"display_enter\">"
674 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
675 "border=\"0\"><span class=\"navbar_link\">"
677 "</span></a></li>\n", _("Write mail")
682 "<li class=\"newmess\">"
683 "<a href=\"display_enter\">"
684 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
685 "border=\"0\"><span class=\"navbar_link\">"
687 "</span></a></li>\n", _("Enter a message")
693 if (navbar_style == navbar_default) wprintf(
694 "<li class=\"skipthisroom\">"
697 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
698 "<span class=\"navbar_link\">%s</span></a>"
700 _("Leave all messages marked as unread, go to next room with unread messages"),
704 if (navbar_style == navbar_default) wprintf(
705 "<li class=\"markngo\">"
706 "<a href=\"gotonext\" "
708 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
709 "<span class=\"navbar_link\">%s</span></a>"
711 _("Mark all messages as read, go to next room with unread messages"),
715 wprintf("</ul></div>\n");
722 * \brief back end routine to take the session to a new room
723 * \param gname room to go to
726 int gotoroom(char *gname)
729 static long ls = (-1L);
732 /** store ungoto information */
733 strcpy(WC->ugname, WC->wc_roomname);
736 /** move to the new room */
737 serv_printf("GOTO %s", gname);
738 serv_getln(buf, sizeof buf);
742 serv_puts("GOTO _BASEROOM_");
743 serv_getln(buf, sizeof buf);
750 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
751 WC->room_flags = extract_int(&buf[4], 4);
752 /* highest_msg_read = extract_int(&buf[4],6);
753 maxmsgnum = extract_int(&buf[4],5);
755 WC->is_mailbox = extract_int(&buf[4],7);
756 ls = extract_long(&buf[4], 6);
757 WC->wc_floor = extract_int(&buf[4], 10);
758 WC->wc_view = extract_int(&buf[4], 11);
759 WC->wc_default_view = extract_int(&buf[4], 12);
760 WC->wc_is_trash = extract_int(&buf[4], 13);
761 WC->room_flags2 = extract_int(&buf[4], 14);
764 WC->is_room_aide = WC->is_aide;
766 WC->is_room_aide = (char) extract_int(&buf[4], 8);
768 remove_march(WC->wc_roomname);
769 if (!strcasecmp(gname, "_BASEROOM_"))
777 * \brief Locate the room on the march list which we most want to go to.
779 * is measured given a "weight" of preference based on various factors.
780 * \param desired_floor the room number on the citadel server
781 * \return the roomname
783 char *pop_march(int desired_floor)
785 static char TheRoom[128];
787 int TheOrder = 32767;
790 struct march *mptr = NULL;
792 strcpy(TheRoom, "_BASEROOM_");
793 if (WC->march == NULL)
796 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
798 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
799 weight = weight + 10000;
800 if (mptr->march_floor == desired_floor)
801 weight = weight + 5000;
803 weight = weight + ((128 - (mptr->march_floor)) * 128);
804 weight = weight + (128 - (mptr->march_order));
806 if (weight > TheWeight) {
808 strcpy(TheRoom, mptr->march_name);
809 TheFloor = mptr->march_floor;
810 TheOrder = mptr->march_order;
819 *\brief Goto next room having unread messages.
820 * We want to skip over rooms that the user has already been to, and take the
821 * user back to the lobby when done. The room we end up in is placed in
822 * newroom - which is set to 0 (the lobby) initially.
823 * We start the search in the current room rather than the beginning to prevent
824 * two or more concurrent users from dragging each other back to the same room.
829 struct march *mptr, *mptr2;
834 * First check to see if the march-mode list is already allocated.
835 * If it is, pop the first room off the list and go there.
838 if (WC->march == NULL) {
840 serv_getln(buf, sizeof buf);
842 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
843 extract_token(room_name, buf, 0, '|', sizeof room_name);
844 if (strcasecmp(room_name, WC->wc_roomname)) {
845 mptr = (struct march *) malloc(sizeof(struct march));
847 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
848 mptr->march_floor = extract_int(buf, 2);
849 mptr->march_order = extract_int(buf, 3);
850 if (WC->march == NULL) {
854 while (mptr2->next != NULL)
861 * add _BASEROOM_ to the end of the march list, so the user will end up
862 * in the system base room (usually the Lobby>) at the end of the loop
864 mptr = (struct march *) malloc(sizeof(struct march));
866 strcpy(mptr->march_name, "_BASEROOM_");
867 if (WC->march == NULL) {
871 while (mptr2->next != NULL)
876 * ...and remove the room we're currently in, so a <G>oto doesn't make us
877 * walk around in circles
879 remove_march(WC->wc_roomname);
881 if (WC->march != NULL) {
882 strcpy(next_room, pop_march(-1));
884 strcpy(next_room, "_BASEROOM_");
888 smart_goto(next_room);
893 * \brief goto next room
894 * \param next_room next room to go to
896 void smart_goto(char *next_room) {
904 * \brief mark all messages in current room as having been read
906 void slrp_highest(void)
910 serv_puts("SLRP HIGHEST");
911 serv_getln(buf, sizeof buf);
916 * \brief un-goto the previous room
922 if (!strcmp(WC->ugname, "")) {
923 smart_goto(WC->wc_roomname);
926 serv_printf("GOTO %s", WC->ugname);
927 serv_getln(buf, sizeof buf);
929 smart_goto(WC->wc_roomname);
932 if (WC->uglsn >= 0L) {
933 serv_printf("SLRP %ld", WC->uglsn);
934 serv_getln(buf, sizeof buf);
936 strcpy(buf, WC->ugname);
937 strcpy(WC->ugname, "");
946 * \brief Set/clear/read the "self-service list subscribe" flag for a room
948 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
949 * \return return the new value.
952 int self_service(int newval) {
953 int current_value = 0;
959 int flags, floor, order, view, flags2;
962 serv_getln(buf, sizeof buf);
963 if (buf[0] != '2') return(0);
965 extract_token(name, &buf[4], 0, '|', sizeof name);
966 extract_token(password, &buf[4], 1, '|', sizeof password);
967 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
968 flags = extract_int(&buf[4], 3);
969 floor = extract_int(&buf[4], 4);
970 order = extract_int(&buf[4], 5);
971 view = extract_int(&buf[4], 6);
972 flags2 = extract_int(&buf[4], 7);
974 if (flags2 & QR2_SELFLIST) {
982 flags2 = flags2 | QR2_SELFLIST;
984 else if (newval == 0) {
985 flags2 = flags2 & ~QR2_SELFLIST;
988 return(current_value);
991 if (newval != current_value) {
992 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
993 name, password, dirname, flags,
994 floor, order, view, flags2);
995 serv_getln(buf, sizeof buf);
1008 * \brief display the form for editing a room
1010 void display_editroom(void)
1015 char remote_room[128];
1018 char er_password[10];
1019 char er_dirname[15];
1020 char er_roomaide[26];
1027 char *not_shared_with;
1030 int floorpolicy = 0;
1034 if (IsEmptyStr(tab)) tab = "admin";
1038 serv_getln(buf, sizeof buf);
1040 if (buf[0] != '2') {
1041 strcpy(WC->ImportantMessage, &buf[4]);
1042 display_main_menu();
1045 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1046 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1047 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1048 er_flags = extract_int(&buf[4], 3);
1049 er_floor = extract_int(&buf[4], 4);
1050 er_flags2 = extract_int(&buf[4], 7);
1052 output_headers(1, 1, 1, 0, 0, 0);
1054 /** print the tabbed dialog */
1056 "<div class=\"fix_scrollbar_bug\">"
1057 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
1059 "<TD> </TD>\n");
1061 if (!strcmp(tab, "admin")) {
1062 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1065 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1067 wprintf(_("Administration"));
1068 if (!strcmp(tab, "admin")) {
1069 wprintf("</SPAN></TD>\n");
1072 wprintf("</A></TD>\n");
1075 wprintf("<TD> </TD>\n");
1077 if (!strcmp(tab, "config")) {
1078 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1081 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=config\">");
1083 wprintf(_("Configuration"));
1084 if (!strcmp(tab, "config")) {
1085 wprintf("</SPAN></TD>\n");
1088 wprintf("</A></TD>\n");
1091 wprintf("<TD> </TD>\n");
1093 if (!strcmp(tab, "expire")) {
1094 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1097 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1099 wprintf(_("Message expire policy"));
1100 if (!strcmp(tab, "expire")) {
1101 wprintf("</SPAN></TD>\n");
1104 wprintf("</A></TD>\n");
1107 wprintf("<TD> </TD>\n");
1109 if (!strcmp(tab, "access")) {
1110 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1113 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=access\">");
1115 wprintf(_("Access controls"));
1116 if (!strcmp(tab, "access")) {
1117 wprintf("</SPAN></TD>\n");
1120 wprintf("</A></TD>\n");
1123 wprintf("<TD> </TD>\n");
1125 if (!strcmp(tab, "sharing")) {
1126 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1129 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1131 wprintf(_("Sharing"));
1132 if (!strcmp(tab, "sharing")) {
1133 wprintf("</SPAN></TD>\n");
1136 wprintf("</A></TD>\n");
1139 wprintf("<TD> </TD>\n");
1141 if (!strcmp(tab, "listserv")) {
1142 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1145 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1147 wprintf(_("Mailing list service"));
1148 if (!strcmp(tab, "listserv")) {
1149 wprintf("</SPAN></TD>\n");
1152 wprintf("</A></TD>\n");
1155 wprintf("<TD> </TD>\n");
1157 wprintf("</TR></TABLE></div>\n");
1158 /** end tabbed dialog */
1160 /** begin content of whatever tab is open now */
1161 wprintf("<div class=\"fix_scrollbar_bug\">"
1162 "<TABLE class=\"roomops_background\">\n"
1165 if (!strcmp(tab, "admin")) {
1167 "<LI><a href=\"delete_room\" "
1168 "onClick=\"return confirm('");
1169 wprintf(_("Are you sure you want to delete this room?"));
1170 wprintf("');\">\n");
1171 wprintf(_("Delete this room"));
1173 "<LI><a href=\"display_editroompic\">\n");
1174 wprintf(_("Set or change the icon for this room's banner"));
1176 "<LI><a href=\"display_editinfo\">\n");
1177 wprintf(_("Edit this room's Info file"));
1182 if (!strcmp(tab, "config")) {
1183 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1184 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1186 wprintf("<UL><LI>");
1187 wprintf(_("Name of room: "));
1188 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1194 wprintf(_("Resides on floor: "));
1195 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1196 for (i = 0; i < 128; ++i)
1197 if (!IsEmptyStr(floorlist[i])) {
1198 wprintf("<OPTION ");
1200 wprintf("SELECTED ");
1201 wprintf("VALUE=\"%d\">", i);
1202 escputs(floorlist[i]);
1203 wprintf("</OPTION>\n");
1205 wprintf("</SELECT>\n");
1208 wprintf(_("Type of room:"));
1211 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1212 if ((er_flags & QR_PRIVATE) == 0)
1213 wprintf("CHECKED ");
1215 wprintf(_("Public (automatically appears to everyone)"));
1218 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1219 if ((er_flags & QR_PRIVATE) &&
1220 (er_flags & QR_GUESSNAME))
1221 wprintf("CHECKED ");
1223 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1225 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1226 if ((er_flags & QR_PRIVATE) &&
1227 (er_flags & QR_PASSWORDED))
1228 wprintf("CHECKED ");
1230 wprintf(_("Private - require password: "));
1231 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1234 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1235 if ((er_flags & QR_PRIVATE)
1236 && ((er_flags & QR_GUESSNAME) == 0)
1237 && ((er_flags & QR_PASSWORDED) == 0))
1238 wprintf("CHECKED ");
1240 wprintf(_("Private - invitation only"));
1242 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1244 wprintf(_("If private, cause current users to forget room"));
1246 wprintf("\n</UL>\n");
1248 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1249 if (er_flags & QR_PREFONLY)
1250 wprintf("CHECKED ");
1252 wprintf(_("Preferred users only"));
1254 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1255 if (er_flags & QR_READONLY)
1256 wprintf("CHECKED ");
1258 wprintf(_("Read-only room"));
1260 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1261 if (er_flags2 & QR2_COLLABDEL)
1262 wprintf("CHECKED ");
1264 wprintf(_("All users allowed to post may also delete messages"));
1266 /** directory stuff */
1267 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1268 if (er_flags & QR_DIRECTORY)
1269 wprintf("CHECKED ");
1271 wprintf(_("File directory room"));
1273 wprintf("\n<UL><LI>");
1274 wprintf(_("Directory name: "));
1275 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1278 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1279 if (er_flags & QR_UPLOAD)
1280 wprintf("CHECKED ");
1282 wprintf(_("Uploading allowed"));
1284 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1285 if (er_flags & QR_DOWNLOAD)
1286 wprintf("CHECKED ");
1288 wprintf(_("Downloading allowed"));
1290 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1291 if (er_flags & QR_VISDIR)
1292 wprintf("CHECKED ");
1294 wprintf(_("Visible directory"));
1297 /** end of directory stuff */
1299 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1300 if (er_flags & QR_NETWORK)
1301 wprintf("CHECKED ");
1303 wprintf(_("Network shared room"));
1305 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1306 if (er_flags & QR_PERMANENT)
1307 wprintf("CHECKED ");
1309 wprintf(_("Permanent (does not auto-purge)"));
1311 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1312 if (er_flags2 & QR2_SUBJECTREQ)
1313 wprintf("CHECKED ");
1315 wprintf(_("Subject Required (Force users to specify a message subject)"));
1317 /** start of anon options */
1320 wprintf(_("Anonymous messages"));
1323 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1324 if (((er_flags & QR_ANONONLY) == 0)
1325 && ((er_flags & QR_ANONOPT) == 0))
1326 wprintf("CHECKED ");
1328 wprintf(_("No anonymous messages"));
1330 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1331 if (er_flags & QR_ANONONLY)
1332 wprintf("CHECKED ");
1334 wprintf(_("All messages are anonymous"));
1336 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1337 if (er_flags & QR_ANONOPT)
1338 wprintf("CHECKED ");
1340 wprintf(_("Prompt user when entering messages"));
1343 /* end of anon options */
1346 wprintf(_("Room aide: "));
1348 serv_getln(buf, sizeof buf);
1349 if (buf[0] != '2') {
1350 wprintf("<em>%s</em>\n", &buf[4]);
1352 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1353 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1356 wprintf("</UL><CENTER>\n");
1357 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1358 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1360 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1368 /** Sharing the room with other Citadel nodes... */
1369 if (!strcmp(tab, "sharing")) {
1371 shared_with = strdup("");
1372 not_shared_with = strdup("");
1374 /** Learn the current configuration */
1375 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1376 serv_getln(buf, sizeof buf);
1377 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1378 extract_token(node, buf, 0, '|', sizeof node);
1379 not_shared_with = realloc(not_shared_with,
1380 strlen(not_shared_with) + 32);
1381 strcat(not_shared_with, node);
1382 strcat(not_shared_with, "\n");
1386 serv_getln(buf, sizeof buf);
1387 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1388 extract_token(cmd, buf, 0, '|', sizeof cmd);
1389 extract_token(node, buf, 1, '|', sizeof node);
1390 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1391 if (!strcasecmp(cmd, "ignet_push_share")) {
1392 shared_with = realloc(shared_with,
1393 strlen(shared_with) + 32);
1394 strcat(shared_with, node);
1395 if (!IsEmptyStr(remote_room)) {
1396 strcat(shared_with, "|");
1397 strcat(shared_with, remote_room);
1399 strcat(shared_with, "\n");
1403 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1404 extract_token(buf, shared_with, i, '\n', sizeof buf);
1405 extract_token(node, buf, 0, '|', sizeof node);
1406 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1407 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1408 if (!strcasecmp(node, cmd)) {
1409 remove_token(not_shared_with, j, '\n');
1414 /** Display the stuff */
1415 wprintf("<CENTER><br />"
1416 "<TABLE border=1 cellpadding=5><TR>"
1418 wprintf(_("Shared with"));
1419 wprintf("</I></B></TD>"
1421 wprintf(_("Not shared with"));
1422 wprintf("</I></B></TD></TR>\n"
1423 "<TR><TD VALIGN=TOP>\n");
1425 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1426 wprintf(_("Remote node name"));
1427 wprintf("</TD><TD>");
1428 wprintf(_("Remote room name"));
1429 wprintf("</TD><TD>");
1430 wprintf(_("Actions"));
1431 wprintf("</TD></TR>\n");
1433 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1434 extract_token(buf, shared_with, i, '\n', sizeof buf);
1435 extract_token(node, buf, 0, '|', sizeof node);
1436 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1437 if (!IsEmptyStr(node)) {
1438 wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
1439 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1440 wprintf("<TR><TD>%s</TD>\n", node);
1443 if (!IsEmptyStr(remote_room)) {
1444 escputs(remote_room);
1450 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1451 "VALUE=\"ignet_push_share|");
1453 if (!IsEmptyStr(remote_room)) {
1455 urlescputs(remote_room);
1458 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1459 "VALUE=\"sharing\">\n");
1460 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1461 "VALUE=\"remove\">\n");
1462 wprintf("<INPUT TYPE=\"submit\" "
1463 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1464 wprintf("</TD></TR></FORM>\n");
1468 wprintf("</TABLE>\n");
1469 wprintf("</TD><TD VALIGN=TOP>\n");
1470 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1471 wprintf(_("Remote node name"));
1472 wprintf("</TD><TD>");
1473 wprintf(_("Remote room name"));
1474 wprintf("</TD><TD>");
1475 wprintf(_("Actions"));
1476 wprintf("</TD></TR>\n");
1478 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1479 extract_token(node, not_shared_with, i, '\n', sizeof node);
1480 if (!IsEmptyStr(node)) {
1481 wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
1482 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1483 wprintf("<TR><TD>");
1486 "<INPUT TYPE=\"INPUT\" "
1490 wprintf("<INPUT TYPE=\"hidden\" "
1492 "VALUE=\"ignet_push_share|");
1495 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1496 "VALUE=\"sharing\">\n");
1497 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1498 "VALUE=\"add\">\n");
1499 wprintf("<INPUT TYPE=\"submit\" "
1500 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1501 wprintf("</TD></TR></FORM>\n");
1505 wprintf("</TABLE>\n");
1506 wprintf("</TD></TR>"
1507 "</TABLE></CENTER><br />\n"
1508 "<I><B>%s</B><UL><LI>", _("Notes:"));
1509 wprintf(_("When sharing a room, "
1510 "it must be shared from both ends. Adding a node to "
1511 "the 'shared' list sends messages out, but in order to"
1512 " receive messages, the other nodes must be configured"
1513 " to send messages out to your system as well. "
1514 "<LI>If the remote room name is blank, it is assumed "
1515 "that the room name is identical on the remote node."
1516 "<LI>If the remote room name is different, the remote "
1517 "node must also configure the name of the room here."
1523 /** Mailing list management */
1524 if (!strcmp(tab, "listserv")) {
1526 wprintf("<br /><center>"
1527 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1528 "<TR><TD VALIGN=TOP>");
1530 wprintf(_("<i>The contents of this room are being "
1531 "mailed <b>as individual messages</b> "
1532 "to the following list recipients:"
1533 "</i><br /><br />\n"));
1536 serv_getln(buf, sizeof buf);
1537 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1538 extract_token(cmd, buf, 0, '|', sizeof cmd);
1539 if (!strcasecmp(cmd, "listrecp")) {
1540 extract_token(recp, buf, 1, '|', sizeof recp);
1543 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1546 wprintf(_("(remove)"));
1547 wprintf("</A><br />");
1550 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1551 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1552 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1553 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1554 wprintf("<INPUT TYPE=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1555 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1556 wprintf("</FORM>\n");
1558 wprintf("</TD><TD VALIGN=TOP>\n");
1560 wprintf(_("<i>The contents of this room are being "
1561 "mailed <b>in digest form</b> "
1562 "to the following list recipients:"
1563 "</i><br /><br />\n"));
1566 serv_getln(buf, sizeof buf);
1567 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1568 extract_token(cmd, buf, 0, '|', sizeof cmd);
1569 if (!strcasecmp(cmd, "digestrecp")) {
1570 extract_token(recp, buf, 1, '|', sizeof recp);
1573 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1577 wprintf(_("(remove)"));
1578 wprintf("</A><br />");
1581 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1582 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1583 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1584 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1585 wprintf("<INPUT TYPE=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1586 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1587 wprintf("</FORM>\n");
1589 wprintf("</TD></TR></TABLE>\n");
1591 /** Pop open an address book -- begin **/
1592 wprintf("<div align=right>"
1593 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1595 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1600 _("Add recipients from Contacts or other address books"),
1601 _("Add recipients from Contacts or other address books")
1603 /** Pop open an address book -- end **/
1606 if (self_service(999) == 1) {
1607 wprintf(_("This room is configured to allow "
1608 "self-service subscribe/unsubscribe requests."));
1609 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1610 wprintf(_("Click to disable."));
1611 wprintf("</A><br />\n");
1612 wprintf(_("The URL for subscribe/unsubscribe is: "));
1613 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1614 (is_https ? "https" : "http"),
1618 wprintf(_("This room is <i>not</i> configured to allow "
1619 "self-service subscribe/unsubscribe requests."));
1620 wprintf(" <a href=\"toggle_self_service?newval=1&"
1622 wprintf(_("Click to enable."));
1623 wprintf("</A><br />\n");
1627 wprintf("</CENTER>\n");
1631 /** Mailing list management */
1632 if (!strcmp(tab, "expire")) {
1634 serv_puts("GPEX room");
1635 serv_getln(buf, sizeof buf);
1636 if (buf[0] == '2') {
1637 roompolicy = extract_int(&buf[4], 0);
1638 roomvalue = extract_int(&buf[4], 1);
1641 serv_puts("GPEX floor");
1642 serv_getln(buf, sizeof buf);
1643 if (buf[0] == '2') {
1644 floorpolicy = extract_int(&buf[4], 0);
1645 floorvalue = extract_int(&buf[4], 1);
1648 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1649 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1650 wprintf("<TABLE border=0 cellspacing=5>\n");
1651 wprintf("<TR><TD>");
1652 wprintf(_("Message expire policy for this room"));
1654 escputs(WC->wc_roomname);
1655 wprintf(")</TD><TD>");
1656 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1657 ((roompolicy == 0) ? "CHECKED" : "") );
1658 wprintf(_("Use the default policy for this floor"));
1659 wprintf("<br />\n");
1660 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1661 ((roompolicy == 1) ? "CHECKED" : "") );
1662 wprintf(_("Never automatically expire messages"));
1663 wprintf("<br />\n");
1664 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1665 ((roompolicy == 2) ? "CHECKED" : "") );
1666 wprintf(_("Expire by message count"));
1667 wprintf("<br />\n");
1668 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1669 ((roompolicy == 3) ? "CHECKED" : "") );
1670 wprintf(_("Expire by message age"));
1672 wprintf(_("Number of messages or days: "));
1673 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1674 wprintf("</TD></TR>\n");
1676 if (WC->axlevel >= 6) {
1677 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1678 wprintf("<TR><TD>");
1679 wprintf(_("Message expire policy for this floor"));
1681 escputs(floorlist[WC->wc_floor]);
1682 wprintf(")</TD><TD>");
1683 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1684 ((floorpolicy == 0) ? "CHECKED" : "") );
1685 wprintf(_("Use the system default"));
1686 wprintf("<br />\n");
1687 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1688 ((floorpolicy == 1) ? "CHECKED" : "") );
1689 wprintf(_("Never automatically expire messages"));
1690 wprintf("<br />\n");
1691 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1692 ((floorpolicy == 2) ? "CHECKED" : "") );
1693 wprintf(_("Expire by message count"));
1694 wprintf("<br />\n");
1695 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1696 ((floorpolicy == 3) ? "CHECKED" : "") );
1697 wprintf(_("Expire by message age"));
1699 wprintf(_("Number of messages or days: "));
1700 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1704 wprintf("<CENTER>\n");
1705 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1706 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1708 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1709 wprintf("</CENTER></TD><TR>\n");
1711 wprintf("</TABLE>\n"
1712 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1718 /** Mailing list management */
1719 if (!strcmp(tab, "access")) {
1723 /** end content of whatever tab is open now */
1724 wprintf("</TD></TR></TABLE></div>\n");
1726 address_book_popup();
1732 * \brief Toggle self-service list subscription
1734 void toggle_self_service(void) {
1737 newval = atoi(bstr("newval"));
1738 self_service(newval);
1745 * \brief save new parameters for a room
1751 char er_password[10];
1752 char er_dirname[15];
1753 char er_roomaide[26];
1756 int er_listingorder;
1762 if (IsEmptyStr(bstr("ok_button"))) {
1763 strcpy(WC->ImportantMessage,
1764 _("Cancelled. Changes were not saved."));
1769 serv_getln(buf, sizeof buf);
1771 if (buf[0] != '2') {
1772 strcpy(WC->ImportantMessage, &buf[4]);
1776 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1777 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1778 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1779 er_flags = extract_int(&buf[4], 3);
1780 er_listingorder = extract_int(&buf[4], 5);
1781 er_defaultview = extract_int(&buf[4], 6);
1782 er_flags2 = extract_int(&buf[4], 7);
1784 strcpy(er_roomaide, bstr("er_roomaide"));
1785 if (IsEmptyStr(er_roomaide)) {
1787 serv_getln(buf, sizeof buf);
1788 if (buf[0] != '2') {
1789 strcpy(er_roomaide, "");
1791 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1794 strcpy(buf, bstr("er_name"));
1796 if (!IsEmptyStr(buf)) {
1797 strcpy(er_name, buf);
1800 strcpy(buf, bstr("er_password"));
1802 if (!IsEmptyStr(buf))
1803 strcpy(er_password, buf);
1805 strcpy(buf, bstr("er_dirname"));
1807 if (!IsEmptyStr(buf))
1808 strcpy(er_dirname, buf);
1810 strcpy(buf, bstr("type"));
1811 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1813 if (!strcmp(buf, "invonly")) {
1814 er_flags |= (QR_PRIVATE);
1816 if (!strcmp(buf, "hidden")) {
1817 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1819 if (!strcmp(buf, "passworded")) {
1820 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1822 if (!strcmp(bstr("prefonly"), "yes")) {
1823 er_flags |= QR_PREFONLY;
1825 er_flags &= ~QR_PREFONLY;
1828 if (!strcmp(bstr("readonly"), "yes")) {
1829 er_flags |= QR_READONLY;
1831 er_flags &= ~QR_READONLY;
1834 if (!strcmp(bstr("collabdel"), "yes")) {
1835 er_flags2 |= QR2_COLLABDEL;
1837 er_flags2 &= ~QR2_COLLABDEL;
1840 if (!strcmp(bstr("permanent"), "yes")) {
1841 er_flags |= QR_PERMANENT;
1843 er_flags &= ~QR_PERMANENT;
1846 if (!strcmp(bstr("subjectreq"), "yes")) {
1847 er_flags2 |= QR2_SUBJECTREQ;
1849 er_flags2 &= ~QR2_SUBJECTREQ;
1852 if (!strcmp(bstr("network"), "yes")) {
1853 er_flags |= QR_NETWORK;
1855 er_flags &= ~QR_NETWORK;
1858 if (!strcmp(bstr("directory"), "yes")) {
1859 er_flags |= QR_DIRECTORY;
1861 er_flags &= ~QR_DIRECTORY;
1864 if (!strcmp(bstr("ulallowed"), "yes")) {
1865 er_flags |= QR_UPLOAD;
1867 er_flags &= ~QR_UPLOAD;
1870 if (!strcmp(bstr("dlallowed"), "yes")) {
1871 er_flags |= QR_DOWNLOAD;
1873 er_flags &= ~QR_DOWNLOAD;
1876 if (!strcmp(bstr("visdir"), "yes")) {
1877 er_flags |= QR_VISDIR;
1879 er_flags &= ~QR_VISDIR;
1882 strcpy(buf, bstr("anon"));
1884 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1885 if (!strcmp(buf, "anononly"))
1886 er_flags |= QR_ANONONLY;
1887 if (!strcmp(buf, "anon2"))
1888 er_flags |= QR_ANONOPT;
1891 if (!strcmp(bstr("bump"), "yes"))
1894 er_floor = atoi(bstr("er_floor"));
1896 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
1897 er_name, er_password, er_dirname, er_flags, bump, er_floor,
1898 er_listingorder, er_defaultview, er_flags2);
1900 serv_getln(buf, sizeof buf);
1901 if (buf[0] != '2') {
1902 strcpy(WC->ImportantMessage, &buf[4]);
1908 if (!IsEmptyStr(er_roomaide)) {
1909 sprintf(buf, "SETA %s", er_roomaide);
1911 serv_getln(buf, sizeof buf);
1912 if (buf[0] != '2') {
1913 strcpy(WC->ImportantMessage, &buf[4]);
1914 display_main_menu();
1919 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1926 * \brief Display form for Invite, Kick, and show Who Knows a room
1928 void do_invt_kick(void) {
1929 char buf[SIZ], room[SIZ], username[SIZ];
1932 serv_getln(buf, sizeof buf);
1934 if (buf[0] != '2') {
1938 extract_token(room, &buf[4], 0, '|', sizeof room);
1940 strcpy(username, bstr("username"));
1942 if (!IsEmptyStr(bstr("kick_button"))) {
1943 sprintf(buf, "KICK %s", username);
1945 serv_getln(buf, sizeof buf);
1947 if (buf[0] != '2') {
1948 strcpy(WC->ImportantMessage, &buf[4]);
1950 sprintf(WC->ImportantMessage,
1951 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1956 if (!IsEmptyStr(bstr("invite_button"))) {
1957 sprintf(buf, "INVT %s", username);
1959 serv_getln(buf, sizeof buf);
1961 if (buf[0] != '2') {
1962 strcpy(WC->ImportantMessage, &buf[4]);
1964 sprintf(WC->ImportantMessage,
1965 _("<B><I>User %s invited to room %s.</I></B>\n"),
1976 * \brief Display form for Invite, Kick, and show Who Knows a room
1978 void display_whok(void)
1980 char buf[SIZ], room[SIZ], username[SIZ];
1983 serv_getln(buf, sizeof buf);
1985 if (buf[0] != '2') {
1989 extract_token(room, &buf[4], 0, '|', sizeof room);
1992 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1993 wprintf(_("The users listed below have access to this room. "
1994 "To remove a user from the access list, select the user "
1995 "name from the list and click 'Kick'."));
1996 wprintf("<br /><br />");
1998 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1999 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2000 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2001 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2003 serv_getln(buf, sizeof buf);
2004 if (buf[0] == '1') {
2005 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2006 extract_token(username, buf, 0, '|', sizeof username);
2007 wprintf("<OPTION>");
2012 wprintf("</SELECT><br />\n");
2014 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2015 wprintf("</FORM></CENTER>\n");
2017 wprintf("</TD><TD>");
2018 wprintf(_("To grant another user access to this room, enter the "
2019 "user name in the box below and click 'Invite'."));
2020 wprintf("<br /><br />");
2022 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
2023 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2024 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2025 wprintf(_("Invite:"));
2027 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
2028 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2029 "<input type=\"submit\" value=\"%s\">"
2030 "</FORM></CENTER>\n", _("Invite"));
2032 wprintf("</TD></TR></TABLE>\n");
2039 * \brief display the form for entering a new room
2041 void display_entroom(void)
2046 serv_puts("CRE8 0");
2047 serv_getln(buf, sizeof buf);
2049 if (buf[0] != '2') {
2050 strcpy(WC->ImportantMessage, &buf[4]);
2051 display_main_menu();
2055 output_headers(1, 1, 2, 0, 0, 0);
2056 wprintf("<div id=\"banner\">\n"
2057 "<TABLE class=\"roomops_banner\"><TR><TD>"
2058 "<SPAN CLASS=\"titlebar\">");
2059 wprintf(_("Create a new room"));
2061 "</TD></TR></TABLE>\n"
2062 "</div>\n<div id=\"content\">\n"
2065 wprintf("<div class=\"fix_scrollbar_bug\">"
2066 "<table class=\"roomops_background\"><tr><td>\n");
2068 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2069 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2071 wprintf("<UL><LI>");
2072 wprintf(_("Name of room: "));
2073 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2076 wprintf(_("Resides on floor: "));
2078 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
2079 for (i = 0; i < 128; ++i)
2080 if (!IsEmptyStr(floorlist[i])) {
2081 wprintf("<OPTION ");
2082 wprintf("VALUE=\"%d\">", i);
2083 escputs(floorlist[i]);
2084 wprintf("</OPTION>\n");
2086 wprintf("</SELECT>\n");
2089 * Our clever little snippet of JavaScript automatically selects
2090 * a public room if the view is set to Bulletin Board or wiki, and
2091 * it selects a mailbox room otherwise. The user can override this,
2092 * of course. We also disable the floor selector for mailboxes.
2095 wprintf(_("Default view for room: "));
2096 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
2097 " if ( (this.form.er_view.value == 0) "
2098 " || (this.form.er_view.value == 6) ) { "
2099 " this.form.type[0].checked=true; "
2100 " this.form.er_floor.disabled = false; "
2103 " this.form.type[4].checked=true; "
2104 " this.form.er_floor.disabled = true; "
2107 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2108 if (is_view_allowed_as_default(i)) {
2109 wprintf("<OPTION %s VALUE=\"%d\">",
2110 ((i == 0) ? "SELECTED" : ""), i );
2111 escputs(viewdefs[i]);
2112 wprintf("</OPTION>\n");
2115 wprintf("</SELECT>\n");
2118 wprintf(_("Type of room:"));
2121 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2122 wprintf("CHECKED OnChange=\""
2123 " if (this.form.type[0].checked == true) { "
2124 " this.form.er_floor.disabled = false; "
2127 wprintf(_("Public (automatically appears to everyone)"));
2129 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2130 " if (this.form.type[1].checked == true) { "
2131 " this.form.er_floor.disabled = false; "
2134 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2136 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2137 " if (this.form.type[2].checked == true) { "
2138 " this.form.er_floor.disabled = false; "
2141 wprintf(_("Private - require password: "));
2142 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2144 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2145 " if (this.form.type[3].checked == true) { "
2146 " this.form.er_floor.disabled = false; "
2149 wprintf(_("Private - invitation only"));
2151 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2153 " if (this.form.type[4].checked == true) { "
2154 " this.form.er_floor.disabled = true; "
2157 wprintf(_("Personal (mailbox for you only)"));
2159 wprintf("\n</UL>\n");
2161 wprintf("<CENTER>\n");
2162 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2164 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2165 wprintf("</CENTER>\n");
2166 wprintf("</FORM>\n<hr />");
2167 serv_printf("MESG roomaccess");
2168 serv_getln(buf, sizeof buf);
2169 if (buf[0] == '1') {
2172 wprintf("</td></tr></table></div>\n");
2180 * \brief support function for entroom() -- sets the default view
2182 void er_set_default_view(int newview) {
2195 serv_getln(buf, sizeof buf);
2196 if (buf[0] != '2') return;
2198 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2199 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2200 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2201 rm_bits1 = extract_int(&buf[4], 3);
2202 rm_floor = extract_int(&buf[4], 4);
2203 rm_listorder = extract_int(&buf[4], 5);
2204 rm_bits2 = extract_int(&buf[4], 7);
2206 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2207 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2208 rm_listorder, newview, rm_bits2
2210 serv_getln(buf, sizeof buf);
2216 * \brief enter a new room
2223 char er_password[SIZ];
2228 if (IsEmptyStr(bstr("ok_button"))) {
2229 strcpy(WC->ImportantMessage,
2230 _("Cancelled. No new room was created."));
2231 display_main_menu();
2234 strcpy(er_name, bstr("er_name"));
2235 strcpy(er_type, bstr("type"));
2236 strcpy(er_password, bstr("er_password"));
2237 er_floor = atoi(bstr("er_floor"));
2238 er_view = atoi(bstr("er_view"));
2241 if (!strcmp(er_type, "hidden"))
2243 if (!strcmp(er_type, "passworded"))
2245 if (!strcmp(er_type, "invonly"))
2247 if (!strcmp(er_type, "personal"))
2250 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2251 er_name, er_num_type, er_password, er_floor, 0, er_view);
2253 serv_getln(buf, sizeof buf);
2254 if (buf[0] != '2') {
2255 strcpy(WC->ImportantMessage, &buf[4]);
2256 display_main_menu();
2260 do_change_view(er_view); /* Now go there */
2265 * \brief display the screen to enter a private room
2267 void display_private(char *rname, int req_pass)
2269 output_headers(1, 1, 2, 0, 0, 0);
2270 wprintf("<div id=\"banner\">\n"
2271 "<TABLE class=\"roomops_banner\"><TR><TD>"
2272 "<SPAN CLASS=\"titlebar\">");
2273 wprintf(_("Go to a hidden room"));
2275 "</TD></TR></TABLE>\n"
2276 "</div>\n<div id=\"content\">\n"
2279 wprintf("<div class=\"fix_scrollbar_bug\">"
2280 "<table class=\"roomops_background\"><tr><td>\n");
2282 wprintf("<CENTER>\n");
2284 wprintf(_("If you know the name of a hidden (guess-name) or "
2285 "passworded room, you can enter that room by typing "
2286 "its name below. Once you gain access to a private "
2287 "room, it will appear in your regular room listings "
2288 "so you don't have to keep returning here."));
2289 wprintf("\n<br /><br />");
2291 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2292 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2294 wprintf("<table border=\"0\" cellspacing=\"5\" "
2295 "cellpadding=\"5\" class=\"roomops_background_alt\">\n"
2297 wprintf(_("Enter room name:"));
2299 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2300 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2303 wprintf("</TD></TR><TR><TD>");
2304 wprintf(_("Enter room password:"));
2305 wprintf("</TD><TD>");
2306 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2308 wprintf("</TD></TR></TABLE><br />\n");
2310 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2312 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2316 wprintf("</FORM>\n");
2317 wprintf("</td></tr></table></div>\n");
2322 * \brief goto a private room
2324 void goto_private(void)
2329 if (IsEmptyStr(bstr("ok_button"))) {
2330 display_main_menu();
2333 strcpy(hold_rm, WC->wc_roomname);
2334 strcpy(buf, "GOTO ");
2335 strcat(buf, bstr("gr_name"));
2337 strcat(buf, bstr("gr_pass"));
2339 serv_getln(buf, sizeof buf);
2341 if (buf[0] == '2') {
2342 smart_goto(bstr("gr_name"));
2345 if (!strncmp(buf, "540", 3)) {
2346 display_private(bstr("gr_name"), 1);
2349 output_headers(1, 1, 1, 0, 0, 0);
2350 wprintf("%s\n", &buf[4]);
2357 * \brief display the screen to zap a room
2359 void display_zap(void)
2361 output_headers(1, 1, 2, 0, 0, 0);
2363 wprintf("<div id=\"banner\">\n");
2364 wprintf("<TABLE class=\"roomops_zap\"><TR><TD>");
2365 wprintf("<SPAN CLASS=\"titlebar\">");
2366 wprintf(_("Zap (forget/unsubscribe) the current room"));
2367 wprintf("</SPAN>\n");
2368 wprintf("</TD></TR></TABLE>\n");
2369 wprintf("</div>\n<div id=\"content\">\n");
2371 wprintf(_("If you select this option, <em>%s</em> will "
2372 "disappear from your room list. Is this what you wish "
2373 "to do?<br />\n"), WC->wc_roomname);
2375 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2376 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2377 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2379 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2380 wprintf("</FORM>\n");
2391 char final_destination[SIZ];
2394 * If the forget-room routine fails for any reason, we fall back
2395 * to the current room; otherwise, we go to the Lobby
2397 strcpy(final_destination, WC->wc_roomname);
2399 if (!IsEmptyStr(bstr("ok_button"))) {
2400 serv_printf("GOTO %s", WC->wc_roomname);
2401 serv_getln(buf, sizeof buf);
2402 if (buf[0] == '2') {
2404 serv_getln(buf, sizeof buf);
2405 if (buf[0] == '2') {
2406 strcpy(final_destination, "_BASEROOM_");
2410 smart_goto(final_destination);
2416 * \brief Delete the current room
2418 void delete_room(void)
2422 serv_puts("KILL 1");
2423 serv_getln(buf, sizeof buf);
2424 if (buf[0] != '2') {
2425 strcpy(WC->ImportantMessage, &buf[4]);
2426 display_main_menu();
2429 smart_goto("_BASEROOM_");
2436 * \brief Perform changes to a room's network configuration
2438 void netedit(void) {
2448 if (IsEmptyStr(bstr("line"))) {
2453 strcpy(line, bstr("prefix"));
2454 strcat(line, bstr("line"));
2455 strcat(line, bstr("suffix"));
2464 serv_getln(buf, sizeof buf);
2465 if (buf[0] != '1') {
2471 /** This loop works for add *or* remove. Spiffy, eh? */
2472 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2473 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2474 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2475 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2476 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2477 if ( (strcasecmp(cmpa0, cmpb0))
2478 || (strcasecmp(cmpa1, cmpb1)) ) {
2479 fprintf(fp, "%s\n", buf);
2485 serv_getln(buf, sizeof buf);
2486 if (buf[0] != '4') {
2492 while (fgets(buf, sizeof buf, fp) != NULL) {
2493 buf[strlen(buf)-1] = 0;
2497 if (!IsEmptyStr(bstr("add_button"))) {
2498 num_addrs = num_tokens(bstr("line"), ',');
2499 if (num_addrs < 2) {
2500 /* just adding one node or address */
2504 /* adding multiple addresses separated by commas */
2505 for (i=0; i<num_addrs; ++i) {
2506 strcpy(line, bstr("prefix"));
2507 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2510 strcat(line, bstr("suffix"));
2524 * \brief Convert a room name to a folder-ish-looking name.
2525 * \param folder the folderish name
2526 * \param room the room name
2527 * \param floor the floor name
2528 * \param is_mailbox is it a mailbox?
2530 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2535 * For mailboxes, just do it straight...
2538 sprintf(folder, "My folders|%s", room);
2542 * Otherwise, prefix the floor name as a "public folders" moniker
2545 sprintf(folder, "%s|%s", floorlist[floor], room);
2549 * Replace "\" characters with "|" for pseudo-folder-delimiting
2551 len = strlen (folder);
2552 for (i=0; i<len; ++i) {
2553 if (folder[i] == '\\') folder[i] = '|';
2561 * \brief Back end for change_view()
2562 * \param newview set newview???
2564 void do_change_view(int newview) {
2567 serv_printf("VIEW %d", newview);
2568 serv_getln(buf, sizeof buf);
2569 WC->wc_view = newview;
2570 smart_goto(WC->wc_roomname);
2576 * \brief Change the view for this room
2578 void change_view(void) {
2581 view = atol(bstr("view"));
2582 do_change_view(view);
2587 * \brief One big expanded tree list view --- like a folder list
2588 * \param fold the folder to view
2589 * \param max_folders how many folders???
2590 * \param num_floors hom many floors???
2592 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2596 int has_subfolders = 0;
2599 parents = malloc(max_folders * sizeof(int));
2601 /** BEGIN TREE MENU */
2602 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2604 /** include NanoTree */
2605 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2607 /** initialize NanoTree */
2608 wprintf("<script type=\"text/javascript\"> \n"
2609 " showRootNode = false; \n"
2610 " sortNodes = false; \n"
2611 " dragable = false; \n"
2613 " function standardClick(treeNode) { \n"
2616 " var closedGif = 'static/folder_closed.gif'; \n"
2617 " var openGif = 'static/folder_open.gif'; \n"
2619 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2623 for (i=0; i<max_folders; ++i) {
2626 if ((i+1) < max_folders) {
2628 len = strlen(fold[i].name);
2629 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2630 && (fold[i+1].name[len] == '|') ) {
2635 levels = num_tokens(fold[i].name, '|');
2636 parents[levels] = i;
2638 wprintf("var node%d = new TreeNode(%d, '", i, i);
2640 if (fold[i].selectable) {
2641 wprintf("<a href=\"dotgoto?room=");
2642 urlescputs(fold[i].room);
2647 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2649 else if (fold[i].hasnewmsgs) {
2650 wprintf("<SPAN CLASS=\"roomlist_new\">");
2653 wprintf("<SPAN CLASS=\"roomlist_old\">");
2655 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2660 if (has_subfolders) {
2661 wprintf("new Array(closedGif, openGif)");
2663 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2664 wprintf("'static/viewcontacts_16x.gif'");
2666 else if (fold[i].view == VIEW_CALENDAR) {
2667 wprintf("'static/calarea_16x.gif'");
2669 else if (fold[i].view == VIEW_CALBRIEF) {
2670 wprintf("'static/calarea_16x.gif'");
2672 else if (fold[i].view == VIEW_TASKS) {
2673 wprintf("'static/taskmanag_16x.gif'");
2675 else if (fold[i].view == VIEW_NOTES) {
2676 wprintf("'static/storenotes_16x.gif'");
2678 else if (fold[i].view == VIEW_MAILBOX) {
2679 wprintf("'static/privatemess_16x.gif'");
2682 wprintf("'static/chatrooms_16x.gif'");
2685 urlescputs(fold[i].name);
2689 wprintf("rootNode.addChild(node%d);\n", i);
2692 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2696 wprintf("container = document.getElementById('roomlist_div'); \n"
2702 /** END TREE MENU */
2706 * \brief Boxes and rooms and lists ... oh my!
2707 * \param fold the folder to view
2708 * \param max_folders how many folders???
2709 * \param num_floors hom many floors???
2711 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2713 char floor_name[256];
2714 char old_floor_name[256];
2716 int levels, oldlevels;
2719 static int columns = 3;
2720 int boxes_per_column = 0;
2721 int current_column = 0;
2724 strcpy(floor_name, "");
2725 strcpy(old_floor_name, "");
2728 while (nf % columns != 0) ++nf;
2729 boxes_per_column = (nf / columns);
2730 if (boxes_per_column < 1) boxes_per_column = 1;
2732 /** Outer table (for columnization) */
2733 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2734 "<tr><td valign=top>");
2738 for (i=0; i<max_folders; ++i) {
2740 levels = num_tokens(fold[i].name, '|');
2741 extract_token(floor_name, fold[i].name, 0,
2742 '|', sizeof floor_name);
2744 if ( (strcasecmp(floor_name, old_floor_name))
2745 && (!IsEmptyStr(old_floor_name)) ) {
2747 do_template("endbox");
2750 if ((num_boxes % boxes_per_column) == 0) {
2752 if (current_column < columns) {
2753 wprintf("</td><td valign=top>\n");
2757 strcpy(old_floor_name, floor_name);
2760 /** Begin inner box */
2761 stresc(boxtitle, floor_name, 1, 0);
2762 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2763 do_template("beginbox");
2770 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2771 if (fold[i].selectable) {
2772 wprintf("<a href=\"dotgoto?room=");
2773 urlescputs(fold[i].room);
2779 if (fold[i].hasnewmsgs) {
2780 wprintf("<SPAN CLASS=\"roomlist_new\">");
2783 wprintf("<SPAN CLASS=\"roomlist_old\">");
2785 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2788 if (fold[i].selectable) {
2794 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2795 wprintf(" (INBOX)");
2797 wprintf("<br />\n");
2800 /** End the final inner box */
2801 do_template("endbox");
2803 wprintf("</TD></TR></TABLE>\n");
2807 * \brief print a floor div???
2808 * \param which_floordiv name of the floordiv???
2810 void set_floordiv_expanded(char *which_floordiv) {
2811 begin_ajax_response();
2812 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2813 end_ajax_response();
2817 * \brief view the iconbar
2818 * \param fold the folder to view
2819 * \param max_folders how many folders???
2820 * \param num_floors hom many floors???
2822 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2824 char floor_name[256];
2825 char old_floor_name[256];
2826 char floordivtitle[256];
2827 char floordiv_id[32];
2828 int levels, oldlevels;
2830 int num_drop_targets = 0;
2833 strcpy(floor_name, "");
2834 strcpy(old_floor_name, "");
2838 for (i=0; i<max_folders; ++i) {
2840 levels = num_tokens(fold[i].name, '|');
2841 extract_token(floor_name, fold[i].name, 0,
2842 '|', sizeof floor_name);
2844 if ( (strcasecmp(floor_name, old_floor_name))
2845 && (!IsEmptyStr(old_floor_name)) ) {
2846 /** End inner box */
2848 wprintf("</div>\n"); /** floordiv */
2850 strcpy(old_floor_name, floor_name);
2854 stresc(floordivtitle, floor_name, 0, 0);
2855 sprintf(floordiv_id, "floordiv%d", i);
2856 wprintf("<span class=\"ib_roomlist_floor\" "
2857 "onClick=\"expand_floor('%s')\">"
2858 "%s</span><br>\n", floordiv_id, floordivtitle);
2859 wprintf("<div id=\"%s\" style=\"display:%s\">",
2861 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2868 wprintf("<div id=\"roomdiv%d\">", i);
2870 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2872 /** choose the icon */
2873 if (fold[i].view == VIEW_ADDRESSBOOK) {
2874 icon = "viewcontacts_16x.gif" ;
2876 else if (fold[i].view == VIEW_CALENDAR) {
2877 icon = "calarea_16x.gif" ;
2879 else if (fold[i].view == VIEW_CALBRIEF) {
2880 icon = "calarea_16x.gif" ;
2882 else if (fold[i].view == VIEW_TASKS) {
2883 icon = "taskmanag_16x.gif" ;
2885 else if (fold[i].view == VIEW_NOTES) {
2886 icon = "storenotes_16x.gif" ;
2888 else if (fold[i].view == VIEW_MAILBOX) {
2889 icon = "privatemess_16x.gif" ;
2892 icon = "chatrooms_16x.gif" ;
2895 if (fold[i].selectable) {
2896 wprintf("<a href=\"dotgoto?room=");
2897 urlescputs(fold[i].room);
2899 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2904 if (fold[i].hasnewmsgs) {
2905 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2908 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2910 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2912 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2913 wprintf(" (INBOX)");
2916 if (fold[i].selectable) {
2923 wprintf("</div>\n"); /** roomdiv */
2926 wprintf("</div>\n"); /** floordiv */
2929 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2930 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2932 num_drop_targets = 0;
2934 for (i=0; i<max_folders; ++i) {
2935 levels = num_tokens(fold[i].name, '|');
2937 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2938 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2939 jsescputs(fold[i].room);
2945 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2946 if ((WC->floordiv_expanded[0] != '\0')&&
2947 (WC->floordiv_expanded[1] != '\0')){
2948 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2952 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2958 * \brief Show the room list.
2959 * (only should get called by
2960 * knrooms() because that's where output_headers() is called from)
2961 * \param viewpref the view preferences???
2964 void list_all_rooms_by_floor(char *viewpref) {
2967 struct folder *fold = NULL;
2969 int max_folders = 0;
2970 int alloc_folders = 0;
2974 int num_floors = 1; /** add an extra one for private folders */
2976 /** If our cached folder list is very old, burn it. */
2977 if (WC->cache_fold != NULL) {
2978 if ((time(NULL) - WC->cache_timestamp) > 300) {
2979 free(WC->cache_fold);
2980 WC->cache_fold = NULL;
2984 /** Can we do the iconbar roomlist from cache? */
2985 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2986 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2990 /** Grab the floor table so we know how to build the list... */
2993 /** Start with the mailboxes */
2996 fold = malloc(sizeof(struct folder));
2997 memset(fold, 0, sizeof(struct folder));
2998 strcpy(fold[0].name, "My folders");
2999 fold[0].is_mailbox = 1;
3001 /** Then add floors */
3003 serv_getln(buf, sizeof buf);
3004 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3005 if (max_folders >= alloc_folders) {
3006 alloc_folders = max_folders + 100;
3007 fold = realloc(fold,
3008 alloc_folders * sizeof(struct folder));
3010 memset(&fold[max_folders], 0, sizeof(struct folder));
3011 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3016 /** refresh the messages index for this room */
3017 // serv_puts("GOTO ");
3018 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3019 /** Now add rooms */
3021 serv_getln(buf, sizeof buf);
3022 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3023 if (max_folders >= alloc_folders) {
3024 alloc_folders = max_folders + 100;
3025 fold = realloc(fold,
3026 alloc_folders * sizeof(struct folder));
3028 memset(&fold[max_folders], 0, sizeof(struct folder));
3029 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3030 ra_flags = extract_int(buf, 5);
3031 flags = extract_int(buf, 1);
3032 fold[max_folders].floor = extract_int(buf, 2);
3033 fold[max_folders].hasnewmsgs =
3034 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3035 if (flags & QR_MAILBOX) {
3036 fold[max_folders].is_mailbox = 1;
3038 fold[max_folders].view = extract_int(buf, 6);
3039 room_to_folder(fold[max_folders].name,
3040 fold[max_folders].room,
3041 fold[max_folders].floor,
3042 fold[max_folders].is_mailbox);
3043 fold[max_folders].selectable = 1;
3047 /** Bubble-sort the folder list */
3048 for (i=0; i<max_folders; ++i) {
3049 for (j=0; j<(max_folders-1)-i; ++j) {
3050 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3051 swap = strcasecmp(fold[j].name, fold[j+1].name);
3054 if ( (fold[j+1].is_mailbox)
3055 && (!fold[j].is_mailbox)) {
3063 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3064 memcpy(&fold[j], &fold[j+1],
3065 sizeof(struct folder));
3066 memcpy(&fold[j+1], &ftmp,
3067 sizeof(struct folder));
3073 if (!strcasecmp(viewpref, "folders")) {
3074 do_folder_view(fold, max_folders, num_floors);
3076 else if (!strcasecmp(viewpref, "hackish_view")) {
3077 for (i=0; i<max_folders; ++i) {
3078 escputs(fold[i].name);
3079 wprintf("<br />\n");
3082 else if (!strcasecmp(viewpref, "iconbar")) {
3083 do_iconbar_view(fold, max_folders, num_floors);
3086 do_rooms_view(fold, max_folders, num_floors);
3089 /* Don't free the folder list ... cache it for future use! */
3090 if (WC->cache_fold != NULL) {
3091 free(WC->cache_fold);
3093 WC->cache_fold = fold;
3094 WC->cache_max_folders = max_folders;
3095 WC->cache_num_floors = num_floors;
3096 WC->cache_timestamp = time(NULL);
3101 * \brief Do either a known rooms list or a folders list, depending on the
3106 char listviewpref[SIZ];
3108 output_headers(1, 1, 2, 0, 0, 0);
3110 /** Determine whether the user is trying to change views */
3111 if (bstr("view") != NULL) {
3112 if (!IsEmptyStr(bstr("view"))) {
3113 set_preference("roomlistview", bstr("view"), 1);
3117 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3119 if ( (strcasecmp(listviewpref, "folders"))
3120 && (strcasecmp(listviewpref, "table")) ) {
3121 strcpy(listviewpref, "rooms");
3125 wprintf("<div id=\"banner\">\n"
3126 "<TABLE class=\"roomops_banner\"><TR><TD>"
3127 "<SPAN CLASS=\"titlebar\">"
3129 if (!strcasecmp(listviewpref, "rooms")) {
3130 wprintf(_("Room list"));
3132 if (!strcasecmp(listviewpref, "folders")) {
3133 wprintf(_("Folder list"));
3135 if (!strcasecmp(listviewpref, "table")) {
3136 wprintf(_("Room list"));
3138 wprintf("</SPAN></TD>\n");
3140 /** offer the ability to switch views */
3141 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
3142 "<SELECT NAME=\"newview\" SIZE=\"1\" "
3143 "OnChange=\"location.href=roomlistomatic.newview.options"
3144 "[selectedIndex].value\">\n");
3146 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3149 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3152 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3153 "View as folder list"
3155 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3158 wprintf("</SELECT><br />");
3160 wprintf("</FORM></TD></TR></TABLE>\n");
3163 "<div id=\"content\">\n");
3165 /** Display the room list in the user's preferred format */
3166 list_all_rooms_by_floor(listviewpref);
3173 * \brief Set the message expire policy for this room and/or floor
3175 void set_room_policy(void) {
3178 if (IsEmptyStr(bstr("ok_button"))) {
3179 strcpy(WC->ImportantMessage,
3180 _("Cancelled. Changes were not saved."));
3185 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3186 serv_getln(buf, sizeof buf);
3187 strcpy(WC->ImportantMessage, &buf[4]);
3189 if (WC->axlevel >= 6) {
3190 strcat(WC->ImportantMessage, "<br />\n");
3191 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3192 serv_getln(buf, sizeof buf);
3193 strcat(WC->ImportantMessage, &buf[4]);