3 * Lots of different room-related operations.
9 char floorlist[MAX_FLOORS][SIZ]; /**< list of our floor names */
11 char *viewdefs[9]; /**< the different kinds of available views */
14 * Initialize the viewdefs with localized strings
16 void initialize_viewdefs(void) {
17 viewdefs[0] = _("Bulletin Board");
18 viewdefs[1] = _("Mail Folder");
19 viewdefs[2] = _("Address Book");
20 viewdefs[3] = _("Calendar");
21 viewdefs[4] = _("Task List");
22 viewdefs[5] = _("Notes List");
23 viewdefs[6] = _("Wiki");
24 viewdefs[7] = _("Calendar List");
25 viewdefs[8] = _("Journal");
29 * Determine which views are allowed as the default for creating a new room.
31 int is_view_allowed_as_default(int which_view)
34 case VIEW_BBS: return(1);
35 case VIEW_MAILBOX: return(1);
36 case VIEW_ADDRESSBOOK: return(1);
37 case VIEW_CALENDAR: return(1);
38 case VIEW_TASKS: return(1);
39 case VIEW_NOTES: return(1);
42 case VIEW_WIKI: return(1);
43 #else /* TECH_PREVIEW */
44 case VIEW_WIKI: return(0); /* because it isn't finished yet */
45 #endif /* TECH_PREVIEW */
47 case VIEW_CALBRIEF: return(0);
48 case VIEW_JOURNAL: return(0);
49 default: return(0); /* should never get here */
55 * load the list of floors
57 void load_floorlist(void)
62 for (a = 0; a < MAX_FLOORS; ++a)
66 serv_getln(buf, sizeof buf);
68 strcpy(floorlist[0], "Main Floor");
71 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
72 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
78 * Free a session's march list
80 void free_march_list(struct wcsession *wcf)
84 while (wcf->march != NULL) {
85 mptr = wcf->march->next;
95 * 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 * display rooms in tree structure
128 void room_tree_list(struct roomlisting *rp)
137 room_tree_list(rp->lnext);
139 strcpy(rmname, rp->rlname);
142 wprintf("<a href=\"dotgoto&room=");
146 escputs1(rmname, 1, 1);
147 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
149 else if (f & QR_DIRECTORY)
151 else if (f & QR_NETWORK)
155 wprintf("</a><tt> </tt>\n");
157 room_tree_list(rp->rnext);
163 * \brief Room ordering stuff (compare first by floor, then by order)
164 * \param r1 first roomlist to compare
165 * \param r2 second roomlist co compare
166 * \return are they the same???
168 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
170 if ((r1 == NULL) && (r2 == NULL))
176 if (r1->rlfloor < r2->rlfloor)
178 if (r1->rlfloor > r2->rlfloor)
180 if (r1->rlorder < r2->rlorder)
182 if (r1->rlorder > r2->rlorder)
189 * \brief Common code for all room listings
190 * \param variety what???
192 void listrms(char *variety)
197 struct roomlisting *rl = NULL;
198 struct roomlisting *rp;
199 struct roomlisting *rs;
201 /** Ask the server for a room list */
203 serv_getln(buf, sizeof buf);
209 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
211 rp = malloc(sizeof(struct roomlisting));
212 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
213 rp->rlflags = extract_int(buf, 1);
214 rp->rlfloor = extract_int(buf, 2);
215 rp->rlorder = extract_int(buf, 3);
224 if (rordercmp(rp, rs) < 0) {
225 if (rs->lnext == NULL) {
232 if (rs->rnext == NULL) {
245 * If no rooms were listed, print an nbsp to make the cell
246 * borders show up anyway.
248 if (num_rooms == 0) wprintf(" ");
253 * \brief list all forgotten rooms
255 void zapped_list(void)
257 output_headers(1, 1, 1, 0, 0, 0);
259 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
260 do_template("beginbox");
264 wprintf("<br /><br />\n");
265 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
266 do_template("endbox");
272 * \brief read this room's info file (set v to 1 for verbose mode)
279 int fullinfo_len = 0;
282 serv_getln(buf, sizeof buf);
285 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
286 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
287 strcpy(&fullinfo[fullinfo_len], buf);
288 fullinfo_len += strlen(buf);
292 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
293 strcpy(&briefinfo[50], "...");
295 wprintf("<div class=\"infos\" "
296 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
299 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
300 wprintf("<img class=\"close_infos\" "
301 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
302 "src=\"static/closewindow.gif\" alt=\"%s\">",
317 * \brief Display room banner icon.
318 * The server doesn't actually
319 * need the room name, but we supply it in order to
320 * keep the browser from using a cached icon from
323 void embed_room_graphic(void) {
326 serv_puts("OIMG _roompic_");
327 serv_getln(buf, sizeof buf);
329 wprintf("<img height=\"64px\" src=\"image&name=_roompic_&room=");
330 urlescputs(WC->wc_roomname);
333 serv_getln(buf, sizeof buf);
335 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
336 wprintf("<img class=\"roompic\" alt=\"\" src=\""
337 "static/viewcontacts_48x.gif"
341 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
342 wprintf("<img class=\"roompic\" alt=\"\" src=\""
343 "static/calarea_48x.gif"
347 else if (WC->wc_view == VIEW_TASKS) {
348 wprintf("<img class=\"roompic\" alt=\"\" src=\""
349 "static/taskmanag_48x.gif"
353 else if (WC->wc_view == VIEW_NOTES) {
354 wprintf("<img class=\"roompic\" alt=\"\" src=\""
355 "static/storenotes_48x.gif"
359 else if (WC->wc_view == VIEW_MAILBOX) {
360 wprintf("<img class=\"roompic\" alt=\"\" src=\""
361 "static/privatemess_48x.gif"
366 wprintf("<img class=\"roompic\" alt=\"\" src=\""
367 "static/chatrooms_48x.gif"
377 * \brief Display the current view and offer an option to change it
379 void embed_view_o_matic(void) {
382 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
383 wprintf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
384 wprintf("<label for=\"view_name\">");
385 wprintf(_("View as:"));
387 "<select name=\"newview\" size=\"1\" "
388 "id=\"view_name\" class=\"selectbox\" "
389 "OnChange=\"location.href=viewomatic.newview.options"
390 "[selectedIndex].value\">\n");
392 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
394 * Only offer the views that make sense, given the default
395 * view for the room. For example, don't offer a Calendar
396 * view in a non-Calendar room.
400 || (i == WC->wc_default_view) /**< default */
401 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
402 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
403 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
406 wprintf("<option %s value=\"changeview?view=%d\">",
407 ((i == WC->wc_view) ? "selected" : ""),
409 escputs(viewdefs[i]);
410 wprintf("</option>\n");
413 wprintf("</select></div></form>\n");
418 * \brief Display a search box
420 void embed_search_o_matic(void) {
421 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
422 wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
423 wprintf("<label for=\"search_name\">");
424 wprintf(_("Search: "));
425 wprintf("</label><input ");
426 wprintf("%s", serv_info.serv_fulltext_enabled ? "" : "disabled ");
427 wprintf("type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
428 "id=\"search_name\" class=\"inputbox\">\n"
430 wprintf("</div></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) {
445 char sanitized_roomname[256];
446 char with_files[256];
450 * We need to have the information returned by a GOTO server command.
451 * If it isn't supplied, we fake it by issuing our own GOTO.
454 serv_printf("GOTO %s", WC->wc_roomname);
455 serv_getln(buf, sizeof buf);
459 /** The browser needs some information for its own use */
460 wprintf("<script type=\"text/javascript\"> \n"
461 " room_is_trash = %d; \n"
467 * If the user happens to select the "make this my start page" link,
468 * we want it to remember the URL as a "/dotskip" one instead of
469 * a "skip" or "gotonext" or something like that.
471 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
474 /** Check for new mail. */
475 WC->new_mail = extract_int(&got[4], 9);
476 WC->wc_view = extract_int(&got[4], 11);
478 /* Is this a directory room and does it contain files and how many? */
479 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
482 serv_getln(buf2, sizeof buf2);
483 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
485 snprintf (with_files, sizeof with_files,
486 "; <a href=\"display_room_directory\"> %d %s </a>",
488 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
491 strcpy (with_files, "");
493 stresc(sanitized_roomname, 256, WC->wc_roomname, 1, 1);
494 svprintf("ROOMNAME", WCS_STRING, "%s", sanitized_roomname);
495 svprintf("NUMMSGS", WCS_STRING,
496 _("%d new of %d messages%s"),
497 extract_int(&got[4], 1),
498 extract_int(&got[4], 2),
501 svcallback("ROOMPIC", embed_room_graphic);
502 svcallback("ROOMINFO", readinfo);
503 svcallback("VIEWOMATIC", embed_view_o_matic);
504 svcallback("SEARCHOMATIC", embed_search_o_matic);
505 svcallback("START", offer_start_page);
507 do_template("roombanner");
508 if (navbar_style != navbar_none) {
510 wprintf("<div id=\"navbar\"><ul>");
512 if (navbar_style == navbar_default) wprintf(
513 "<li class=\"ungoto\">"
514 "<a href=\"ungoto\">"
515 "<img src=\"static/ungoto2_24x.gif\" alt=\"\">"
516 "<span class=\"navbar_link\">%s</span></A>"
517 "</li>\n", _("Ungoto")
520 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
522 "<li class=\"newmess\">"
523 "<a href=\"readnew\">"
524 "<img src=\"static/newmess2_24x.gif\" alt=\"\">"
525 "<span class=\"navbar_link\">%s</span></A>"
526 "</li>\n", _("Read new messages")
530 if (navbar_style == navbar_default) {
531 switch(WC->wc_view) {
532 case VIEW_ADDRESSBOOK:
534 "<li class=\"viewcontacts\">"
535 "<a href=\"readfwd\">"
536 "<img src=\"static/viewcontacts_24x.gif\" "
538 "<span class=\"navbar_link\">"
540 "</span></a></li>\n", _("View contacts")
545 "<li class=\"staskday\">"
546 "<a href=\"readfwd?calview=day\">"
547 "<img src=\"static/taskday2_24x.gif\" "
549 "<span class=\"navbar_link\">"
551 "</span></a></li>\n", _("Day view")
554 "<li class=\"monthview\">"
555 "<a href=\"readfwd?calview=month\">"
556 "<img src=\"static/monthview2_24x.gif\" "
558 "<span class=\"navbar_link\">"
560 "</span></a></li>\n", _("Month view")
565 "<li class=\"monthview\">"
566 "<a href=\"readfwd?calview=month\">"
567 "<img src=\"static/monthview2_24x.gif\" "
569 "<span class=\"navbar_link\">"
571 "</span></a></li>\n", _("Calendar list")
576 "<li class=\"taskmanag\">"
577 "<a href=\"readfwd\">"
578 "<img src=\"static/taskmanag_24x.gif\" "
580 "<span class=\"navbar_link\">"
582 "</span></a></li>\n", _("View tasks")
587 "<li class=\"viewnotes\">"
588 "<a href=\"readfwd\">"
589 "<img src=\"static/viewnotes_24x.gif\" "
591 "<span class=\"navbar_link\">"
593 "</span></a></li>\n", _("View notes")
598 "<li class=\"readallmess\">"
599 "<a href=\"readfwd\">"
600 "<img src=\"static/readallmess3_24x.gif\" "
602 "<span class=\"navbar_link\">"
604 "</span></a></li>\n", _("View message list")
609 "<li class=\"readallmess\">"
610 "<a href=\"readfwd\">"
611 "<img src=\"static/readallmess3_24x.gif\" "
613 "<span class=\"navbar_link\">"
615 "</span></a></li>\n", _("Wiki home")
620 "<li class=\"readallmess\">"
621 "<a href=\"readfwd\">"
622 "<img src=\"static/readallmess3_24x.gif\" "
624 "<span class=\"navbar_link\">"
626 "</span></a></li>\n", _("Read all messages")
632 if (navbar_style == navbar_default) {
633 switch(WC->wc_view) {
634 case VIEW_ADDRESSBOOK:
636 "<li class=\"addnewcontact\">"
637 "<a href=\"display_enter\">"
638 "<img src=\"static/addnewcontact_24x.gif\" "
639 "alt=\"\"><span class=\"navbar_link\">"
641 "</span></a></li>\n", _("Add new contact")
646 wprintf("<li class=\"addevent\"><a href=\"display_enter");
647 if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
648 if (havebstr("month")) wprintf("?month=%s", bstr("month"));
649 if (havebstr("day" )) wprintf("?day=%s", bstr("day"));
651 "<img src=\"static/addevent_24x.gif\" "
652 "alt=\"\"><span class=\"navbar_link\">"
654 "</span></a></li>\n", _("Add new event")
659 "<li class=\"newmess\">"
660 "<a href=\"display_enter\">"
661 "<img src=\"static/newmess3_24x.gif\" "
662 "alt=\"\"><span class=\"navbar_link\">"
664 "</span></a></li>\n", _("Add new task")
669 "<li class=\"enternewnote\">"
670 "<a href=\"javascript:add_new_note();\">"
671 "<img src=\"static/enternewnote_24x.gif\" "
672 "alt=\"\"><span class=\"navbar_link\">"
674 "</span></a></li>\n", _("Add new note")
678 safestrncpy(buf, bstr("page"), sizeof buf);
681 "<li class=\"newmess\">"
682 "<a href=\"display_enter?wikipage=%s\">"
683 "<img src=\"static/newmess3_24x.gif\" "
684 "alt=\"\"><span class=\"navbar_link\">"
686 "</span></a></li>\n", buf, _("Edit this page")
691 "<li class=\"newmess\">"
692 "<a href=\"display_enter\">"
693 "<img src=\"static/newmess3_24x.gif\" "
694 "alt=\"\"><span class=\"navbar_link\">"
696 "</span></a></li>\n", _("Write mail")
701 "<li class=\"newmess\">"
702 "<a href=\"display_enter\">"
703 "<img src=\"static/newmess3_24x.gif\" "
704 "alt=\"\"><span class=\"navbar_link\">"
706 "</span></a></li>\n", _("Enter a message")
712 if (navbar_style == navbar_default) wprintf(
713 "<li class=\"skipthisroom\">"
716 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\">"
717 "<span class=\"navbar_link\">%s</span></a>"
719 _("Leave all messages marked as unread, go to next room with unread messages"),
723 if (navbar_style == navbar_default) wprintf(
724 "<li class=\"markngo\">"
725 "<a href=\"gotonext\" "
727 "<img src=\"static/markngo_24x.gif\" alt=\"\">"
728 "<span class=\"navbar_link\">%s</span></a>"
730 _("Mark all messages as read, go to next room with unread messages"),
734 wprintf("</ul></div>\n");
741 * \brief back end routine to take the session to a new room
742 * \param gname room to go to
745 int gotoroom(char *gname)
748 static long ls = (-1L);
751 /** store ungoto information */
752 strcpy(WC->ugname, WC->wc_roomname);
755 /** move to the new room */
756 serv_printf("GOTO %s", gname);
757 serv_getln(buf, sizeof buf);
761 serv_puts("GOTO _BASEROOM_");
762 serv_getln(buf, sizeof buf);
769 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
770 WC->room_flags = extract_int(&buf[4], 4);
771 /* highest_msg_read = extract_int(&buf[4],6);
772 maxmsgnum = extract_int(&buf[4],5);
774 WC->is_mailbox = extract_int(&buf[4],7);
775 ls = extract_long(&buf[4], 6);
776 WC->wc_floor = extract_int(&buf[4], 10);
777 WC->wc_view = extract_int(&buf[4], 11);
778 WC->wc_default_view = extract_int(&buf[4], 12);
779 WC->wc_is_trash = extract_int(&buf[4], 13);
780 WC->room_flags2 = extract_int(&buf[4], 14);
783 WC->is_room_aide = WC->is_aide;
785 WC->is_room_aide = (char) extract_int(&buf[4], 8);
787 remove_march(WC->wc_roomname);
788 if (!strcasecmp(gname, "_BASEROOM_"))
796 * \brief Locate the room on the march list which we most want to go to.
798 * is measured given a "weight" of preference based on various factors.
799 * \param desired_floor the room number on the citadel server
800 * \return the roomname
802 char *pop_march(int desired_floor)
804 static char TheRoom[128];
806 int TheOrder = 32767;
809 struct march *mptr = NULL;
811 strcpy(TheRoom, "_BASEROOM_");
812 if (WC->march == NULL)
815 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
817 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
818 weight = weight + 10000;
819 if (mptr->march_floor == desired_floor)
820 weight = weight + 5000;
822 weight = weight + ((128 - (mptr->march_floor)) * 128);
823 weight = weight + (128 - (mptr->march_order));
825 if (weight > TheWeight) {
827 strcpy(TheRoom, mptr->march_name);
828 TheFloor = mptr->march_floor;
829 TheOrder = mptr->march_order;
838 * Goto next room having unread messages.
840 * We want to skip over rooms that the user has already been to, and take the
841 * user back to the lobby when done. The room we end up in is placed in
842 * newroom - which is set to 0 (the lobby) initially.
843 * We start the search in the current room rather than the beginning to prevent
844 * two or more concurrent users from dragging each other back to the same room.
849 struct march *mptr = NULL;
850 struct march *mptr2 = NULL;
856 * First check to see if the march-mode list is already allocated.
857 * If it is, pop the first room off the list and go there.
860 if (WC->march == NULL) {
862 serv_getln(buf, sizeof buf);
864 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
865 if (IsEmptyStr(buf)) {
868 if (ELoop % 100 == 0)
873 extract_token(room_name, buf, 0, '|', sizeof room_name);
874 if (strcasecmp(room_name, WC->wc_roomname)) {
875 mptr = (struct march *) malloc(sizeof(struct march));
877 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
878 mptr->march_floor = extract_int(buf, 2);
879 mptr->march_order = extract_int(buf, 3);
880 if (WC->march == NULL)
889 * add _BASEROOM_ to the end of the march list, so the user will end up
890 * in the system base room (usually the Lobby>) at the end of the loop
892 mptr = (struct march *) malloc(sizeof(struct march));
894 mptr->march_order = 0;
895 mptr->march_floor = 0;
896 strcpy(mptr->march_name, "_BASEROOM_");
897 if (WC->march == NULL) {
901 while (mptr2->next != NULL)
906 * ...and remove the room we're currently in, so a <G>oto doesn't make us
907 * walk around in circles
909 remove_march(WC->wc_roomname);
911 if (WC->march != NULL) {
912 strcpy(next_room, pop_march(-1));
914 strcpy(next_room, "_BASEROOM_");
918 smart_goto(next_room);
925 void smart_goto(char *next_room) {
933 * mark all messages in current room as having been read
935 void slrp_highest(void)
939 serv_puts("SLRP HIGHEST");
940 serv_getln(buf, sizeof buf);
945 * un-goto the previous room
951 if (!strcmp(WC->ugname, "")) {
952 smart_goto(WC->wc_roomname);
955 serv_printf("GOTO %s", WC->ugname);
956 serv_getln(buf, sizeof buf);
958 smart_goto(WC->wc_roomname);
961 if (WC->uglsn >= 0L) {
962 serv_printf("SLRP %ld", WC->uglsn);
963 serv_getln(buf, sizeof buf);
965 strcpy(buf, WC->ugname);
966 strcpy(WC->ugname, "");
970 typedef struct __room_states {
985 * Set/clear/read the "self-service list subscribe" flag for a room
987 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
988 * returns the new value.
991 int self_service(int newval) {
992 int current_value = 0;
998 int flags, floor, order, view, flags2;
1001 serv_getln(buf, sizeof buf);
1002 if (buf[0] != '2') return(0);
1004 extract_token(name, &buf[4], 0, '|', sizeof name);
1005 extract_token(password, &buf[4], 1, '|', sizeof password);
1006 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1007 flags = extract_int(&buf[4], 3);
1008 floor = extract_int(&buf[4], 4);
1009 order = extract_int(&buf[4], 5);
1010 view = extract_int(&buf[4], 6);
1011 flags2 = extract_int(&buf[4], 7);
1013 if (flags2 & QR2_SELFLIST) {
1021 flags2 = flags2 | QR2_SELFLIST;
1023 else if (newval == 0) {
1024 flags2 = flags2 & ~QR2_SELFLIST;
1027 return(current_value);
1030 if (newval != current_value) {
1031 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1032 name, password, dirname, flags,
1033 floor, order, view, flags2);
1034 serv_getln(buf, sizeof buf);
1041 int is_selflist(room_states *RoomFlags)
1043 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1046 int is_publiclist(room_states *RoomFlags)
1048 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1051 int is_moderatedlist(room_states *RoomFlags)
1053 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1057 * Set/clear/read the "self-service list subscribe" flag for a room
1059 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1060 * returns the new value.
1063 int get_roomflags(room_states *RoomOps)
1068 serv_getln(buf, sizeof buf);
1069 if (buf[0] != '2') return(0);
1071 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1072 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1073 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1074 RoomOps->flags = extract_int(&buf[4], 3);
1075 RoomOps->floor = extract_int(&buf[4], 4);
1076 RoomOps->order = extract_int(&buf[4], 5);
1077 RoomOps->view = extract_int(&buf[4], 6);
1078 RoomOps->flags2 = extract_int(&buf[4], 7);
1082 int set_roomflags(room_states *RoomOps)
1086 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1095 serv_getln(buf, sizeof buf);
1105 * display the form for editing a room
1107 void display_editroom(void)
1112 char remote_room[128];
1115 char er_password[10];
1116 char er_dirname[15];
1117 char er_roomaide[26];
1124 char *not_shared_with;
1127 int floorpolicy = 0;
1129 char pop3_host[128];
1134 if (IsEmptyStr(tab)) tab = "admin";
1137 output_headers(1, 1, 1, 0, 0, 0);
1139 wprintf("<div class=\"fix_scrollbar_bug\">");
1141 /** print the tabbed dialog */
1142 wprintf("<ul class=\"tabbed_dialog\">\n");
1144 wprintf("<li class=\"tablabel ");
1145 if (!strcmp(tab, "admin")) {
1146 wprintf(" tab_cell_label\">");
1147 wprintf(_("Administration"));
1150 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1151 wprintf(_("Administration"));
1156 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1158 wprintf("<li class=\"tablabel ");
1159 if (!strcmp(tab, "config")) {
1160 wprintf(" tab_cell_label\">");
1161 wprintf(_("Configuration"));
1164 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1165 wprintf(_("Configuration"));
1170 wprintf("<li class=\"tablabel ");
1171 if (!strcmp(tab, "expire")) {
1172 wprintf(" tab_cell_label\">");
1173 wprintf(_("Message expire policy"));
1176 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1177 wprintf(_("Message expire policy"));
1182 wprintf("<li class=\"tablabel ");
1183 if (!strcmp(tab, "access")) {
1184 wprintf(" tab_cell_label\">");
1185 wprintf(_("Access controls"));
1188 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1189 wprintf(_("Access controls"));
1194 wprintf("<li class=\"tablabel ");
1195 if (!strcmp(tab, "sharing")) {
1196 wprintf(" tab_cell_label\">");
1197 wprintf(_("Sharing"));
1200 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1201 wprintf(_("Sharing"));
1206 wprintf("<li class=\"tablabel ");
1207 if (!strcmp(tab, "listserv")) {
1208 wprintf(" tab_cell_label\">");
1209 wprintf(_("Mailing list service"));
1212 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1213 wprintf(_("Mailing list service"));
1220 wprintf("<li class=\"tablabel ");
1221 if (!strcmp(tab, "feeds")) {
1222 wprintf(" tab_cell_label\">");
1223 wprintf(_("Remote retrieval"));
1226 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1227 wprintf(_("Remote retrieval"));
1233 /* end tabbed dialog */
1235 /* begin content of whatever tab is open now */
1237 if (!strcmp(tab, "admin")) {
1238 wprintf("<div class=\"tabcontent\">");
1240 "<li><a href=\"delete_room\" "
1241 "onClick=\"return confirm('");
1242 wprintf(_("Are you sure you want to delete this room?"));
1243 wprintf("');\">\n");
1244 wprintf(_("Delete this room"));
1246 "<li><a href=\"display_editroompic\">\n");
1247 wprintf(_("Set or change the icon for this room's banner"));
1249 "<li><a href=\"display_editinfo\">\n");
1250 wprintf(_("Edit this room's Info file"));
1256 if (!strcmp(tab, "config")) {
1257 wprintf("<div class=\"tabcontent\">");
1259 serv_getln(buf, sizeof buf);
1261 if (!strncmp(buf, "550", 3)) {
1262 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1263 _("Higher access is required to access this function.")
1266 else if (buf[0] != '2') {
1267 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1270 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1271 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1272 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1273 er_flags = extract_int(&buf[4], 3);
1274 er_floor = extract_int(&buf[4], 4);
1275 er_flags2 = extract_int(&buf[4], 7);
1277 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1278 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1280 wprintf("<ul><li>");
1281 wprintf(_("Name of room: "));
1282 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1288 wprintf(_("Resides on floor: "));
1289 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1290 if (er_flags & QR_MAILBOX)
1291 wprintf("disabled >\n");
1292 for (i = 0; i < 128; ++i)
1293 if (!IsEmptyStr(floorlist[i])) {
1294 wprintf("<OPTION ");
1296 wprintf("SELECTED ");
1297 wprintf("VALUE=\"%d\">", i);
1298 escputs(floorlist[i]);
1299 wprintf("</OPTION>\n");
1301 wprintf("</select>\n");
1304 wprintf(_("Type of room:"));
1307 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1308 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1309 wprintf("CHECKED ");
1310 wprintf("OnChange=\""
1311 " if (this.form.type[0].checked == true) { "
1312 " this.form.er_floor.disabled = false; "
1315 wprintf(_("Public (automatically appears to everyone)"));
1318 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1319 if ((er_flags & QR_PRIVATE) &&
1320 (er_flags & QR_GUESSNAME))
1321 wprintf("CHECKED ");
1322 wprintf(" OnChange=\""
1323 " if (this.form.type[1].checked == true) { "
1324 " this.form.er_floor.disabled = false; "
1327 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1329 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1330 if ((er_flags & QR_PRIVATE) &&
1331 (er_flags & QR_PASSWORDED))
1332 wprintf("CHECKED ");
1333 wprintf(" OnChange=\""
1334 " if (this.form.type[2].checked == true) { "
1335 " this.form.er_floor.disabled = false; "
1338 wprintf(_("Private - require password: "));
1339 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1342 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1343 if ((er_flags & QR_PRIVATE)
1344 && ((er_flags & QR_GUESSNAME) == 0)
1345 && ((er_flags & QR_PASSWORDED) == 0))
1346 wprintf("CHECKED ");
1347 wprintf(" OnChange=\""
1348 " if (this.form.type[3].checked == true) { "
1349 " this.form.er_floor.disabled = false; "
1352 wprintf(_("Private - invitation only"));
1354 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1355 if (er_flags & QR_MAILBOX)
1356 wprintf("CHECKED ");
1357 wprintf (" OnChange=\""
1358 " if (this.form.type[4].checked == true) { "
1359 " this.form.er_floor.disabled = true; "
1362 wprintf(_("Personal (mailbox for you only)"));
1364 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1366 wprintf(_("If private, cause current users to forget room"));
1368 wprintf("\n</ul>\n");
1370 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1371 if (er_flags & QR_PREFONLY)
1372 wprintf("CHECKED ");
1374 wprintf(_("Preferred users only"));
1376 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1377 if (er_flags & QR_READONLY)
1378 wprintf("CHECKED ");
1380 wprintf(_("Read-only room"));
1382 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1383 if (er_flags2 & QR2_COLLABDEL)
1384 wprintf("CHECKED ");
1386 wprintf(_("All users allowed to post may also delete messages"));
1388 /** directory stuff */
1389 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1390 if (er_flags & QR_DIRECTORY)
1391 wprintf("CHECKED ");
1393 wprintf(_("File directory room"));
1395 wprintf("\n<ul><li>");
1396 wprintf(_("Directory name: "));
1397 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1400 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1401 if (er_flags & QR_UPLOAD)
1402 wprintf("CHECKED ");
1404 wprintf(_("Uploading allowed"));
1406 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1407 if (er_flags & QR_DOWNLOAD)
1408 wprintf("CHECKED ");
1410 wprintf(_("Downloading allowed"));
1412 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1413 if (er_flags & QR_VISDIR)
1414 wprintf("CHECKED ");
1416 wprintf(_("Visible directory"));
1419 /** end of directory stuff */
1421 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1422 if (er_flags & QR_NETWORK)
1423 wprintf("CHECKED ");
1425 wprintf(_("Network shared room"));
1427 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1428 if (er_flags & QR_PERMANENT)
1429 wprintf("CHECKED ");
1431 wprintf(_("Permanent (does not auto-purge)"));
1433 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1434 if (er_flags2 & QR2_SUBJECTREQ)
1435 wprintf("CHECKED ");
1437 wprintf(_("Subject Required (Force users to specify a message subject)"));
1439 /** start of anon options */
1442 wprintf(_("Anonymous messages"));
1445 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1446 if (((er_flags & QR_ANONONLY) == 0)
1447 && ((er_flags & QR_ANONOPT) == 0))
1448 wprintf("CHECKED ");
1450 wprintf(_("No anonymous messages"));
1452 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1453 if (er_flags & QR_ANONONLY)
1454 wprintf("CHECKED ");
1456 wprintf(_("All messages are anonymous"));
1458 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1459 if (er_flags & QR_ANONOPT)
1460 wprintf("CHECKED ");
1462 wprintf(_("Prompt user when entering messages"));
1465 /* end of anon options */
1468 wprintf(_("Room aide: "));
1470 serv_getln(buf, sizeof buf);
1471 if (buf[0] != '2') {
1472 wprintf("<em>%s</em>\n", &buf[4]);
1474 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1475 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1478 wprintf("</ul><CENTER>\n");
1479 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1480 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1482 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1492 /* Sharing the room with other Citadel nodes... */
1493 if (!strcmp(tab, "sharing")) {
1494 wprintf("<div class=\"tabcontent\">");
1496 shared_with = strdup("");
1497 not_shared_with = strdup("");
1499 /** Learn the current configuration */
1500 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1501 serv_getln(buf, sizeof buf);
1502 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1503 extract_token(node, buf, 0, '|', sizeof node);
1504 not_shared_with = realloc(not_shared_with,
1505 strlen(not_shared_with) + 32);
1506 strcat(not_shared_with, node);
1507 strcat(not_shared_with, "\n");
1511 serv_getln(buf, sizeof buf);
1512 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1513 extract_token(cmd, buf, 0, '|', sizeof cmd);
1514 extract_token(node, buf, 1, '|', sizeof node);
1515 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1516 if (!strcasecmp(cmd, "ignet_push_share")) {
1517 shared_with = realloc(shared_with,
1518 strlen(shared_with) + 32);
1519 strcat(shared_with, node);
1520 if (!IsEmptyStr(remote_room)) {
1521 strcat(shared_with, "|");
1522 strcat(shared_with, remote_room);
1524 strcat(shared_with, "\n");
1528 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1529 extract_token(buf, shared_with, i, '\n', sizeof buf);
1530 extract_token(node, buf, 0, '|', sizeof node);
1531 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1532 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1533 if (!strcasecmp(node, cmd)) {
1534 remove_token(not_shared_with, j, '\n');
1539 /* Display the stuff */
1540 wprintf("<CENTER><br />"
1541 "<table border=1 cellpadding=5><tr>"
1543 wprintf(_("Shared with"));
1544 wprintf("</I></B></td>"
1546 wprintf(_("Not shared with"));
1547 wprintf("</I></B></td></tr>\n"
1548 "<tr><td VALIGN=TOP>\n");
1550 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1551 wprintf(_("Remote node name"));
1552 wprintf("</td><td>");
1553 wprintf(_("Remote room name"));
1554 wprintf("</td><td>");
1555 wprintf(_("Actions"));
1556 wprintf("</td></tr>\n");
1558 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1559 extract_token(buf, shared_with, i, '\n', sizeof buf);
1560 extract_token(node, buf, 0, '|', sizeof node);
1561 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1562 if (!IsEmptyStr(node)) {
1563 wprintf("<form method=\"POST\" action=\"netedit\">");
1564 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1565 wprintf("<tr><td>%s</td>\n", node);
1568 if (!IsEmptyStr(remote_room)) {
1569 escputs(remote_room);
1575 wprintf("<input type=\"hidden\" NAME=\"line\" "
1576 "VALUE=\"ignet_push_share|");
1578 if (!IsEmptyStr(remote_room)) {
1580 urlescputs(remote_room);
1583 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1584 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1585 wprintf("<input type=\"submit\" "
1586 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1587 wprintf("</td></tr></form>\n");
1591 wprintf("</table>\n");
1592 wprintf("</td><td VALIGN=TOP>\n");
1593 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1594 wprintf(_("Remote node name"));
1595 wprintf("</td><td>");
1596 wprintf(_("Remote room name"));
1597 wprintf("</td><td>");
1598 wprintf(_("Actions"));
1599 wprintf("</td></tr>\n");
1601 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1602 extract_token(node, not_shared_with, i, '\n', sizeof node);
1603 if (!IsEmptyStr(node)) {
1604 wprintf("<form method=\"POST\" action=\"netedit\">");
1605 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1606 wprintf("<tr><td>");
1609 "<input type=\"INPUT\" "
1613 wprintf("<input type=\"hidden\" "
1615 "VALUE=\"ignet_push_share|");
1618 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1619 "VALUE=\"sharing\">\n");
1620 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1621 "VALUE=\"add\">\n");
1622 wprintf("<input type=\"submit\" "
1623 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1624 wprintf("</td></tr></form>\n");
1628 wprintf("</table>\n");
1629 wprintf("</td></tr>"
1630 "</table></CENTER><br />\n"
1631 "<I><B>%s</B><ul><li>", _("Notes:"));
1632 wprintf(_("When sharing a room, "
1633 "it must be shared from both ends. Adding a node to "
1634 "the 'shared' list sends messages out, but in order to"
1635 " receive messages, the other nodes must be configured"
1636 " to send messages out to your system as well. "
1637 "<li>If the remote room name is blank, it is assumed "
1638 "that the room name is identical on the remote node."
1639 "<li>If the remote room name is different, the remote "
1640 "node must also configure the name of the room here."
1647 /* Mailing list management */
1648 if (!strcmp(tab, "listserv")) {
1649 room_states RoomFlags;
1650 wprintf("<div class=\"tabcontent\">");
1652 wprintf("<br /><center>"
1653 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1654 "<tr><td VALIGN=TOP>");
1656 wprintf(_("<i>The contents of this room are being "
1657 "mailed <b>as individual messages</b> "
1658 "to the following list recipients:"
1659 "</i><br /><br />\n"));
1662 serv_getln(buf, sizeof buf);
1663 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1664 extract_token(cmd, buf, 0, '|', sizeof cmd);
1665 if (!strcasecmp(cmd, "listrecp")) {
1666 extract_token(recp, buf, 1, '|', sizeof recp);
1669 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1672 wprintf(_("(remove)"));
1673 wprintf("</A><br />");
1676 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1677 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1678 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1679 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1680 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1681 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1682 wprintf("</form>\n");
1684 wprintf("</td><td VALIGN=TOP>\n");
1686 wprintf(_("<i>The contents of this room are being "
1687 "mailed <b>in digest form</b> "
1688 "to the following list recipients:"
1689 "</i><br /><br />\n"));
1692 serv_getln(buf, sizeof buf);
1693 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1694 extract_token(cmd, buf, 0, '|', sizeof cmd);
1695 if (!strcasecmp(cmd, "digestrecp")) {
1696 extract_token(recp, buf, 1, '|', sizeof recp);
1699 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1703 wprintf(_("(remove)"));
1704 wprintf("</A><br />");
1707 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1708 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1709 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1710 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1711 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1712 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1713 wprintf("</form>\n");
1715 wprintf("</td></tr></table>\n");
1717 /** Pop open an address book -- begin **/
1718 wprintf("<div align=right>"
1719 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1721 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1726 _("Add recipients from Contacts or other address books"),
1727 _("Add recipients from Contacts or other address books")
1729 /* Pop open an address book -- end **/
1731 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1733 get_roomflags (&RoomFlags);
1735 /* Self Service subscription? */
1736 wprintf("<table><tr><td>\n");
1737 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1738 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1739 " <tr><td colspan=\"2\">\n",
1740 (is_selflist(&RoomFlags))?"checked":"");
1741 wprintf(_("The URL for subscribe/unsubscribe is: "));
1742 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1743 (is_https ? "https" : "http"),
1745 /* Public posting? */
1746 wprintf("<tr><td>");
1747 wprintf(_("Allow non-subscribers to mail to this room."));
1748 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1749 (is_publiclist(&RoomFlags))?"checked":"");
1751 /* Moderated List? */
1752 wprintf("<tr><td>");
1753 wprintf(_("Room post publication needs Aide permission."));
1754 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1755 (is_moderatedlist(&RoomFlags))?"checked":"");
1758 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1759 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1760 wprintf("</table></form>");
1763 wprintf("</CENTER>\n");
1768 /* Configuration of The Dreaded Auto-Purger */
1769 if (!strcmp(tab, "expire")) {
1770 wprintf("<div class=\"tabcontent\">");
1772 serv_puts("GPEX room");
1773 serv_getln(buf, sizeof buf);
1774 if (!strncmp(buf, "550", 3)) {
1775 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1776 _("Higher access is required to access this function.")
1779 else if (buf[0] != '2') {
1780 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1783 roompolicy = extract_int(&buf[4], 0);
1784 roomvalue = extract_int(&buf[4], 1);
1786 serv_puts("GPEX floor");
1787 serv_getln(buf, sizeof buf);
1788 if (buf[0] == '2') {
1789 floorpolicy = extract_int(&buf[4], 0);
1790 floorvalue = extract_int(&buf[4], 1);
1793 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1794 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1795 wprintf("<table border=0 cellspacing=5>\n");
1796 wprintf("<tr><td>");
1797 wprintf(_("Message expire policy for this room"));
1799 escputs(WC->wc_roomname);
1800 wprintf(")</td><td>");
1801 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1802 ((roompolicy == 0) ? "CHECKED" : "") );
1803 wprintf(_("Use the default policy for this floor"));
1804 wprintf("<br />\n");
1805 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1806 ((roompolicy == 1) ? "CHECKED" : "") );
1807 wprintf(_("Never automatically expire messages"));
1808 wprintf("<br />\n");
1809 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1810 ((roompolicy == 2) ? "CHECKED" : "") );
1811 wprintf(_("Expire by message count"));
1812 wprintf("<br />\n");
1813 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1814 ((roompolicy == 3) ? "CHECKED" : "") );
1815 wprintf(_("Expire by message age"));
1817 wprintf(_("Number of messages or days: "));
1818 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1819 wprintf("</td></tr>\n");
1821 if (WC->axlevel >= 6) {
1822 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1823 wprintf("<tr><td>");
1824 wprintf(_("Message expire policy for this floor"));
1826 escputs(floorlist[WC->wc_floor]);
1827 wprintf(")</td><td>");
1828 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1829 ((floorpolicy == 0) ? "CHECKED" : "") );
1830 wprintf(_("Use the system default"));
1831 wprintf("<br />\n");
1832 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1833 ((floorpolicy == 1) ? "CHECKED" : "") );
1834 wprintf(_("Never automatically expire messages"));
1835 wprintf("<br />\n");
1836 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1837 ((floorpolicy == 2) ? "CHECKED" : "") );
1838 wprintf(_("Expire by message count"));
1839 wprintf("<br />\n");
1840 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1841 ((floorpolicy == 3) ? "CHECKED" : "") );
1842 wprintf(_("Expire by message age"));
1844 wprintf(_("Number of messages or days: "));
1845 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1849 wprintf("<CENTER>\n");
1850 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1851 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1853 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1854 wprintf("</CENTER></td><tr>\n");
1856 wprintf("</table>\n"
1857 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1865 /* Access controls */
1866 if (!strcmp(tab, "access")) {
1867 wprintf("<div class=\"tabcontent\">");
1872 /* Fetch messages from remote locations */
1873 if (!strcmp(tab, "feeds")) {
1874 wprintf("<div class=\"tabcontent\">");
1877 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1878 wprintf("</i><br />\n");
1880 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1881 "<tr class=\"even\"><th>");
1882 wprintf(_("Remote host"));
1883 wprintf("</th><th>");
1884 wprintf(_("User name"));
1885 wprintf("</th><th>");
1886 wprintf(_("Password"));
1887 wprintf("</th><th>");
1888 wprintf(_("Keep messages on server?"));
1889 wprintf("</th><th>");
1890 wprintf(_("Interval"));
1891 wprintf("</th><th> </th></tr>");
1894 serv_getln(buf, sizeof buf);
1896 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1897 extract_token(cmd, buf, 0, '|', sizeof cmd);
1898 if (!strcasecmp(cmd, "pop3client")) {
1899 safestrncpy(recp, &buf[11], sizeof recp);
1902 wprintf("<tr class=\"%s\">",
1903 (bg ? "even" : "odd")
1907 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1912 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1916 wprintf("<td>*****</td>"); /* Don't show the password */
1918 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1920 wprintf("<td>%ld</td>", extract_long(buf, 5)); // Fetching interval
1922 wprintf("<td class=\"button_link\">");
1923 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1926 wprintf(_("(remove)"));
1927 wprintf("</a></td>");
1933 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1935 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1936 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1937 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1939 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1942 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1945 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1948 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1951 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
1954 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1955 wprintf("</td></tr>");
1956 wprintf("</form></table>\n");
1961 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1962 wprintf("</i><br />\n");
1964 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1965 "<tr class=\"even\"><th>");
1966 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1967 wprintf(_("Feed URL"));
1968 wprintf("</th><th>");
1969 wprintf("</th></tr>");
1972 serv_getln(buf, sizeof buf);
1974 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1975 extract_token(cmd, buf, 0, '|', sizeof cmd);
1976 if (!strcasecmp(cmd, "rssclient")) {
1977 safestrncpy(recp, &buf[10], sizeof recp);
1980 wprintf("<tr class=\"%s\">",
1981 (bg ? "even" : "odd")
1985 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1989 wprintf("<td class=\"button_link\">");
1990 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=rssclient|");
1993 wprintf(_("(remove)"));
1994 wprintf("</a></td>");
2000 wprintf("<form method=\"POST\" action=\"netedit\">\n"
2002 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2003 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2004 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2006 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2007 "maxlength=\"256\" name=\"line_pop3host\">\n");
2010 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2011 wprintf("</td></tr>");
2012 wprintf("</form></table>\n");
2018 /* end content of whatever tab is open now */
2019 wprintf("</div>\n");
2021 address_book_popup();
2027 * Toggle self-service list subscription
2029 void toggle_self_service(void) {
2030 room_states RoomFlags;
2032 get_roomflags (&RoomFlags);
2034 if (yesbstr("QR2_SelfList"))
2035 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2037 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2039 if (yesbstr("QR2_SMTP_PUBLIC"))
2040 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2042 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2044 if (yesbstr("QR2_Moderated"))
2045 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2047 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2048 if (yesbstr("QR2_SubsOnly"))
2049 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2051 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2053 set_roomflags (&RoomFlags);
2061 * save new parameters for a room
2067 char er_password[10];
2068 char er_dirname[15];
2069 char er_roomaide[26];
2072 int er_listingorder;
2078 if (!havebstr("ok_button")) {
2079 strcpy(WC->ImportantMessage,
2080 _("Cancelled. Changes were not saved."));
2085 serv_getln(buf, sizeof buf);
2087 if (buf[0] != '2') {
2088 strcpy(WC->ImportantMessage, &buf[4]);
2092 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
2093 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
2094 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
2095 er_flags = extract_int(&buf[4], 3);
2096 er_listingorder = extract_int(&buf[4], 5);
2097 er_defaultview = extract_int(&buf[4], 6);
2098 er_flags2 = extract_int(&buf[4], 7);
2100 strcpy(er_roomaide, bstr("er_roomaide"));
2101 if (IsEmptyStr(er_roomaide)) {
2103 serv_getln(buf, sizeof buf);
2104 if (buf[0] != '2') {
2105 strcpy(er_roomaide, "");
2107 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
2110 strcpy(buf, bstr("er_name"));
2112 if (!IsEmptyStr(buf)) {
2113 strcpy(er_name, buf);
2116 strcpy(buf, bstr("er_password"));
2118 if (!IsEmptyStr(buf))
2119 strcpy(er_password, buf);
2121 strcpy(buf, bstr("er_dirname"));
2123 if (!IsEmptyStr(buf))
2124 strcpy(er_dirname, buf);
2126 strcpy(buf, bstr("type"));
2127 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2129 if (!strcmp(buf, "invonly")) {
2130 er_flags |= (QR_PRIVATE);
2132 if (!strcmp(buf, "hidden")) {
2133 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2135 if (!strcmp(buf, "passworded")) {
2136 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2138 if (!strcmp(buf, "personal")) {
2139 er_flags |= QR_MAILBOX;
2141 er_flags &= ~QR_MAILBOX;
2144 if (yesbstr("prefonly")) {
2145 er_flags |= QR_PREFONLY;
2147 er_flags &= ~QR_PREFONLY;
2150 if (yesbstr("readonly")) {
2151 er_flags |= QR_READONLY;
2153 er_flags &= ~QR_READONLY;
2157 if (yesbstr("collabdel")) {
2158 er_flags2 |= QR2_COLLABDEL;
2160 er_flags2 &= ~QR2_COLLABDEL;
2163 if (yesbstr("permanent")) {
2164 er_flags |= QR_PERMANENT;
2166 er_flags &= ~QR_PERMANENT;
2169 if (yesbstr("subjectreq")) {
2170 er_flags2 |= QR2_SUBJECTREQ;
2172 er_flags2 &= ~QR2_SUBJECTREQ;
2175 if (yesbstr("network")) {
2176 er_flags |= QR_NETWORK;
2178 er_flags &= ~QR_NETWORK;
2181 if (yesbstr("directory")) {
2182 er_flags |= QR_DIRECTORY;
2184 er_flags &= ~QR_DIRECTORY;
2187 if (yesbstr("ulallowed")) {
2188 er_flags |= QR_UPLOAD;
2190 er_flags &= ~QR_UPLOAD;
2193 if (yesbstr("dlallowed")) {
2194 er_flags |= QR_DOWNLOAD;
2196 er_flags &= ~QR_DOWNLOAD;
2199 if (yesbstr("visdir")) {
2200 er_flags |= QR_VISDIR;
2202 er_flags &= ~QR_VISDIR;
2205 strcpy(buf, bstr("anon"));
2207 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2208 if (!strcmp(buf, "anononly"))
2209 er_flags |= QR_ANONONLY;
2210 if (!strcmp(buf, "anon2"))
2211 er_flags |= QR_ANONOPT;
2214 if (!strcmp(bstr("bump"), "yes"))
2217 er_floor = ibstr("er_floor");
2219 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2220 er_name, er_password, er_dirname, er_flags, bump, er_floor,
2221 er_listingorder, er_defaultview, er_flags2);
2223 serv_getln(buf, sizeof buf);
2224 if (buf[0] != '2') {
2225 strcpy(WC->ImportantMessage, &buf[4]);
2231 if (!IsEmptyStr(er_roomaide)) {
2232 sprintf(buf, "SETA %s", er_roomaide);
2234 serv_getln(buf, sizeof buf);
2235 if (buf[0] != '2') {
2236 strcpy(WC->ImportantMessage, &buf[4]);
2237 display_main_menu();
2242 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2249 * Display form for Invite, Kick, and show Who Knows a room
2251 void do_invt_kick(void) {
2252 char buf[SIZ], room[SIZ], username[SIZ];
2255 serv_getln(buf, sizeof buf);
2257 if (buf[0] != '2') {
2261 extract_token(room, &buf[4], 0, '|', sizeof room);
2263 strcpy(username, bstr("username"));
2265 if (havebstr("kick_button")) {
2266 sprintf(buf, "KICK %s", username);
2268 serv_getln(buf, sizeof buf);
2270 if (buf[0] != '2') {
2271 strcpy(WC->ImportantMessage, &buf[4]);
2273 sprintf(WC->ImportantMessage,
2274 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2279 if (havebstr("invite_button")) {
2280 sprintf(buf, "INVT %s", username);
2282 serv_getln(buf, sizeof buf);
2284 if (buf[0] != '2') {
2285 strcpy(WC->ImportantMessage, &buf[4]);
2287 sprintf(WC->ImportantMessage,
2288 _("<B><I>User %s invited to room %s.</I></B>\n"),
2299 * Display form for Invite, Kick, and show Who Knows a room
2301 void display_whok(void)
2303 char buf[SIZ], room[SIZ], username[SIZ];
2306 serv_getln(buf, sizeof buf);
2308 if (buf[0] != '2') {
2312 extract_token(room, &buf[4], 0, '|', sizeof room);
2315 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2316 wprintf(_("The users listed below have access to this room. "
2317 "To remove a user from the access list, select the user "
2318 "name from the list and click 'Kick'."));
2319 wprintf("<br /><br />");
2321 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2322 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2323 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2324 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2326 serv_getln(buf, sizeof buf);
2327 if (buf[0] == '1') {
2328 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2329 extract_token(username, buf, 0, '|', sizeof username);
2330 wprintf("<OPTION>");
2335 wprintf("</select><br />\n");
2337 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2338 wprintf("</form></CENTER>\n");
2340 wprintf("</td><td>");
2341 wprintf(_("To grant another user access to this room, enter the "
2342 "user name in the box below and click 'Invite'."));
2343 wprintf("<br /><br />");
2345 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2346 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2347 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2348 wprintf(_("Invite:"));
2350 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2351 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2352 "<input type=\"submit\" value=\"%s\">"
2353 "</form></CENTER>\n", _("Invite"));
2354 /* Pop open an address book -- begin **/
2356 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2358 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2361 _("Users"), _("Users")
2363 /* Pop open an address book -- end **/
2365 wprintf("</td></tr></table>\n");
2366 address_book_popup();
2373 * display the form for entering a new room
2375 void display_entroom(void)
2380 serv_puts("CRE8 0");
2381 serv_getln(buf, sizeof buf);
2383 if (buf[0] != '2') {
2384 strcpy(WC->ImportantMessage, &buf[4]);
2385 display_main_menu();
2389 output_headers(1, 1, 1, 0, 0, 0);
2391 svprintf("BOXTITLE", WCS_STRING, _("Create a new room"));
2392 do_template("beginbox");
2394 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2395 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2397 wprintf("<table class=\"altern\"> ");
2399 wprintf("<tr class=\"even\"><td>");
2400 wprintf(_("Name of room: "));
2401 wprintf("</td><td>");
2402 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2403 wprintf("</td></tr>");
2405 wprintf("<tr class=\"odd\"><td>");
2406 wprintf(_("Resides on floor: "));
2407 wprintf("</td><td>");
2409 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2410 for (i = 0; i < 128; ++i)
2411 if (!IsEmptyStr(floorlist[i])) {
2412 wprintf("<option ");
2413 wprintf("value=\"%d\">", i);
2414 escputs(floorlist[i]);
2415 wprintf("</option>\n");
2417 wprintf("</select>\n");
2418 wprintf("</td></tr>");
2421 * Our clever little snippet of JavaScript automatically selects
2422 * a public room if the view is set to Bulletin Board or wiki, and
2423 * it selects a mailbox room otherwise. The user can override this,
2424 * of course. We also disable the floor selector for mailboxes.
2426 wprintf("<tr class=\"even\"><td>");
2427 wprintf(_("Default view for room: "));
2428 wprintf("</td><td>");
2429 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2430 " if ( (this.form.er_view.value == 0) "
2431 " || (this.form.er_view.value == 6) ) { "
2432 " this.form.type[0].checked=true; "
2433 " this.form.er_floor.disabled = false; "
2436 " this.form.type[4].checked=true; "
2437 " this.form.er_floor.disabled = true; "
2440 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2441 if (is_view_allowed_as_default(i)) {
2442 wprintf("<option %s value=\"%d\">",
2443 ((i == 0) ? "selected" : ""), i );
2444 escputs(viewdefs[i]);
2445 wprintf("</option>\n");
2448 wprintf("</select>\n");
2449 wprintf("</td></tr>");
2451 wprintf("<tr class=\"even\"><td>");
2452 wprintf(_("Type of room:"));
2453 wprintf("</td><td>");
2454 wprintf("<ul class=\"adminlist\">\n");
2456 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2457 wprintf("CHECKED OnChange=\""
2458 " if (this.form.type[0].checked == true) { "
2459 " this.form.er_floor.disabled = false; "
2462 wprintf(_("Public (automatically appears to everyone)"));
2465 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2466 " if (this.form.type[1].checked == true) { "
2467 " this.form.er_floor.disabled = false; "
2470 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2473 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2474 " if (this.form.type[2].checked == true) { "
2475 " this.form.er_floor.disabled = false; "
2478 wprintf(_("Private - require password: "));
2479 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2482 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2483 " if (this.form.type[3].checked == true) { "
2484 " this.form.er_floor.disabled = false; "
2487 wprintf(_("Private - invitation only"));
2490 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2492 " if (this.form.type[4].checked == true) { "
2493 " this.form.er_floor.disabled = true; "
2496 wprintf(_("Personal (mailbox for you only)"));
2499 wprintf("\n</ul>\n");
2500 wprintf("</td></tr></table>\n");
2502 wprintf("<div class=\"buttons\">\n");
2503 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2505 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2506 wprintf("</div>\n");
2507 wprintf("</form>\n<hr />");
2508 serv_printf("MESG roomaccess");
2509 serv_getln(buf, sizeof buf);
2510 if (buf[0] == '1') {
2514 do_template("endbox");
2523 * support function for entroom() -- sets the default view
2525 void er_set_default_view(int newview) {
2538 serv_getln(buf, sizeof buf);
2539 if (buf[0] != '2') return;
2541 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2542 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2543 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2544 rm_bits1 = extract_int(&buf[4], 3);
2545 rm_floor = extract_int(&buf[4], 4);
2546 rm_listorder = extract_int(&buf[4], 5);
2547 rm_bits2 = extract_int(&buf[4], 7);
2549 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2550 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2551 rm_listorder, newview, rm_bits2
2553 serv_getln(buf, sizeof buf);
2566 char er_password[SIZ];
2571 if (!havebstr("ok_button")) {
2572 strcpy(WC->ImportantMessage,
2573 _("Cancelled. No new room was created."));
2574 display_main_menu();
2577 strcpy(er_name, bstr("er_name"));
2578 strcpy(er_type, bstr("type"));
2579 strcpy(er_password, bstr("er_password"));
2580 er_floor = ibstr("er_floor");
2581 er_view = ibstr("er_view");
2584 if (!strcmp(er_type, "hidden"))
2586 if (!strcmp(er_type, "passworded"))
2588 if (!strcmp(er_type, "invonly"))
2590 if (!strcmp(er_type, "personal"))
2593 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2594 er_name, er_num_type, er_password, er_floor, 0, er_view);
2596 serv_getln(buf, sizeof buf);
2597 if (buf[0] != '2') {
2598 strcpy(WC->ImportantMessage, &buf[4]);
2599 display_main_menu();
2602 /** TODO: Room created, now udate the left hand icon bar for this user */
2603 burn_folder_cache(0); /* burn the old folder cache */
2607 do_change_view(er_view); /* Now go there */
2612 * \brief display the screen to enter a private room
2614 void display_private(char *rname, int req_pass)
2616 output_headers(1, 1, 1, 0, 0, 0);
2618 svprintf("BOXTITLE", WCS_STRING, _("Go to a hidden room"));
2619 do_template("beginbox");
2622 wprintf(_("If you know the name of a hidden (guess-name) or "
2623 "passworded room, you can enter that room by typing "
2624 "its name below. Once you gain access to a private "
2625 "room, it will appear in your regular room listings "
2626 "so you don't have to keep returning here."));
2629 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2630 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2632 wprintf("<table class=\"altern\"> "
2633 "<tr class=\"even\"><td>");
2634 wprintf(_("Enter room name:"));
2636 "<input type=\"text\" name=\"gr_name\" "
2637 "value=\"%s\" maxlength=\"128\">\n", rname);
2640 wprintf("</td></tr><tr class=\"odd\"><td>");
2641 wprintf(_("Enter room password:"));
2642 wprintf("</td><td>");
2643 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2645 wprintf("</td></tr></table>\n");
2647 wprintf("<div class=\"buttons\">\n");
2648 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2650 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2654 wprintf("</div></form>\n");
2656 do_template("endbox");
2662 * \brief goto a private room
2664 void goto_private(void)
2669 if (!havebstr("ok_button")) {
2670 display_main_menu();
2673 strcpy(hold_rm, WC->wc_roomname);
2674 strcpy(buf, "GOTO ");
2675 strcat(buf, bstr("gr_name"));
2677 strcat(buf, bstr("gr_pass"));
2679 serv_getln(buf, sizeof buf);
2681 if (buf[0] == '2') {
2682 smart_goto(bstr("gr_name"));
2685 if (!strncmp(buf, "540", 3)) {
2686 display_private(bstr("gr_name"), 1);
2689 output_headers(1, 1, 1, 0, 0, 0);
2690 wprintf("%s\n", &buf[4]);
2697 * \brief display the screen to zap a room
2699 void display_zap(void)
2701 output_headers(1, 1, 2, 0, 0, 0);
2703 wprintf("<div id=\"banner\">\n");
2705 wprintf(_("Zap (forget/unsubscribe) the current room"));
2707 wprintf("</div>\n");
2709 wprintf("<div id=\"content\" class=\"service\">\n");
2711 wprintf(_("If you select this option, <em>%s</em> will "
2712 "disappear from your room list. Is this what you wish "
2713 "to do?<br />\n"), WC->wc_roomname);
2715 wprintf("<form method=\"POST\" action=\"zap\">\n");
2716 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2717 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2719 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2720 wprintf("</form>\n");
2731 char final_destination[SIZ];
2734 * If the forget-room routine fails for any reason, we fall back
2735 * to the current room; otherwise, we go to the Lobby
2737 strcpy(final_destination, WC->wc_roomname);
2739 if (havebstr("ok_button")) {
2740 serv_printf("GOTO %s", WC->wc_roomname);
2741 serv_getln(buf, sizeof buf);
2742 if (buf[0] == '2') {
2744 serv_getln(buf, sizeof buf);
2745 if (buf[0] == '2') {
2746 strcpy(final_destination, "_BASEROOM_");
2750 smart_goto(final_destination);
2756 * \brief Delete the current room
2758 void delete_room(void)
2763 serv_puts("KILL 1");
2764 serv_getln(buf, sizeof buf);
2765 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2766 if (buf[0] != '2') {
2767 strcpy(WC->ImportantMessage, &buf[4]);
2768 display_main_menu();
2771 smart_goto("_BASEROOM_");
2778 * \brief Perform changes to a room's network configuration
2780 void netedit(void) {
2789 // TODO: do line dynamic!
2790 if (havebstr("line_pop3host")) {
2791 strcpy(line, bstr("prefix"));
2792 strcat(line, bstr("line_pop3host"));
2794 strcat(line, bstr("line_pop3user"));
2796 strcat(line, bstr("line_pop3pass"));
2798 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2800 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2801 strcat(line, bstr("suffix"));
2803 else if (havebstr("line")) {
2804 strcpy(line, bstr("prefix"));
2805 strcat(line, bstr("line"));
2806 strcat(line, bstr("suffix"));
2821 serv_getln(buf, sizeof buf);
2822 if (buf[0] != '1') {
2828 /** This loop works for add *or* remove. Spiffy, eh? */
2829 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2830 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2831 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2832 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2833 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2834 if ( (strcasecmp(cmpa0, cmpb0))
2835 || (strcasecmp(cmpa1, cmpb1)) ) {
2836 fprintf(fp, "%s\n", buf);
2842 serv_getln(buf, sizeof buf);
2843 if (buf[0] != '4') {
2849 while (fgets(buf, sizeof buf, fp) != NULL) {
2850 buf[strlen(buf)-1] = 0;
2854 if (havebstr("add_button")) {
2855 num_addrs = num_tokens(bstr("line"), ',');
2856 if (num_addrs < 2) {
2857 /* just adding one node or address */
2861 /* adding multiple addresses separated by commas */
2862 for (i=0; i<num_addrs; ++i) {
2863 strcpy(line, bstr("prefix"));
2864 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2867 strcat(line, bstr("suffix"));
2881 * \brief Convert a room name to a folder-ish-looking name.
2882 * \param folder the folderish name
2883 * \param room the room name
2884 * \param floor the floor name
2885 * \param is_mailbox is it a mailbox?
2887 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2892 * For mailboxes, just do it straight...
2895 sprintf(folder, "My folders|%s", room);
2899 * Otherwise, prefix the floor name as a "public folders" moniker
2902 if (floor > MAX_FLOORS) {
2904 sprintf(folder, "%%%%%%|%s", room);
2907 sprintf(folder, "%s|%s", floorlist[floor], room);
2912 * Replace "\" characters with "|" for pseudo-folder-delimiting
2914 len = strlen (folder);
2915 for (i=0; i<len; ++i) {
2916 if (folder[i] == '\\') folder[i] = '|';
2924 * \brief Back end for change_view()
2925 * \param newview set newview???
2927 void do_change_view(int newview) {
2930 serv_printf("VIEW %d", newview);
2931 serv_getln(buf, sizeof buf);
2932 WC->wc_view = newview;
2933 smart_goto(WC->wc_roomname);
2939 * \brief Change the view for this room
2941 void change_view(void) {
2944 view = lbstr("view");
2945 do_change_view(view);
2950 * \brief One big expanded tree list view --- like a folder list
2951 * \param fold the folder to view
2952 * \param max_folders how many folders???
2953 * \param num_floors hom many floors???
2955 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2959 int has_subfolders = 0;
2962 parents = malloc(max_folders * sizeof(int));
2964 /** BEGIN TREE MENU */
2965 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2967 /** include NanoTree */
2968 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2970 /** initialize NanoTree */
2971 wprintf("<script type=\"text/javascript\"> \n"
2972 " showRootNode = false; \n"
2973 " sortNodes = false; \n"
2974 " dragable = false; \n"
2976 " function standardClick(treeNode) { \n"
2979 " var closedGif = 'static/folder_closed.gif'; \n"
2980 " var openGif = 'static/folder_open.gif'; \n"
2982 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2986 for (i=0; i<max_folders; ++i) {
2989 if ((i+1) < max_folders) {
2991 len = strlen(fold[i].name);
2992 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2993 && (fold[i+1].name[len] == '|') ) {
2998 levels = num_tokens(fold[i].name, '|');
2999 parents[levels] = i;
3001 wprintf("var node%d = new TreeNode(%d, '", i, i);
3003 if (fold[i].selectable) {
3004 wprintf("<a href=\"dotgoto?room=");
3005 urlescputs(fold[i].room);
3010 wprintf("<span class=\"roomlist_floor\">");
3012 else if (fold[i].hasnewmsgs) {
3013 wprintf("<span class=\"roomlist_new\">");
3016 wprintf("<span class=\"roomlist_old\">");
3018 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3023 if (has_subfolders) {
3024 wprintf("new Array(closedGif, openGif)");
3026 else if (fold[i].view == VIEW_ADDRESSBOOK) {
3027 wprintf("'static/viewcontacts_16x.gif'");
3029 else if (fold[i].view == VIEW_CALENDAR) {
3030 wprintf("'static/calarea_16x.gif'");
3032 else if (fold[i].view == VIEW_CALBRIEF) {
3033 wprintf("'static/calarea_16x.gif'");
3035 else if (fold[i].view == VIEW_TASKS) {
3036 wprintf("'static/taskmanag_16x.gif'");
3038 else if (fold[i].view == VIEW_NOTES) {
3039 wprintf("'static/storenotes_16x.gif'");
3041 else if (fold[i].view == VIEW_MAILBOX) {
3042 wprintf("'static/privatemess_16x.gif'");
3045 wprintf("'static/chatrooms_16x.gif'");
3048 urlescputs(fold[i].name);
3052 wprintf("rootNode.addChild(node%d);\n", i);
3055 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3059 wprintf("container = document.getElementById('roomlist_div'); \n"
3065 /** END TREE MENU */
3069 * \brief Boxes and rooms and lists ... oh my!
3070 * \param fold the folder to view
3071 * \param max_folders how many folders???
3072 * \param num_floors hom many floors???
3074 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3076 char floor_name[256];
3077 char old_floor_name[256];
3079 int levels, oldlevels;
3082 static int columns = 3;
3083 int boxes_per_column = 0;
3084 int current_column = 0;
3087 strcpy(floor_name, "");
3088 strcpy(old_floor_name, "");
3091 while (nf % columns != 0) ++nf;
3092 boxes_per_column = (nf / columns);
3093 if (boxes_per_column < 1) boxes_per_column = 1;
3095 /** Outer table (for columnization) */
3096 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3097 "<tr><td valign=top>");
3101 for (i=0; i<max_folders; ++i) {
3103 levels = num_tokens(fold[i].name, '|');
3104 extract_token(floor_name, fold[i].name, 0,
3105 '|', sizeof floor_name);
3107 if ( (strcasecmp(floor_name, old_floor_name))
3108 && (!IsEmptyStr(old_floor_name)) ) {
3110 do_template("endbox");
3114 if ((num_boxes % boxes_per_column) == 0) {
3116 if (current_column < columns) {
3117 wprintf("</td><td valign=top>\n");
3121 strcpy(old_floor_name, floor_name);
3124 /** Begin inner box */
3125 stresc(boxtitle, 256, floor_name, 1, 0);
3126 svprintf("BOXTITLE", WCS_STRING, boxtitle);
3127 do_template("beginbox");
3134 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3135 if (fold[i].selectable) {
3136 wprintf("<a href=\"dotgoto?room=");
3137 urlescputs(fold[i].room);
3143 if (fold[i].hasnewmsgs) {
3144 wprintf("<span class=\"roomlist_new\">");
3147 wprintf("<span class=\"roomlist_old\">");
3149 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3152 if (fold[i].selectable) {
3158 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3159 wprintf(" (INBOX)");
3161 wprintf("<br />\n");
3164 /** End the final inner box */
3165 do_template("endbox");
3167 wprintf("</td></tr></table>\n");
3171 * \brief print a floor div???
3172 * \param which_floordiv name of the floordiv???
3174 void set_floordiv_expanded(char *which_floordiv) {
3175 begin_ajax_response();
3176 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
3177 end_ajax_response();
3181 * \brief view the iconbar
3182 * \param fold the folder to view
3183 * \param max_folders how many folders???
3184 * \param num_floors hom many floors???
3186 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3188 char floor_name[256];
3189 char old_floor_name[256];
3190 char floordivtitle[256];
3191 char floordiv_id[32];
3192 int levels, oldlevels;
3194 int num_drop_targets = 0;
3197 strcpy(floor_name, "");
3198 strcpy(old_floor_name, "");
3202 for (i=0; i<max_folders; ++i) {
3204 levels = num_tokens(fold[i].name, '|');
3205 extract_token(floor_name, fold[i].name, 0,
3206 '|', sizeof floor_name);
3208 if ( (strcasecmp(floor_name, old_floor_name))
3209 && (!IsEmptyStr(old_floor_name)) ) {
3210 /** End inner box */
3212 wprintf("</div>\n"); /** floordiv */
3214 strcpy(old_floor_name, floor_name);
3218 stresc(floordivtitle, 256, floor_name, 0, 0);
3219 sprintf(floordiv_id, "floordiv%d", i);
3220 wprintf("<span class=\"ib_roomlist_floor\" "
3221 "onClick=\"expand_floor('%s')\">"
3222 "%s</span><br>\n", floordiv_id, floordivtitle);
3223 wprintf("<div id=\"%s\" style=\"display:%s\">",
3225 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
3232 wprintf("<div id=\"roomdiv%d\">", i);
3234 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3236 /** choose the icon */
3237 if (fold[i].view == VIEW_ADDRESSBOOK) {
3238 icon = "viewcontacts_16x.gif" ;
3240 else if (fold[i].view == VIEW_CALENDAR) {
3241 icon = "calarea_16x.gif" ;
3243 else if (fold[i].view == VIEW_CALBRIEF) {
3244 icon = "calarea_16x.gif" ;
3246 else if (fold[i].view == VIEW_TASKS) {
3247 icon = "taskmanag_16x.gif" ;
3249 else if (fold[i].view == VIEW_NOTES) {
3250 icon = "storenotes_16x.gif" ;
3252 else if (fold[i].view == VIEW_MAILBOX) {
3253 icon = "privatemess_16x.gif" ;
3256 icon = "chatrooms_16x.gif" ;
3259 if (fold[i].selectable) {
3260 wprintf("<a href=\"dotgoto?room=");
3261 urlescputs(fold[i].room);
3263 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3268 if (fold[i].hasnewmsgs) {
3269 wprintf("<span class=\"ib_roomlist_new\">");
3272 wprintf("<span class=\"ib_roomlist_old\">");
3274 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3276 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3277 wprintf(" (INBOX)");
3280 if (fold[i].selectable) {
3287 wprintf("</div>\n"); /** roomdiv */
3290 wprintf("</div>\n"); /** floordiv */
3293 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3294 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3296 num_drop_targets = 0;
3298 for (i=0; i<max_folders; ++i) {
3299 levels = num_tokens(fold[i].name, '|');
3301 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3302 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3303 jsescputs(fold[i].room);
3309 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3310 if ((WC->floordiv_expanded[0] != '\0')&&
3311 (WC->floordiv_expanded[1] != '\0')){
3312 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
3316 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3322 * \brief Burn the cached folder list.
3323 * \param age How old the cahce needs to be before we burn it.
3326 void burn_folder_cache(time_t age)
3328 /** If our cached folder list is very old, burn it. */
3329 if (WC->cache_fold != NULL) {
3330 if ((time(NULL) - WC->cache_timestamp) > age) {
3331 free(WC->cache_fold);
3332 WC->cache_fold = NULL;
3341 * \brief Show the room list.
3342 * (only should get called by
3343 * knrooms() because that's where output_headers() is called from)
3344 * \param viewpref the view preferences???
3347 void list_all_rooms_by_floor(char *viewpref) {
3350 struct folder *fold = NULL;
3352 int max_folders = 0;
3353 int alloc_folders = 0;
3359 int num_floors = 1; /** add an extra one for private folders */
3363 /** If our cached folder list is very old, burn it. */
3364 burn_folder_cache(300);
3366 /** Can we do the iconbar roomlist from cache? */
3367 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3368 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3372 /** Grab the floor table so we know how to build the list... */
3375 /** Start with the mailboxes */
3378 fold = malloc(sizeof(struct folder));
3379 memset(fold, 0, sizeof(struct folder));
3380 strcpy(fold[0].name, "My folders");
3381 fold[0].is_mailbox = 1;
3383 /** Then add floors */
3385 serv_getln(buf, sizeof buf);
3386 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3387 if (max_folders >= alloc_folders) {
3388 alloc_folders = max_folders + 100;
3389 fold = realloc(fold,
3390 alloc_folders * sizeof(struct folder));
3392 memset(&fold[max_folders], 0, sizeof(struct folder));
3393 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3394 extract_token(buf3, buf, 0, '|', SIZ);
3395 fold[max_folders].floor = atol (buf3);
3400 for (i=0; i<num_floors; i++)
3401 if (IDMax < fold[i].floor)
3402 IDMax = fold[i].floor;
3403 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3404 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3405 for (i=0; i<num_floors; i++)
3406 floor_mapping[fold[i].floor]=i;
3408 /** refresh the messages index for this room */
3409 // serv_puts("GOTO ");
3410 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3411 /** Now add rooms */
3413 serv_getln(buf, sizeof buf);
3414 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3415 if (max_folders >= alloc_folders) {
3416 alloc_folders = max_folders + 100;
3417 fold = realloc(fold,
3418 alloc_folders * sizeof(struct folder));
3420 memset(&fold[max_folders], 0, sizeof(struct folder));
3421 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3422 ra_flags = extract_int(buf, 5);
3423 flags = extract_int(buf, 1);
3424 fold[max_folders].floor = extract_int(buf, 2);
3425 fold[max_folders].hasnewmsgs =
3426 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3427 if (flags & QR_MAILBOX) {
3428 fold[max_folders].is_mailbox = 1;
3430 fold[max_folders].view = extract_int(buf, 6);
3431 room_to_folder(fold[max_folders].name,
3432 fold[max_folders].room,
3433 fold[max_folders].floor,
3434 fold[max_folders].is_mailbox);
3435 fold[max_folders].selectable = 1;
3436 /* Increase the room count for the associtaed floor */
3437 if (fold[max_folders].is_mailbox) {
3438 fold[0].num_rooms++;
3441 i = floor_mapping[fold[max_folders].floor];
3442 fold[i].num_rooms++;
3448 * Remove any floors that don't have rooms
3450 get_preference("emptyfloors", buf2, sizeof buf2);
3451 if (buf2[0]==0 || (strcasecmp(buf2, "no") == 0))
3453 for (i=0; i<num_floors; i++)
3455 if (fold[i].num_rooms == 0) {
3456 for (j=i; j<max_folders; j++) {
3457 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3466 /** Bubble-sort the folder list */
3467 for (i=0; i<max_folders; ++i) {
3468 for (j=0; j<(max_folders-1)-i; ++j) {
3469 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3470 swap = strcasecmp(fold[j].name, fold[j+1].name);
3473 if ( (fold[j+1].is_mailbox)
3474 && (!fold[j].is_mailbox)) {
3482 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3483 memcpy(&fold[j], &fold[j+1],
3484 sizeof(struct folder));
3485 memcpy(&fold[j+1], &ftmp,
3486 sizeof(struct folder));
3492 if (!strcasecmp(viewpref, "folders")) {
3493 do_folder_view(fold, max_folders, num_floors);
3495 else if (!strcasecmp(viewpref, "hackish_view")) {
3496 for (i=0; i<max_folders; ++i) {
3497 escputs(fold[i].name);
3498 wprintf("<br />\n");
3501 else if (!strcasecmp(viewpref, "iconbar")) {
3502 do_iconbar_view(fold, max_folders, num_floors);
3505 do_rooms_view(fold, max_folders, num_floors);
3508 /* Don't free the folder list ... cache it for future use! */
3509 if (WC->cache_fold != NULL) {
3510 free(WC->cache_fold);
3512 WC->cache_fold = fold;
3513 WC->cache_max_folders = max_folders;
3514 WC->cache_num_floors = num_floors;
3515 WC->cache_timestamp = time(NULL);
3516 free(floor_mapping);
3521 * \brief Do either a known rooms list or a folders list, depending on the
3526 char listviewpref[SIZ];
3528 output_headers(1, 1, 2, 0, 0, 0);
3530 /** Determine whether the user is trying to change views */
3531 if (bstr("view") != NULL) {
3532 if (havebstr("view")) {
3533 set_preference("roomlistview", bstr("view"), 1);
3537 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3539 if ( (strcasecmp(listviewpref, "folders"))
3540 && (strcasecmp(listviewpref, "table")) ) {
3541 strcpy(listviewpref, "rooms");
3545 wprintf("<div id=\"banner\">\n");
3546 wprintf("<div class=\"room_banner\">");
3548 if (!strcasecmp(listviewpref, "rooms")) {
3549 wprintf(_("Room list"));
3551 if (!strcasecmp(listviewpref, "folders")) {
3552 wprintf(_("Folder list"));
3554 if (!strcasecmp(listviewpref, "table")) {
3555 wprintf(_("Room list"));
3557 wprintf("</h1></div>\n");
3559 /** offer the ability to switch views */
3560 wprintf("<ul class=\"room_actions\">\n");
3561 wprintf("<li class=\"start_page\">");
3564 wprintf("<li><form name=\"roomlistomatic\">\n"
3565 "<select name=\"newview\" size=\"1\" "
3566 "OnChange=\"location.href=roomlistomatic.newview.options"
3567 "[selectedIndex].value\">\n");
3569 wprintf("<option %s value=\"knrooms&view=rooms\">"
3572 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3575 wprintf("<option %s value=\"knrooms&view=folders\">"
3576 "View as folder list"
3578 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3581 wprintf("</select>");
3582 wprintf("</form></li>");
3583 wprintf("</ul></div>\n");
3585 wprintf("<div id=\"content\" class=\"service\">\n");
3587 /** Display the room list in the user's preferred format */
3588 list_all_rooms_by_floor(listviewpref);
3595 * \brief Set the message expire policy for this room and/or floor
3597 void set_room_policy(void) {
3600 if (!havebstr("ok_button")) {
3601 strcpy(WC->ImportantMessage,
3602 _("Cancelled. Changes were not saved."));
3607 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3608 serv_getln(buf, sizeof buf);
3609 strcpy(WC->ImportantMessage, &buf[4]);
3611 if (WC->axlevel >= 6) {
3612 strcat(WC->ImportantMessage, "<br />\n");
3613 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), bstr("floorvalue"));
3614 serv_getln(buf, sizeof buf);
3615 strcat(WC->ImportantMessage, &buf[4]);