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 height=48 width=48 src=\""
337 "static/viewcontacts_48x.gif"
341 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
342 wprintf("<img height=48 width=48 src=\""
343 "static/calarea_48x.gif"
347 else if (WC->wc_view == VIEW_TASKS) {
348 wprintf("<img height=48 width=48 src=\""
349 "static/taskmanag_48x.gif"
353 else if (WC->wc_view == VIEW_NOTES) {
354 wprintf("<img height=48 width=48 src=\""
355 "static/storenotes_48x.gif"
359 else if (WC->wc_view == VIEW_MAILBOX) {
360 wprintf("<img height=48 width=48 src=\""
361 "static/privatemess_48x.gif"
366 wprintf("<img height=48 width=48 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("<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></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("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
423 wprintf("<label for=\"search_name\">");
424 wprintf(_("Search: "));
425 wprintf("</label> <input "
426 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
427 "id=\"search_name\" class=\"inputbox\">\n"
429 wprintf("</form>\n");
434 * \brief Embed the room banner
436 * \param got The information returned from a GOTO server command
437 * \param navbar_style Determines which navigation buttons to display
441 void embed_room_banner(char *got, int navbar_style) {
444 char sanitized_roomname[256];
445 char with_files[256];
449 * We need to have the information returned by a GOTO server command.
450 * If it isn't supplied, we fake it by issuing our own GOTO.
453 serv_printf("GOTO %s", WC->wc_roomname);
454 serv_getln(buf, sizeof buf);
458 /** The browser needs some information for its own use */
459 wprintf("<script type=\"text/javascript\"> \n"
460 " room_is_trash = %d; \n"
466 * If the user happens to select the "make this my start page" link,
467 * we want it to remember the URL as a "/dotskip" one instead of
468 * a "skip" or "gotonext" or something like that.
470 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
473 /** Check for new mail. */
474 WC->new_mail = extract_int(&got[4], 9);
475 WC->wc_view = extract_int(&got[4], 11);
477 /* Is this a directory room and does it contain files and how many? */
478 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
481 serv_getln(buf2, sizeof buf2);
482 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
484 snprintf (with_files, sizeof with_files,
485 "; <a href=\"display_room_directory\"> %d %s </a>",
487 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
490 strcpy (with_files, "");
492 stresc(sanitized_roomname, 256, WC->wc_roomname, 1, 1);
493 svprintf("ROOMNAME", WCS_STRING, "%s", sanitized_roomname);
494 svprintf("NUMMSGS", WCS_STRING,
495 _("%d new of %d messages%s"),
496 extract_int(&got[4], 1),
497 extract_int(&got[4], 2),
500 svcallback("ROOMPIC", embed_room_graphic);
501 svcallback("ROOMINFO", readinfo);
502 svcallback("VIEWOMATIC", embed_view_o_matic);
503 svcallback("SEARCHOMATIC", embed_search_o_matic);
504 svcallback("START", offer_start_page);
506 do_template("roombanner");
507 if (navbar_style != navbar_none) {
509 wprintf("<div id=\"navbar\"><ul>");
511 if (navbar_style == navbar_default) wprintf(
512 "<li class=\"ungoto\">"
513 "<a href=\"ungoto\">"
514 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
515 "<span class=\"navbar_link\">%s</span></A>"
516 "</li>\n", _("Ungoto")
519 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
521 "<li class=\"newmess\">"
522 "<a href=\"readnew\">"
523 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
524 "<span class=\"navbar_link\">%s</span></A>"
525 "</li>\n", _("Read new messages")
529 if (navbar_style == navbar_default) {
530 switch(WC->wc_view) {
531 case VIEW_ADDRESSBOOK:
533 "<li class=\"viewcontacts\">"
534 "<a href=\"readfwd\">"
535 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
537 "<span class=\"navbar_link\">"
539 "</span></a></li>\n", _("View contacts")
544 "<li class=\"staskday\">"
545 "<a href=\"readfwd?calview=day\">"
546 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
548 "<span class=\"navbar_link\">"
550 "</span></a></li>\n", _("Day view")
553 "<li class=\"monthview\">"
554 "<a href=\"readfwd?calview=month\">"
555 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
557 "<span class=\"navbar_link\">"
559 "</span></a></li>\n", _("Month view")
564 "<li class=\"monthview\">"
565 "<a href=\"readfwd?calview=month\">"
566 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
568 "<span class=\"navbar_link\">"
570 "</span></a></li>\n", _("Calendar list")
575 "<li class=\"taskmanag\">"
576 "<a href=\"readfwd\">"
577 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
579 "<span class=\"navbar_link\">"
581 "</span></a></li>\n", _("View tasks")
586 "<li class=\"viewnotes\">"
587 "<a href=\"readfwd\">"
588 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
590 "<span class=\"navbar_link\">"
592 "</span></a></li>\n", _("View notes")
597 "<li class=\"readallmess\">"
598 "<a href=\"readfwd\">"
599 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
601 "<span class=\"navbar_link\">"
603 "</span></a></li>\n", _("View message list")
608 "<li class=\"readallmess\">"
609 "<a href=\"readfwd\">"
610 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
612 "<span class=\"navbar_link\">"
614 "</span></a></li>\n", _("Wiki home")
619 "<li class=\"readallmess\">"
620 "<a href=\"readfwd\">"
621 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
623 "<span class=\"navbar_link\">"
625 "</span></a></li>\n", _("Read all messages")
631 if (navbar_style == navbar_default) {
632 switch(WC->wc_view) {
633 case VIEW_ADDRESSBOOK:
635 "<li class=\"addnewcontact\">"
636 "<a href=\"display_enter\">"
637 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
638 "border=\"0\"><span class=\"navbar_link\">"
640 "</span></a></li>\n", _("Add new contact")
645 wprintf("<li class=\"addevent\"><a href=\"display_enter");
646 if (!IsEmptyStr(bstr("year" ))) wprintf("?year=%s", bstr("year"));
647 if (!IsEmptyStr(bstr("month"))) wprintf("?month=%s", bstr("month"));
648 if (!IsEmptyStr(bstr("day" ))) wprintf("?day=%s", bstr("day"));
650 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
651 "border=\"0\"><span class=\"navbar_link\">"
653 "</span></a></li>\n", _("Add new event")
658 "<li class=\"newmess\">"
659 "<a href=\"display_enter\">"
660 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
661 "border=\"0\"><span class=\"navbar_link\">"
663 "</span></a></li>\n", _("Add new task")
668 "<li class=\"enternewnote\">"
669 "<a href=\"javascript:add_new_note();\">"
670 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
671 "border=\"0\"><span class=\"navbar_link\">"
673 "</span></a></li>\n", _("Add new note")
677 safestrncpy(buf, bstr("page"), sizeof buf);
680 "<li class=\"newmess\">"
681 "<a href=\"display_enter?wikipage=%s\">"
682 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
683 "border=\"0\"><span class=\"navbar_link\">"
685 "</span></a></li>\n", buf, _("Edit this page")
690 "<li class=\"newmess\">"
691 "<a href=\"display_enter\">"
692 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
693 "border=\"0\"><span class=\"navbar_link\">"
695 "</span></a></li>\n", _("Write mail")
700 "<li class=\"newmess\">"
701 "<a href=\"display_enter\">"
702 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
703 "border=\"0\"><span class=\"navbar_link\">"
705 "</span></a></li>\n", _("Enter a message")
711 if (navbar_style == navbar_default) wprintf(
712 "<li class=\"skipthisroom\">"
715 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
716 "<span class=\"navbar_link\">%s</span></a>"
718 _("Leave all messages marked as unread, go to next room with unread messages"),
722 if (navbar_style == navbar_default) wprintf(
723 "<li class=\"markngo\">"
724 "<a href=\"gotonext\" "
726 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
727 "<span class=\"navbar_link\">%s</span></a>"
729 _("Mark all messages as read, go to next room with unread messages"),
733 wprintf("</ul></div>\n");
740 * \brief back end routine to take the session to a new room
741 * \param gname room to go to
744 int gotoroom(char *gname)
747 static long ls = (-1L);
750 /** store ungoto information */
751 strcpy(WC->ugname, WC->wc_roomname);
754 /** move to the new room */
755 serv_printf("GOTO %s", gname);
756 serv_getln(buf, sizeof buf);
760 serv_puts("GOTO _BASEROOM_");
761 serv_getln(buf, sizeof buf);
768 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
769 WC->room_flags = extract_int(&buf[4], 4);
770 /* highest_msg_read = extract_int(&buf[4],6);
771 maxmsgnum = extract_int(&buf[4],5);
773 WC->is_mailbox = extract_int(&buf[4],7);
774 ls = extract_long(&buf[4], 6);
775 WC->wc_floor = extract_int(&buf[4], 10);
776 WC->wc_view = extract_int(&buf[4], 11);
777 WC->wc_default_view = extract_int(&buf[4], 12);
778 WC->wc_is_trash = extract_int(&buf[4], 13);
779 WC->room_flags2 = extract_int(&buf[4], 14);
782 WC->is_room_aide = WC->is_aide;
784 WC->is_room_aide = (char) extract_int(&buf[4], 8);
786 remove_march(WC->wc_roomname);
787 if (!strcasecmp(gname, "_BASEROOM_"))
795 * \brief Locate the room on the march list which we most want to go to.
797 * is measured given a "weight" of preference based on various factors.
798 * \param desired_floor the room number on the citadel server
799 * \return the roomname
801 char *pop_march(int desired_floor)
803 static char TheRoom[128];
805 int TheOrder = 32767;
808 struct march *mptr = NULL;
810 strcpy(TheRoom, "_BASEROOM_");
811 if (WC->march == NULL)
814 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
816 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
817 weight = weight + 10000;
818 if (mptr->march_floor == desired_floor)
819 weight = weight + 5000;
821 weight = weight + ((128 - (mptr->march_floor)) * 128);
822 weight = weight + (128 - (mptr->march_order));
824 if (weight > TheWeight) {
826 strcpy(TheRoom, mptr->march_name);
827 TheFloor = mptr->march_floor;
828 TheOrder = mptr->march_order;
837 * Goto next room having unread messages.
839 * We want to skip over rooms that the user has already been to, and take the
840 * user back to the lobby when done. The room we end up in is placed in
841 * newroom - which is set to 0 (the lobby) initially.
842 * We start the search in the current room rather than the beginning to prevent
843 * two or more concurrent users from dragging each other back to the same room.
848 struct march *mptr = NULL;
849 struct march *mptr2 = NULL;
855 * First check to see if the march-mode list is already allocated.
856 * If it is, pop the first room off the list and go there.
859 if (WC->march == NULL) {
861 serv_getln(buf, sizeof buf);
863 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
864 if (IsEmptyStr(buf)) {
867 if (ELoop % 100 == 0)
872 extract_token(room_name, buf, 0, '|', sizeof room_name);
873 if (strcasecmp(room_name, WC->wc_roomname)) {
874 mptr = (struct march *) malloc(sizeof(struct march));
876 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
877 mptr->march_floor = extract_int(buf, 2);
878 mptr->march_order = extract_int(buf, 3);
879 if (WC->march == NULL)
888 * add _BASEROOM_ to the end of the march list, so the user will end up
889 * in the system base room (usually the Lobby>) at the end of the loop
891 mptr = (struct march *) malloc(sizeof(struct march));
893 mptr->march_order = 0;
894 mptr->march_floor = 0;
895 strcpy(mptr->march_name, "_BASEROOM_");
896 if (WC->march == NULL) {
900 while (mptr2->next != NULL)
905 * ...and remove the room we're currently in, so a <G>oto doesn't make us
906 * walk around in circles
908 remove_march(WC->wc_roomname);
910 if (WC->march != NULL) {
911 strcpy(next_room, pop_march(-1));
913 strcpy(next_room, "_BASEROOM_");
917 smart_goto(next_room);
924 void smart_goto(char *next_room) {
932 * mark all messages in current room as having been read
934 void slrp_highest(void)
938 serv_puts("SLRP HIGHEST");
939 serv_getln(buf, sizeof buf);
944 * un-goto the previous room
950 if (!strcmp(WC->ugname, "")) {
951 smart_goto(WC->wc_roomname);
954 serv_printf("GOTO %s", WC->ugname);
955 serv_getln(buf, sizeof buf);
957 smart_goto(WC->wc_roomname);
960 if (WC->uglsn >= 0L) {
961 serv_printf("SLRP %ld", WC->uglsn);
962 serv_getln(buf, sizeof buf);
964 strcpy(buf, WC->ugname);
965 strcpy(WC->ugname, "");
969 typedef struct __room_states {
984 * Set/clear/read the "self-service list subscribe" flag for a room
986 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
987 * returns the new value.
990 int self_service(int newval) {
991 int current_value = 0;
997 int flags, floor, order, view, flags2;
1000 serv_getln(buf, sizeof buf);
1001 if (buf[0] != '2') return(0);
1003 extract_token(name, &buf[4], 0, '|', sizeof name);
1004 extract_token(password, &buf[4], 1, '|', sizeof password);
1005 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1006 flags = extract_int(&buf[4], 3);
1007 floor = extract_int(&buf[4], 4);
1008 order = extract_int(&buf[4], 5);
1009 view = extract_int(&buf[4], 6);
1010 flags2 = extract_int(&buf[4], 7);
1012 if (flags2 & QR2_SELFLIST) {
1020 flags2 = flags2 | QR2_SELFLIST;
1022 else if (newval == 0) {
1023 flags2 = flags2 & ~QR2_SELFLIST;
1026 return(current_value);
1029 if (newval != current_value) {
1030 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1031 name, password, dirname, flags,
1032 floor, order, view, flags2);
1033 serv_getln(buf, sizeof buf);
1040 int is_selflist(room_states *RoomFlags)
1042 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1045 int is_publiclist(room_states *RoomFlags)
1047 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1050 int is_moderatedlist(room_states *RoomFlags)
1052 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1056 * Set/clear/read the "self-service list subscribe" flag for a room
1058 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1059 * returns the new value.
1062 int get_roomflags(room_states *RoomOps)
1067 serv_getln(buf, sizeof buf);
1068 if (buf[0] != '2') return(0);
1070 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1071 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1072 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1073 RoomOps->flags = extract_int(&buf[4], 3);
1074 RoomOps->floor = extract_int(&buf[4], 4);
1075 RoomOps->order = extract_int(&buf[4], 5);
1076 RoomOps->view = extract_int(&buf[4], 6);
1077 RoomOps->flags2 = extract_int(&buf[4], 7);
1081 int set_roomflags(room_states *RoomOps)
1085 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1094 serv_getln(buf, sizeof buf);
1104 * display the form for editing a room
1106 void display_editroom(void)
1111 char remote_room[128];
1114 char er_password[10];
1115 char er_dirname[15];
1116 char er_roomaide[26];
1123 char *not_shared_with;
1126 int floorpolicy = 0;
1128 char pop3_host[128];
1133 if (IsEmptyStr(tab)) tab = "admin";
1136 output_headers(1, 1, 1, 0, 0, 0);
1138 wprintf("<div class=\"fix_scrollbar_bug\">");
1140 /** print the tabbed dialog */
1141 wprintf("<ul class=\"tabbed_dialog\">\n");
1143 wprintf("<li class=\"tablabel ");
1144 if (!strcmp(tab, "admin")) {
1145 wprintf(" tab_cell_label\">");
1146 wprintf(_("Administration"));
1149 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1150 wprintf(_("Administration"));
1155 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1157 wprintf("<li class=\"tablabel ");
1158 if (!strcmp(tab, "config")) {
1159 wprintf(" tab_cell_label\">");
1160 wprintf(_("Configuration"));
1163 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1164 wprintf(_("Configuration"));
1169 wprintf("<li class=\"tablabel ");
1170 if (!strcmp(tab, "expire")) {
1171 wprintf(" tab_cell_label\">");
1172 wprintf(_("Message expire policy"));
1175 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1176 wprintf(_("Message expire policy"));
1181 wprintf("<li class=\"tablabel ");
1182 if (!strcmp(tab, "access")) {
1183 wprintf(" tab_cell_label\">");
1184 wprintf(_("Access controls"));
1187 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1188 wprintf(_("Access controls"));
1193 wprintf("<li class=\"tablabel ");
1194 if (!strcmp(tab, "sharing")) {
1195 wprintf(" tab_cell_label\">");
1196 wprintf(_("Sharing"));
1199 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1200 wprintf(_("Sharing"));
1205 wprintf("<li class=\"tablabel ");
1206 if (!strcmp(tab, "listserv")) {
1207 wprintf(" tab_cell_label\">");
1208 wprintf(_("Mailing list service"));
1211 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1212 wprintf(_("Mailing list service"));
1219 wprintf("<li class=\"tablabel ");
1220 if (!strcmp(tab, "feeds")) {
1221 wprintf(" tab_cell_label\">");
1222 wprintf(_("Remote retrieval"));
1225 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1226 wprintf(_("Remote retrieval"));
1232 /* end tabbed dialog */
1234 /* begin content of whatever tab is open now */
1236 if (!strcmp(tab, "admin")) {
1237 wprintf("<div class=\"tabcontent\">");
1239 "<li><a href=\"delete_room\" "
1240 "onClick=\"return confirm('");
1241 wprintf(_("Are you sure you want to delete this room?"));
1242 wprintf("');\">\n");
1243 wprintf(_("Delete this room"));
1245 "<li><a href=\"display_editroompic\">\n");
1246 wprintf(_("Set or change the icon for this room's banner"));
1248 "<li><a href=\"display_editinfo\">\n");
1249 wprintf(_("Edit this room's Info file"));
1255 if (!strcmp(tab, "config")) {
1256 wprintf("<div class=\"tabcontent\">");
1258 serv_getln(buf, sizeof buf);
1260 if (!strncmp(buf, "550", 3)) {
1261 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1262 _("Higher access is required to access this function.")
1265 else if (buf[0] != '2') {
1266 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1269 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1270 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1271 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1272 er_flags = extract_int(&buf[4], 3);
1273 er_floor = extract_int(&buf[4], 4);
1274 er_flags2 = extract_int(&buf[4], 7);
1276 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1277 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1279 wprintf("<ul><li>");
1280 wprintf(_("Name of room: "));
1281 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1287 wprintf(_("Resides on floor: "));
1288 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1289 if (er_flags & QR_MAILBOX)
1290 wprintf("disabled >\n");
1291 for (i = 0; i < 128; ++i)
1292 if (!IsEmptyStr(floorlist[i])) {
1293 wprintf("<OPTION ");
1295 wprintf("SELECTED ");
1296 wprintf("VALUE=\"%d\">", i);
1297 escputs(floorlist[i]);
1298 wprintf("</OPTION>\n");
1300 wprintf("</select>\n");
1303 wprintf(_("Type of room:"));
1306 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1307 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1308 wprintf("CHECKED ");
1309 wprintf("OnChange=\""
1310 " if (this.form.type[0].checked == true) { "
1311 " this.form.er_floor.disabled = false; "
1314 wprintf(_("Public (automatically appears to everyone)"));
1317 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1318 if ((er_flags & QR_PRIVATE) &&
1319 (er_flags & QR_GUESSNAME))
1320 wprintf("CHECKED ");
1321 wprintf(" OnChange=\""
1322 " if (this.form.type[1].checked == true) { "
1323 " this.form.er_floor.disabled = false; "
1326 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1328 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1329 if ((er_flags & QR_PRIVATE) &&
1330 (er_flags & QR_PASSWORDED))
1331 wprintf("CHECKED ");
1332 wprintf(" OnChange=\""
1333 " if (this.form.type[2].checked == true) { "
1334 " this.form.er_floor.disabled = false; "
1337 wprintf(_("Private - require password: "));
1338 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1341 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1342 if ((er_flags & QR_PRIVATE)
1343 && ((er_flags & QR_GUESSNAME) == 0)
1344 && ((er_flags & QR_PASSWORDED) == 0))
1345 wprintf("CHECKED ");
1346 wprintf(" OnChange=\""
1347 " if (this.form.type[3].checked == true) { "
1348 " this.form.er_floor.disabled = false; "
1351 wprintf(_("Private - invitation only"));
1353 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1354 if (er_flags & QR_MAILBOX)
1355 wprintf("CHECKED ");
1356 wprintf (" OnChange=\""
1357 " if (this.form.type[4].checked == true) { "
1358 " this.form.er_floor.disabled = true; "
1361 wprintf(_("Personal (mailbox for you only)"));
1363 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1365 wprintf(_("If private, cause current users to forget room"));
1367 wprintf("\n</ul>\n");
1369 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1370 if (er_flags & QR_PREFONLY)
1371 wprintf("CHECKED ");
1373 wprintf(_("Preferred users only"));
1375 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1376 if (er_flags & QR_READONLY)
1377 wprintf("CHECKED ");
1379 wprintf(_("Read-only room"));
1381 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1382 if (er_flags2 & QR2_COLLABDEL)
1383 wprintf("CHECKED ");
1385 wprintf(_("All users allowed to post may also delete messages"));
1387 /** directory stuff */
1388 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1389 if (er_flags & QR_DIRECTORY)
1390 wprintf("CHECKED ");
1392 wprintf(_("File directory room"));
1394 wprintf("\n<ul><li>");
1395 wprintf(_("Directory name: "));
1396 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1399 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1400 if (er_flags & QR_UPLOAD)
1401 wprintf("CHECKED ");
1403 wprintf(_("Uploading allowed"));
1405 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1406 if (er_flags & QR_DOWNLOAD)
1407 wprintf("CHECKED ");
1409 wprintf(_("Downloading allowed"));
1411 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1412 if (er_flags & QR_VISDIR)
1413 wprintf("CHECKED ");
1415 wprintf(_("Visible directory"));
1418 /** end of directory stuff */
1420 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1421 if (er_flags & QR_NETWORK)
1422 wprintf("CHECKED ");
1424 wprintf(_("Network shared room"));
1426 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1427 if (er_flags & QR_PERMANENT)
1428 wprintf("CHECKED ");
1430 wprintf(_("Permanent (does not auto-purge)"));
1432 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1433 if (er_flags2 & QR2_SUBJECTREQ)
1434 wprintf("CHECKED ");
1436 wprintf(_("Subject Required (Force users to specify a message subject)"));
1438 /** start of anon options */
1441 wprintf(_("Anonymous messages"));
1444 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1445 if (((er_flags & QR_ANONONLY) == 0)
1446 && ((er_flags & QR_ANONOPT) == 0))
1447 wprintf("CHECKED ");
1449 wprintf(_("No anonymous messages"));
1451 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1452 if (er_flags & QR_ANONONLY)
1453 wprintf("CHECKED ");
1455 wprintf(_("All messages are anonymous"));
1457 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1458 if (er_flags & QR_ANONOPT)
1459 wprintf("CHECKED ");
1461 wprintf(_("Prompt user when entering messages"));
1464 /* end of anon options */
1467 wprintf(_("Room aide: "));
1469 serv_getln(buf, sizeof buf);
1470 if (buf[0] != '2') {
1471 wprintf("<em>%s</em>\n", &buf[4]);
1473 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1474 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1477 wprintf("</ul><CENTER>\n");
1478 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1479 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1481 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1491 /* Sharing the room with other Citadel nodes... */
1492 if (!strcmp(tab, "sharing")) {
1493 wprintf("<div class=\"tabcontent\">");
1495 shared_with = strdup("");
1496 not_shared_with = strdup("");
1498 /** Learn the current configuration */
1499 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1500 serv_getln(buf, sizeof buf);
1501 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1502 extract_token(node, buf, 0, '|', sizeof node);
1503 not_shared_with = realloc(not_shared_with,
1504 strlen(not_shared_with) + 32);
1505 strcat(not_shared_with, node);
1506 strcat(not_shared_with, "\n");
1510 serv_getln(buf, sizeof buf);
1511 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1512 extract_token(cmd, buf, 0, '|', sizeof cmd);
1513 extract_token(node, buf, 1, '|', sizeof node);
1514 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1515 if (!strcasecmp(cmd, "ignet_push_share")) {
1516 shared_with = realloc(shared_with,
1517 strlen(shared_with) + 32);
1518 strcat(shared_with, node);
1519 if (!IsEmptyStr(remote_room)) {
1520 strcat(shared_with, "|");
1521 strcat(shared_with, remote_room);
1523 strcat(shared_with, "\n");
1527 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1528 extract_token(buf, shared_with, i, '\n', sizeof buf);
1529 extract_token(node, buf, 0, '|', sizeof node);
1530 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1531 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1532 if (!strcasecmp(node, cmd)) {
1533 remove_token(not_shared_with, j, '\n');
1538 /* Display the stuff */
1539 wprintf("<CENTER><br />"
1540 "<table border=1 cellpadding=5><tr>"
1542 wprintf(_("Shared with"));
1543 wprintf("</I></B></td>"
1545 wprintf(_("Not shared with"));
1546 wprintf("</I></B></td></tr>\n"
1547 "<tr><td VALIGN=TOP>\n");
1549 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1550 wprintf(_("Remote node name"));
1551 wprintf("</td><td>");
1552 wprintf(_("Remote room name"));
1553 wprintf("</td><td>");
1554 wprintf(_("Actions"));
1555 wprintf("</td></tr>\n");
1557 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1558 extract_token(buf, shared_with, i, '\n', sizeof buf);
1559 extract_token(node, buf, 0, '|', sizeof node);
1560 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1561 if (!IsEmptyStr(node)) {
1562 wprintf("<form method=\"POST\" action=\"netedit\">");
1563 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1564 wprintf("<tr><td>%s</td>\n", node);
1567 if (!IsEmptyStr(remote_room)) {
1568 escputs(remote_room);
1574 wprintf("<input type=\"hidden\" NAME=\"line\" "
1575 "VALUE=\"ignet_push_share|");
1577 if (!IsEmptyStr(remote_room)) {
1579 urlescputs(remote_room);
1582 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1583 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1584 wprintf("<input type=\"submit\" "
1585 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1586 wprintf("</td></tr></form>\n");
1590 wprintf("</table>\n");
1591 wprintf("</td><td VALIGN=TOP>\n");
1592 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1593 wprintf(_("Remote node name"));
1594 wprintf("</td><td>");
1595 wprintf(_("Remote room name"));
1596 wprintf("</td><td>");
1597 wprintf(_("Actions"));
1598 wprintf("</td></tr>\n");
1600 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1601 extract_token(node, not_shared_with, i, '\n', sizeof node);
1602 if (!IsEmptyStr(node)) {
1603 wprintf("<form method=\"POST\" action=\"netedit\">");
1604 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1605 wprintf("<tr><td>");
1608 "<input type=\"INPUT\" "
1612 wprintf("<input type=\"hidden\" "
1614 "VALUE=\"ignet_push_share|");
1617 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1618 "VALUE=\"sharing\">\n");
1619 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1620 "VALUE=\"add\">\n");
1621 wprintf("<input type=\"submit\" "
1622 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1623 wprintf("</td></tr></form>\n");
1627 wprintf("</table>\n");
1628 wprintf("</td></tr>"
1629 "</table></CENTER><br />\n"
1630 "<I><B>%s</B><ul><li>", _("Notes:"));
1631 wprintf(_("When sharing a room, "
1632 "it must be shared from both ends. Adding a node to "
1633 "the 'shared' list sends messages out, but in order to"
1634 " receive messages, the other nodes must be configured"
1635 " to send messages out to your system as well. "
1636 "<li>If the remote room name is blank, it is assumed "
1637 "that the room name is identical on the remote node."
1638 "<li>If the remote room name is different, the remote "
1639 "node must also configure the name of the room here."
1646 /* Mailing list management */
1647 if (!strcmp(tab, "listserv")) {
1648 room_states RoomFlags;
1649 wprintf("<div class=\"tabcontent\">");
1651 wprintf("<br /><center>"
1652 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1653 "<tr><td VALIGN=TOP>");
1655 wprintf(_("<i>The contents of this room are being "
1656 "mailed <b>as individual messages</b> "
1657 "to the following list recipients:"
1658 "</i><br /><br />\n"));
1661 serv_getln(buf, sizeof buf);
1662 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1663 extract_token(cmd, buf, 0, '|', sizeof cmd);
1664 if (!strcasecmp(cmd, "listrecp")) {
1665 extract_token(recp, buf, 1, '|', sizeof recp);
1668 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1671 wprintf(_("(remove)"));
1672 wprintf("</A><br />");
1675 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1676 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1677 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1678 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1679 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1680 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1681 wprintf("</form>\n");
1683 wprintf("</td><td VALIGN=TOP>\n");
1685 wprintf(_("<i>The contents of this room are being "
1686 "mailed <b>in digest form</b> "
1687 "to the following list recipients:"
1688 "</i><br /><br />\n"));
1691 serv_getln(buf, sizeof buf);
1692 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1693 extract_token(cmd, buf, 0, '|', sizeof cmd);
1694 if (!strcasecmp(cmd, "digestrecp")) {
1695 extract_token(recp, buf, 1, '|', sizeof recp);
1698 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1702 wprintf(_("(remove)"));
1703 wprintf("</A><br />");
1706 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1707 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1708 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1709 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1710 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1711 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1712 wprintf("</form>\n");
1714 wprintf("</td></tr></table>\n");
1716 /** Pop open an address book -- begin **/
1717 wprintf("<div align=right>"
1718 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1720 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1725 _("Add recipients from Contacts or other address books"),
1726 _("Add recipients from Contacts or other address books")
1728 /* Pop open an address book -- end **/
1730 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1732 get_roomflags (&RoomFlags);
1734 /* Self Service subscription? */
1735 wprintf("<table><tr><td>\n");
1736 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1737 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1738 " <tr><td colspan=\"2\">\n",
1739 (is_selflist(&RoomFlags))?"checked":"");
1740 wprintf(_("The URL for subscribe/unsubscribe is: "));
1741 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1742 (is_https ? "https" : "http"),
1744 /* Public posting? */
1745 wprintf("<tr><td>");
1746 wprintf(_("Allow non-subscribers to mail to this room."));
1747 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1748 (is_publiclist(&RoomFlags))?"checked":"");
1750 /* Moderated List? */
1751 wprintf("<tr><td>");
1752 wprintf(_("Room post publication needs Aide permission."));
1753 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1754 (is_moderatedlist(&RoomFlags))?"checked":"");
1757 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1758 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1759 wprintf("</table></form>");
1762 wprintf("</CENTER>\n");
1767 /* Configuration of The Dreaded Auto-Purger */
1768 if (!strcmp(tab, "expire")) {
1769 wprintf("<div class=\"tabcontent\">");
1771 serv_puts("GPEX room");
1772 serv_getln(buf, sizeof buf);
1773 if (!strncmp(buf, "550", 3)) {
1774 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1775 _("Higher access is required to access this function.")
1778 else if (buf[0] != '2') {
1779 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1782 roompolicy = extract_int(&buf[4], 0);
1783 roomvalue = extract_int(&buf[4], 1);
1785 serv_puts("GPEX floor");
1786 serv_getln(buf, sizeof buf);
1787 if (buf[0] == '2') {
1788 floorpolicy = extract_int(&buf[4], 0);
1789 floorvalue = extract_int(&buf[4], 1);
1792 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1793 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1794 wprintf("<table border=0 cellspacing=5>\n");
1795 wprintf("<tr><td>");
1796 wprintf(_("Message expire policy for this room"));
1798 escputs(WC->wc_roomname);
1799 wprintf(")</td><td>");
1800 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1801 ((roompolicy == 0) ? "CHECKED" : "") );
1802 wprintf(_("Use the default policy for this floor"));
1803 wprintf("<br />\n");
1804 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1805 ((roompolicy == 1) ? "CHECKED" : "") );
1806 wprintf(_("Never automatically expire messages"));
1807 wprintf("<br />\n");
1808 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1809 ((roompolicy == 2) ? "CHECKED" : "") );
1810 wprintf(_("Expire by message count"));
1811 wprintf("<br />\n");
1812 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1813 ((roompolicy == 3) ? "CHECKED" : "") );
1814 wprintf(_("Expire by message age"));
1816 wprintf(_("Number of messages or days: "));
1817 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1818 wprintf("</td></tr>\n");
1820 if (WC->axlevel >= 6) {
1821 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1822 wprintf("<tr><td>");
1823 wprintf(_("Message expire policy for this floor"));
1825 escputs(floorlist[WC->wc_floor]);
1826 wprintf(")</td><td>");
1827 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1828 ((floorpolicy == 0) ? "CHECKED" : "") );
1829 wprintf(_("Use the system default"));
1830 wprintf("<br />\n");
1831 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1832 ((floorpolicy == 1) ? "CHECKED" : "") );
1833 wprintf(_("Never automatically expire messages"));
1834 wprintf("<br />\n");
1835 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1836 ((floorpolicy == 2) ? "CHECKED" : "") );
1837 wprintf(_("Expire by message count"));
1838 wprintf("<br />\n");
1839 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1840 ((floorpolicy == 3) ? "CHECKED" : "") );
1841 wprintf(_("Expire by message age"));
1843 wprintf(_("Number of messages or days: "));
1844 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1848 wprintf("<CENTER>\n");
1849 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1850 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1852 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1853 wprintf("</CENTER></td><tr>\n");
1855 wprintf("</table>\n"
1856 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1864 /* Access controls */
1865 if (!strcmp(tab, "access")) {
1866 wprintf("<div class=\"tabcontent\">");
1871 /* Fetch messages from remote locations */
1872 if (!strcmp(tab, "feeds")) {
1873 wprintf("<div class=\"tabcontent\">");
1876 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1877 wprintf("</i><br />\n");
1879 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1880 "<tr class=\"even\"><th>");
1881 wprintf(_("Remote host"));
1882 wprintf("</th><th>");
1883 wprintf(_("User name"));
1884 wprintf("</th><th>");
1885 wprintf(_("Password"));
1886 wprintf("</th><th>");
1887 wprintf(_("Keep messages on server?"));
1888 wprintf("</th><th> </th></tr>");
1891 serv_getln(buf, sizeof buf);
1893 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1894 extract_token(cmd, buf, 0, '|', sizeof cmd);
1895 if (!strcasecmp(cmd, "pop3client")) {
1896 safestrncpy(recp, &buf[11], sizeof recp);
1899 wprintf("<tr class=\"%s\">",
1900 (bg ? "even" : "odd")
1904 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1909 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1913 wprintf("<td>*****</td>"); /* Don't show the password */
1915 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1917 wprintf("<td class=\"button_link\">");
1918 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1921 wprintf(_("(remove)"));
1922 wprintf("</a></td>");
1928 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1930 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1931 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1932 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1934 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1937 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1940 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1943 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1946 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1947 wprintf("</td></tr>");
1948 wprintf("</form></table>\n");
1953 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1954 wprintf("</i><br />\n");
1956 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1957 "<tr class=\"even\"><th>");
1958 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1959 wprintf(_("Feed URL"));
1960 wprintf("</th><th>");
1961 wprintf("</th></tr>");
1964 serv_getln(buf, sizeof buf);
1966 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1967 extract_token(cmd, buf, 0, '|', sizeof cmd);
1968 if (!strcasecmp(cmd, "rssclient")) {
1969 safestrncpy(recp, &buf[10], sizeof recp);
1972 wprintf("<tr class=\"%s\">",
1973 (bg ? "even" : "odd")
1977 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1981 wprintf("<td class=\"button_link\">");
1982 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=rssclient|");
1985 wprintf(_("(remove)"));
1986 wprintf("</a></td>");
1992 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1994 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1995 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
1996 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1998 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
1999 "maxlength=\"256\" name=\"line_pop3host\">\n");
2002 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2003 wprintf("</td></tr>");
2004 wprintf("</form></table>\n");
2010 /* end content of whatever tab is open now */
2011 wprintf("</div>\n");
2013 address_book_popup();
2019 * Toggle self-service list subscription
2021 void toggle_self_service(void) {
2022 room_states RoomFlags;
2024 get_roomflags (&RoomFlags);
2026 /* Yank out the bits we want to change */
2027 RoomFlags.flags2 = RoomFlags.flags2 &
2028 !(QR2_SELFLIST|QR2_SMTP_PUBLIC|QR2_MODERATED);
2030 if (!strcasecmp(bstr("QR2_SelfList"), "yes"))
2031 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2032 if (!strcasecmp(bstr("QR2_SMTP_PUBLIC"), "yes"))
2033 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2034 if (!strcasecmp(bstr("QR2_Moderated"), "yes"))
2035 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2037 set_roomflags (&RoomFlags);
2045 * save new parameters for a room
2051 char er_password[10];
2052 char er_dirname[15];
2053 char er_roomaide[26];
2056 int er_listingorder;
2062 if (IsEmptyStr(bstr("ok_button"))) {
2063 strcpy(WC->ImportantMessage,
2064 _("Cancelled. Changes were not saved."));
2069 serv_getln(buf, sizeof buf);
2071 if (buf[0] != '2') {
2072 strcpy(WC->ImportantMessage, &buf[4]);
2076 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
2077 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
2078 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
2079 er_flags = extract_int(&buf[4], 3);
2080 er_listingorder = extract_int(&buf[4], 5);
2081 er_defaultview = extract_int(&buf[4], 6);
2082 er_flags2 = extract_int(&buf[4], 7);
2084 strcpy(er_roomaide, bstr("er_roomaide"));
2085 if (IsEmptyStr(er_roomaide)) {
2087 serv_getln(buf, sizeof buf);
2088 if (buf[0] != '2') {
2089 strcpy(er_roomaide, "");
2091 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
2094 strcpy(buf, bstr("er_name"));
2096 if (!IsEmptyStr(buf)) {
2097 strcpy(er_name, buf);
2100 strcpy(buf, bstr("er_password"));
2102 if (!IsEmptyStr(buf))
2103 strcpy(er_password, buf);
2105 strcpy(buf, bstr("er_dirname"));
2107 if (!IsEmptyStr(buf))
2108 strcpy(er_dirname, buf);
2110 strcpy(buf, bstr("type"));
2111 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2113 if (!strcmp(buf, "invonly")) {
2114 er_flags |= (QR_PRIVATE);
2116 if (!strcmp(buf, "hidden")) {
2117 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2119 if (!strcmp(buf, "passworded")) {
2120 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2122 if (!strcmp(buf, "personal")) {
2123 er_flags |= QR_MAILBOX;
2125 er_flags &= ~QR_MAILBOX;
2128 if (!strcmp(bstr("prefonly"), "yes")) {
2129 er_flags |= QR_PREFONLY;
2131 er_flags &= ~QR_PREFONLY;
2134 if (!strcmp(bstr("readonly"), "yes")) {
2135 er_flags |= QR_READONLY;
2137 er_flags &= ~QR_READONLY;
2141 if (!strcmp(bstr("collabdel"), "yes")) {
2142 er_flags2 |= QR2_COLLABDEL;
2144 er_flags2 &= ~QR2_COLLABDEL;
2147 if (!strcmp(bstr("permanent"), "yes")) {
2148 er_flags |= QR_PERMANENT;
2150 er_flags &= ~QR_PERMANENT;
2153 if (!strcmp(bstr("subjectreq"), "yes")) {
2154 er_flags2 |= QR2_SUBJECTREQ;
2156 er_flags2 &= ~QR2_SUBJECTREQ;
2159 if (!strcmp(bstr("network"), "yes")) {
2160 er_flags |= QR_NETWORK;
2162 er_flags &= ~QR_NETWORK;
2165 if (!strcmp(bstr("directory"), "yes")) {
2166 er_flags |= QR_DIRECTORY;
2168 er_flags &= ~QR_DIRECTORY;
2171 if (!strcmp(bstr("ulallowed"), "yes")) {
2172 er_flags |= QR_UPLOAD;
2174 er_flags &= ~QR_UPLOAD;
2177 if (!strcmp(bstr("dlallowed"), "yes")) {
2178 er_flags |= QR_DOWNLOAD;
2180 er_flags &= ~QR_DOWNLOAD;
2183 if (!strcmp(bstr("visdir"), "yes")) {
2184 er_flags |= QR_VISDIR;
2186 er_flags &= ~QR_VISDIR;
2189 strcpy(buf, bstr("anon"));
2191 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2192 if (!strcmp(buf, "anononly"))
2193 er_flags |= QR_ANONONLY;
2194 if (!strcmp(buf, "anon2"))
2195 er_flags |= QR_ANONOPT;
2198 if (!strcmp(bstr("bump"), "yes"))
2201 er_floor = atoi(bstr("er_floor"));
2203 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2204 er_name, er_password, er_dirname, er_flags, bump, er_floor,
2205 er_listingorder, er_defaultview, er_flags2);
2207 serv_getln(buf, sizeof buf);
2208 if (buf[0] != '2') {
2209 strcpy(WC->ImportantMessage, &buf[4]);
2215 if (!IsEmptyStr(er_roomaide)) {
2216 sprintf(buf, "SETA %s", er_roomaide);
2218 serv_getln(buf, sizeof buf);
2219 if (buf[0] != '2') {
2220 strcpy(WC->ImportantMessage, &buf[4]);
2221 display_main_menu();
2226 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2233 * Display form for Invite, Kick, and show Who Knows a room
2235 void do_invt_kick(void) {
2236 char buf[SIZ], room[SIZ], username[SIZ];
2239 serv_getln(buf, sizeof buf);
2241 if (buf[0] != '2') {
2245 extract_token(room, &buf[4], 0, '|', sizeof room);
2247 strcpy(username, bstr("username"));
2249 if (!IsEmptyStr(bstr("kick_button"))) {
2250 sprintf(buf, "KICK %s", username);
2252 serv_getln(buf, sizeof buf);
2254 if (buf[0] != '2') {
2255 strcpy(WC->ImportantMessage, &buf[4]);
2257 sprintf(WC->ImportantMessage,
2258 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2263 if (!IsEmptyStr(bstr("invite_button"))) {
2264 sprintf(buf, "INVT %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 invited to room %s.</I></B>\n"),
2283 * Display form for Invite, Kick, and show Who Knows a room
2285 void display_whok(void)
2287 char buf[SIZ], room[SIZ], username[SIZ];
2290 serv_getln(buf, sizeof buf);
2292 if (buf[0] != '2') {
2296 extract_token(room, &buf[4], 0, '|', sizeof room);
2299 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2300 wprintf(_("The users listed below have access to this room. "
2301 "To remove a user from the access list, select the user "
2302 "name from the list and click 'Kick'."));
2303 wprintf("<br /><br />");
2305 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2306 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2307 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2308 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2310 serv_getln(buf, sizeof buf);
2311 if (buf[0] == '1') {
2312 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2313 extract_token(username, buf, 0, '|', sizeof username);
2314 wprintf("<OPTION>");
2319 wprintf("</select><br />\n");
2321 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2322 wprintf("</form></CENTER>\n");
2324 wprintf("</td><td>");
2325 wprintf(_("To grant another user access to this room, enter the "
2326 "user name in the box below and click 'Invite'."));
2327 wprintf("<br /><br />");
2329 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2330 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2331 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2332 wprintf(_("Invite:"));
2334 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2335 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2336 "<input type=\"submit\" value=\"%s\">"
2337 "</form></CENTER>\n", _("Invite"));
2338 /* Pop open an address book -- begin **/
2340 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2342 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2345 _("Users"), _("Users")
2347 /* Pop open an address book -- end **/
2349 wprintf("</td></tr></table>\n");
2350 address_book_popup();
2357 * display the form for entering a new room
2359 void display_entroom(void)
2364 serv_puts("CRE8 0");
2365 serv_getln(buf, sizeof buf);
2367 if (buf[0] != '2') {
2368 strcpy(WC->ImportantMessage, &buf[4]);
2369 display_main_menu();
2373 output_headers(1, 1, 1, 0, 0, 0);
2375 svprintf("BOXTITLE", WCS_STRING, _("Create a new room"));
2376 do_template("beginbox");
2378 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2379 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2381 wprintf("<table class=\"altern\"> ");
2383 wprintf("<tr class=\"even\"><td>");
2384 wprintf(_("Name of room: "));
2385 wprintf("</td><td>");
2386 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2387 wprintf("</td></tr>");
2389 wprintf("<tr class=\"odd\"><td>");
2390 wprintf(_("Resides on floor: "));
2391 wprintf("</td><td>");
2393 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2394 for (i = 0; i < 128; ++i)
2395 if (!IsEmptyStr(floorlist[i])) {
2396 wprintf("<option ");
2397 wprintf("value=\"%d\">", i);
2398 escputs(floorlist[i]);
2399 wprintf("</option>\n");
2401 wprintf("</select>\n");
2402 wprintf("</td></tr>");
2405 * Our clever little snippet of JavaScript automatically selects
2406 * a public room if the view is set to Bulletin Board or wiki, and
2407 * it selects a mailbox room otherwise. The user can override this,
2408 * of course. We also disable the floor selector for mailboxes.
2410 wprintf("<tr class=\"even\"><td>");
2411 wprintf(_("Default view for room: "));
2412 wprintf("</td><td>");
2413 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2414 " if ( (this.form.er_view.value == 0) "
2415 " || (this.form.er_view.value == 6) ) { "
2416 " this.form.type[0].checked=true; "
2417 " this.form.er_floor.disabled = false; "
2420 " this.form.type[4].checked=true; "
2421 " this.form.er_floor.disabled = true; "
2424 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2425 if (is_view_allowed_as_default(i)) {
2426 wprintf("<option %s value=\"%d\">",
2427 ((i == 0) ? "selected" : ""), i );
2428 escputs(viewdefs[i]);
2429 wprintf("</option>\n");
2432 wprintf("</select>\n");
2433 wprintf("</td></tr>");
2435 wprintf("<tr class=\"even\"><td>");
2436 wprintf(_("Type of room:"));
2437 wprintf("</td><td>");
2438 wprintf("<ul class=\"adminlist\">\n");
2440 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2441 wprintf("CHECKED OnChange=\""
2442 " if (this.form.type[0].checked == true) { "
2443 " this.form.er_floor.disabled = false; "
2446 wprintf(_("Public (automatically appears to everyone)"));
2449 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2450 " if (this.form.type[1].checked == true) { "
2451 " this.form.er_floor.disabled = false; "
2454 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2457 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2458 " if (this.form.type[2].checked == true) { "
2459 " this.form.er_floor.disabled = false; "
2462 wprintf(_("Private - require password: "));
2463 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2466 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2467 " if (this.form.type[3].checked == true) { "
2468 " this.form.er_floor.disabled = false; "
2471 wprintf(_("Private - invitation only"));
2474 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2476 " if (this.form.type[4].checked == true) { "
2477 " this.form.er_floor.disabled = true; "
2480 wprintf(_("Personal (mailbox for you only)"));
2483 wprintf("\n</ul>\n");
2484 wprintf("</td></tr></table>\n");
2486 wprintf("<div class=\"buttons\">\n");
2487 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2489 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2490 wprintf("</div>\n");
2491 wprintf("</form>\n<hr />");
2492 serv_printf("MESG roomaccess");
2493 serv_getln(buf, sizeof buf);
2494 if (buf[0] == '1') {
2498 do_template("endbox");
2507 * support function for entroom() -- sets the default view
2509 void er_set_default_view(int newview) {
2522 serv_getln(buf, sizeof buf);
2523 if (buf[0] != '2') return;
2525 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2526 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2527 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2528 rm_bits1 = extract_int(&buf[4], 3);
2529 rm_floor = extract_int(&buf[4], 4);
2530 rm_listorder = extract_int(&buf[4], 5);
2531 rm_bits2 = extract_int(&buf[4], 7);
2533 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2534 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2535 rm_listorder, newview, rm_bits2
2537 serv_getln(buf, sizeof buf);
2550 char er_password[SIZ];
2555 if (IsEmptyStr(bstr("ok_button"))) {
2556 strcpy(WC->ImportantMessage,
2557 _("Cancelled. No new room was created."));
2558 display_main_menu();
2561 strcpy(er_name, bstr("er_name"));
2562 strcpy(er_type, bstr("type"));
2563 strcpy(er_password, bstr("er_password"));
2564 er_floor = atoi(bstr("er_floor"));
2565 er_view = atoi(bstr("er_view"));
2568 if (!strcmp(er_type, "hidden"))
2570 if (!strcmp(er_type, "passworded"))
2572 if (!strcmp(er_type, "invonly"))
2574 if (!strcmp(er_type, "personal"))
2577 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2578 er_name, er_num_type, er_password, er_floor, 0, er_view);
2580 serv_getln(buf, sizeof buf);
2581 if (buf[0] != '2') {
2582 strcpy(WC->ImportantMessage, &buf[4]);
2583 display_main_menu();
2586 /** TODO: Room created, now udate the left hand icon bar for this user */
2587 burn_folder_cache(0); /* burn the old folder cache */
2591 do_change_view(er_view); /* Now go there */
2596 * \brief display the screen to enter a private room
2598 void display_private(char *rname, int req_pass)
2600 output_headers(1, 1, 1, 0, 0, 0);
2602 svprintf("BOXTITLE", WCS_STRING, _("Go to a hidden room"));
2603 do_template("beginbox");
2606 wprintf(_("If you know the name of a hidden (guess-name) or "
2607 "passworded room, you can enter that room by typing "
2608 "its name below. Once you gain access to a private "
2609 "room, it will appear in your regular room listings "
2610 "so you don't have to keep returning here."));
2613 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2614 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2616 wprintf("<table class=\"altern\"> "
2617 "<tr class=\"even\"><td>");
2618 wprintf(_("Enter room name:"));
2620 "<input type=\"text\" name=\"gr_name\" "
2621 "value=\"%s\" maxlength=\"128\">\n", rname);
2624 wprintf("</td></tr><tr class=\"odd\"><td>");
2625 wprintf(_("Enter room password:"));
2626 wprintf("</td><td>");
2627 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2629 wprintf("</td></tr></table>\n");
2631 wprintf("<div class=\"buttons\">\n");
2632 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2634 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2638 wprintf("</div></form>\n");
2640 do_template("endbox");
2646 * \brief goto a private room
2648 void goto_private(void)
2653 if (IsEmptyStr(bstr("ok_button"))) {
2654 display_main_menu();
2657 strcpy(hold_rm, WC->wc_roomname);
2658 strcpy(buf, "GOTO ");
2659 strcat(buf, bstr("gr_name"));
2661 strcat(buf, bstr("gr_pass"));
2663 serv_getln(buf, sizeof buf);
2665 if (buf[0] == '2') {
2666 smart_goto(bstr("gr_name"));
2669 if (!strncmp(buf, "540", 3)) {
2670 display_private(bstr("gr_name"), 1);
2673 output_headers(1, 1, 1, 0, 0, 0);
2674 wprintf("%s\n", &buf[4]);
2681 * \brief display the screen to zap a room
2683 void display_zap(void)
2685 output_headers(1, 1, 2, 0, 0, 0);
2687 wprintf("<div id=\"banner\">\n");
2689 wprintf(_("Zap (forget/unsubscribe) the current room"));
2691 wprintf("</div>\n");
2693 wprintf("<div id=\"content\" class=\"service\">\n");
2695 wprintf(_("If you select this option, <em>%s</em> will "
2696 "disappear from your room list. Is this what you wish "
2697 "to do?<br />\n"), WC->wc_roomname);
2699 wprintf("<form method=\"POST\" action=\"zap\">\n");
2700 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2701 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2703 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2704 wprintf("</form>\n");
2715 char final_destination[SIZ];
2718 * If the forget-room routine fails for any reason, we fall back
2719 * to the current room; otherwise, we go to the Lobby
2721 strcpy(final_destination, WC->wc_roomname);
2723 if (!IsEmptyStr(bstr("ok_button"))) {
2724 serv_printf("GOTO %s", WC->wc_roomname);
2725 serv_getln(buf, sizeof buf);
2726 if (buf[0] == '2') {
2728 serv_getln(buf, sizeof buf);
2729 if (buf[0] == '2') {
2730 strcpy(final_destination, "_BASEROOM_");
2734 smart_goto(final_destination);
2740 * \brief Delete the current room
2742 void delete_room(void)
2747 serv_puts("KILL 1");
2748 serv_getln(buf, sizeof buf);
2749 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2750 if (buf[0] != '2') {
2751 strcpy(WC->ImportantMessage, &buf[4]);
2752 display_main_menu();
2755 smart_goto("_BASEROOM_");
2762 * \brief Perform changes to a room's network configuration
2764 void netedit(void) {
2774 if (!IsEmptyStr(bstr("line_pop3host"))) {
2775 strcpy(line, bstr("prefix"));
2776 strcat(line, bstr("line_pop3host"));
2778 strcat(line, bstr("line_pop3user"));
2780 strcat(line, bstr("line_pop3pass"));
2782 strcat(line, atoi(bstr("line_pop3keep")) ? "1" : "0" );
2783 strcat(line, bstr("suffix"));
2785 else if (!IsEmptyStr(bstr("line"))) {
2786 strcpy(line, bstr("prefix"));
2787 strcat(line, bstr("line"));
2788 strcat(line, bstr("suffix"));
2803 serv_getln(buf, sizeof buf);
2804 if (buf[0] != '1') {
2810 /** This loop works for add *or* remove. Spiffy, eh? */
2811 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2812 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2813 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2814 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2815 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2816 if ( (strcasecmp(cmpa0, cmpb0))
2817 || (strcasecmp(cmpa1, cmpb1)) ) {
2818 fprintf(fp, "%s\n", buf);
2824 serv_getln(buf, sizeof buf);
2825 if (buf[0] != '4') {
2831 while (fgets(buf, sizeof buf, fp) != NULL) {
2832 buf[strlen(buf)-1] = 0;
2836 if (!IsEmptyStr(bstr("add_button"))) {
2837 num_addrs = num_tokens(bstr("line"), ',');
2838 if (num_addrs < 2) {
2839 /* just adding one node or address */
2843 /* adding multiple addresses separated by commas */
2844 for (i=0; i<num_addrs; ++i) {
2845 strcpy(line, bstr("prefix"));
2846 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2849 strcat(line, bstr("suffix"));
2863 * \brief Convert a room name to a folder-ish-looking name.
2864 * \param folder the folderish name
2865 * \param room the room name
2866 * \param floor the floor name
2867 * \param is_mailbox is it a mailbox?
2869 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2874 * For mailboxes, just do it straight...
2877 sprintf(folder, "My folders|%s", room);
2881 * Otherwise, prefix the floor name as a "public folders" moniker
2884 if (floor > MAX_FLOORS) {
2886 sprintf(folder, "%%%%%%|%s", room);
2889 sprintf(folder, "%s|%s", floorlist[floor], room);
2894 * Replace "\" characters with "|" for pseudo-folder-delimiting
2896 len = strlen (folder);
2897 for (i=0; i<len; ++i) {
2898 if (folder[i] == '\\') folder[i] = '|';
2906 * \brief Back end for change_view()
2907 * \param newview set newview???
2909 void do_change_view(int newview) {
2912 serv_printf("VIEW %d", newview);
2913 serv_getln(buf, sizeof buf);
2914 WC->wc_view = newview;
2915 smart_goto(WC->wc_roomname);
2921 * \brief Change the view for this room
2923 void change_view(void) {
2926 view = atol(bstr("view"));
2927 do_change_view(view);
2932 * \brief One big expanded tree list view --- like a folder list
2933 * \param fold the folder to view
2934 * \param max_folders how many folders???
2935 * \param num_floors hom many floors???
2937 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2941 int has_subfolders = 0;
2944 parents = malloc(max_folders * sizeof(int));
2946 /** BEGIN TREE MENU */
2947 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2949 /** include NanoTree */
2950 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2952 /** initialize NanoTree */
2953 wprintf("<script type=\"text/javascript\"> \n"
2954 " showRootNode = false; \n"
2955 " sortNodes = false; \n"
2956 " dragable = false; \n"
2958 " function standardClick(treeNode) { \n"
2961 " var closedGif = 'static/folder_closed.gif'; \n"
2962 " var openGif = 'static/folder_open.gif'; \n"
2964 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2968 for (i=0; i<max_folders; ++i) {
2971 if ((i+1) < max_folders) {
2973 len = strlen(fold[i].name);
2974 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2975 && (fold[i+1].name[len] == '|') ) {
2980 levels = num_tokens(fold[i].name, '|');
2981 parents[levels] = i;
2983 wprintf("var node%d = new TreeNode(%d, '", i, i);
2985 if (fold[i].selectable) {
2986 wprintf("<a href=\"dotgoto?room=");
2987 urlescputs(fold[i].room);
2992 wprintf("<span class=\"roomlist_floor\">");
2994 else if (fold[i].hasnewmsgs) {
2995 wprintf("<span class=\"roomlist_new\">");
2998 wprintf("<span class=\"roomlist_old\">");
3000 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3005 if (has_subfolders) {
3006 wprintf("new Array(closedGif, openGif)");
3008 else if (fold[i].view == VIEW_ADDRESSBOOK) {
3009 wprintf("'static/viewcontacts_16x.gif'");
3011 else if (fold[i].view == VIEW_CALENDAR) {
3012 wprintf("'static/calarea_16x.gif'");
3014 else if (fold[i].view == VIEW_CALBRIEF) {
3015 wprintf("'static/calarea_16x.gif'");
3017 else if (fold[i].view == VIEW_TASKS) {
3018 wprintf("'static/taskmanag_16x.gif'");
3020 else if (fold[i].view == VIEW_NOTES) {
3021 wprintf("'static/storenotes_16x.gif'");
3023 else if (fold[i].view == VIEW_MAILBOX) {
3024 wprintf("'static/privatemess_16x.gif'");
3027 wprintf("'static/chatrooms_16x.gif'");
3030 urlescputs(fold[i].name);
3034 wprintf("rootNode.addChild(node%d);\n", i);
3037 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3041 wprintf("container = document.getElementById('roomlist_div'); \n"
3047 /** END TREE MENU */
3051 * \brief Boxes and rooms and lists ... oh my!
3052 * \param fold the folder to view
3053 * \param max_folders how many folders???
3054 * \param num_floors hom many floors???
3056 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3058 char floor_name[256];
3059 char old_floor_name[256];
3061 int levels, oldlevels;
3064 static int columns = 3;
3065 int boxes_per_column = 0;
3066 int current_column = 0;
3069 strcpy(floor_name, "");
3070 strcpy(old_floor_name, "");
3073 while (nf % columns != 0) ++nf;
3074 boxes_per_column = (nf / columns);
3075 if (boxes_per_column < 1) boxes_per_column = 1;
3077 /** Outer table (for columnization) */
3078 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3079 "<tr><td valign=top>");
3083 for (i=0; i<max_folders; ++i) {
3085 levels = num_tokens(fold[i].name, '|');
3086 extract_token(floor_name, fold[i].name, 0,
3087 '|', sizeof floor_name);
3089 if ( (strcasecmp(floor_name, old_floor_name))
3090 && (!IsEmptyStr(old_floor_name)) ) {
3092 do_template("endbox");
3096 if ((num_boxes % boxes_per_column) == 0) {
3098 if (current_column < columns) {
3099 wprintf("</td><td valign=top>\n");
3103 strcpy(old_floor_name, floor_name);
3106 /** Begin inner box */
3107 stresc(boxtitle, 256, floor_name, 1, 0);
3108 svprintf("BOXTITLE", WCS_STRING, boxtitle);
3109 do_template("beginbox");
3116 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3117 if (fold[i].selectable) {
3118 wprintf("<a href=\"dotgoto?room=");
3119 urlescputs(fold[i].room);
3125 if (fold[i].hasnewmsgs) {
3126 wprintf("<span class=\"roomlist_new\">");
3129 wprintf("<span class=\"roomlist_old\">");
3131 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3134 if (fold[i].selectable) {
3140 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3141 wprintf(" (INBOX)");
3143 wprintf("<br />\n");
3146 /** End the final inner box */
3147 do_template("endbox");
3149 wprintf("</td></tr></table>\n");
3153 * \brief print a floor div???
3154 * \param which_floordiv name of the floordiv???
3156 void set_floordiv_expanded(char *which_floordiv) {
3157 begin_ajax_response();
3158 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
3159 end_ajax_response();
3163 * \brief view the iconbar
3164 * \param fold the folder to view
3165 * \param max_folders how many folders???
3166 * \param num_floors hom many floors???
3168 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3170 char floor_name[256];
3171 char old_floor_name[256];
3172 char floordivtitle[256];
3173 char floordiv_id[32];
3174 int levels, oldlevels;
3176 int num_drop_targets = 0;
3179 strcpy(floor_name, "");
3180 strcpy(old_floor_name, "");
3184 for (i=0; i<max_folders; ++i) {
3186 levels = num_tokens(fold[i].name, '|');
3187 extract_token(floor_name, fold[i].name, 0,
3188 '|', sizeof floor_name);
3190 if ( (strcasecmp(floor_name, old_floor_name))
3191 && (!IsEmptyStr(old_floor_name)) ) {
3192 /** End inner box */
3194 wprintf("</div>\n"); /** floordiv */
3196 strcpy(old_floor_name, floor_name);
3200 stresc(floordivtitle, 256, floor_name, 0, 0);
3201 sprintf(floordiv_id, "floordiv%d", i);
3202 wprintf("<span class=\"ib_roomlist_floor\" "
3203 "onClick=\"expand_floor('%s')\">"
3204 "%s</span><br>\n", floordiv_id, floordivtitle);
3205 wprintf("<div id=\"%s\" style=\"display:%s\">",
3207 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
3214 wprintf("<div id=\"roomdiv%d\">", i);
3216 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3218 /** choose the icon */
3219 if (fold[i].view == VIEW_ADDRESSBOOK) {
3220 icon = "viewcontacts_16x.gif" ;
3222 else if (fold[i].view == VIEW_CALENDAR) {
3223 icon = "calarea_16x.gif" ;
3225 else if (fold[i].view == VIEW_CALBRIEF) {
3226 icon = "calarea_16x.gif" ;
3228 else if (fold[i].view == VIEW_TASKS) {
3229 icon = "taskmanag_16x.gif" ;
3231 else if (fold[i].view == VIEW_NOTES) {
3232 icon = "storenotes_16x.gif" ;
3234 else if (fold[i].view == VIEW_MAILBOX) {
3235 icon = "privatemess_16x.gif" ;
3238 icon = "chatrooms_16x.gif" ;
3241 if (fold[i].selectable) {
3242 wprintf("<a href=\"dotgoto?room=");
3243 urlescputs(fold[i].room);
3245 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
3250 if (fold[i].hasnewmsgs) {
3251 wprintf("<span class=\"ib_roomlist_new\">");
3254 wprintf("<span class=\"ib_roomlist_old\">");
3256 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3258 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3259 wprintf(" (INBOX)");
3262 if (fold[i].selectable) {
3269 wprintf("</div>\n"); /** roomdiv */
3272 wprintf("</div>\n"); /** floordiv */
3275 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3276 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3278 num_drop_targets = 0;
3280 for (i=0; i<max_folders; ++i) {
3281 levels = num_tokens(fold[i].name, '|');
3283 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3284 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3285 jsescputs(fold[i].room);
3291 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3292 if ((WC->floordiv_expanded[0] != '\0')&&
3293 (WC->floordiv_expanded[1] != '\0')){
3294 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
3298 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3304 * \brief Burn the cached folder list.
3305 * \param age How old the cahce needs to be before we burn it.
3308 void burn_folder_cache(time_t age)
3310 /** If our cached folder list is very old, burn it. */
3311 if (WC->cache_fold != NULL) {
3312 if ((time(NULL) - WC->cache_timestamp) > age) {
3313 free(WC->cache_fold);
3314 WC->cache_fold = NULL;
3323 * \brief Show the room list.
3324 * (only should get called by
3325 * knrooms() because that's where output_headers() is called from)
3326 * \param viewpref the view preferences???
3329 void list_all_rooms_by_floor(char *viewpref) {
3332 struct folder *fold = NULL;
3334 int max_folders = 0;
3335 int alloc_folders = 0;
3341 int num_floors = 1; /** add an extra one for private folders */
3345 /** If our cached folder list is very old, burn it. */
3346 burn_folder_cache(300);
3348 /** Can we do the iconbar roomlist from cache? */
3349 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3350 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3354 /** Grab the floor table so we know how to build the list... */
3357 /** Start with the mailboxes */
3360 fold = malloc(sizeof(struct folder));
3361 memset(fold, 0, sizeof(struct folder));
3362 strcpy(fold[0].name, "My folders");
3363 fold[0].is_mailbox = 1;
3365 /** Then add floors */
3367 serv_getln(buf, sizeof buf);
3368 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3369 if (max_folders >= alloc_folders) {
3370 alloc_folders = max_folders + 100;
3371 fold = realloc(fold,
3372 alloc_folders * sizeof(struct folder));
3374 memset(&fold[max_folders], 0, sizeof(struct folder));
3375 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3376 extract_token(buf3, buf, 0, '|', SIZ);
3377 fold[max_folders].floor = atol (buf3);
3382 for (i=0; i<num_floors; i++)
3383 if (IDMax < fold[i].floor)
3384 IDMax = fold[i].floor;
3385 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3386 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3387 for (i=0; i<num_floors; i++)
3388 floor_mapping[fold[i].floor]=i;
3390 /** refresh the messages index for this room */
3391 // serv_puts("GOTO ");
3392 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3393 /** Now add rooms */
3395 serv_getln(buf, sizeof buf);
3396 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3397 if (max_folders >= alloc_folders) {
3398 alloc_folders = max_folders + 100;
3399 fold = realloc(fold,
3400 alloc_folders * sizeof(struct folder));
3402 memset(&fold[max_folders], 0, sizeof(struct folder));
3403 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3404 ra_flags = extract_int(buf, 5);
3405 flags = extract_int(buf, 1);
3406 fold[max_folders].floor = extract_int(buf, 2);
3407 fold[max_folders].hasnewmsgs =
3408 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3409 if (flags & QR_MAILBOX) {
3410 fold[max_folders].is_mailbox = 1;
3412 fold[max_folders].view = extract_int(buf, 6);
3413 room_to_folder(fold[max_folders].name,
3414 fold[max_folders].room,
3415 fold[max_folders].floor,
3416 fold[max_folders].is_mailbox);
3417 fold[max_folders].selectable = 1;
3418 /* Increase the room count for the associtaed floor */
3419 if (fold[max_folders].is_mailbox) {
3420 fold[0].num_rooms++;
3423 i = floor_mapping[fold[max_folders].floor];
3424 fold[i].num_rooms++;
3430 * Remove any floors that don't have rooms
3432 get_preference("emptyfloors", buf2, sizeof buf2);
3433 if (buf2[0]==0 || (strcasecmp(buf2, "no") == 0))
3435 for (i=0; i<num_floors; i++)
3437 if (fold[i].num_rooms == 0) {
3438 for (j=i; j<max_folders; j++) {
3439 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3448 /** Bubble-sort the folder list */
3449 for (i=0; i<max_folders; ++i) {
3450 for (j=0; j<(max_folders-1)-i; ++j) {
3451 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3452 swap = strcasecmp(fold[j].name, fold[j+1].name);
3455 if ( (fold[j+1].is_mailbox)
3456 && (!fold[j].is_mailbox)) {
3464 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3465 memcpy(&fold[j], &fold[j+1],
3466 sizeof(struct folder));
3467 memcpy(&fold[j+1], &ftmp,
3468 sizeof(struct folder));
3474 if (!strcasecmp(viewpref, "folders")) {
3475 do_folder_view(fold, max_folders, num_floors);
3477 else if (!strcasecmp(viewpref, "hackish_view")) {
3478 for (i=0; i<max_folders; ++i) {
3479 escputs(fold[i].name);
3480 wprintf("<br />\n");
3483 else if (!strcasecmp(viewpref, "iconbar")) {
3484 do_iconbar_view(fold, max_folders, num_floors);
3487 do_rooms_view(fold, max_folders, num_floors);
3490 /* Don't free the folder list ... cache it for future use! */
3491 if (WC->cache_fold != NULL) {
3492 free(WC->cache_fold);
3494 WC->cache_fold = fold;
3495 WC->cache_max_folders = max_folders;
3496 WC->cache_num_floors = num_floors;
3497 WC->cache_timestamp = time(NULL);
3498 free(floor_mapping);
3503 * \brief Do either a known rooms list or a folders list, depending on the
3508 char listviewpref[SIZ];
3510 output_headers(1, 1, 2, 0, 0, 0);
3512 /** Determine whether the user is trying to change views */
3513 if (bstr("view") != NULL) {
3514 if (!IsEmptyStr(bstr("view"))) {
3515 set_preference("roomlistview", bstr("view"), 1);
3519 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3521 if ( (strcasecmp(listviewpref, "folders"))
3522 && (strcasecmp(listviewpref, "table")) ) {
3523 strcpy(listviewpref, "rooms");
3527 wprintf("<div id=\"banner\">\n");
3528 wprintf("<div class=\"room_banner\">");
3530 if (!strcasecmp(listviewpref, "rooms")) {
3531 wprintf(_("Room list"));
3533 if (!strcasecmp(listviewpref, "folders")) {
3534 wprintf(_("Folder list"));
3536 if (!strcasecmp(listviewpref, "table")) {
3537 wprintf(_("Room list"));
3539 wprintf("</h1></div>\n");
3541 /** offer the ability to switch views */
3542 wprintf("<ul class=\"room_actions\">\n");
3543 wprintf("<li class=\"start_page\">");
3546 wprintf("<li><form name=\"roomlistomatic\">\n"
3547 "<select name=\"newview\" size=\"1\" "
3548 "OnChange=\"location.href=roomlistomatic.newview.options"
3549 "[selectedIndex].value\">\n");
3551 wprintf("<option %s value=\"knrooms&view=rooms\">"
3554 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3557 wprintf("<option %s value=\"knrooms&view=folders\">"
3558 "View as folder list"
3560 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3563 wprintf("</select>");
3564 wprintf("</form></li>");
3565 wprintf("</ul></div>\n");
3567 wprintf("<div id=\"content\" class=\"service\">\n");
3569 /** Display the room list in the user's preferred format */
3570 list_all_rooms_by_floor(listviewpref);
3577 * \brief Set the message expire policy for this room and/or floor
3579 void set_room_policy(void) {
3582 if (IsEmptyStr(bstr("ok_button"))) {
3583 strcpy(WC->ImportantMessage,
3584 _("Cancelled. Changes were not saved."));
3589 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3590 serv_getln(buf, sizeof buf);
3591 strcpy(WC->ImportantMessage, &buf[4]);
3593 if (WC->axlevel >= 6) {
3594 strcat(WC->ImportantMessage, "<br />\n");
3595 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3596 serv_getln(buf, sizeof buf);
3597 strcat(WC->ImportantMessage, &buf[4]);