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, 1, 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=\"64px\" 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, 256, 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;
1034 char pop3_host[128];
1038 if (IsEmptyStr(tab)) tab = "admin";
1041 output_headers(1, 1, 1, 0, 0, 0);
1043 wprintf("<div class=\"fix_scrollbar_bug\">");
1045 /** print the tabbed dialog */
1046 wprintf("<ul class=\"tabbed_dialog\">\n");
1048 wprintf("<li class=\"tablabel ");
1049 if (!strcmp(tab, "admin")) {
1050 wprintf(" tab_cell_label\">");
1051 wprintf(_("Administration"));
1054 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1055 wprintf(_("Administration"));
1060 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1062 wprintf("<li class=\"tablabel ");
1063 if (!strcmp(tab, "config")) {
1064 wprintf(" tab_cell_label\">");
1065 wprintf(_("Configuration"));
1068 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1069 wprintf(_("Configuration"));
1074 wprintf("<li class=\"tablabel ");
1075 if (!strcmp(tab, "expire")) {
1076 wprintf(" tab_cell_label\">");
1077 wprintf(_("Message expire policy"));
1080 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1081 wprintf(_("Message expire policy"));
1086 wprintf("<li class=\"tablabel ");
1087 if (!strcmp(tab, "access")) {
1088 wprintf(" tab_cell_label\">");
1089 wprintf(_("Access controls"));
1092 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1093 wprintf(_("Access controls"));
1098 wprintf("<li class=\"tablabel ");
1099 if (!strcmp(tab, "sharing")) {
1100 wprintf(" tab_cell_label\">");
1101 wprintf(_("Sharing"));
1104 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1105 wprintf(_("Sharing"));
1110 wprintf("<li class=\"tablabel ");
1111 if (!strcmp(tab, "listserv")) {
1112 wprintf(" tab_cell_label\">");
1113 wprintf(_("Mailing list service"));
1116 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1117 wprintf(_("Mailing list service"));
1124 wprintf("<li class=\"tablabel ");
1125 if (!strcmp(tab, "feeds")) {
1126 wprintf(" tab_cell_label\">");
1127 wprintf(_("Remote retrieval"));
1130 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1131 wprintf(_("Remote retrieval"));
1137 /** end tabbed dialog */
1139 /** begin content of whatever tab is open now */
1141 if (!strcmp(tab, "admin")) {
1142 wprintf("<div class=\"tabcontent\">");
1144 "<li><a href=\"delete_room\" "
1145 "onClick=\"return confirm('");
1146 wprintf(_("Are you sure you want to delete this room?"));
1147 wprintf("');\">\n");
1148 wprintf(_("Delete this room"));
1150 "<li><a href=\"display_editroompic\">\n");
1151 wprintf(_("Set or change the icon for this room's banner"));
1153 "<li><a href=\"display_editinfo\">\n");
1154 wprintf(_("Edit this room's Info file"));
1160 if (!strcmp(tab, "config")) {
1161 wprintf("<div class=\"tabcontent\">");
1163 serv_getln(buf, sizeof buf);
1165 if (!strncmp(buf, "550", 3)) {
1166 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1167 _("Higher access is required to access this function.")
1170 else if (buf[0] != '2') {
1171 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1174 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1175 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1176 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1177 er_flags = extract_int(&buf[4], 3);
1178 er_floor = extract_int(&buf[4], 4);
1179 er_flags2 = extract_int(&buf[4], 7);
1181 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1182 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1184 wprintf("<ul><li>");
1185 wprintf(_("Name of room: "));
1186 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1192 wprintf(_("Resides on floor: "));
1193 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1194 if (er_flags & QR_MAILBOX)
1195 wprintf("disabled >\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 + QR_MAILBOX)) == 0)
1213 wprintf("CHECKED ");
1214 wprintf("OnChange=\""
1215 " if (this.form.type[0].checked == true) { "
1216 " this.form.er_floor.disabled = false; "
1219 wprintf(_("Public (automatically appears to everyone)"));
1222 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1223 if ((er_flags & QR_PRIVATE) &&
1224 (er_flags & QR_GUESSNAME))
1225 wprintf("CHECKED ");
1226 wprintf(" OnChange=\""
1227 " if (this.form.type[1].checked == true) { "
1228 " this.form.er_floor.disabled = false; "
1231 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1233 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1234 if ((er_flags & QR_PRIVATE) &&
1235 (er_flags & QR_PASSWORDED))
1236 wprintf("CHECKED ");
1237 wprintf(" OnChange=\""
1238 " if (this.form.type[2].checked == true) { "
1239 " this.form.er_floor.disabled = false; "
1242 wprintf(_("Private - require password: "));
1243 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1246 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1247 if ((er_flags & QR_PRIVATE)
1248 && ((er_flags & QR_GUESSNAME) == 0)
1249 && ((er_flags & QR_PASSWORDED) == 0))
1250 wprintf("CHECKED ");
1251 wprintf(" OnChange=\""
1252 " if (this.form.type[3].checked == true) { "
1253 " this.form.er_floor.disabled = false; "
1256 wprintf(_("Private - invitation only"));
1258 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1259 if (er_flags & QR_MAILBOX)
1260 wprintf("CHECKED ");
1261 wprintf (" OnChange=\""
1262 " if (this.form.type[4].checked == true) { "
1263 " this.form.er_floor.disabled = true; "
1266 wprintf(_("Personal (mailbox for you only)"));
1268 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1270 wprintf(_("If private, cause current users to forget room"));
1272 wprintf("\n</ul>\n");
1274 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1275 if (er_flags & QR_PREFONLY)
1276 wprintf("CHECKED ");
1278 wprintf(_("Preferred users only"));
1280 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1281 if (er_flags & QR_READONLY)
1282 wprintf("CHECKED ");
1284 wprintf(_("Read-only room"));
1286 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1287 if (er_flags2 & QR2_COLLABDEL)
1288 wprintf("CHECKED ");
1290 wprintf(_("All users allowed to post may also delete messages"));
1292 /** directory stuff */
1293 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1294 if (er_flags & QR_DIRECTORY)
1295 wprintf("CHECKED ");
1297 wprintf(_("File directory room"));
1299 wprintf("\n<ul><li>");
1300 wprintf(_("Directory name: "));
1301 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1304 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1305 if (er_flags & QR_UPLOAD)
1306 wprintf("CHECKED ");
1308 wprintf(_("Uploading allowed"));
1310 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1311 if (er_flags & QR_DOWNLOAD)
1312 wprintf("CHECKED ");
1314 wprintf(_("Downloading allowed"));
1316 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1317 if (er_flags & QR_VISDIR)
1318 wprintf("CHECKED ");
1320 wprintf(_("Visible directory"));
1323 /** end of directory stuff */
1325 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1326 if (er_flags & QR_NETWORK)
1327 wprintf("CHECKED ");
1329 wprintf(_("Network shared room"));
1331 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1332 if (er_flags & QR_PERMANENT)
1333 wprintf("CHECKED ");
1335 wprintf(_("Permanent (does not auto-purge)"));
1337 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1338 if (er_flags2 & QR2_SUBJECTREQ)
1339 wprintf("CHECKED ");
1341 wprintf(_("Subject Required (Force users to specify a message subject)"));
1343 /** start of anon options */
1346 wprintf(_("Anonymous messages"));
1349 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1350 if (((er_flags & QR_ANONONLY) == 0)
1351 && ((er_flags & QR_ANONOPT) == 0))
1352 wprintf("CHECKED ");
1354 wprintf(_("No anonymous messages"));
1356 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1357 if (er_flags & QR_ANONONLY)
1358 wprintf("CHECKED ");
1360 wprintf(_("All messages are anonymous"));
1362 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1363 if (er_flags & QR_ANONOPT)
1364 wprintf("CHECKED ");
1366 wprintf(_("Prompt user when entering messages"));
1369 /* end of anon options */
1372 wprintf(_("Room aide: "));
1374 serv_getln(buf, sizeof buf);
1375 if (buf[0] != '2') {
1376 wprintf("<em>%s</em>\n", &buf[4]);
1378 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1379 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1382 wprintf("</ul><CENTER>\n");
1383 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1384 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1386 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1396 /** Sharing the room with other Citadel nodes... */
1397 if (!strcmp(tab, "sharing")) {
1398 wprintf("<div class=\"tabcontent\">");
1400 shared_with = strdup("");
1401 not_shared_with = strdup("");
1403 /** Learn the current configuration */
1404 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1405 serv_getln(buf, sizeof buf);
1406 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1407 extract_token(node, buf, 0, '|', sizeof node);
1408 not_shared_with = realloc(not_shared_with,
1409 strlen(not_shared_with) + 32);
1410 strcat(not_shared_with, node);
1411 strcat(not_shared_with, "\n");
1415 serv_getln(buf, sizeof buf);
1416 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1417 extract_token(cmd, buf, 0, '|', sizeof cmd);
1418 extract_token(node, buf, 1, '|', sizeof node);
1419 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1420 if (!strcasecmp(cmd, "ignet_push_share")) {
1421 shared_with = realloc(shared_with,
1422 strlen(shared_with) + 32);
1423 strcat(shared_with, node);
1424 if (!IsEmptyStr(remote_room)) {
1425 strcat(shared_with, "|");
1426 strcat(shared_with, remote_room);
1428 strcat(shared_with, "\n");
1432 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1433 extract_token(buf, shared_with, i, '\n', sizeof buf);
1434 extract_token(node, buf, 0, '|', sizeof node);
1435 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1436 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1437 if (!strcasecmp(node, cmd)) {
1438 remove_token(not_shared_with, j, '\n');
1443 /** Display the stuff */
1444 wprintf("<CENTER><br />"
1445 "<table border=1 cellpadding=5><tr>"
1447 wprintf(_("Shared with"));
1448 wprintf("</I></B></td>"
1450 wprintf(_("Not shared with"));
1451 wprintf("</I></B></td></tr>\n"
1452 "<tr><td VALIGN=TOP>\n");
1454 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1455 wprintf(_("Remote node name"));
1456 wprintf("</td><td>");
1457 wprintf(_("Remote room name"));
1458 wprintf("</td><td>");
1459 wprintf(_("Actions"));
1460 wprintf("</td></tr>\n");
1462 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1463 extract_token(buf, shared_with, i, '\n', sizeof buf);
1464 extract_token(node, buf, 0, '|', sizeof node);
1465 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1466 if (!IsEmptyStr(node)) {
1467 wprintf("<form method=\"POST\" action=\"netedit\">");
1468 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1469 wprintf("<tr><td>%s</td>\n", node);
1472 if (!IsEmptyStr(remote_room)) {
1473 escputs(remote_room);
1479 wprintf("<input type=\"hidden\" NAME=\"line\" "
1480 "VALUE=\"ignet_push_share|");
1482 if (!IsEmptyStr(remote_room)) {
1484 urlescputs(remote_room);
1487 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1488 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1489 wprintf("<input type=\"submit\" "
1490 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1491 wprintf("</td></tr></form>\n");
1495 wprintf("</table>\n");
1496 wprintf("</td><td VALIGN=TOP>\n");
1497 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1498 wprintf(_("Remote node name"));
1499 wprintf("</td><td>");
1500 wprintf(_("Remote room name"));
1501 wprintf("</td><td>");
1502 wprintf(_("Actions"));
1503 wprintf("</td></tr>\n");
1505 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1506 extract_token(node, not_shared_with, i, '\n', sizeof node);
1507 if (!IsEmptyStr(node)) {
1508 wprintf("<form method=\"POST\" action=\"netedit\">");
1509 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1510 wprintf("<tr><td>");
1513 "<input type=\"INPUT\" "
1517 wprintf("<input type=\"hidden\" "
1519 "VALUE=\"ignet_push_share|");
1522 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1523 "VALUE=\"sharing\">\n");
1524 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1525 "VALUE=\"add\">\n");
1526 wprintf("<input type=\"submit\" "
1527 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1528 wprintf("</td></tr></form>\n");
1532 wprintf("</table>\n");
1533 wprintf("</td></tr>"
1534 "</table></CENTER><br />\n"
1535 "<I><B>%s</B><ul><li>", _("Notes:"));
1536 wprintf(_("When sharing a room, "
1537 "it must be shared from both ends. Adding a node to "
1538 "the 'shared' list sends messages out, but in order to"
1539 " receive messages, the other nodes must be configured"
1540 " to send messages out to your system as well. "
1541 "<li>If the remote room name is blank, it is assumed "
1542 "that the room name is identical on the remote node."
1543 "<li>If the remote room name is different, the remote "
1544 "node must also configure the name of the room here."
1551 /** Mailing list management */
1552 if (!strcmp(tab, "listserv")) {
1553 wprintf("<div class=\"tabcontent\">");
1555 wprintf("<br /><center>"
1556 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1557 "<tr><td VALIGN=TOP>");
1559 wprintf(_("<i>The contents of this room are being "
1560 "mailed <b>as individual messages</b> "
1561 "to the following list recipients:"
1562 "</i><br /><br />\n"));
1565 serv_getln(buf, sizeof buf);
1566 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1567 extract_token(cmd, buf, 0, '|', sizeof cmd);
1568 if (!strcasecmp(cmd, "listrecp")) {
1569 extract_token(recp, buf, 1, '|', sizeof recp);
1572 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1575 wprintf(_("(remove)"));
1576 wprintf("</A><br />");
1579 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1580 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1581 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1582 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1583 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1584 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1585 wprintf("</form>\n");
1587 wprintf("</td><td VALIGN=TOP>\n");
1589 wprintf(_("<i>The contents of this room are being "
1590 "mailed <b>in digest form</b> "
1591 "to the following list recipients:"
1592 "</i><br /><br />\n"));
1595 serv_getln(buf, sizeof buf);
1596 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1597 extract_token(cmd, buf, 0, '|', sizeof cmd);
1598 if (!strcasecmp(cmd, "digestrecp")) {
1599 extract_token(recp, buf, 1, '|', sizeof recp);
1602 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1606 wprintf(_("(remove)"));
1607 wprintf("</A><br />");
1610 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1611 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1612 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1613 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1614 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1615 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1616 wprintf("</form>\n");
1618 wprintf("</td></tr></table>\n");
1620 /** Pop open an address book -- begin **/
1621 wprintf("<div align=right>"
1622 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1624 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1629 _("Add recipients from Contacts or other address books"),
1630 _("Add recipients from Contacts or other address books")
1632 /** Pop open an address book -- end **/
1635 if (self_service(999) == 1) {
1636 wprintf(_("This room is configured to allow "
1637 "self-service subscribe/unsubscribe requests."));
1638 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1639 wprintf(_("Click to disable."));
1640 wprintf("</A><br />\n");
1641 wprintf(_("The URL for subscribe/unsubscribe is: "));
1642 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1643 (is_https ? "https" : "http"),
1647 wprintf(_("This room is <i>not</i> configured to allow "
1648 "self-service subscribe/unsubscribe requests."));
1649 wprintf(" <a href=\"toggle_self_service?newval=1&"
1651 wprintf(_("Click to enable."));
1652 wprintf("</A><br />\n");
1656 wprintf("</CENTER>\n");
1661 /** Configuration of The Dreaded Auto-Purger */
1662 if (!strcmp(tab, "expire")) {
1663 wprintf("<div class=\"tabcontent\">");
1665 serv_puts("GPEX room");
1666 serv_getln(buf, sizeof buf);
1667 if (!strncmp(buf, "550", 3)) {
1668 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1669 _("Higher access is required to access this function.")
1672 else if (buf[0] != '2') {
1673 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1676 roompolicy = extract_int(&buf[4], 0);
1677 roomvalue = extract_int(&buf[4], 1);
1679 serv_puts("GPEX floor");
1680 serv_getln(buf, sizeof buf);
1681 if (buf[0] == '2') {
1682 floorpolicy = extract_int(&buf[4], 0);
1683 floorvalue = extract_int(&buf[4], 1);
1686 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1687 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1688 wprintf("<table border=0 cellspacing=5>\n");
1689 wprintf("<tr><td>");
1690 wprintf(_("Message expire policy for this room"));
1692 escputs(WC->wc_roomname);
1693 wprintf(")</td><td>");
1694 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1695 ((roompolicy == 0) ? "CHECKED" : "") );
1696 wprintf(_("Use the default policy for this floor"));
1697 wprintf("<br />\n");
1698 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1699 ((roompolicy == 1) ? "CHECKED" : "") );
1700 wprintf(_("Never automatically expire messages"));
1701 wprintf("<br />\n");
1702 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1703 ((roompolicy == 2) ? "CHECKED" : "") );
1704 wprintf(_("Expire by message count"));
1705 wprintf("<br />\n");
1706 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1707 ((roompolicy == 3) ? "CHECKED" : "") );
1708 wprintf(_("Expire by message age"));
1710 wprintf(_("Number of messages or days: "));
1711 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1712 wprintf("</td></tr>\n");
1714 if (WC->axlevel >= 6) {
1715 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1716 wprintf("<tr><td>");
1717 wprintf(_("Message expire policy for this floor"));
1719 escputs(floorlist[WC->wc_floor]);
1720 wprintf(")</td><td>");
1721 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1722 ((floorpolicy == 0) ? "CHECKED" : "") );
1723 wprintf(_("Use the system default"));
1724 wprintf("<br />\n");
1725 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1726 ((floorpolicy == 1) ? "CHECKED" : "") );
1727 wprintf(_("Never automatically expire messages"));
1728 wprintf("<br />\n");
1729 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1730 ((floorpolicy == 2) ? "CHECKED" : "") );
1731 wprintf(_("Expire by message count"));
1732 wprintf("<br />\n");
1733 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1734 ((floorpolicy == 3) ? "CHECKED" : "") );
1735 wprintf(_("Expire by message age"));
1737 wprintf(_("Number of messages or days: "));
1738 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1742 wprintf("<CENTER>\n");
1743 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1744 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1746 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1747 wprintf("</CENTER></td><tr>\n");
1749 wprintf("</table>\n"
1750 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1758 /** Access controls */
1759 if (!strcmp(tab, "access")) {
1760 wprintf("<div class=\"tabcontent\">");
1765 /** Fetch messages from remote locations */
1766 if (!strcmp(tab, "feeds")) {
1767 wprintf("<div class=\"tabcontent\">");
1770 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1771 wprintf("</i><br /><br />\n");
1773 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1774 wprintf(_("Remote host"));
1775 wprintf("</td><td>");
1776 wprintf(_("User name"));
1777 wprintf("</td><td>");
1778 wprintf(_("Password"));
1779 wprintf("</td><td>");
1780 wprintf(_("Keep messages on server?"));
1781 wprintf("</td></tr>");
1784 serv_getln(buf, sizeof buf);
1785 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1786 extract_token(cmd, buf, 0, '|', sizeof cmd);
1787 if (!strcasecmp(cmd, "pop3client")) {
1788 safestrncpy(recp, &buf[11], sizeof recp);
1792 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1797 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1801 wprintf("<td>*****</td>"); /* Don't show the password */
1803 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1806 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1809 wprintf(_("(remove)"));
1810 wprintf("</A></td>");
1816 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1818 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"feeds\">"
1819 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"pop3client|\">\n");
1820 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1822 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1825 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1828 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1831 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1834 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1835 wprintf("</td></tr>");
1836 wprintf("</form></table>\n");
1842 /** end content of whatever tab is open now */
1843 wprintf("</div>\n");
1845 address_book_popup();
1851 * \brief Toggle self-service list subscription
1853 void toggle_self_service(void) {
1856 newval = atoi(bstr("newval"));
1857 self_service(newval);
1864 * \brief save new parameters for a room
1870 char er_password[10];
1871 char er_dirname[15];
1872 char er_roomaide[26];
1875 int er_listingorder;
1881 if (IsEmptyStr(bstr("ok_button"))) {
1882 strcpy(WC->ImportantMessage,
1883 _("Cancelled. Changes were not saved."));
1888 serv_getln(buf, sizeof buf);
1890 if (buf[0] != '2') {
1891 strcpy(WC->ImportantMessage, &buf[4]);
1895 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1896 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1897 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1898 er_flags = extract_int(&buf[4], 3);
1899 er_listingorder = extract_int(&buf[4], 5);
1900 er_defaultview = extract_int(&buf[4], 6);
1901 er_flags2 = extract_int(&buf[4], 7);
1903 strcpy(er_roomaide, bstr("er_roomaide"));
1904 if (IsEmptyStr(er_roomaide)) {
1906 serv_getln(buf, sizeof buf);
1907 if (buf[0] != '2') {
1908 strcpy(er_roomaide, "");
1910 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1913 strcpy(buf, bstr("er_name"));
1915 if (!IsEmptyStr(buf)) {
1916 strcpy(er_name, buf);
1919 strcpy(buf, bstr("er_password"));
1921 if (!IsEmptyStr(buf))
1922 strcpy(er_password, buf);
1924 strcpy(buf, bstr("er_dirname"));
1926 if (!IsEmptyStr(buf))
1927 strcpy(er_dirname, buf);
1929 strcpy(buf, bstr("type"));
1930 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1932 if (!strcmp(buf, "invonly")) {
1933 er_flags |= (QR_PRIVATE);
1935 if (!strcmp(buf, "hidden")) {
1936 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1938 if (!strcmp(buf, "passworded")) {
1939 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1941 if (!strcmp(buf, "personal")) {
1942 er_flags |= QR_MAILBOX;
1944 er_flags &= ~QR_MAILBOX;
1947 if (!strcmp(bstr("prefonly"), "yes")) {
1948 er_flags |= QR_PREFONLY;
1950 er_flags &= ~QR_PREFONLY;
1953 if (!strcmp(bstr("readonly"), "yes")) {
1954 er_flags |= QR_READONLY;
1956 er_flags &= ~QR_READONLY;
1960 if (!strcmp(bstr("collabdel"), "yes")) {
1961 er_flags2 |= QR2_COLLABDEL;
1963 er_flags2 &= ~QR2_COLLABDEL;
1966 if (!strcmp(bstr("permanent"), "yes")) {
1967 er_flags |= QR_PERMANENT;
1969 er_flags &= ~QR_PERMANENT;
1972 if (!strcmp(bstr("subjectreq"), "yes")) {
1973 er_flags2 |= QR2_SUBJECTREQ;
1975 er_flags2 &= ~QR2_SUBJECTREQ;
1978 if (!strcmp(bstr("network"), "yes")) {
1979 er_flags |= QR_NETWORK;
1981 er_flags &= ~QR_NETWORK;
1984 if (!strcmp(bstr("directory"), "yes")) {
1985 er_flags |= QR_DIRECTORY;
1987 er_flags &= ~QR_DIRECTORY;
1990 if (!strcmp(bstr("ulallowed"), "yes")) {
1991 er_flags |= QR_UPLOAD;
1993 er_flags &= ~QR_UPLOAD;
1996 if (!strcmp(bstr("dlallowed"), "yes")) {
1997 er_flags |= QR_DOWNLOAD;
1999 er_flags &= ~QR_DOWNLOAD;
2002 if (!strcmp(bstr("visdir"), "yes")) {
2003 er_flags |= QR_VISDIR;
2005 er_flags &= ~QR_VISDIR;
2008 strcpy(buf, bstr("anon"));
2010 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2011 if (!strcmp(buf, "anononly"))
2012 er_flags |= QR_ANONONLY;
2013 if (!strcmp(buf, "anon2"))
2014 er_flags |= QR_ANONOPT;
2017 if (!strcmp(bstr("bump"), "yes"))
2020 er_floor = atoi(bstr("er_floor"));
2022 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2023 er_name, er_password, er_dirname, er_flags, bump, er_floor,
2024 er_listingorder, er_defaultview, er_flags2);
2026 serv_getln(buf, sizeof buf);
2027 if (buf[0] != '2') {
2028 strcpy(WC->ImportantMessage, &buf[4]);
2034 if (!IsEmptyStr(er_roomaide)) {
2035 sprintf(buf, "SETA %s", er_roomaide);
2037 serv_getln(buf, sizeof buf);
2038 if (buf[0] != '2') {
2039 strcpy(WC->ImportantMessage, &buf[4]);
2040 display_main_menu();
2045 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2052 * \brief Display form for Invite, Kick, and show Who Knows a room
2054 void do_invt_kick(void) {
2055 char buf[SIZ], room[SIZ], username[SIZ];
2058 serv_getln(buf, sizeof buf);
2060 if (buf[0] != '2') {
2064 extract_token(room, &buf[4], 0, '|', sizeof room);
2066 strcpy(username, bstr("username"));
2068 if (!IsEmptyStr(bstr("kick_button"))) {
2069 sprintf(buf, "KICK %s", username);
2071 serv_getln(buf, sizeof buf);
2073 if (buf[0] != '2') {
2074 strcpy(WC->ImportantMessage, &buf[4]);
2076 sprintf(WC->ImportantMessage,
2077 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2082 if (!IsEmptyStr(bstr("invite_button"))) {
2083 sprintf(buf, "INVT %s", username);
2085 serv_getln(buf, sizeof buf);
2087 if (buf[0] != '2') {
2088 strcpy(WC->ImportantMessage, &buf[4]);
2090 sprintf(WC->ImportantMessage,
2091 _("<B><I>User %s invited to room %s.</I></B>\n"),
2102 * \brief Display form for Invite, Kick, and show Who Knows a room
2104 void display_whok(void)
2106 char buf[SIZ], room[SIZ], username[SIZ];
2109 serv_getln(buf, sizeof buf);
2111 if (buf[0] != '2') {
2115 extract_token(room, &buf[4], 0, '|', sizeof room);
2118 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2119 wprintf(_("The users listed below have access to this room. "
2120 "To remove a user from the access list, select the user "
2121 "name from the list and click 'Kick'."));
2122 wprintf("<br /><br />");
2124 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2125 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2126 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2127 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2129 serv_getln(buf, sizeof buf);
2130 if (buf[0] == '1') {
2131 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2132 extract_token(username, buf, 0, '|', sizeof username);
2133 wprintf("<OPTION>");
2138 wprintf("</select><br />\n");
2140 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2141 wprintf("</form></CENTER>\n");
2143 wprintf("</td><td>");
2144 wprintf(_("To grant another user access to this room, enter the "
2145 "user name in the box below and click 'Invite'."));
2146 wprintf("<br /><br />");
2148 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2149 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2150 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2151 wprintf(_("Invite:"));
2153 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2154 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2155 "<input type=\"submit\" value=\"%s\">"
2156 "</form></CENTER>\n", _("Invite"));
2157 /** Pop open an address book -- begin **/
2159 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2161 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2164 _("Users"), _("Users")
2166 /** Pop open an address book -- end **/
2168 wprintf("</td></tr></table>\n");
2169 address_book_popup();
2176 * \brief display the form for entering a new room
2178 void display_entroom(void)
2183 serv_puts("CRE8 0");
2184 serv_getln(buf, sizeof buf);
2186 if (buf[0] != '2') {
2187 strcpy(WC->ImportantMessage, &buf[4]);
2188 display_main_menu();
2192 output_headers(1, 1, 1, 0, 0, 0);
2194 svprintf("BOXTITLE", WCS_STRING, _("Create a new room"));
2195 do_template("beginbox");
2197 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2198 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2200 wprintf("<table class=\"altern\"> ");
2202 wprintf("<tr class=\"even\"><td>");
2203 wprintf(_("Name of room: "));
2204 wprintf("</td><td>");
2205 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2206 wprintf("</td></tr>");
2208 wprintf("<tr class=\"odd\"><td>");
2209 wprintf(_("Resides on floor: "));
2210 wprintf("</td><td>");
2212 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2213 for (i = 0; i < 128; ++i)
2214 if (!IsEmptyStr(floorlist[i])) {
2215 wprintf("<option ");
2216 wprintf("value=\"%d\">", i);
2217 escputs(floorlist[i]);
2218 wprintf("</option>\n");
2220 wprintf("</select>\n");
2221 wprintf("</td></tr>");
2224 * Our clever little snippet of JavaScript automatically selects
2225 * a public room if the view is set to Bulletin Board or wiki, and
2226 * it selects a mailbox room otherwise. The user can override this,
2227 * of course. We also disable the floor selector for mailboxes.
2229 wprintf("<tr class=\"even\"><td>");
2230 wprintf(_("Default view for room: "));
2231 wprintf("</td><td>");
2232 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2233 " if ( (this.form.er_view.value == 0) "
2234 " || (this.form.er_view.value == 6) ) { "
2235 " this.form.type[0].checked=true; "
2236 " this.form.er_floor.disabled = false; "
2239 " this.form.type[4].checked=true; "
2240 " this.form.er_floor.disabled = true; "
2243 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2244 if (is_view_allowed_as_default(i)) {
2245 wprintf("<option %s value=\"%d\">",
2246 ((i == 0) ? "selected" : ""), i );
2247 escputs(viewdefs[i]);
2248 wprintf("</option>\n");
2251 wprintf("</select>\n");
2252 wprintf("</td></tr>");
2254 wprintf("<tr class=\"even\"><td>");
2255 wprintf(_("Type of room:"));
2256 wprintf("</td><td>");
2257 wprintf("<ul class=\"adminlist\">\n");
2259 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2260 wprintf("CHECKED OnChange=\""
2261 " if (this.form.type[0].checked == true) { "
2262 " this.form.er_floor.disabled = false; "
2265 wprintf(_("Public (automatically appears to everyone)"));
2268 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2269 " if (this.form.type[1].checked == true) { "
2270 " this.form.er_floor.disabled = false; "
2273 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2276 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2277 " if (this.form.type[2].checked == true) { "
2278 " this.form.er_floor.disabled = false; "
2281 wprintf(_("Private - require password: "));
2282 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2285 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2286 " if (this.form.type[3].checked == true) { "
2287 " this.form.er_floor.disabled = false; "
2290 wprintf(_("Private - invitation only"));
2293 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2295 " if (this.form.type[4].checked == true) { "
2296 " this.form.er_floor.disabled = true; "
2299 wprintf(_("Personal (mailbox for you only)"));
2302 wprintf("\n</ul>\n");
2303 wprintf("</td></tr></table>\n");
2305 wprintf("<div class=\"buttons\">\n");
2306 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2308 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2309 wprintf("</div>\n");
2310 wprintf("</form>\n<hr />");
2311 serv_printf("MESG roomaccess");
2312 serv_getln(buf, sizeof buf);
2313 if (buf[0] == '1') {
2317 do_template("endbox");
2326 * \brief support function for entroom() -- sets the default view
2328 void er_set_default_view(int newview) {
2341 serv_getln(buf, sizeof buf);
2342 if (buf[0] != '2') return;
2344 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2345 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2346 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2347 rm_bits1 = extract_int(&buf[4], 3);
2348 rm_floor = extract_int(&buf[4], 4);
2349 rm_listorder = extract_int(&buf[4], 5);
2350 rm_bits2 = extract_int(&buf[4], 7);
2352 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2353 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2354 rm_listorder, newview, rm_bits2
2356 serv_getln(buf, sizeof buf);
2362 * \brief enter a new room
2369 char er_password[SIZ];
2374 if (IsEmptyStr(bstr("ok_button"))) {
2375 strcpy(WC->ImportantMessage,
2376 _("Cancelled. No new room was created."));
2377 display_main_menu();
2380 strcpy(er_name, bstr("er_name"));
2381 strcpy(er_type, bstr("type"));
2382 strcpy(er_password, bstr("er_password"));
2383 er_floor = atoi(bstr("er_floor"));
2384 er_view = atoi(bstr("er_view"));
2387 if (!strcmp(er_type, "hidden"))
2389 if (!strcmp(er_type, "passworded"))
2391 if (!strcmp(er_type, "invonly"))
2393 if (!strcmp(er_type, "personal"))
2396 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2397 er_name, er_num_type, er_password, er_floor, 0, er_view);
2399 serv_getln(buf, sizeof buf);
2400 if (buf[0] != '2') {
2401 strcpy(WC->ImportantMessage, &buf[4]);
2402 display_main_menu();
2406 do_change_view(er_view); /* Now go there */
2411 * \brief display the screen to enter a private room
2413 void display_private(char *rname, int req_pass)
2415 output_headers(1, 1, 1, 0, 0, 0);
2417 svprintf("BOXTITLE", WCS_STRING, _("Go to a hidden room"));
2418 do_template("beginbox");
2421 wprintf(_("If you know the name of a hidden (guess-name) or "
2422 "passworded room, you can enter that room by typing "
2423 "its name below. Once you gain access to a private "
2424 "room, it will appear in your regular room listings "
2425 "so you don't have to keep returning here."));
2428 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2429 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2431 wprintf("<table class=\"altern\"> "
2432 "<tr class=\"even\"><td>");
2433 wprintf(_("Enter room name:"));
2435 "<input type=\"text\" name=\"gr_name\" "
2436 "value=\"%s\" maxlength=\"128\">\n", rname);
2439 wprintf("</td></tr><tr class=\"odd\"><td>");
2440 wprintf(_("Enter room password:"));
2441 wprintf("</td><td>");
2442 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2444 wprintf("</td></tr></table>\n");
2446 wprintf("<div class=\"buttons\">\n");
2447 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2449 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2453 wprintf("</div></form>\n");
2455 do_template("endbox");
2461 * \brief goto a private room
2463 void goto_private(void)
2468 if (IsEmptyStr(bstr("ok_button"))) {
2469 display_main_menu();
2472 strcpy(hold_rm, WC->wc_roomname);
2473 strcpy(buf, "GOTO ");
2474 strcat(buf, bstr("gr_name"));
2476 strcat(buf, bstr("gr_pass"));
2478 serv_getln(buf, sizeof buf);
2480 if (buf[0] == '2') {
2481 smart_goto(bstr("gr_name"));
2484 if (!strncmp(buf, "540", 3)) {
2485 display_private(bstr("gr_name"), 1);
2488 output_headers(1, 1, 1, 0, 0, 0);
2489 wprintf("%s\n", &buf[4]);
2496 * \brief display the screen to zap a room
2498 void display_zap(void)
2500 output_headers(1, 1, 2, 0, 0, 0);
2502 wprintf("<div id=\"banner\">\n");
2504 wprintf(_("Zap (forget/unsubscribe) the current room"));
2506 wprintf("</div>\n");
2508 wprintf("<div id=\"content\" class=\"service\">\n");
2510 wprintf(_("If you select this option, <em>%s</em> will "
2511 "disappear from your room list. Is this what you wish "
2512 "to do?<br />\n"), WC->wc_roomname);
2514 wprintf("<form method=\"POST\" action=\"zap\">\n");
2515 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2516 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2518 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2519 wprintf("</form>\n");
2530 char final_destination[SIZ];
2533 * If the forget-room routine fails for any reason, we fall back
2534 * to the current room; otherwise, we go to the Lobby
2536 strcpy(final_destination, WC->wc_roomname);
2538 if (!IsEmptyStr(bstr("ok_button"))) {
2539 serv_printf("GOTO %s", WC->wc_roomname);
2540 serv_getln(buf, sizeof buf);
2541 if (buf[0] == '2') {
2543 serv_getln(buf, sizeof buf);
2544 if (buf[0] == '2') {
2545 strcpy(final_destination, "_BASEROOM_");
2549 smart_goto(final_destination);
2555 * \brief Delete the current room
2557 void delete_room(void)
2561 serv_puts("KILL 1");
2562 serv_getln(buf, sizeof buf);
2563 if (buf[0] != '2') {
2564 strcpy(WC->ImportantMessage, &buf[4]);
2565 display_main_menu();
2568 smart_goto("_BASEROOM_");
2575 * \brief Perform changes to a room's network configuration
2577 void netedit(void) {
2587 if (!IsEmptyStr(bstr("line_pop3host"))) {
2588 strcpy(line, bstr("prefix"));
2589 strcat(line, bstr("line_pop3host"));
2591 strcat(line, bstr("line_pop3user"));
2593 strcat(line, bstr("line_pop3pass"));
2595 strcat(line, atoi(bstr("line_pop3keep")) ? "1" : "0" );
2596 strcat(line, bstr("suffix"));
2598 else if (!IsEmptyStr(bstr("line"))) {
2599 strcpy(line, bstr("prefix"));
2600 strcat(line, bstr("line"));
2601 strcat(line, bstr("suffix"));
2616 serv_getln(buf, sizeof buf);
2617 if (buf[0] != '1') {
2623 /** This loop works for add *or* remove. Spiffy, eh? */
2624 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2625 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2626 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2627 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2628 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2629 if ( (strcasecmp(cmpa0, cmpb0))
2630 || (strcasecmp(cmpa1, cmpb1)) ) {
2631 fprintf(fp, "%s\n", buf);
2637 serv_getln(buf, sizeof buf);
2638 if (buf[0] != '4') {
2644 while (fgets(buf, sizeof buf, fp) != NULL) {
2645 buf[strlen(buf)-1] = 0;
2649 if (!IsEmptyStr(bstr("add_button"))) {
2650 num_addrs = num_tokens(bstr("line"), ',');
2651 if (num_addrs < 2) {
2652 /* just adding one node or address */
2656 /* adding multiple addresses separated by commas */
2657 for (i=0; i<num_addrs; ++i) {
2658 strcpy(line, bstr("prefix"));
2659 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2662 strcat(line, bstr("suffix"));
2676 * \brief Convert a room name to a folder-ish-looking name.
2677 * \param folder the folderish name
2678 * \param room the room name
2679 * \param floor the floor name
2680 * \param is_mailbox is it a mailbox?
2682 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2687 * For mailboxes, just do it straight...
2690 sprintf(folder, "My folders|%s", room);
2694 * Otherwise, prefix the floor name as a "public folders" moniker
2697 sprintf(folder, "%s|%s", floorlist[floor], room);
2701 * Replace "\" characters with "|" for pseudo-folder-delimiting
2703 len = strlen (folder);
2704 for (i=0; i<len; ++i) {
2705 if (folder[i] == '\\') folder[i] = '|';
2713 * \brief Back end for change_view()
2714 * \param newview set newview???
2716 void do_change_view(int newview) {
2719 serv_printf("VIEW %d", newview);
2720 serv_getln(buf, sizeof buf);
2721 WC->wc_view = newview;
2722 smart_goto(WC->wc_roomname);
2728 * \brief Change the view for this room
2730 void change_view(void) {
2733 view = atol(bstr("view"));
2734 do_change_view(view);
2739 * \brief One big expanded tree list view --- like a folder list
2740 * \param fold the folder to view
2741 * \param max_folders how many folders???
2742 * \param num_floors hom many floors???
2744 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2748 int has_subfolders = 0;
2751 parents = malloc(max_folders * sizeof(int));
2753 /** BEGIN TREE MENU */
2754 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2756 /** include NanoTree */
2757 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2759 /** initialize NanoTree */
2760 wprintf("<script type=\"text/javascript\"> \n"
2761 " showRootNode = false; \n"
2762 " sortNodes = false; \n"
2763 " dragable = false; \n"
2765 " function standardClick(treeNode) { \n"
2768 " var closedGif = 'static/folder_closed.gif'; \n"
2769 " var openGif = 'static/folder_open.gif'; \n"
2771 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2775 for (i=0; i<max_folders; ++i) {
2778 if ((i+1) < max_folders) {
2780 len = strlen(fold[i].name);
2781 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2782 && (fold[i+1].name[len] == '|') ) {
2787 levels = num_tokens(fold[i].name, '|');
2788 parents[levels] = i;
2790 wprintf("var node%d = new TreeNode(%d, '", i, i);
2792 if (fold[i].selectable) {
2793 wprintf("<a href=\"dotgoto?room=");
2794 urlescputs(fold[i].room);
2799 wprintf("<span class=\"roomlist_floor\">");
2801 else if (fold[i].hasnewmsgs) {
2802 wprintf("<span class=\"roomlist_new\">");
2805 wprintf("<span class=\"roomlist_old\">");
2807 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2812 if (has_subfolders) {
2813 wprintf("new Array(closedGif, openGif)");
2815 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2816 wprintf("'static/viewcontacts_16x.gif'");
2818 else if (fold[i].view == VIEW_CALENDAR) {
2819 wprintf("'static/calarea_16x.gif'");
2821 else if (fold[i].view == VIEW_CALBRIEF) {
2822 wprintf("'static/calarea_16x.gif'");
2824 else if (fold[i].view == VIEW_TASKS) {
2825 wprintf("'static/taskmanag_16x.gif'");
2827 else if (fold[i].view == VIEW_NOTES) {
2828 wprintf("'static/storenotes_16x.gif'");
2830 else if (fold[i].view == VIEW_MAILBOX) {
2831 wprintf("'static/privatemess_16x.gif'");
2834 wprintf("'static/chatrooms_16x.gif'");
2837 urlescputs(fold[i].name);
2841 wprintf("rootNode.addChild(node%d);\n", i);
2844 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2848 wprintf("container = document.getElementById('roomlist_div'); \n"
2854 /** END TREE MENU */
2858 * \brief Boxes and rooms and lists ... oh my!
2859 * \param fold the folder to view
2860 * \param max_folders how many folders???
2861 * \param num_floors hom many floors???
2863 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2865 char floor_name[256];
2866 char old_floor_name[256];
2868 int levels, oldlevels;
2871 static int columns = 3;
2872 int boxes_per_column = 0;
2873 int current_column = 0;
2876 strcpy(floor_name, "");
2877 strcpy(old_floor_name, "");
2880 while (nf % columns != 0) ++nf;
2881 boxes_per_column = (nf / columns);
2882 if (boxes_per_column < 1) boxes_per_column = 1;
2884 /** Outer table (for columnization) */
2885 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
2886 "<tr><td valign=top>");
2890 for (i=0; i<max_folders; ++i) {
2892 levels = num_tokens(fold[i].name, '|');
2893 extract_token(floor_name, fold[i].name, 0,
2894 '|', sizeof floor_name);
2896 if ( (strcasecmp(floor_name, old_floor_name))
2897 && (!IsEmptyStr(old_floor_name)) ) {
2899 do_template("endbox");
2903 if ((num_boxes % boxes_per_column) == 0) {
2905 if (current_column < columns) {
2906 wprintf("</td><td valign=top>\n");
2910 strcpy(old_floor_name, floor_name);
2913 /** Begin inner box */
2914 stresc(boxtitle, 256, floor_name, 1, 0);
2915 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2916 do_template("beginbox");
2923 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2924 if (fold[i].selectable) {
2925 wprintf("<a href=\"dotgoto?room=");
2926 urlescputs(fold[i].room);
2932 if (fold[i].hasnewmsgs) {
2933 wprintf("<span class=\"roomlist_new\">");
2936 wprintf("<span class=\"roomlist_old\">");
2938 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2941 if (fold[i].selectable) {
2947 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2948 wprintf(" (INBOX)");
2950 wprintf("<br />\n");
2953 /** End the final inner box */
2954 do_template("endbox");
2956 wprintf("</td></tr></table>\n");
2960 * \brief print a floor div???
2961 * \param which_floordiv name of the floordiv???
2963 void set_floordiv_expanded(char *which_floordiv) {
2964 begin_ajax_response();
2965 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2966 end_ajax_response();
2970 * \brief view the iconbar
2971 * \param fold the folder to view
2972 * \param max_folders how many folders???
2973 * \param num_floors hom many floors???
2975 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2977 char floor_name[256];
2978 char old_floor_name[256];
2979 char floordivtitle[256];
2980 char floordiv_id[32];
2981 int levels, oldlevels;
2983 int num_drop_targets = 0;
2986 strcpy(floor_name, "");
2987 strcpy(old_floor_name, "");
2991 for (i=0; i<max_folders; ++i) {
2993 levels = num_tokens(fold[i].name, '|');
2994 extract_token(floor_name, fold[i].name, 0,
2995 '|', sizeof floor_name);
2997 if ( (strcasecmp(floor_name, old_floor_name))
2998 && (!IsEmptyStr(old_floor_name)) ) {
2999 /** End inner box */
3001 wprintf("</div>\n"); /** floordiv */
3003 strcpy(old_floor_name, floor_name);
3007 stresc(floordivtitle, 256, floor_name, 0, 0);
3008 sprintf(floordiv_id, "floordiv%d", i);
3009 wprintf("<span class=\"ib_roomlist_floor\" "
3010 "onClick=\"expand_floor('%s')\">"
3011 "%s</span><br>\n", floordiv_id, floordivtitle);
3012 wprintf("<div id=\"%s\" style=\"display:%s\">",
3014 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
3021 wprintf("<div id=\"roomdiv%d\">", i);
3023 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3025 /** choose the icon */
3026 if (fold[i].view == VIEW_ADDRESSBOOK) {
3027 icon = "viewcontacts_16x.gif" ;
3029 else if (fold[i].view == VIEW_CALENDAR) {
3030 icon = "calarea_16x.gif" ;
3032 else if (fold[i].view == VIEW_CALBRIEF) {
3033 icon = "calarea_16x.gif" ;
3035 else if (fold[i].view == VIEW_TASKS) {
3036 icon = "taskmanag_16x.gif" ;
3038 else if (fold[i].view == VIEW_NOTES) {
3039 icon = "storenotes_16x.gif" ;
3041 else if (fold[i].view == VIEW_MAILBOX) {
3042 icon = "privatemess_16x.gif" ;
3045 icon = "chatrooms_16x.gif" ;
3048 if (fold[i].selectable) {
3049 wprintf("<a href=\"dotgoto?room=");
3050 urlescputs(fold[i].room);
3052 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
3057 if (fold[i].hasnewmsgs) {
3058 wprintf("<span class=\"ib_roomlist_new\">");
3061 wprintf("<span class=\"ib_roomlist_old\">");
3063 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3065 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3066 wprintf(" (INBOX)");
3069 if (fold[i].selectable) {
3076 wprintf("</div>\n"); /** roomdiv */
3079 wprintf("</div>\n"); /** floordiv */
3082 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3083 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3085 num_drop_targets = 0;
3087 for (i=0; i<max_folders; ++i) {
3088 levels = num_tokens(fold[i].name, '|');
3090 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3091 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3092 jsescputs(fold[i].room);
3098 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3099 if ((WC->floordiv_expanded[0] != '\0')&&
3100 (WC->floordiv_expanded[1] != '\0')){
3101 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
3105 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3111 * \brief Show the room list.
3112 * (only should get called by
3113 * knrooms() because that's where output_headers() is called from)
3114 * \param viewpref the view preferences???
3117 void list_all_rooms_by_floor(char *viewpref) {
3120 struct folder *fold = NULL;
3122 int max_folders = 0;
3123 int alloc_folders = 0;
3129 int num_floors = 1; /** add an extra one for private folders */
3133 /** If our cached folder list is very old, burn it. */
3134 if (WC->cache_fold != NULL) {
3135 if ((time(NULL) - WC->cache_timestamp) > 300) {
3136 free(WC->cache_fold);
3137 WC->cache_fold = NULL;
3141 /** Can we do the iconbar roomlist from cache? */
3142 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3143 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3147 /** Grab the floor table so we know how to build the list... */
3150 /** Start with the mailboxes */
3153 fold = malloc(sizeof(struct folder));
3154 memset(fold, 0, sizeof(struct folder));
3155 strcpy(fold[0].name, "My folders");
3156 fold[0].is_mailbox = 1;
3158 /** Then add floors */
3160 serv_getln(buf, sizeof buf);
3161 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3162 if (max_folders >= alloc_folders) {
3163 alloc_folders = max_folders + 100;
3164 fold = realloc(fold,
3165 alloc_folders * sizeof(struct folder));
3167 memset(&fold[max_folders], 0, sizeof(struct folder));
3168 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3169 extract_token(buf3, buf, 0, '|', SIZ);
3170 fold[max_folders].floor = atol (buf3);
3175 for (i=0; i<num_floors; i++)
3176 if (IDMax < fold[i].floor)
3177 IDMax = fold[i].floor;
3178 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3179 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3180 for (i=0; i<num_floors; i++)
3181 floor_mapping[fold[i].floor]=i;
3183 /** refresh the messages index for this room */
3184 // serv_puts("GOTO ");
3185 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3186 /** Now add rooms */
3188 serv_getln(buf, sizeof buf);
3189 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3190 if (max_folders >= alloc_folders) {
3191 alloc_folders = max_folders + 100;
3192 fold = realloc(fold,
3193 alloc_folders * sizeof(struct folder));
3195 memset(&fold[max_folders], 0, sizeof(struct folder));
3196 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3197 ra_flags = extract_int(buf, 5);
3198 flags = extract_int(buf, 1);
3199 fold[max_folders].floor = extract_int(buf, 2);
3200 fold[max_folders].hasnewmsgs =
3201 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3202 if (flags & QR_MAILBOX) {
3203 fold[max_folders].is_mailbox = 1;
3205 fold[max_folders].view = extract_int(buf, 6);
3206 room_to_folder(fold[max_folders].name,
3207 fold[max_folders].room,
3208 fold[max_folders].floor,
3209 fold[max_folders].is_mailbox);
3210 fold[max_folders].selectable = 1;
3211 /* Increase the room count for the associtaed floor */
3212 if (fold[max_folders].is_mailbox) {
3213 fold[0].num_rooms++;
3216 i = floor_mapping[fold[max_folders].floor];
3217 fold[i].num_rooms++;
3223 * Remove any floors that don't have rooms
3225 get_preference("emptyfloors", buf2, sizeof buf2);
3226 if (buf2[0]==0 || (strcasecmp(buf2, "no") == 0))
3228 for (i=0; i<num_floors; i++)
3230 if (fold[i].num_rooms == 0) {
3231 for (j=i; j<max_folders; j++) {
3232 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3241 /** Bubble-sort the folder list */
3242 for (i=0; i<max_folders; ++i) {
3243 for (j=0; j<(max_folders-1)-i; ++j) {
3244 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3245 swap = strcasecmp(fold[j].name, fold[j+1].name);
3248 if ( (fold[j+1].is_mailbox)
3249 && (!fold[j].is_mailbox)) {
3257 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3258 memcpy(&fold[j], &fold[j+1],
3259 sizeof(struct folder));
3260 memcpy(&fold[j+1], &ftmp,
3261 sizeof(struct folder));
3267 if (!strcasecmp(viewpref, "folders")) {
3268 do_folder_view(fold, max_folders, num_floors);
3270 else if (!strcasecmp(viewpref, "hackish_view")) {
3271 for (i=0; i<max_folders; ++i) {
3272 escputs(fold[i].name);
3273 wprintf("<br />\n");
3276 else if (!strcasecmp(viewpref, "iconbar")) {
3277 do_iconbar_view(fold, max_folders, num_floors);
3280 do_rooms_view(fold, max_folders, num_floors);
3283 /* Don't free the folder list ... cache it for future use! */
3284 if (WC->cache_fold != NULL) {
3285 free(WC->cache_fold);
3287 WC->cache_fold = fold;
3288 WC->cache_max_folders = max_folders;
3289 WC->cache_num_floors = num_floors;
3290 WC->cache_timestamp = time(NULL);
3291 free(floor_mapping);
3296 * \brief Do either a known rooms list or a folders list, depending on the
3301 char listviewpref[SIZ];
3303 output_headers(1, 1, 2, 0, 0, 0);
3305 /** Determine whether the user is trying to change views */
3306 if (bstr("view") != NULL) {
3307 if (!IsEmptyStr(bstr("view"))) {
3308 set_preference("roomlistview", bstr("view"), 1);
3312 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3314 if ( (strcasecmp(listviewpref, "folders"))
3315 && (strcasecmp(listviewpref, "table")) ) {
3316 strcpy(listviewpref, "rooms");
3320 wprintf("<div id=\"banner\">\n");
3321 wprintf("<div class=\"room_banner\">");
3323 if (!strcasecmp(listviewpref, "rooms")) {
3324 wprintf(_("Room list"));
3326 if (!strcasecmp(listviewpref, "folders")) {
3327 wprintf(_("Folder list"));
3329 if (!strcasecmp(listviewpref, "table")) {
3330 wprintf(_("Room list"));
3332 wprintf("</h1></div>\n");
3334 /** offer the ability to switch views */
3335 wprintf("<ul class=\"room_actions\">\n");
3336 wprintf("<li class=\"start_page\">");
3339 wprintf("<li><form name=\"roomlistomatic\">\n"
3340 "<select name=\"newview\" size=\"1\" "
3341 "OnChange=\"location.href=roomlistomatic.newview.options"
3342 "[selectedIndex].value\">\n");
3344 wprintf("<option %s value=\"knrooms&view=rooms\">"
3347 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3350 wprintf("<option %s value=\"knrooms&view=folders\">"
3351 "View as folder list"
3353 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3356 wprintf("</select>");
3357 wprintf("</form></li>");
3358 wprintf("</ul></div>\n");
3360 wprintf("<div id=\"content\" class=\"service\">\n");
3362 /** Display the room list in the user's preferred format */
3363 list_all_rooms_by_floor(listviewpref);
3370 * \brief Set the message expire policy for this room and/or floor
3372 void set_room_policy(void) {
3375 if (IsEmptyStr(bstr("ok_button"))) {
3376 strcpy(WC->ImportantMessage,
3377 _("Cancelled. Changes were not saved."));
3382 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3383 serv_getln(buf, sizeof buf);
3384 strcpy(WC->ImportantMessage, &buf[4]);
3386 if (WC->axlevel >= 6) {
3387 strcat(WC->ImportantMessage, "<br />\n");
3388 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3389 serv_getln(buf, sizeof buf);
3390 strcat(WC->ImportantMessage, &buf[4]);