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 mptr->march_order = 0;
867 mptr->march_floor = 0;
868 strcpy(mptr->march_name, "_BASEROOM_");
869 if (WC->march == NULL) {
873 while (mptr2->next != NULL)
878 * ...and remove the room we're currently in, so a <G>oto doesn't make us
879 * walk around in circles
881 remove_march(WC->wc_roomname);
883 if (WC->march != NULL) {
884 strcpy(next_room, pop_march(-1));
886 strcpy(next_room, "_BASEROOM_");
890 smart_goto(next_room);
895 * \brief goto next room
896 * \param next_room next room to go to
898 void smart_goto(char *next_room) {
906 * \brief mark all messages in current room as having been read
908 void slrp_highest(void)
912 serv_puts("SLRP HIGHEST");
913 serv_getln(buf, sizeof buf);
918 * \brief un-goto the previous room
924 if (!strcmp(WC->ugname, "")) {
925 smart_goto(WC->wc_roomname);
928 serv_printf("GOTO %s", WC->ugname);
929 serv_getln(buf, sizeof buf);
931 smart_goto(WC->wc_roomname);
934 if (WC->uglsn >= 0L) {
935 serv_printf("SLRP %ld", WC->uglsn);
936 serv_getln(buf, sizeof buf);
938 strcpy(buf, WC->ugname);
939 strcpy(WC->ugname, "");
948 * \brief Set/clear/read the "self-service list subscribe" flag for a room
950 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
951 * \return return the new value.
954 int self_service(int newval) {
955 int current_value = 0;
961 int flags, floor, order, view, flags2;
964 serv_getln(buf, sizeof buf);
965 if (buf[0] != '2') return(0);
967 extract_token(name, &buf[4], 0, '|', sizeof name);
968 extract_token(password, &buf[4], 1, '|', sizeof password);
969 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
970 flags = extract_int(&buf[4], 3);
971 floor = extract_int(&buf[4], 4);
972 order = extract_int(&buf[4], 5);
973 view = extract_int(&buf[4], 6);
974 flags2 = extract_int(&buf[4], 7);
976 if (flags2 & QR2_SELFLIST) {
984 flags2 = flags2 | QR2_SELFLIST;
986 else if (newval == 0) {
987 flags2 = flags2 & ~QR2_SELFLIST;
990 return(current_value);
993 if (newval != current_value) {
994 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
995 name, password, dirname, flags,
996 floor, order, view, flags2);
997 serv_getln(buf, sizeof buf);
1010 * \brief display the form for editing a room
1012 void display_editroom(void)
1017 char remote_room[128];
1020 char er_password[10];
1021 char er_dirname[15];
1022 char er_roomaide[26];
1029 char *not_shared_with;
1032 int floorpolicy = 0;
1036 if (IsEmptyStr(tab)) tab = "admin";
1040 serv_getln(buf, sizeof buf);
1042 if (buf[0] != '2') {
1043 strcpy(WC->ImportantMessage, &buf[4]);
1044 display_main_menu();
1047 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1048 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1049 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1050 er_flags = extract_int(&buf[4], 3);
1051 er_floor = extract_int(&buf[4], 4);
1052 er_flags2 = extract_int(&buf[4], 7);
1054 output_headers(1, 1, 1, 0, 0, 0);
1056 /** print the tabbed dialog */
1058 "<div class=\"fix_scrollbar_bug\">"
1059 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
1061 "<TD> </TD>\n");
1063 if (!strcmp(tab, "admin")) {
1064 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1067 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1069 wprintf(_("Administration"));
1070 if (!strcmp(tab, "admin")) {
1071 wprintf("</SPAN></TD>\n");
1074 wprintf("</A></TD>\n");
1077 wprintf("<TD> </TD>\n");
1079 if (!strcmp(tab, "config")) {
1080 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1083 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=config\">");
1085 wprintf(_("Configuration"));
1086 if (!strcmp(tab, "config")) {
1087 wprintf("</SPAN></TD>\n");
1090 wprintf("</A></TD>\n");
1093 wprintf("<TD> </TD>\n");
1095 if (!strcmp(tab, "expire")) {
1096 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1099 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1101 wprintf(_("Message expire policy"));
1102 if (!strcmp(tab, "expire")) {
1103 wprintf("</SPAN></TD>\n");
1106 wprintf("</A></TD>\n");
1109 wprintf("<TD> </TD>\n");
1111 if (!strcmp(tab, "access")) {
1112 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1115 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=access\">");
1117 wprintf(_("Access controls"));
1118 if (!strcmp(tab, "access")) {
1119 wprintf("</SPAN></TD>\n");
1122 wprintf("</A></TD>\n");
1125 wprintf("<TD> </TD>\n");
1127 if (!strcmp(tab, "sharing")) {
1128 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1131 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1133 wprintf(_("Sharing"));
1134 if (!strcmp(tab, "sharing")) {
1135 wprintf("</SPAN></TD>\n");
1138 wprintf("</A></TD>\n");
1141 wprintf("<TD> </TD>\n");
1143 if (!strcmp(tab, "listserv")) {
1144 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1147 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1149 wprintf(_("Mailing list service"));
1150 if (!strcmp(tab, "listserv")) {
1151 wprintf("</SPAN></TD>\n");
1154 wprintf("</A></TD>\n");
1157 wprintf("<TD> </TD>\n");
1159 wprintf("</TR></TABLE></div>\n");
1160 /** end tabbed dialog */
1162 /** begin content of whatever tab is open now */
1163 wprintf("<div class=\"fix_scrollbar_bug\">"
1164 "<TABLE class=\"roomops_background\">\n"
1167 if (!strcmp(tab, "admin")) {
1169 "<LI><a href=\"delete_room\" "
1170 "onClick=\"return confirm('");
1171 wprintf(_("Are you sure you want to delete this room?"));
1172 wprintf("');\">\n");
1173 wprintf(_("Delete this room"));
1175 "<LI><a href=\"display_editroompic\">\n");
1176 wprintf(_("Set or change the icon for this room's banner"));
1178 "<LI><a href=\"display_editinfo\">\n");
1179 wprintf(_("Edit this room's Info file"));
1184 if (!strcmp(tab, "config")) {
1185 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1186 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1188 wprintf("<UL><LI>");
1189 wprintf(_("Name of room: "));
1190 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1196 wprintf(_("Resides on floor: "));
1197 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1198 for (i = 0; i < 128; ++i)
1199 if (!IsEmptyStr(floorlist[i])) {
1200 wprintf("<OPTION ");
1202 wprintf("SELECTED ");
1203 wprintf("VALUE=\"%d\">", i);
1204 escputs(floorlist[i]);
1205 wprintf("</OPTION>\n");
1207 wprintf("</SELECT>\n");
1210 wprintf(_("Type of room:"));
1213 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1214 if ((er_flags & QR_PRIVATE) == 0)
1215 wprintf("CHECKED ");
1217 wprintf(_("Public (automatically appears to everyone)"));
1220 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1221 if ((er_flags & QR_PRIVATE) &&
1222 (er_flags & QR_GUESSNAME))
1223 wprintf("CHECKED ");
1225 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1227 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1228 if ((er_flags & QR_PRIVATE) &&
1229 (er_flags & QR_PASSWORDED))
1230 wprintf("CHECKED ");
1232 wprintf(_("Private - require password: "));
1233 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1236 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1237 if ((er_flags & QR_PRIVATE)
1238 && ((er_flags & QR_GUESSNAME) == 0)
1239 && ((er_flags & QR_PASSWORDED) == 0))
1240 wprintf("CHECKED ");
1242 wprintf(_("Private - invitation only"));
1244 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1246 wprintf(_("If private, cause current users to forget room"));
1248 wprintf("\n</UL>\n");
1250 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1251 if (er_flags & QR_PREFONLY)
1252 wprintf("CHECKED ");
1254 wprintf(_("Preferred users only"));
1256 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1257 if (er_flags & QR_READONLY)
1258 wprintf("CHECKED ");
1260 wprintf(_("Read-only room"));
1262 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1263 if (er_flags2 & QR2_COLLABDEL)
1264 wprintf("CHECKED ");
1266 wprintf(_("All users allowed to post may also delete messages"));
1268 /** directory stuff */
1269 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1270 if (er_flags & QR_DIRECTORY)
1271 wprintf("CHECKED ");
1273 wprintf(_("File directory room"));
1275 wprintf("\n<UL><LI>");
1276 wprintf(_("Directory name: "));
1277 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1280 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1281 if (er_flags & QR_UPLOAD)
1282 wprintf("CHECKED ");
1284 wprintf(_("Uploading allowed"));
1286 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1287 if (er_flags & QR_DOWNLOAD)
1288 wprintf("CHECKED ");
1290 wprintf(_("Downloading allowed"));
1292 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1293 if (er_flags & QR_VISDIR)
1294 wprintf("CHECKED ");
1296 wprintf(_("Visible directory"));
1299 /** end of directory stuff */
1301 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1302 if (er_flags & QR_NETWORK)
1303 wprintf("CHECKED ");
1305 wprintf(_("Network shared room"));
1307 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1308 if (er_flags & QR_PERMANENT)
1309 wprintf("CHECKED ");
1311 wprintf(_("Permanent (does not auto-purge)"));
1313 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1314 if (er_flags2 & QR2_SUBJECTREQ)
1315 wprintf("CHECKED ");
1317 wprintf(_("Subject Required (Force users to specify a message subject)"));
1319 /** start of anon options */
1322 wprintf(_("Anonymous messages"));
1325 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1326 if (((er_flags & QR_ANONONLY) == 0)
1327 && ((er_flags & QR_ANONOPT) == 0))
1328 wprintf("CHECKED ");
1330 wprintf(_("No anonymous messages"));
1332 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1333 if (er_flags & QR_ANONONLY)
1334 wprintf("CHECKED ");
1336 wprintf(_("All messages are anonymous"));
1338 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1339 if (er_flags & QR_ANONOPT)
1340 wprintf("CHECKED ");
1342 wprintf(_("Prompt user when entering messages"));
1345 /* end of anon options */
1348 wprintf(_("Room aide: "));
1350 serv_getln(buf, sizeof buf);
1351 if (buf[0] != '2') {
1352 wprintf("<em>%s</em>\n", &buf[4]);
1354 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1355 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1358 wprintf("</UL><CENTER>\n");
1359 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1360 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1362 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1370 /** Sharing the room with other Citadel nodes... */
1371 if (!strcmp(tab, "sharing")) {
1373 shared_with = strdup("");
1374 not_shared_with = strdup("");
1376 /** Learn the current configuration */
1377 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1378 serv_getln(buf, sizeof buf);
1379 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1380 extract_token(node, buf, 0, '|', sizeof node);
1381 not_shared_with = realloc(not_shared_with,
1382 strlen(not_shared_with) + 32);
1383 strcat(not_shared_with, node);
1384 strcat(not_shared_with, "\n");
1388 serv_getln(buf, sizeof buf);
1389 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1390 extract_token(cmd, buf, 0, '|', sizeof cmd);
1391 extract_token(node, buf, 1, '|', sizeof node);
1392 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1393 if (!strcasecmp(cmd, "ignet_push_share")) {
1394 shared_with = realloc(shared_with,
1395 strlen(shared_with) + 32);
1396 strcat(shared_with, node);
1397 if (!IsEmptyStr(remote_room)) {
1398 strcat(shared_with, "|");
1399 strcat(shared_with, remote_room);
1401 strcat(shared_with, "\n");
1405 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1406 extract_token(buf, shared_with, i, '\n', sizeof buf);
1407 extract_token(node, buf, 0, '|', sizeof node);
1408 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1409 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1410 if (!strcasecmp(node, cmd)) {
1411 remove_token(not_shared_with, j, '\n');
1416 /** Display the stuff */
1417 wprintf("<CENTER><br />"
1418 "<TABLE border=1 cellpadding=5><TR>"
1420 wprintf(_("Shared with"));
1421 wprintf("</I></B></TD>"
1423 wprintf(_("Not shared with"));
1424 wprintf("</I></B></TD></TR>\n"
1425 "<TR><TD VALIGN=TOP>\n");
1427 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1428 wprintf(_("Remote node name"));
1429 wprintf("</TD><TD>");
1430 wprintf(_("Remote room name"));
1431 wprintf("</TD><TD>");
1432 wprintf(_("Actions"));
1433 wprintf("</TD></TR>\n");
1435 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1436 extract_token(buf, shared_with, i, '\n', sizeof buf);
1437 extract_token(node, buf, 0, '|', sizeof node);
1438 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1439 if (!IsEmptyStr(node)) {
1440 wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
1441 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1442 wprintf("<TR><TD>%s</TD>\n", node);
1445 if (!IsEmptyStr(remote_room)) {
1446 escputs(remote_room);
1452 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1453 "VALUE=\"ignet_push_share|");
1455 if (!IsEmptyStr(remote_room)) {
1457 urlescputs(remote_room);
1460 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1461 "VALUE=\"sharing\">\n");
1462 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1463 "VALUE=\"remove\">\n");
1464 wprintf("<INPUT TYPE=\"submit\" "
1465 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1466 wprintf("</TD></TR></FORM>\n");
1470 wprintf("</TABLE>\n");
1471 wprintf("</TD><TD VALIGN=TOP>\n");
1472 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1473 wprintf(_("Remote node name"));
1474 wprintf("</TD><TD>");
1475 wprintf(_("Remote room name"));
1476 wprintf("</TD><TD>");
1477 wprintf(_("Actions"));
1478 wprintf("</TD></TR>\n");
1480 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1481 extract_token(node, not_shared_with, i, '\n', sizeof node);
1482 if (!IsEmptyStr(node)) {
1483 wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
1484 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1485 wprintf("<TR><TD>");
1488 "<INPUT TYPE=\"INPUT\" "
1492 wprintf("<INPUT TYPE=\"hidden\" "
1494 "VALUE=\"ignet_push_share|");
1497 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1498 "VALUE=\"sharing\">\n");
1499 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1500 "VALUE=\"add\">\n");
1501 wprintf("<INPUT TYPE=\"submit\" "
1502 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1503 wprintf("</TD></TR></FORM>\n");
1507 wprintf("</TABLE>\n");
1508 wprintf("</TD></TR>"
1509 "</TABLE></CENTER><br />\n"
1510 "<I><B>%s</B><UL><LI>", _("Notes:"));
1511 wprintf(_("When sharing a room, "
1512 "it must be shared from both ends. Adding a node to "
1513 "the 'shared' list sends messages out, but in order to"
1514 " receive messages, the other nodes must be configured"
1515 " to send messages out to your system as well. "
1516 "<LI>If the remote room name is blank, it is assumed "
1517 "that the room name is identical on the remote node."
1518 "<LI>If the remote room name is different, the remote "
1519 "node must also configure the name of the room here."
1525 /** Mailing list management */
1526 if (!strcmp(tab, "listserv")) {
1528 wprintf("<br /><center>"
1529 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1530 "<TR><TD VALIGN=TOP>");
1532 wprintf(_("<i>The contents of this room are being "
1533 "mailed <b>as individual messages</b> "
1534 "to the following list recipients:"
1535 "</i><br /><br />\n"));
1538 serv_getln(buf, sizeof buf);
1539 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1540 extract_token(cmd, buf, 0, '|', sizeof cmd);
1541 if (!strcasecmp(cmd, "listrecp")) {
1542 extract_token(recp, buf, 1, '|', sizeof recp);
1545 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1548 wprintf(_("(remove)"));
1549 wprintf("</A><br />");
1552 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1553 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1554 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1555 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1556 wprintf("<INPUT TYPE=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1557 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1558 wprintf("</FORM>\n");
1560 wprintf("</TD><TD VALIGN=TOP>\n");
1562 wprintf(_("<i>The contents of this room are being "
1563 "mailed <b>in digest form</b> "
1564 "to the following list recipients:"
1565 "</i><br /><br />\n"));
1568 serv_getln(buf, sizeof buf);
1569 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1570 extract_token(cmd, buf, 0, '|', sizeof cmd);
1571 if (!strcasecmp(cmd, "digestrecp")) {
1572 extract_token(recp, buf, 1, '|', sizeof recp);
1575 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1579 wprintf(_("(remove)"));
1580 wprintf("</A><br />");
1583 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1584 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1585 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1586 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1587 wprintf("<INPUT TYPE=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1588 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1589 wprintf("</FORM>\n");
1591 wprintf("</TD></TR></TABLE>\n");
1593 /** Pop open an address book -- begin **/
1594 wprintf("<div align=right>"
1595 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1597 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1602 _("Add recipients from Contacts or other address books"),
1603 _("Add recipients from Contacts or other address books")
1605 /** Pop open an address book -- end **/
1608 if (self_service(999) == 1) {
1609 wprintf(_("This room is configured to allow "
1610 "self-service subscribe/unsubscribe requests."));
1611 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1612 wprintf(_("Click to disable."));
1613 wprintf("</A><br />\n");
1614 wprintf(_("The URL for subscribe/unsubscribe is: "));
1615 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1616 (is_https ? "https" : "http"),
1620 wprintf(_("This room is <i>not</i> configured to allow "
1621 "self-service subscribe/unsubscribe requests."));
1622 wprintf(" <a href=\"toggle_self_service?newval=1&"
1624 wprintf(_("Click to enable."));
1625 wprintf("</A><br />\n");
1629 wprintf("</CENTER>\n");
1633 /** Mailing list management */
1634 if (!strcmp(tab, "expire")) {
1636 serv_puts("GPEX room");
1637 serv_getln(buf, sizeof buf);
1638 if (buf[0] == '2') {
1639 roompolicy = extract_int(&buf[4], 0);
1640 roomvalue = extract_int(&buf[4], 1);
1643 serv_puts("GPEX floor");
1644 serv_getln(buf, sizeof buf);
1645 if (buf[0] == '2') {
1646 floorpolicy = extract_int(&buf[4], 0);
1647 floorvalue = extract_int(&buf[4], 1);
1650 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1651 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1652 wprintf("<TABLE border=0 cellspacing=5>\n");
1653 wprintf("<TR><TD>");
1654 wprintf(_("Message expire policy for this room"));
1656 escputs(WC->wc_roomname);
1657 wprintf(")</TD><TD>");
1658 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1659 ((roompolicy == 0) ? "CHECKED" : "") );
1660 wprintf(_("Use the default policy for this floor"));
1661 wprintf("<br />\n");
1662 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1663 ((roompolicy == 1) ? "CHECKED" : "") );
1664 wprintf(_("Never automatically expire messages"));
1665 wprintf("<br />\n");
1666 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1667 ((roompolicy == 2) ? "CHECKED" : "") );
1668 wprintf(_("Expire by message count"));
1669 wprintf("<br />\n");
1670 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1671 ((roompolicy == 3) ? "CHECKED" : "") );
1672 wprintf(_("Expire by message age"));
1674 wprintf(_("Number of messages or days: "));
1675 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1676 wprintf("</TD></TR>\n");
1678 if (WC->axlevel >= 6) {
1679 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1680 wprintf("<TR><TD>");
1681 wprintf(_("Message expire policy for this floor"));
1683 escputs(floorlist[WC->wc_floor]);
1684 wprintf(")</TD><TD>");
1685 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1686 ((floorpolicy == 0) ? "CHECKED" : "") );
1687 wprintf(_("Use the system default"));
1688 wprintf("<br />\n");
1689 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1690 ((floorpolicy == 1) ? "CHECKED" : "") );
1691 wprintf(_("Never automatically expire messages"));
1692 wprintf("<br />\n");
1693 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1694 ((floorpolicy == 2) ? "CHECKED" : "") );
1695 wprintf(_("Expire by message count"));
1696 wprintf("<br />\n");
1697 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1698 ((floorpolicy == 3) ? "CHECKED" : "") );
1699 wprintf(_("Expire by message age"));
1701 wprintf(_("Number of messages or days: "));
1702 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1706 wprintf("<CENTER>\n");
1707 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1708 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1710 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1711 wprintf("</CENTER></TD><TR>\n");
1713 wprintf("</TABLE>\n"
1714 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1720 /** Mailing list management */
1721 if (!strcmp(tab, "access")) {
1725 /** end content of whatever tab is open now */
1726 wprintf("</TD></TR></TABLE></div>\n");
1728 address_book_popup();
1734 * \brief Toggle self-service list subscription
1736 void toggle_self_service(void) {
1739 newval = atoi(bstr("newval"));
1740 self_service(newval);
1747 * \brief save new parameters for a room
1753 char er_password[10];
1754 char er_dirname[15];
1755 char er_roomaide[26];
1758 int er_listingorder;
1764 if (IsEmptyStr(bstr("ok_button"))) {
1765 strcpy(WC->ImportantMessage,
1766 _("Cancelled. Changes were not saved."));
1771 serv_getln(buf, sizeof buf);
1773 if (buf[0] != '2') {
1774 strcpy(WC->ImportantMessage, &buf[4]);
1778 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1779 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1780 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1781 er_flags = extract_int(&buf[4], 3);
1782 er_listingorder = extract_int(&buf[4], 5);
1783 er_defaultview = extract_int(&buf[4], 6);
1784 er_flags2 = extract_int(&buf[4], 7);
1786 strcpy(er_roomaide, bstr("er_roomaide"));
1787 if (IsEmptyStr(er_roomaide)) {
1789 serv_getln(buf, sizeof buf);
1790 if (buf[0] != '2') {
1791 strcpy(er_roomaide, "");
1793 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1796 strcpy(buf, bstr("er_name"));
1798 if (!IsEmptyStr(buf)) {
1799 strcpy(er_name, buf);
1802 strcpy(buf, bstr("er_password"));
1804 if (!IsEmptyStr(buf))
1805 strcpy(er_password, buf);
1807 strcpy(buf, bstr("er_dirname"));
1809 if (!IsEmptyStr(buf))
1810 strcpy(er_dirname, buf);
1812 strcpy(buf, bstr("type"));
1813 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1815 if (!strcmp(buf, "invonly")) {
1816 er_flags |= (QR_PRIVATE);
1818 if (!strcmp(buf, "hidden")) {
1819 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1821 if (!strcmp(buf, "passworded")) {
1822 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1824 if (!strcmp(bstr("prefonly"), "yes")) {
1825 er_flags |= QR_PREFONLY;
1827 er_flags &= ~QR_PREFONLY;
1830 if (!strcmp(bstr("readonly"), "yes")) {
1831 er_flags |= QR_READONLY;
1833 er_flags &= ~QR_READONLY;
1836 if (!strcmp(bstr("collabdel"), "yes")) {
1837 er_flags2 |= QR2_COLLABDEL;
1839 er_flags2 &= ~QR2_COLLABDEL;
1842 if (!strcmp(bstr("permanent"), "yes")) {
1843 er_flags |= QR_PERMANENT;
1845 er_flags &= ~QR_PERMANENT;
1848 if (!strcmp(bstr("subjectreq"), "yes")) {
1849 er_flags2 |= QR2_SUBJECTREQ;
1851 er_flags2 &= ~QR2_SUBJECTREQ;
1854 if (!strcmp(bstr("network"), "yes")) {
1855 er_flags |= QR_NETWORK;
1857 er_flags &= ~QR_NETWORK;
1860 if (!strcmp(bstr("directory"), "yes")) {
1861 er_flags |= QR_DIRECTORY;
1863 er_flags &= ~QR_DIRECTORY;
1866 if (!strcmp(bstr("ulallowed"), "yes")) {
1867 er_flags |= QR_UPLOAD;
1869 er_flags &= ~QR_UPLOAD;
1872 if (!strcmp(bstr("dlallowed"), "yes")) {
1873 er_flags |= QR_DOWNLOAD;
1875 er_flags &= ~QR_DOWNLOAD;
1878 if (!strcmp(bstr("visdir"), "yes")) {
1879 er_flags |= QR_VISDIR;
1881 er_flags &= ~QR_VISDIR;
1884 strcpy(buf, bstr("anon"));
1886 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1887 if (!strcmp(buf, "anononly"))
1888 er_flags |= QR_ANONONLY;
1889 if (!strcmp(buf, "anon2"))
1890 er_flags |= QR_ANONOPT;
1893 if (!strcmp(bstr("bump"), "yes"))
1896 er_floor = atoi(bstr("er_floor"));
1898 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
1899 er_name, er_password, er_dirname, er_flags, bump, er_floor,
1900 er_listingorder, er_defaultview, er_flags2);
1902 serv_getln(buf, sizeof buf);
1903 if (buf[0] != '2') {
1904 strcpy(WC->ImportantMessage, &buf[4]);
1910 if (!IsEmptyStr(er_roomaide)) {
1911 sprintf(buf, "SETA %s", er_roomaide);
1913 serv_getln(buf, sizeof buf);
1914 if (buf[0] != '2') {
1915 strcpy(WC->ImportantMessage, &buf[4]);
1916 display_main_menu();
1921 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1928 * \brief Display form for Invite, Kick, and show Who Knows a room
1930 void do_invt_kick(void) {
1931 char buf[SIZ], room[SIZ], username[SIZ];
1934 serv_getln(buf, sizeof buf);
1936 if (buf[0] != '2') {
1940 extract_token(room, &buf[4], 0, '|', sizeof room);
1942 strcpy(username, bstr("username"));
1944 if (!IsEmptyStr(bstr("kick_button"))) {
1945 sprintf(buf, "KICK %s", username);
1947 serv_getln(buf, sizeof buf);
1949 if (buf[0] != '2') {
1950 strcpy(WC->ImportantMessage, &buf[4]);
1952 sprintf(WC->ImportantMessage,
1953 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1958 if (!IsEmptyStr(bstr("invite_button"))) {
1959 sprintf(buf, "INVT %s", username);
1961 serv_getln(buf, sizeof buf);
1963 if (buf[0] != '2') {
1964 strcpy(WC->ImportantMessage, &buf[4]);
1966 sprintf(WC->ImportantMessage,
1967 _("<B><I>User %s invited to room %s.</I></B>\n"),
1978 * \brief Display form for Invite, Kick, and show Who Knows a room
1980 void display_whok(void)
1982 char buf[SIZ], room[SIZ], username[SIZ];
1985 serv_getln(buf, sizeof buf);
1987 if (buf[0] != '2') {
1991 extract_token(room, &buf[4], 0, '|', sizeof room);
1994 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1995 wprintf(_("The users listed below have access to this room. "
1996 "To remove a user from the access list, select the user "
1997 "name from the list and click 'Kick'."));
1998 wprintf("<br /><br />");
2000 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
2001 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2002 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2003 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2005 serv_getln(buf, sizeof buf);
2006 if (buf[0] == '1') {
2007 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2008 extract_token(username, buf, 0, '|', sizeof username);
2009 wprintf("<OPTION>");
2014 wprintf("</SELECT><br />\n");
2016 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2017 wprintf("</FORM></CENTER>\n");
2019 wprintf("</TD><TD>");
2020 wprintf(_("To grant another user access to this room, enter the "
2021 "user name in the box below and click 'Invite'."));
2022 wprintf("<br /><br />");
2024 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
2025 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2026 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2027 wprintf(_("Invite:"));
2029 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
2030 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2031 "<input type=\"submit\" value=\"%s\">"
2032 "</FORM></CENTER>\n", _("Invite"));
2034 wprintf("</TD></TR></TABLE>\n");
2041 * \brief display the form for entering a new room
2043 void display_entroom(void)
2048 serv_puts("CRE8 0");
2049 serv_getln(buf, sizeof buf);
2051 if (buf[0] != '2') {
2052 strcpy(WC->ImportantMessage, &buf[4]);
2053 display_main_menu();
2057 output_headers(1, 1, 2, 0, 0, 0);
2058 wprintf("<div id=\"banner\">\n");
2060 wprintf(_("Create a new room"));
2064 wprintf("<div id=\"content\" class=\"service\">\n");
2066 wprintf("<div class=\"fix_scrollbar_bug\">"
2067 "<table class=\"roomops_background\"><tr><td>\n");
2069 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2070 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2072 wprintf("<UL><LI>");
2073 wprintf(_("Name of room: "));
2074 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2077 wprintf(_("Resides on floor: "));
2079 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
2080 for (i = 0; i < 128; ++i)
2081 if (!IsEmptyStr(floorlist[i])) {
2082 wprintf("<OPTION ");
2083 wprintf("VALUE=\"%d\">", i);
2084 escputs(floorlist[i]);
2085 wprintf("</OPTION>\n");
2087 wprintf("</SELECT>\n");
2090 * Our clever little snippet of JavaScript automatically selects
2091 * a public room if the view is set to Bulletin Board or wiki, and
2092 * it selects a mailbox room otherwise. The user can override this,
2093 * of course. We also disable the floor selector for mailboxes.
2096 wprintf(_("Default view for room: "));
2097 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
2098 " if ( (this.form.er_view.value == 0) "
2099 " || (this.form.er_view.value == 6) ) { "
2100 " this.form.type[0].checked=true; "
2101 " this.form.er_floor.disabled = false; "
2104 " this.form.type[4].checked=true; "
2105 " this.form.er_floor.disabled = true; "
2108 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2109 if (is_view_allowed_as_default(i)) {
2110 wprintf("<OPTION %s VALUE=\"%d\">",
2111 ((i == 0) ? "SELECTED" : ""), i );
2112 escputs(viewdefs[i]);
2113 wprintf("</OPTION>\n");
2116 wprintf("</SELECT>\n");
2119 wprintf(_("Type of room:"));
2122 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2123 wprintf("CHECKED OnChange=\""
2124 " if (this.form.type[0].checked == true) { "
2125 " this.form.er_floor.disabled = false; "
2128 wprintf(_("Public (automatically appears to everyone)"));
2130 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2131 " if (this.form.type[1].checked == true) { "
2132 " this.form.er_floor.disabled = false; "
2135 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2137 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2138 " if (this.form.type[2].checked == true) { "
2139 " this.form.er_floor.disabled = false; "
2142 wprintf(_("Private - require password: "));
2143 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2145 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2146 " if (this.form.type[3].checked == true) { "
2147 " this.form.er_floor.disabled = false; "
2150 wprintf(_("Private - invitation only"));
2152 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2154 " if (this.form.type[4].checked == true) { "
2155 " this.form.er_floor.disabled = true; "
2158 wprintf(_("Personal (mailbox for you only)"));
2160 wprintf("\n</UL>\n");
2162 wprintf("<CENTER>\n");
2163 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2165 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2166 wprintf("</CENTER>\n");
2167 wprintf("</FORM>\n<hr />");
2168 serv_printf("MESG roomaccess");
2169 serv_getln(buf, sizeof buf);
2170 if (buf[0] == '1') {
2173 wprintf("</td></tr></table></div>\n");
2181 * \brief support function for entroom() -- sets the default view
2183 void er_set_default_view(int newview) {
2196 serv_getln(buf, sizeof buf);
2197 if (buf[0] != '2') return;
2199 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2200 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2201 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2202 rm_bits1 = extract_int(&buf[4], 3);
2203 rm_floor = extract_int(&buf[4], 4);
2204 rm_listorder = extract_int(&buf[4], 5);
2205 rm_bits2 = extract_int(&buf[4], 7);
2207 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2208 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2209 rm_listorder, newview, rm_bits2
2211 serv_getln(buf, sizeof buf);
2217 * \brief enter a new room
2224 char er_password[SIZ];
2229 if (IsEmptyStr(bstr("ok_button"))) {
2230 strcpy(WC->ImportantMessage,
2231 _("Cancelled. No new room was created."));
2232 display_main_menu();
2235 strcpy(er_name, bstr("er_name"));
2236 strcpy(er_type, bstr("type"));
2237 strcpy(er_password, bstr("er_password"));
2238 er_floor = atoi(bstr("er_floor"));
2239 er_view = atoi(bstr("er_view"));
2242 if (!strcmp(er_type, "hidden"))
2244 if (!strcmp(er_type, "passworded"))
2246 if (!strcmp(er_type, "invonly"))
2248 if (!strcmp(er_type, "personal"))
2251 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2252 er_name, er_num_type, er_password, er_floor, 0, er_view);
2254 serv_getln(buf, sizeof buf);
2255 if (buf[0] != '2') {
2256 strcpy(WC->ImportantMessage, &buf[4]);
2257 display_main_menu();
2261 do_change_view(er_view); /* Now go there */
2266 * \brief display the screen to enter a private room
2268 void display_private(char *rname, int req_pass)
2270 output_headers(1, 1, 2, 0, 0, 0);
2271 wprintf("<div id=\"banner\">\n");
2273 wprintf(_("Go to a hidden room"));
2275 wprintf("</div>\n");
2277 wprintf("<div id=\"content\" class=\"service\">\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");
2365 wprintf(_("Zap (forget/unsubscribe) the current room"));
2367 wprintf("</div>\n");
2369 wprintf("<div id=\"content\" class=\"service\">\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");
3127 if (!strcasecmp(listviewpref, "rooms")) {
3128 wprintf(_("Room list"));
3130 if (!strcasecmp(listviewpref, "folders")) {
3131 wprintf(_("Folder list"));
3133 if (!strcasecmp(listviewpref, "table")) {
3134 wprintf(_("Room list"));
3138 /** offer the ability to switch views */
3139 wprintf("<form name=\"roomlistomatic\">\n"
3140 "<select name=\"newview\" size=\"1\" "
3141 "OnChange=\"location.href=roomlistomatic.newview.options"
3142 "[selectedIndex].value\">\n");
3144 wprintf("<option %s value=\"knrooms&view=rooms\">"
3147 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3150 wprintf("<option %s value=\"knrooms&view=folders\">"
3151 "View as folder list"
3153 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3156 wprintf("</select>");
3159 wprintf("</div>\n");
3161 wprintf("<div id=\"content\" class=\"service\">\n");
3163 /** Display the room list in the user's preferred format */
3164 list_all_rooms_by_floor(listviewpref);
3171 * \brief Set the message expire policy for this room and/or floor
3173 void set_room_policy(void) {
3176 if (IsEmptyStr(bstr("ok_button"))) {
3177 strcpy(WC->ImportantMessage,
3178 _("Cancelled. Changes were not saved."));
3183 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3184 serv_getln(buf, sizeof buf);
3185 strcpy(WC->ImportantMessage, &buf[4]);
3187 if (WC->axlevel >= 6) {
3188 strcat(WC->ImportantMessage, "<br />\n");
3189 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3190 serv_getln(buf, sizeof buf);
3191 strcat(WC->ImportantMessage, &buf[4]);