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 svput("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(HKEY("ROOMNAME"), WCS_STRING, "%s", sanitized_roomname);
495 svprintf(HKEY("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=\"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 * back end routine to take the session to a new room
743 int gotoroom(char *gname)
746 static long ls = (-1L);
749 /* store ungoto information */
750 strcpy(WC->ugname, WC->wc_roomname);
753 /** move to the new room */
754 serv_printf("GOTO %s", gname);
755 serv_getln(buf, sizeof buf);
759 serv_puts("GOTO _BASEROOM_");
760 serv_getln(buf, sizeof buf);
767 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
768 WC->room_flags = extract_int(&buf[4], 4);
769 /* highest_msg_read = extract_int(&buf[4],6);
770 maxmsgnum = extract_int(&buf[4],5);
772 WC->is_mailbox = extract_int(&buf[4],7);
773 ls = extract_long(&buf[4], 6);
774 WC->wc_floor = extract_int(&buf[4], 10);
775 WC->wc_view = extract_int(&buf[4], 11);
776 WC->wc_default_view = extract_int(&buf[4], 12);
777 WC->wc_is_trash = extract_int(&buf[4], 13);
778 WC->room_flags2 = extract_int(&buf[4], 14);
781 WC->is_room_aide = WC->is_aide;
783 WC->is_room_aide = (char) extract_int(&buf[4], 8);
785 remove_march(WC->wc_roomname);
786 if (!strcasecmp(gname, "_BASEROOM_"))
794 * \brief Locate the room on the march list which we most want to go to.
796 * is measured given a "weight" of preference based on various factors.
797 * \param desired_floor the room number on the citadel server
798 * \return the roomname
800 char *pop_march(int desired_floor)
802 static char TheRoom[128];
804 int TheOrder = 32767;
807 struct march *mptr = NULL;
809 strcpy(TheRoom, "_BASEROOM_");
810 if (WC->march == NULL)
813 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
815 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
816 weight = weight + 10000;
817 if (mptr->march_floor == desired_floor)
818 weight = weight + 5000;
820 weight = weight + ((128 - (mptr->march_floor)) * 128);
821 weight = weight + (128 - (mptr->march_order));
823 if (weight > TheWeight) {
825 strcpy(TheRoom, mptr->march_name);
826 TheFloor = mptr->march_floor;
827 TheOrder = mptr->march_order;
836 * Goto next room having unread messages.
838 * We want to skip over rooms that the user has already been to, and take the
839 * user back to the lobby when done. The room we end up in is placed in
840 * newroom - which is set to 0 (the lobby) initially.
841 * We start the search in the current room rather than the beginning to prevent
842 * two or more concurrent users from dragging each other back to the same room.
847 struct march *mptr = NULL;
848 struct march *mptr2 = NULL;
854 * First check to see if the march-mode list is already allocated.
855 * If it is, pop the first room off the list and go there.
858 if (WC->march == NULL) {
860 serv_getln(buf, sizeof buf);
862 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
863 if (IsEmptyStr(buf)) {
866 if (ELoop % 100 == 0)
871 extract_token(room_name, buf, 0, '|', sizeof room_name);
872 if (strcasecmp(room_name, WC->wc_roomname)) {
873 mptr = (struct march *) malloc(sizeof(struct march));
875 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
876 mptr->march_floor = extract_int(buf, 2);
877 mptr->march_order = extract_int(buf, 3);
878 if (WC->march == NULL)
887 * add _BASEROOM_ to the end of the march list, so the user will end up
888 * in the system base room (usually the Lobby>) at the end of the loop
890 mptr = (struct march *) malloc(sizeof(struct march));
892 mptr->march_order = 0;
893 mptr->march_floor = 0;
894 strcpy(mptr->march_name, "_BASEROOM_");
895 if (WC->march == NULL) {
899 while (mptr2->next != NULL)
904 * ...and remove the room we're currently in, so a <G>oto doesn't make us
905 * walk around in circles
907 remove_march(WC->wc_roomname);
909 if (WC->march != NULL) {
910 strcpy(next_room, pop_march(-1));
912 strcpy(next_room, "_BASEROOM_");
916 smart_goto(next_room);
923 void smart_goto(char *next_room) {
931 * mark all messages in current room as having been read
933 void slrp_highest(void)
937 serv_puts("SLRP HIGHEST");
938 serv_getln(buf, sizeof buf);
943 * un-goto the previous room
949 if (!strcmp(WC->ugname, "")) {
950 smart_goto(WC->wc_roomname);
953 serv_printf("GOTO %s", WC->ugname);
954 serv_getln(buf, sizeof buf);
956 smart_goto(WC->wc_roomname);
959 if (WC->uglsn >= 0L) {
960 serv_printf("SLRP %ld", WC->uglsn);
961 serv_getln(buf, sizeof buf);
963 strcpy(buf, WC->ugname);
964 strcpy(WC->ugname, "");
968 typedef struct __room_states {
983 * Set/clear/read the "self-service list subscribe" flag for a room
985 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
986 * returns the new value.
989 int self_service(int newval) {
990 int current_value = 0;
996 int flags, floor, order, view, flags2;
999 serv_getln(buf, sizeof buf);
1000 if (buf[0] != '2') return(0);
1002 extract_token(name, &buf[4], 0, '|', sizeof name);
1003 extract_token(password, &buf[4], 1, '|', sizeof password);
1004 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1005 flags = extract_int(&buf[4], 3);
1006 floor = extract_int(&buf[4], 4);
1007 order = extract_int(&buf[4], 5);
1008 view = extract_int(&buf[4], 6);
1009 flags2 = extract_int(&buf[4], 7);
1011 if (flags2 & QR2_SELFLIST) {
1019 flags2 = flags2 | QR2_SELFLIST;
1021 else if (newval == 0) {
1022 flags2 = flags2 & ~QR2_SELFLIST;
1025 return(current_value);
1028 if (newval != current_value) {
1029 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1030 name, password, dirname, flags,
1031 floor, order, view, flags2);
1032 serv_getln(buf, sizeof buf);
1039 int is_selflist(room_states *RoomFlags)
1041 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1044 int is_publiclist(room_states *RoomFlags)
1046 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1049 int is_moderatedlist(room_states *RoomFlags)
1051 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1055 * Set/clear/read the "self-service list subscribe" flag for a room
1057 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1058 * returns the new value.
1061 int get_roomflags(room_states *RoomOps)
1066 serv_getln(buf, sizeof buf);
1067 if (buf[0] != '2') return(0);
1069 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1070 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1071 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1072 RoomOps->flags = extract_int(&buf[4], 3);
1073 RoomOps->floor = extract_int(&buf[4], 4);
1074 RoomOps->order = extract_int(&buf[4], 5);
1075 RoomOps->view = extract_int(&buf[4], 6);
1076 RoomOps->flags2 = extract_int(&buf[4], 7);
1080 int set_roomflags(room_states *RoomOps)
1084 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1093 serv_getln(buf, sizeof buf);
1103 * display the form for editing a room
1105 void display_editroom(void)
1110 char remote_room[128];
1113 char er_password[10];
1114 char er_dirname[15];
1115 char er_roomaide[26];
1122 char *not_shared_with;
1125 int floorpolicy = 0;
1127 char pop3_host[128];
1132 if (IsEmptyStr(tab)) tab = "admin";
1135 output_headers(1, 1, 1, 0, 0, 0);
1137 wprintf("<div class=\"fix_scrollbar_bug\">");
1139 /** print the tabbed dialog */
1140 wprintf("<ul class=\"tabbed_dialog\">\n");
1142 wprintf("<li class=\"tablabel ");
1143 if (!strcmp(tab, "admin")) {
1144 wprintf(" tab_cell_label\">");
1145 wprintf(_("Administration"));
1148 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1149 wprintf(_("Administration"));
1154 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1156 wprintf("<li class=\"tablabel ");
1157 if (!strcmp(tab, "config")) {
1158 wprintf(" tab_cell_label\">");
1159 wprintf(_("Configuration"));
1162 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1163 wprintf(_("Configuration"));
1168 wprintf("<li class=\"tablabel ");
1169 if (!strcmp(tab, "expire")) {
1170 wprintf(" tab_cell_label\">");
1171 wprintf(_("Message expire policy"));
1174 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1175 wprintf(_("Message expire policy"));
1180 wprintf("<li class=\"tablabel ");
1181 if (!strcmp(tab, "access")) {
1182 wprintf(" tab_cell_label\">");
1183 wprintf(_("Access controls"));
1186 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1187 wprintf(_("Access controls"));
1192 wprintf("<li class=\"tablabel ");
1193 if (!strcmp(tab, "sharing")) {
1194 wprintf(" tab_cell_label\">");
1195 wprintf(_("Sharing"));
1198 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1199 wprintf(_("Sharing"));
1204 wprintf("<li class=\"tablabel ");
1205 if (!strcmp(tab, "listserv")) {
1206 wprintf(" tab_cell_label\">");
1207 wprintf(_("Mailing list service"));
1210 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1211 wprintf(_("Mailing list service"));
1218 wprintf("<li class=\"tablabel ");
1219 if (!strcmp(tab, "feeds")) {
1220 wprintf(" tab_cell_label\">");
1221 wprintf(_("Remote retrieval"));
1224 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1225 wprintf(_("Remote retrieval"));
1231 /* end tabbed dialog */
1233 /* begin content of whatever tab is open now */
1235 if (!strcmp(tab, "admin")) {
1236 wprintf("<div class=\"tabcontent\">");
1238 "<li><a href=\"delete_room\" "
1239 "onClick=\"return confirm('");
1240 wprintf(_("Are you sure you want to delete this room?"));
1241 wprintf("');\">\n");
1242 wprintf(_("Delete this room"));
1244 "<li><a href=\"display_editroompic\">\n");
1245 wprintf(_("Set or change the icon for this room's banner"));
1247 "<li><a href=\"display_editinfo\">\n");
1248 wprintf(_("Edit this room's Info file"));
1254 if (!strcmp(tab, "config")) {
1255 wprintf("<div class=\"tabcontent\">");
1257 serv_getln(buf, sizeof buf);
1259 if (!strncmp(buf, "550", 3)) {
1260 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1261 _("Higher access is required to access this function.")
1264 else if (buf[0] != '2') {
1265 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1268 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1269 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1270 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1271 er_flags = extract_int(&buf[4], 3);
1272 er_floor = extract_int(&buf[4], 4);
1273 er_flags2 = extract_int(&buf[4], 7);
1275 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1276 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1278 wprintf("<ul><li>");
1279 wprintf(_("Name of room: "));
1280 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1286 wprintf(_("Resides on floor: "));
1287 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1288 if (er_flags & QR_MAILBOX)
1289 wprintf("disabled >\n");
1290 for (i = 0; i < 128; ++i)
1291 if (!IsEmptyStr(floorlist[i])) {
1292 wprintf("<OPTION ");
1294 wprintf("SELECTED ");
1295 wprintf("VALUE=\"%d\">", i);
1296 escputs(floorlist[i]);
1297 wprintf("</OPTION>\n");
1299 wprintf("</select>\n");
1302 wprintf(_("Type of room:"));
1305 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1306 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1307 wprintf("CHECKED ");
1308 wprintf("OnChange=\""
1309 " if (this.form.type[0].checked == true) { "
1310 " this.form.er_floor.disabled = false; "
1313 wprintf(_("Public (automatically appears to everyone)"));
1316 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1317 if ((er_flags & QR_PRIVATE) &&
1318 (er_flags & QR_GUESSNAME))
1319 wprintf("CHECKED ");
1320 wprintf(" OnChange=\""
1321 " if (this.form.type[1].checked == true) { "
1322 " this.form.er_floor.disabled = false; "
1325 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1327 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1328 if ((er_flags & QR_PRIVATE) &&
1329 (er_flags & QR_PASSWORDED))
1330 wprintf("CHECKED ");
1331 wprintf(" OnChange=\""
1332 " if (this.form.type[2].checked == true) { "
1333 " this.form.er_floor.disabled = false; "
1336 wprintf(_("Private - require password: "));
1337 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1340 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1341 if ((er_flags & QR_PRIVATE)
1342 && ((er_flags & QR_GUESSNAME) == 0)
1343 && ((er_flags & QR_PASSWORDED) == 0))
1344 wprintf("CHECKED ");
1345 wprintf(" OnChange=\""
1346 " if (this.form.type[3].checked == true) { "
1347 " this.form.er_floor.disabled = false; "
1350 wprintf(_("Private - invitation only"));
1352 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1353 if (er_flags & QR_MAILBOX)
1354 wprintf("CHECKED ");
1355 wprintf (" OnChange=\""
1356 " if (this.form.type[4].checked == true) { "
1357 " this.form.er_floor.disabled = true; "
1360 wprintf(_("Personal (mailbox for you only)"));
1362 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1364 wprintf(_("If private, cause current users to forget room"));
1366 wprintf("\n</ul>\n");
1368 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1369 if (er_flags & QR_PREFONLY)
1370 wprintf("CHECKED ");
1372 wprintf(_("Preferred users only"));
1374 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1375 if (er_flags & QR_READONLY)
1376 wprintf("CHECKED ");
1378 wprintf(_("Read-only room"));
1380 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1381 if (er_flags2 & QR2_COLLABDEL)
1382 wprintf("CHECKED ");
1384 wprintf(_("All users allowed to post may also delete messages"));
1386 /** directory stuff */
1387 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1388 if (er_flags & QR_DIRECTORY)
1389 wprintf("CHECKED ");
1391 wprintf(_("File directory room"));
1393 wprintf("\n<ul><li>");
1394 wprintf(_("Directory name: "));
1395 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1398 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1399 if (er_flags & QR_UPLOAD)
1400 wprintf("CHECKED ");
1402 wprintf(_("Uploading allowed"));
1404 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1405 if (er_flags & QR_DOWNLOAD)
1406 wprintf("CHECKED ");
1408 wprintf(_("Downloading allowed"));
1410 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1411 if (er_flags & QR_VISDIR)
1412 wprintf("CHECKED ");
1414 wprintf(_("Visible directory"));
1417 /** end of directory stuff */
1419 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1420 if (er_flags & QR_NETWORK)
1421 wprintf("CHECKED ");
1423 wprintf(_("Network shared room"));
1425 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1426 if (er_flags & QR_PERMANENT)
1427 wprintf("CHECKED ");
1429 wprintf(_("Permanent (does not auto-purge)"));
1431 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1432 if (er_flags2 & QR2_SUBJECTREQ)
1433 wprintf("CHECKED ");
1435 wprintf(_("Subject Required (Force users to specify a message subject)"));
1437 /** start of anon options */
1440 wprintf(_("Anonymous messages"));
1443 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1444 if (((er_flags & QR_ANONONLY) == 0)
1445 && ((er_flags & QR_ANONOPT) == 0))
1446 wprintf("CHECKED ");
1448 wprintf(_("No anonymous messages"));
1450 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1451 if (er_flags & QR_ANONONLY)
1452 wprintf("CHECKED ");
1454 wprintf(_("All messages are anonymous"));
1456 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1457 if (er_flags & QR_ANONOPT)
1458 wprintf("CHECKED ");
1460 wprintf(_("Prompt user when entering messages"));
1463 /* end of anon options */
1466 wprintf(_("Room aide: "));
1468 serv_getln(buf, sizeof buf);
1469 if (buf[0] != '2') {
1470 wprintf("<em>%s</em>\n", &buf[4]);
1472 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1473 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1476 wprintf("</ul><CENTER>\n");
1477 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1478 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1480 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1490 /* Sharing the room with other Citadel nodes... */
1491 if (!strcmp(tab, "sharing")) {
1492 wprintf("<div class=\"tabcontent\">");
1494 shared_with = strdup("");
1495 not_shared_with = strdup("");
1497 /** Learn the current configuration */
1498 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1499 serv_getln(buf, sizeof buf);
1500 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1501 extract_token(node, buf, 0, '|', sizeof node);
1502 not_shared_with = realloc(not_shared_with,
1503 strlen(not_shared_with) + 32);
1504 strcat(not_shared_with, node);
1505 strcat(not_shared_with, "\n");
1509 serv_getln(buf, sizeof buf);
1510 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1511 extract_token(cmd, buf, 0, '|', sizeof cmd);
1512 extract_token(node, buf, 1, '|', sizeof node);
1513 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1514 if (!strcasecmp(cmd, "ignet_push_share")) {
1515 shared_with = realloc(shared_with,
1516 strlen(shared_with) + 32);
1517 strcat(shared_with, node);
1518 if (!IsEmptyStr(remote_room)) {
1519 strcat(shared_with, "|");
1520 strcat(shared_with, remote_room);
1522 strcat(shared_with, "\n");
1526 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1527 extract_token(buf, shared_with, i, '\n', sizeof buf);
1528 extract_token(node, buf, 0, '|', sizeof node);
1529 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1530 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1531 if (!strcasecmp(node, cmd)) {
1532 remove_token(not_shared_with, j, '\n');
1537 /* Display the stuff */
1538 wprintf("<CENTER><br />"
1539 "<table border=1 cellpadding=5><tr>"
1541 wprintf(_("Shared with"));
1542 wprintf("</I></B></td>"
1544 wprintf(_("Not shared with"));
1545 wprintf("</I></B></td></tr>\n"
1546 "<tr><td VALIGN=TOP>\n");
1548 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1549 wprintf(_("Remote node name"));
1550 wprintf("</td><td>");
1551 wprintf(_("Remote room name"));
1552 wprintf("</td><td>");
1553 wprintf(_("Actions"));
1554 wprintf("</td></tr>\n");
1556 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1557 extract_token(buf, shared_with, i, '\n', sizeof buf);
1558 extract_token(node, buf, 0, '|', sizeof node);
1559 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1560 if (!IsEmptyStr(node)) {
1561 wprintf("<form method=\"POST\" action=\"netedit\">");
1562 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1563 wprintf("<tr><td>%s</td>\n", node);
1566 if (!IsEmptyStr(remote_room)) {
1567 escputs(remote_room);
1573 wprintf("<input type=\"hidden\" NAME=\"line\" "
1574 "VALUE=\"ignet_push_share|");
1576 if (!IsEmptyStr(remote_room)) {
1578 urlescputs(remote_room);
1581 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1582 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1583 wprintf("<input type=\"submit\" "
1584 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1585 wprintf("</td></tr></form>\n");
1589 wprintf("</table>\n");
1590 wprintf("</td><td VALIGN=TOP>\n");
1591 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1592 wprintf(_("Remote node name"));
1593 wprintf("</td><td>");
1594 wprintf(_("Remote room name"));
1595 wprintf("</td><td>");
1596 wprintf(_("Actions"));
1597 wprintf("</td></tr>\n");
1599 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1600 extract_token(node, not_shared_with, i, '\n', sizeof node);
1601 if (!IsEmptyStr(node)) {
1602 wprintf("<form method=\"POST\" action=\"netedit\">");
1603 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1604 wprintf("<tr><td>");
1607 "<input type=\"INPUT\" "
1611 wprintf("<input type=\"hidden\" "
1613 "VALUE=\"ignet_push_share|");
1616 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1617 "VALUE=\"sharing\">\n");
1618 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1619 "VALUE=\"add\">\n");
1620 wprintf("<input type=\"submit\" "
1621 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1622 wprintf("</td></tr></form>\n");
1626 wprintf("</table>\n");
1627 wprintf("</td></tr>"
1628 "</table></CENTER><br />\n"
1629 "<I><B>%s</B><ul><li>", _("Notes:"));
1630 wprintf(_("When sharing a room, "
1631 "it must be shared from both ends. Adding a node to "
1632 "the 'shared' list sends messages out, but in order to"
1633 " receive messages, the other nodes must be configured"
1634 " to send messages out to your system as well. "
1635 "<li>If the remote room name is blank, it is assumed "
1636 "that the room name is identical on the remote node."
1637 "<li>If the remote room name is different, the remote "
1638 "node must also configure the name of the room here."
1645 /* Mailing list management */
1646 if (!strcmp(tab, "listserv")) {
1647 room_states RoomFlags;
1648 wprintf("<div class=\"tabcontent\">");
1650 wprintf("<br /><center>"
1651 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1652 "<tr><td VALIGN=TOP>");
1654 wprintf(_("<i>The contents of this room are being "
1655 "mailed <b>as individual messages</b> "
1656 "to the following list recipients:"
1657 "</i><br /><br />\n"));
1660 serv_getln(buf, sizeof buf);
1661 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1662 extract_token(cmd, buf, 0, '|', sizeof cmd);
1663 if (!strcasecmp(cmd, "listrecp")) {
1664 extract_token(recp, buf, 1, '|', sizeof recp);
1667 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1670 wprintf(_("(remove)"));
1671 wprintf("</A><br />");
1674 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1675 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1676 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1677 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1678 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1679 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1680 wprintf("</form>\n");
1682 wprintf("</td><td VALIGN=TOP>\n");
1684 wprintf(_("<i>The contents of this room are being "
1685 "mailed <b>in digest form</b> "
1686 "to the following list recipients:"
1687 "</i><br /><br />\n"));
1690 serv_getln(buf, sizeof buf);
1691 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1692 extract_token(cmd, buf, 0, '|', sizeof cmd);
1693 if (!strcasecmp(cmd, "digestrecp")) {
1694 extract_token(recp, buf, 1, '|', sizeof recp);
1697 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1701 wprintf(_("(remove)"));
1702 wprintf("</A><br />");
1705 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1706 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1707 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1708 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1709 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1710 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1711 wprintf("</form>\n");
1713 wprintf("</td></tr></table>\n");
1715 /** Pop open an address book -- begin **/
1716 wprintf("<div align=right>"
1717 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1719 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1724 _("Add recipients from Contacts or other address books"),
1725 _("Add recipients from Contacts or other address books")
1727 /* Pop open an address book -- end **/
1729 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1731 get_roomflags (&RoomFlags);
1733 /* Self Service subscription? */
1734 wprintf("<table><tr><td>\n");
1735 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1736 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1737 " <tr><td colspan=\"2\">\n",
1738 (is_selflist(&RoomFlags))?"checked":"");
1739 wprintf(_("The URL for subscribe/unsubscribe is: "));
1740 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1741 (is_https ? "https" : "http"),
1743 /* Public posting? */
1744 wprintf("<tr><td>");
1745 wprintf(_("Allow non-subscribers to mail to this room."));
1746 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1747 (is_publiclist(&RoomFlags))?"checked":"");
1749 /* Moderated List? */
1750 wprintf("<tr><td>");
1751 wprintf(_("Room post publication needs Aide permission."));
1752 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1753 (is_moderatedlist(&RoomFlags))?"checked":"");
1756 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1757 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1758 wprintf("</table></form>");
1761 wprintf("</CENTER>\n");
1766 /* Configuration of The Dreaded Auto-Purger */
1767 if (!strcmp(tab, "expire")) {
1768 wprintf("<div class=\"tabcontent\">");
1770 serv_puts("GPEX room");
1771 serv_getln(buf, sizeof buf);
1772 if (!strncmp(buf, "550", 3)) {
1773 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1774 _("Higher access is required to access this function.")
1777 else if (buf[0] != '2') {
1778 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1781 roompolicy = extract_int(&buf[4], 0);
1782 roomvalue = extract_int(&buf[4], 1);
1784 serv_puts("GPEX floor");
1785 serv_getln(buf, sizeof buf);
1786 if (buf[0] == '2') {
1787 floorpolicy = extract_int(&buf[4], 0);
1788 floorvalue = extract_int(&buf[4], 1);
1791 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1792 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1793 wprintf("<table border=0 cellspacing=5>\n");
1794 wprintf("<tr><td>");
1795 wprintf(_("Message expire policy for this room"));
1797 escputs(WC->wc_roomname);
1798 wprintf(")</td><td>");
1799 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1800 ((roompolicy == 0) ? "CHECKED" : "") );
1801 wprintf(_("Use the default policy for this floor"));
1802 wprintf("<br />\n");
1803 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1804 ((roompolicy == 1) ? "CHECKED" : "") );
1805 wprintf(_("Never automatically expire messages"));
1806 wprintf("<br />\n");
1807 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1808 ((roompolicy == 2) ? "CHECKED" : "") );
1809 wprintf(_("Expire by message count"));
1810 wprintf("<br />\n");
1811 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1812 ((roompolicy == 3) ? "CHECKED" : "") );
1813 wprintf(_("Expire by message age"));
1815 wprintf(_("Number of messages or days: "));
1816 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1817 wprintf("</td></tr>\n");
1819 if (WC->axlevel >= 6) {
1820 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1821 wprintf("<tr><td>");
1822 wprintf(_("Message expire policy for this floor"));
1824 escputs(floorlist[WC->wc_floor]);
1825 wprintf(")</td><td>");
1826 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1827 ((floorpolicy == 0) ? "CHECKED" : "") );
1828 wprintf(_("Use the system default"));
1829 wprintf("<br />\n");
1830 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1831 ((floorpolicy == 1) ? "CHECKED" : "") );
1832 wprintf(_("Never automatically expire messages"));
1833 wprintf("<br />\n");
1834 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1835 ((floorpolicy == 2) ? "CHECKED" : "") );
1836 wprintf(_("Expire by message count"));
1837 wprintf("<br />\n");
1838 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1839 ((floorpolicy == 3) ? "CHECKED" : "") );
1840 wprintf(_("Expire by message age"));
1842 wprintf(_("Number of messages or days: "));
1843 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1847 wprintf("<CENTER>\n");
1848 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1849 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1851 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1852 wprintf("</CENTER></td><tr>\n");
1854 wprintf("</table>\n"
1855 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1863 /* Access controls */
1864 if (!strcmp(tab, "access")) {
1865 wprintf("<div class=\"tabcontent\">");
1870 /* Fetch messages from remote locations */
1871 if (!strcmp(tab, "feeds")) {
1872 wprintf("<div class=\"tabcontent\">");
1875 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1876 wprintf("</i><br />\n");
1878 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1879 "<tr class=\"even\"><th>");
1880 wprintf(_("Remote host"));
1881 wprintf("</th><th>");
1882 wprintf(_("User name"));
1883 wprintf("</th><th>");
1884 wprintf(_("Password"));
1885 wprintf("</th><th>");
1886 wprintf(_("Keep messages on server?"));
1887 wprintf("</th><th>");
1888 wprintf(_("Interval"));
1889 wprintf("</th><th> </th></tr>");
1892 serv_getln(buf, sizeof buf);
1894 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1895 extract_token(cmd, buf, 0, '|', sizeof cmd);
1896 if (!strcasecmp(cmd, "pop3client")) {
1897 safestrncpy(recp, &buf[11], sizeof recp);
1900 wprintf("<tr class=\"%s\">",
1901 (bg ? "even" : "odd")
1905 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1910 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1914 wprintf("<td>*****</td>"); /* Don't show the password */
1916 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1918 wprintf("<td>%ld</td>", extract_long(buf, 5)); // Fetching interval
1920 wprintf("<td class=\"button_link\">");
1921 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1924 wprintf(_("(remove)"));
1925 wprintf("</a></td>");
1931 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1933 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1934 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1935 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1937 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1940 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1943 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1946 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1949 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
1952 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1953 wprintf("</td></tr>");
1954 wprintf("</form></table>\n");
1959 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1960 wprintf("</i><br />\n");
1962 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1963 "<tr class=\"even\"><th>");
1964 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1965 wprintf(_("Feed URL"));
1966 wprintf("</th><th>");
1967 wprintf("</th></tr>");
1970 serv_getln(buf, sizeof buf);
1972 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1973 extract_token(cmd, buf, 0, '|', sizeof cmd);
1974 if (!strcasecmp(cmd, "rssclient")) {
1975 safestrncpy(recp, &buf[10], sizeof recp);
1978 wprintf("<tr class=\"%s\">",
1979 (bg ? "even" : "odd")
1983 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1987 wprintf("<td class=\"button_link\">");
1988 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=rssclient|");
1991 wprintf(_("(remove)"));
1992 wprintf("</a></td>");
1998 wprintf("<form method=\"POST\" action=\"netedit\">\n"
2000 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2001 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2002 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2004 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2005 "maxlength=\"256\" name=\"line_pop3host\">\n");
2008 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2009 wprintf("</td></tr>");
2010 wprintf("</form></table>\n");
2016 /* end content of whatever tab is open now */
2017 wprintf("</div>\n");
2019 address_book_popup();
2025 * Toggle self-service list subscription
2027 void toggle_self_service(void) {
2028 room_states RoomFlags;
2030 get_roomflags (&RoomFlags);
2032 if (yesbstr("QR2_SelfList"))
2033 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2035 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2037 if (yesbstr("QR2_SMTP_PUBLIC"))
2038 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2040 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2042 if (yesbstr("QR2_Moderated"))
2043 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2045 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2046 if (yesbstr("QR2_SubsOnly"))
2047 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2049 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2051 set_roomflags (&RoomFlags);
2059 * save new parameters for a room
2065 char er_password[10];
2066 char er_dirname[15];
2067 char er_roomaide[26];
2070 int er_listingorder;
2076 if (!havebstr("ok_button")) {
2077 strcpy(WC->ImportantMessage,
2078 _("Cancelled. Changes were not saved."));
2083 serv_getln(buf, sizeof buf);
2085 if (buf[0] != '2') {
2086 strcpy(WC->ImportantMessage, &buf[4]);
2090 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
2091 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
2092 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
2093 er_flags = extract_int(&buf[4], 3);
2094 er_listingorder = extract_int(&buf[4], 5);
2095 er_defaultview = extract_int(&buf[4], 6);
2096 er_flags2 = extract_int(&buf[4], 7);
2098 strcpy(er_roomaide, bstr("er_roomaide"));
2099 if (IsEmptyStr(er_roomaide)) {
2101 serv_getln(buf, sizeof buf);
2102 if (buf[0] != '2') {
2103 strcpy(er_roomaide, "");
2105 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
2108 strcpy(buf, bstr("er_name"));
2110 if (!IsEmptyStr(buf)) {
2111 strcpy(er_name, buf);
2114 strcpy(buf, bstr("er_password"));
2116 if (!IsEmptyStr(buf))
2117 strcpy(er_password, buf);
2119 strcpy(buf, bstr("er_dirname"));
2121 if (!IsEmptyStr(buf))
2122 strcpy(er_dirname, buf);
2124 strcpy(buf, bstr("type"));
2125 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2127 if (!strcmp(buf, "invonly")) {
2128 er_flags |= (QR_PRIVATE);
2130 if (!strcmp(buf, "hidden")) {
2131 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2133 if (!strcmp(buf, "passworded")) {
2134 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2136 if (!strcmp(buf, "personal")) {
2137 er_flags |= QR_MAILBOX;
2139 er_flags &= ~QR_MAILBOX;
2142 if (yesbstr("prefonly")) {
2143 er_flags |= QR_PREFONLY;
2145 er_flags &= ~QR_PREFONLY;
2148 if (yesbstr("readonly")) {
2149 er_flags |= QR_READONLY;
2151 er_flags &= ~QR_READONLY;
2155 if (yesbstr("collabdel")) {
2156 er_flags2 |= QR2_COLLABDEL;
2158 er_flags2 &= ~QR2_COLLABDEL;
2161 if (yesbstr("permanent")) {
2162 er_flags |= QR_PERMANENT;
2164 er_flags &= ~QR_PERMANENT;
2167 if (yesbstr("subjectreq")) {
2168 er_flags2 |= QR2_SUBJECTREQ;
2170 er_flags2 &= ~QR2_SUBJECTREQ;
2173 if (yesbstr("network")) {
2174 er_flags |= QR_NETWORK;
2176 er_flags &= ~QR_NETWORK;
2179 if (yesbstr("directory")) {
2180 er_flags |= QR_DIRECTORY;
2182 er_flags &= ~QR_DIRECTORY;
2185 if (yesbstr("ulallowed")) {
2186 er_flags |= QR_UPLOAD;
2188 er_flags &= ~QR_UPLOAD;
2191 if (yesbstr("dlallowed")) {
2192 er_flags |= QR_DOWNLOAD;
2194 er_flags &= ~QR_DOWNLOAD;
2197 if (yesbstr("visdir")) {
2198 er_flags |= QR_VISDIR;
2200 er_flags &= ~QR_VISDIR;
2203 strcpy(buf, bstr("anon"));
2205 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2206 if (!strcmp(buf, "anononly"))
2207 er_flags |= QR_ANONONLY;
2208 if (!strcmp(buf, "anon2"))
2209 er_flags |= QR_ANONOPT;
2212 if (!strcmp(bstr("bump"), "yes"))
2215 er_floor = ibstr("er_floor");
2217 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2218 er_name, er_password, er_dirname, er_flags, bump, er_floor,
2219 er_listingorder, er_defaultview, er_flags2);
2221 serv_getln(buf, sizeof buf);
2222 if (buf[0] != '2') {
2223 strcpy(WC->ImportantMessage, &buf[4]);
2229 if (!IsEmptyStr(er_roomaide)) {
2230 sprintf(buf, "SETA %s", er_roomaide);
2232 serv_getln(buf, sizeof buf);
2233 if (buf[0] != '2') {
2234 strcpy(WC->ImportantMessage, &buf[4]);
2235 display_main_menu();
2240 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2247 * Display form for Invite, Kick, and show Who Knows a room
2249 void do_invt_kick(void) {
2250 char buf[SIZ], room[SIZ], username[SIZ];
2253 serv_getln(buf, sizeof buf);
2255 if (buf[0] != '2') {
2259 extract_token(room, &buf[4], 0, '|', sizeof room);
2261 strcpy(username, bstr("username"));
2263 if (havebstr("kick_button")) {
2264 sprintf(buf, "KICK %s", username);
2266 serv_getln(buf, sizeof buf);
2268 if (buf[0] != '2') {
2269 strcpy(WC->ImportantMessage, &buf[4]);
2271 sprintf(WC->ImportantMessage,
2272 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2277 if (havebstr("invite_button")) {
2278 sprintf(buf, "INVT %s", username);
2280 serv_getln(buf, sizeof buf);
2282 if (buf[0] != '2') {
2283 strcpy(WC->ImportantMessage, &buf[4]);
2285 sprintf(WC->ImportantMessage,
2286 _("<B><I>User %s invited to room %s.</I></B>\n"),
2297 * Display form for Invite, Kick, and show Who Knows a room
2299 void display_whok(void)
2301 char buf[SIZ], room[SIZ], username[SIZ];
2304 serv_getln(buf, sizeof buf);
2306 if (buf[0] != '2') {
2310 extract_token(room, &buf[4], 0, '|', sizeof room);
2313 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2314 wprintf(_("The users listed below have access to this room. "
2315 "To remove a user from the access list, select the user "
2316 "name from the list and click 'Kick'."));
2317 wprintf("<br /><br />");
2319 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2320 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2321 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2322 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2324 serv_getln(buf, sizeof buf);
2325 if (buf[0] == '1') {
2326 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2327 extract_token(username, buf, 0, '|', sizeof username);
2328 wprintf("<OPTION>");
2333 wprintf("</select><br />\n");
2335 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2336 wprintf("</form></CENTER>\n");
2338 wprintf("</td><td>");
2339 wprintf(_("To grant another user access to this room, enter the "
2340 "user name in the box below and click 'Invite'."));
2341 wprintf("<br /><br />");
2343 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2344 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2345 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2346 wprintf(_("Invite:"));
2348 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2349 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2350 "<input type=\"submit\" value=\"%s\">"
2351 "</form></CENTER>\n", _("Invite"));
2352 /* Pop open an address book -- begin **/
2354 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2356 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2359 _("Users"), _("Users")
2361 /* Pop open an address book -- end **/
2363 wprintf("</td></tr></table>\n");
2364 address_book_popup();
2371 * display the form for entering a new room
2373 void display_entroom(void)
2378 serv_puts("CRE8 0");
2379 serv_getln(buf, sizeof buf);
2381 if (buf[0] != '2') {
2382 strcpy(WC->ImportantMessage, &buf[4]);
2383 display_main_menu();
2387 output_headers(1, 1, 1, 0, 0, 0);
2389 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2390 do_template("beginbox");
2392 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2393 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2395 wprintf("<table class=\"altern\"> ");
2397 wprintf("<tr class=\"even\"><td>");
2398 wprintf(_("Name of room: "));
2399 wprintf("</td><td>");
2400 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2401 wprintf("</td></tr>");
2403 wprintf("<tr class=\"odd\"><td>");
2404 wprintf(_("Resides on floor: "));
2405 wprintf("</td><td>");
2407 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2408 for (i = 0; i < 128; ++i)
2409 if (!IsEmptyStr(floorlist[i])) {
2410 wprintf("<option ");
2411 wprintf("value=\"%d\">", i);
2412 escputs(floorlist[i]);
2413 wprintf("</option>\n");
2415 wprintf("</select>\n");
2416 wprintf("</td></tr>");
2419 * Our clever little snippet of JavaScript automatically selects
2420 * a public room if the view is set to Bulletin Board or wiki, and
2421 * it selects a mailbox room otherwise. The user can override this,
2422 * of course. We also disable the floor selector for mailboxes.
2424 wprintf("<tr class=\"even\"><td>");
2425 wprintf(_("Default view for room: "));
2426 wprintf("</td><td>");
2427 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2428 " if ( (this.form.er_view.value == 0) "
2429 " || (this.form.er_view.value == 6) ) { "
2430 " this.form.type[0].checked=true; "
2431 " this.form.er_floor.disabled = false; "
2434 " this.form.type[4].checked=true; "
2435 " this.form.er_floor.disabled = true; "
2438 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2439 if (is_view_allowed_as_default(i)) {
2440 wprintf("<option %s value=\"%d\">",
2441 ((i == 0) ? "selected" : ""), i );
2442 escputs(viewdefs[i]);
2443 wprintf("</option>\n");
2446 wprintf("</select>\n");
2447 wprintf("</td></tr>");
2449 wprintf("<tr class=\"even\"><td>");
2450 wprintf(_("Type of room:"));
2451 wprintf("</td><td>");
2452 wprintf("<ul class=\"adminlist\">\n");
2454 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2455 wprintf("CHECKED OnChange=\""
2456 " if (this.form.type[0].checked == true) { "
2457 " this.form.er_floor.disabled = false; "
2460 wprintf(_("Public (automatically appears to everyone)"));
2463 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2464 " if (this.form.type[1].checked == true) { "
2465 " this.form.er_floor.disabled = false; "
2468 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2471 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2472 " if (this.form.type[2].checked == true) { "
2473 " this.form.er_floor.disabled = false; "
2476 wprintf(_("Private - require password: "));
2477 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2480 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2481 " if (this.form.type[3].checked == true) { "
2482 " this.form.er_floor.disabled = false; "
2485 wprintf(_("Private - invitation only"));
2488 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2490 " if (this.form.type[4].checked == true) { "
2491 " this.form.er_floor.disabled = true; "
2494 wprintf(_("Personal (mailbox for you only)"));
2497 wprintf("\n</ul>\n");
2498 wprintf("</td></tr></table>\n");
2500 wprintf("<div class=\"buttons\">\n");
2501 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2503 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2504 wprintf("</div>\n");
2505 wprintf("</form>\n<hr />");
2506 serv_printf("MESG roomaccess");
2507 serv_getln(buf, sizeof buf);
2508 if (buf[0] == '1') {
2512 do_template("endbox");
2521 * support function for entroom() -- sets the default view
2523 void er_set_default_view(int newview) {
2536 serv_getln(buf, sizeof buf);
2537 if (buf[0] != '2') return;
2539 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2540 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2541 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2542 rm_bits1 = extract_int(&buf[4], 3);
2543 rm_floor = extract_int(&buf[4], 4);
2544 rm_listorder = extract_int(&buf[4], 5);
2545 rm_bits2 = extract_int(&buf[4], 7);
2547 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2548 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2549 rm_listorder, newview, rm_bits2
2551 serv_getln(buf, sizeof buf);
2564 char er_password[SIZ];
2569 if (!havebstr("ok_button")) {
2570 strcpy(WC->ImportantMessage,
2571 _("Cancelled. No new room was created."));
2572 display_main_menu();
2575 strcpy(er_name, bstr("er_name"));
2576 strcpy(er_type, bstr("type"));
2577 strcpy(er_password, bstr("er_password"));
2578 er_floor = ibstr("er_floor");
2579 er_view = ibstr("er_view");
2582 if (!strcmp(er_type, "hidden"))
2584 if (!strcmp(er_type, "passworded"))
2586 if (!strcmp(er_type, "invonly"))
2588 if (!strcmp(er_type, "personal"))
2591 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2592 er_name, er_num_type, er_password, er_floor, 0, er_view);
2594 serv_getln(buf, sizeof buf);
2595 if (buf[0] != '2') {
2596 strcpy(WC->ImportantMessage, &buf[4]);
2597 display_main_menu();
2600 /** TODO: Room created, now udate the left hand icon bar for this user */
2601 burn_folder_cache(0); /* burn the old folder cache */
2605 do_change_view(er_view); /* Now go there */
2610 * \brief display the screen to enter a private room
2612 void display_private(char *rname, int req_pass)
2614 output_headers(1, 1, 1, 0, 0, 0);
2616 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Go to a hidden room"));
2617 do_template("beginbox");
2620 wprintf(_("If you know the name of a hidden (guess-name) or "
2621 "passworded room, you can enter that room by typing "
2622 "its name below. Once you gain access to a private "
2623 "room, it will appear in your regular room listings "
2624 "so you don't have to keep returning here."));
2627 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2628 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2630 wprintf("<table class=\"altern\"> "
2631 "<tr class=\"even\"><td>");
2632 wprintf(_("Enter room name:"));
2634 "<input type=\"text\" name=\"gr_name\" "
2635 "value=\"%s\" maxlength=\"128\">\n", rname);
2638 wprintf("</td></tr><tr class=\"odd\"><td>");
2639 wprintf(_("Enter room password:"));
2640 wprintf("</td><td>");
2641 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2643 wprintf("</td></tr></table>\n");
2645 wprintf("<div class=\"buttons\">\n");
2646 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2648 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2652 wprintf("</div></form>\n");
2654 do_template("endbox");
2660 * \brief goto a private room
2662 void goto_private(void)
2667 if (!havebstr("ok_button")) {
2668 display_main_menu();
2671 strcpy(hold_rm, WC->wc_roomname);
2672 strcpy(buf, "GOTO ");
2673 strcat(buf, bstr("gr_name"));
2675 strcat(buf, bstr("gr_pass"));
2677 serv_getln(buf, sizeof buf);
2679 if (buf[0] == '2') {
2680 smart_goto(bstr("gr_name"));
2683 if (!strncmp(buf, "540", 3)) {
2684 display_private(bstr("gr_name"), 1);
2687 output_headers(1, 1, 1, 0, 0, 0);
2688 wprintf("%s\n", &buf[4]);
2695 * \brief display the screen to zap a room
2697 void display_zap(void)
2699 output_headers(1, 1, 2, 0, 0, 0);
2701 wprintf("<div id=\"banner\">\n");
2703 wprintf(_("Zap (forget/unsubscribe) the current room"));
2705 wprintf("</div>\n");
2707 wprintf("<div id=\"content\" class=\"service\">\n");
2709 wprintf(_("If you select this option, <em>%s</em> will "
2710 "disappear from your room list. Is this what you wish "
2711 "to do?<br />\n"), WC->wc_roomname);
2713 wprintf("<form method=\"POST\" action=\"zap\">\n");
2714 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2715 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2717 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2718 wprintf("</form>\n");
2729 char final_destination[SIZ];
2732 * If the forget-room routine fails for any reason, we fall back
2733 * to the current room; otherwise, we go to the Lobby
2735 strcpy(final_destination, WC->wc_roomname);
2737 if (havebstr("ok_button")) {
2738 serv_printf("GOTO %s", WC->wc_roomname);
2739 serv_getln(buf, sizeof buf);
2740 if (buf[0] == '2') {
2742 serv_getln(buf, sizeof buf);
2743 if (buf[0] == '2') {
2744 strcpy(final_destination, "_BASEROOM_");
2748 smart_goto(final_destination);
2754 * \brief Delete the current room
2756 void delete_room(void)
2761 serv_puts("KILL 1");
2762 serv_getln(buf, sizeof buf);
2763 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2764 if (buf[0] != '2') {
2765 strcpy(WC->ImportantMessage, &buf[4]);
2766 display_main_menu();
2769 smart_goto("_BASEROOM_");
2776 * \brief Perform changes to a room's network configuration
2778 void netedit(void) {
2787 // TODO: do line dynamic!
2788 if (havebstr("line_pop3host")) {
2789 strcpy(line, bstr("prefix"));
2790 strcat(line, bstr("line_pop3host"));
2792 strcat(line, bstr("line_pop3user"));
2794 strcat(line, bstr("line_pop3pass"));
2796 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2798 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2799 strcat(line, bstr("suffix"));
2801 else if (havebstr("line")) {
2802 strcpy(line, bstr("prefix"));
2803 strcat(line, bstr("line"));
2804 strcat(line, bstr("suffix"));
2819 serv_getln(buf, sizeof buf);
2820 if (buf[0] != '1') {
2826 /** This loop works for add *or* remove. Spiffy, eh? */
2827 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2828 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2829 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2830 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2831 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2832 if ( (strcasecmp(cmpa0, cmpb0))
2833 || (strcasecmp(cmpa1, cmpb1)) ) {
2834 fprintf(fp, "%s\n", buf);
2840 serv_getln(buf, sizeof buf);
2841 if (buf[0] != '4') {
2847 while (fgets(buf, sizeof buf, fp) != NULL) {
2848 buf[strlen(buf)-1] = 0;
2852 if (havebstr("add_button")) {
2853 num_addrs = num_tokens(bstr("line"), ',');
2854 if (num_addrs < 2) {
2855 /* just adding one node or address */
2859 /* adding multiple addresses separated by commas */
2860 for (i=0; i<num_addrs; ++i) {
2861 strcpy(line, bstr("prefix"));
2862 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2865 strcat(line, bstr("suffix"));
2879 * \brief Convert a room name to a folder-ish-looking name.
2880 * \param folder the folderish name
2881 * \param room the room name
2882 * \param floor the floor name
2883 * \param is_mailbox is it a mailbox?
2885 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2890 * For mailboxes, just do it straight...
2893 sprintf(folder, "My folders|%s", room);
2897 * Otherwise, prefix the floor name as a "public folders" moniker
2900 if (floor > MAX_FLOORS) {
2902 sprintf(folder, "%%%%%%|%s", room);
2905 sprintf(folder, "%s|%s", floorlist[floor], room);
2910 * Replace "\" characters with "|" for pseudo-folder-delimiting
2912 len = strlen (folder);
2913 for (i=0; i<len; ++i) {
2914 if (folder[i] == '\\') folder[i] = '|';
2922 * \brief Back end for change_view()
2923 * \param newview set newview???
2925 void do_change_view(int newview) {
2928 serv_printf("VIEW %d", newview);
2929 serv_getln(buf, sizeof buf);
2930 WC->wc_view = newview;
2931 smart_goto(WC->wc_roomname);
2937 * \brief Change the view for this room
2939 void change_view(void) {
2942 view = lbstr("view");
2943 do_change_view(view);
2948 * \brief One big expanded tree list view --- like a folder list
2949 * \param fold the folder to view
2950 * \param max_folders how many folders???
2951 * \param num_floors hom many floors???
2953 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2957 int has_subfolders = 0;
2960 parents = malloc(max_folders * sizeof(int));
2962 /** BEGIN TREE MENU */
2963 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2965 /** include NanoTree */
2966 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2968 /** initialize NanoTree */
2969 wprintf("<script type=\"text/javascript\"> \n"
2970 " showRootNode = false; \n"
2971 " sortNodes = false; \n"
2972 " dragable = false; \n"
2974 " function standardClick(treeNode) { \n"
2977 " var closedGif = 'static/folder_closed.gif'; \n"
2978 " var openGif = 'static/folder_open.gif'; \n"
2980 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2984 for (i=0; i<max_folders; ++i) {
2987 if ((i+1) < max_folders) {
2989 len = strlen(fold[i].name);
2990 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2991 && (fold[i+1].name[len] == '|') ) {
2996 levels = num_tokens(fold[i].name, '|');
2997 parents[levels] = i;
2999 wprintf("var node%d = new TreeNode(%d, '", i, i);
3001 if (fold[i].selectable) {
3002 wprintf("<a href=\"dotgoto?room=");
3003 urlescputs(fold[i].room);
3008 wprintf("<span class=\"roomlist_floor\">");
3010 else if (fold[i].hasnewmsgs) {
3011 wprintf("<span class=\"roomlist_new\">");
3014 wprintf("<span class=\"roomlist_old\">");
3016 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3021 if (has_subfolders) {
3022 wprintf("new Array(closedGif, openGif)");
3024 else if (fold[i].view == VIEW_ADDRESSBOOK) {
3025 wprintf("'static/viewcontacts_16x.gif'");
3027 else if (fold[i].view == VIEW_CALENDAR) {
3028 wprintf("'static/calarea_16x.gif'");
3030 else if (fold[i].view == VIEW_CALBRIEF) {
3031 wprintf("'static/calarea_16x.gif'");
3033 else if (fold[i].view == VIEW_TASKS) {
3034 wprintf("'static/taskmanag_16x.gif'");
3036 else if (fold[i].view == VIEW_NOTES) {
3037 wprintf("'static/storenotes_16x.gif'");
3039 else if (fold[i].view == VIEW_MAILBOX) {
3040 wprintf("'static/privatemess_16x.gif'");
3043 wprintf("'static/chatrooms_16x.gif'");
3046 urlescputs(fold[i].name);
3050 wprintf("rootNode.addChild(node%d);\n", i);
3053 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3057 wprintf("container = document.getElementById('roomlist_div'); \n"
3063 /** END TREE MENU */
3067 * \brief Boxes and rooms and lists ... oh my!
3068 * \param fold the folder to view
3069 * \param max_folders how many folders???
3070 * \param num_floors hom many floors???
3072 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3074 char floor_name[256];
3075 char old_floor_name[256];
3077 int levels, oldlevels;
3080 static int columns = 3;
3081 int boxes_per_column = 0;
3082 int current_column = 0;
3085 strcpy(floor_name, "");
3086 strcpy(old_floor_name, "");
3089 while (nf % columns != 0) ++nf;
3090 boxes_per_column = (nf / columns);
3091 if (boxes_per_column < 1) boxes_per_column = 1;
3093 /** Outer table (for columnization) */
3094 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3095 "<tr><td valign=top>");
3099 for (i=0; i<max_folders; ++i) {
3101 levels = num_tokens(fold[i].name, '|');
3102 extract_token(floor_name, fold[i].name, 0,
3103 '|', sizeof floor_name);
3105 if ( (strcasecmp(floor_name, old_floor_name))
3106 && (!IsEmptyStr(old_floor_name)) ) {
3108 do_template("endbox");
3112 if ((num_boxes % boxes_per_column) == 0) {
3114 if (current_column < columns) {
3115 wprintf("</td><td valign=top>\n");
3119 strcpy(old_floor_name, floor_name);
3122 /** Begin inner box */
3123 stresc(boxtitle, 256, floor_name, 1, 0);
3124 svprintf(HKEY("BOXTITLE"), WCS_STRING, boxtitle);
3125 do_template("beginbox");
3132 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3133 if (fold[i].selectable) {
3134 wprintf("<a href=\"dotgoto?room=");
3135 urlescputs(fold[i].room);
3141 if (fold[i].hasnewmsgs) {
3142 wprintf("<span class=\"roomlist_new\">");
3145 wprintf("<span class=\"roomlist_old\">");
3147 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3150 if (fold[i].selectable) {
3156 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3157 wprintf(" (INBOX)");
3159 wprintf("<br />\n");
3162 /** End the final inner box */
3163 do_template("endbox");
3165 wprintf("</td></tr></table>\n");
3169 * \brief print a floor div???
3170 * \param which_floordiv name of the floordiv???
3172 void set_floordiv_expanded(char *which_floordiv) {
3173 begin_ajax_response();
3174 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
3175 end_ajax_response();
3179 * \brief view the iconbar
3180 * \param fold the folder to view
3181 * \param max_folders how many folders???
3182 * \param num_floors hom many floors???
3184 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3186 char floor_name[256];
3187 char old_floor_name[256];
3188 char floordivtitle[256];
3189 char floordiv_id[32];
3190 int levels, oldlevels;
3192 int num_drop_targets = 0;
3195 strcpy(floor_name, "");
3196 strcpy(old_floor_name, "");
3200 for (i=0; i<max_folders; ++i) {
3202 levels = num_tokens(fold[i].name, '|');
3203 extract_token(floor_name, fold[i].name, 0,
3204 '|', sizeof floor_name);
3206 if ( (strcasecmp(floor_name, old_floor_name))
3207 && (!IsEmptyStr(old_floor_name)) ) {
3208 /** End inner box */
3210 wprintf("</div>\n"); /** floordiv */
3212 strcpy(old_floor_name, floor_name);
3216 stresc(floordivtitle, 256, floor_name, 0, 0);
3217 sprintf(floordiv_id, "floordiv%d", i);
3218 wprintf("<span class=\"ib_roomlist_floor\" "
3219 "onClick=\"expand_floor('%s')\">"
3220 "%s</span><br>\n", floordiv_id, floordivtitle);
3221 wprintf("<div id=\"%s\" style=\"display:%s\">",
3223 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
3230 wprintf("<div id=\"roomdiv%d\">", i);
3232 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3234 /** choose the icon */
3235 if (fold[i].view == VIEW_ADDRESSBOOK) {
3236 icon = "viewcontacts_16x.gif" ;
3238 else if (fold[i].view == VIEW_CALENDAR) {
3239 icon = "calarea_16x.gif" ;
3241 else if (fold[i].view == VIEW_CALBRIEF) {
3242 icon = "calarea_16x.gif" ;
3244 else if (fold[i].view == VIEW_TASKS) {
3245 icon = "taskmanag_16x.gif" ;
3247 else if (fold[i].view == VIEW_NOTES) {
3248 icon = "storenotes_16x.gif" ;
3250 else if (fold[i].view == VIEW_MAILBOX) {
3251 icon = "privatemess_16x.gif" ;
3254 icon = "chatrooms_16x.gif" ;
3257 if (fold[i].selectable) {
3258 wprintf("<a href=\"dotgoto?room=");
3259 urlescputs(fold[i].room);
3261 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3266 if (fold[i].hasnewmsgs) {
3267 wprintf("<span class=\"ib_roomlist_new\">");
3270 wprintf("<span class=\"ib_roomlist_old\">");
3272 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3274 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3275 wprintf(" (INBOX)");
3278 if (fold[i].selectable) {
3285 wprintf("</div>\n"); /** roomdiv */
3288 wprintf("</div>\n"); /** floordiv */
3291 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3292 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3294 num_drop_targets = 0;
3296 for (i=0; i<max_folders; ++i) {
3297 levels = num_tokens(fold[i].name, '|');
3299 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3300 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3301 jsescputs(fold[i].room);
3307 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3308 if ((WC->floordiv_expanded[0] != '\0')&&
3309 (WC->floordiv_expanded[1] != '\0')){
3310 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
3314 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3320 * \brief Burn the cached folder list.
3321 * \param age How old the cahce needs to be before we burn it.
3324 void burn_folder_cache(time_t age)
3326 /** If our cached folder list is very old, burn it. */
3327 if (WC->cache_fold != NULL) {
3328 if ((time(NULL) - WC->cache_timestamp) > age) {
3329 free(WC->cache_fold);
3330 WC->cache_fold = NULL;
3339 * \brief Show the room list.
3340 * (only should get called by
3341 * knrooms() because that's where output_headers() is called from)
3342 * \param viewpref the view preferences???
3345 void list_all_rooms_by_floor(char *viewpref) {
3348 struct folder *fold = NULL;
3350 int max_folders = 0;
3351 int alloc_folders = 0;
3357 int num_floors = 1; /** add an extra one for private folders */
3361 /** If our cached folder list is very old, burn it. */
3362 burn_folder_cache(300);
3364 /** Can we do the iconbar roomlist from cache? */
3365 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3366 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3370 /** Grab the floor table so we know how to build the list... */
3373 /** Start with the mailboxes */
3376 fold = malloc(sizeof(struct folder));
3377 memset(fold, 0, sizeof(struct folder));
3378 strcpy(fold[0].name, "My folders");
3379 fold[0].is_mailbox = 1;
3381 /** Then add floors */
3383 serv_getln(buf, sizeof buf);
3384 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3385 if (max_folders >= alloc_folders) {
3386 alloc_folders = max_folders + 100;
3387 fold = realloc(fold,
3388 alloc_folders * sizeof(struct folder));
3390 memset(&fold[max_folders], 0, sizeof(struct folder));
3391 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3392 extract_token(buf3, buf, 0, '|', SIZ);
3393 fold[max_folders].floor = atol (buf3);
3398 for (i=0; i<num_floors; i++)
3399 if (IDMax < fold[i].floor)
3400 IDMax = fold[i].floor;
3401 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3402 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3403 for (i=0; i<num_floors; i++)
3404 floor_mapping[fold[i].floor]=i;
3406 /** refresh the messages index for this room */
3407 // serv_puts("GOTO ");
3408 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3409 /** Now add rooms */
3411 serv_getln(buf, sizeof buf);
3412 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3413 if (max_folders >= alloc_folders) {
3414 alloc_folders = max_folders + 100;
3415 fold = realloc(fold,
3416 alloc_folders * sizeof(struct folder));
3418 memset(&fold[max_folders], 0, sizeof(struct folder));
3419 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3420 ra_flags = extract_int(buf, 5);
3421 flags = extract_int(buf, 1);
3422 fold[max_folders].floor = extract_int(buf, 2);
3423 fold[max_folders].hasnewmsgs =
3424 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3425 if (flags & QR_MAILBOX) {
3426 fold[max_folders].is_mailbox = 1;
3428 fold[max_folders].view = extract_int(buf, 6);
3429 room_to_folder(fold[max_folders].name,
3430 fold[max_folders].room,
3431 fold[max_folders].floor,
3432 fold[max_folders].is_mailbox);
3433 fold[max_folders].selectable = 1;
3434 /* Increase the room count for the associtaed floor */
3435 if (fold[max_folders].is_mailbox) {
3436 fold[0].num_rooms++;
3439 i = floor_mapping[fold[max_folders].floor];
3440 fold[i].num_rooms++;
3446 * Remove any floors that don't have rooms
3448 get_preference("emptyfloors", buf2, sizeof buf2);
3449 if (buf2[0]==0 || (strcasecmp(buf2, "no") == 0))
3451 for (i=0; i<num_floors; i++)
3453 if (fold[i].num_rooms == 0) {
3454 for (j=i; j<max_folders; j++) {
3455 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3464 /** Bubble-sort the folder list */
3465 for (i=0; i<max_folders; ++i) {
3466 for (j=0; j<(max_folders-1)-i; ++j) {
3467 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3468 swap = strcasecmp(fold[j].name, fold[j+1].name);
3471 if ( (fold[j+1].is_mailbox)
3472 && (!fold[j].is_mailbox)) {
3480 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3481 memcpy(&fold[j], &fold[j+1],
3482 sizeof(struct folder));
3483 memcpy(&fold[j+1], &ftmp,
3484 sizeof(struct folder));
3490 if (!strcasecmp(viewpref, "folders")) {
3491 do_folder_view(fold, max_folders, num_floors);
3493 else if (!strcasecmp(viewpref, "hackish_view")) {
3494 for (i=0; i<max_folders; ++i) {
3495 escputs(fold[i].name);
3496 wprintf("<br />\n");
3499 else if (!strcasecmp(viewpref, "iconbar")) {
3500 do_iconbar_view(fold, max_folders, num_floors);
3503 do_rooms_view(fold, max_folders, num_floors);
3506 /* Don't free the folder list ... cache it for future use! */
3507 if (WC->cache_fold != NULL) {
3508 free(WC->cache_fold);
3510 WC->cache_fold = fold;
3511 WC->cache_max_folders = max_folders;
3512 WC->cache_num_floors = num_floors;
3513 WC->cache_timestamp = time(NULL);
3514 free(floor_mapping);
3519 * \brief Do either a known rooms list or a folders list, depending on the
3524 char listviewpref[SIZ];
3526 output_headers(1, 1, 2, 0, 0, 0);
3528 /** Determine whether the user is trying to change views */
3529 if (bstr("view") != NULL) {
3530 if (havebstr("view")) {
3531 set_preference("roomlistview", bstr("view"), 1);
3535 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3537 if ( (strcasecmp(listviewpref, "folders"))
3538 && (strcasecmp(listviewpref, "table")) ) {
3539 strcpy(listviewpref, "rooms");
3543 wprintf("<div id=\"banner\">\n");
3544 wprintf("<div class=\"room_banner\">");
3546 if (!strcasecmp(listviewpref, "rooms")) {
3547 wprintf(_("Room list"));
3549 if (!strcasecmp(listviewpref, "folders")) {
3550 wprintf(_("Folder list"));
3552 if (!strcasecmp(listviewpref, "table")) {
3553 wprintf(_("Room list"));
3555 wprintf("</h1></div>\n");
3557 /** offer the ability to switch views */
3558 wprintf("<ul class=\"room_actions\">\n");
3559 wprintf("<li class=\"start_page\">");
3562 wprintf("<li><form name=\"roomlistomatic\">\n"
3563 "<select name=\"newview\" size=\"1\" "
3564 "OnChange=\"location.href=roomlistomatic.newview.options"
3565 "[selectedIndex].value\">\n");
3567 wprintf("<option %s value=\"knrooms&view=rooms\">"
3570 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3573 wprintf("<option %s value=\"knrooms&view=folders\">"
3574 "View as folder list"
3576 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3579 wprintf("</select>");
3580 wprintf("</form></li>");
3581 wprintf("</ul></div>\n");
3583 wprintf("<div id=\"content\" class=\"service\">\n");
3585 /** Display the room list in the user's preferred format */
3586 list_all_rooms_by_floor(listviewpref);
3593 * \brief Set the message expire policy for this room and/or floor
3595 void set_room_policy(void) {
3598 if (!havebstr("ok_button")) {
3599 strcpy(WC->ImportantMessage,
3600 _("Cancelled. Changes were not saved."));
3605 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3606 serv_getln(buf, sizeof buf);
3607 strcpy(WC->ImportantMessage, &buf[4]);
3609 if (WC->axlevel >= 6) {
3610 strcat(WC->ImportantMessage, "<br />\n");
3611 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), bstr("floorvalue"));
3612 serv_getln(buf, sizeof buf);
3613 strcat(WC->ImportantMessage, &buf[4]);