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);
40 case VIEW_WIKI: return(0); /**< because it isn't finished yet */
41 case VIEW_CALBRIEF: return(0);
42 case VIEW_JOURNAL: return(0);
43 default: return(0); /**< should never get here */
49 * load the list of floors
51 void load_floorlist(void)
56 for (a = 0; a < MAX_FLOORS; ++a)
60 serv_getln(buf, sizeof buf);
62 strcpy(floorlist[0], "Main Floor");
65 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
66 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
72 * Free a session's march list
74 void free_march_list(struct wcsession *wcf)
78 while (wcf->march != NULL) {
79 mptr = wcf->march->next;
89 * remove a room from the march list
91 void remove_march(char *aaa)
93 struct march *mptr, *mptr2;
95 if (WC->march == NULL)
98 if (!strcasecmp(WC->march->march_name, aaa)) {
99 mptr = WC->march->next;
105 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
106 if (!strcasecmp(mptr->march_name, aaa)) {
107 mptr2->next = mptr->next;
120 * display rooms in tree structure
122 void room_tree_list(struct roomlisting *rp)
131 room_tree_list(rp->lnext);
133 strcpy(rmname, rp->rlname);
136 wprintf("<a href=\"dotgoto&room=");
140 escputs1(rmname, 1, 1);
141 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
143 else if (f & QR_DIRECTORY)
145 else if (f & QR_NETWORK)
149 wprintf("</a><tt> </tt>\n");
151 room_tree_list(rp->rnext);
157 * \brief Room ordering stuff (compare first by floor, then by order)
158 * \param r1 first roomlist to compare
159 * \param r2 second roomlist co compare
160 * \return are they the same???
162 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
164 if ((r1 == NULL) && (r2 == NULL))
170 if (r1->rlfloor < r2->rlfloor)
172 if (r1->rlfloor > r2->rlfloor)
174 if (r1->rlorder < r2->rlorder)
176 if (r1->rlorder > r2->rlorder)
183 * \brief Common code for all room listings
184 * \param variety what???
186 void listrms(char *variety)
191 struct roomlisting *rl = NULL;
192 struct roomlisting *rp;
193 struct roomlisting *rs;
195 /** Ask the server for a room list */
197 serv_getln(buf, sizeof buf);
203 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
205 rp = malloc(sizeof(struct roomlisting));
206 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
207 rp->rlflags = extract_int(buf, 1);
208 rp->rlfloor = extract_int(buf, 2);
209 rp->rlorder = extract_int(buf, 3);
218 if (rordercmp(rp, rs) < 0) {
219 if (rs->lnext == NULL) {
226 if (rs->rnext == NULL) {
239 * If no rooms were listed, print an nbsp to make the cell
240 * borders show up anyway.
242 if (num_rooms == 0) wprintf(" ");
247 * \brief list all forgotten rooms
249 void zapped_list(void)
251 output_headers(1, 1, 1, 0, 0, 0);
253 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
254 do_template("beginbox");
258 wprintf("<br /><br />\n");
259 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
260 do_template("endbox");
266 * \brief read this room's info file (set v to 1 for verbose mode)
273 int fullinfo_len = 0;
276 serv_getln(buf, sizeof buf);
279 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
280 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
281 strcpy(&fullinfo[fullinfo_len], buf);
282 fullinfo_len += strlen(buf);
286 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
287 strcpy(&briefinfo[50], "...");
289 wprintf("<div class=\"infos\" "
290 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
293 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
294 wprintf("<img class=\"close_infos\" "
295 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
296 "src=\"static/closewindow.gif\" alt=\"%s\">",
311 * \brief Display room banner icon.
312 * The server doesn't actually
313 * need the room name, but we supply it in order to
314 * keep the browser from using a cached icon from
317 void embed_room_graphic(void) {
320 serv_puts("OIMG _roompic_");
321 serv_getln(buf, sizeof buf);
323 wprintf("<img height=\"64px\" src=\"image&name=_roompic_&room=");
324 urlescputs(WC->wc_roomname);
327 serv_getln(buf, sizeof buf);
329 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
330 wprintf("<img height=48 width=48 src=\""
331 "static/viewcontacts_48x.gif"
335 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
336 wprintf("<img height=48 width=48 src=\""
337 "static/calarea_48x.gif"
341 else if (WC->wc_view == VIEW_TASKS) {
342 wprintf("<img height=48 width=48 src=\""
343 "static/taskmanag_48x.gif"
347 else if (WC->wc_view == VIEW_NOTES) {
348 wprintf("<img height=48 width=48 src=\""
349 "static/storenotes_48x.gif"
353 else if (WC->wc_view == VIEW_MAILBOX) {
354 wprintf("<img height=48 width=48 src=\""
355 "static/privatemess_48x.gif"
360 wprintf("<img height=48 width=48 src=\""
361 "static/chatrooms_48x.gif"
371 * \brief Display the current view and offer an option to change it
373 void embed_view_o_matic(void) {
376 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
377 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
378 wprintf("<label for=\"view_name\">");
379 wprintf(_("View as:"));
381 "<select name=\"newview\" size=\"1\" "
382 "id=\"view_name\" class=\"selectbox\" "
383 "OnChange=\"location.href=viewomatic.newview.options"
384 "[selectedIndex].value\">\n");
386 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
388 * Only offer the views that make sense, given the default
389 * view for the room. For example, don't offer a Calendar
390 * view in a non-Calendar room.
394 || (i == WC->wc_default_view) /**< default */
395 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
396 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
397 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
400 wprintf("<option %s value=\"changeview?view=%d\">",
401 ((i == WC->wc_view) ? "selected" : ""),
403 escputs(viewdefs[i]);
404 wprintf("</option>\n");
407 wprintf("</select></form>\n");
412 * \brief Display a search box
414 void embed_search_o_matic(void) {
415 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
416 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
417 wprintf("<label for=\"search_name\">");
418 wprintf(_("Search: "));
419 wprintf("</label> <input "
420 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
421 "id=\"search_name\" class=\"inputbox\">\n"
423 wprintf("</form>\n");
428 * \brief Embed the room banner
430 * \param got The information returned from a GOTO server command
431 * \param navbar_style Determines which navigation buttons to display
435 void embed_room_banner(char *got, int navbar_style) {
438 char sanitized_roomname[256];
439 char with_files[256];
443 * We need to have the information returned by a GOTO server command.
444 * If it isn't supplied, we fake it by issuing our own GOTO.
447 serv_printf("GOTO %s", WC->wc_roomname);
448 serv_getln(buf, sizeof buf);
452 /** The browser needs some information for its own use */
453 wprintf("<script type=\"text/javascript\"> \n"
454 " room_is_trash = %d; \n"
460 * If the user happens to select the "make this my start page" link,
461 * we want it to remember the URL as a "/dotskip" one instead of
462 * a "skip" or "gotonext" or something like that.
464 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
467 /** Check for new mail. */
468 WC->new_mail = extract_int(&got[4], 9);
469 WC->wc_view = extract_int(&got[4], 11);
471 /* Is this a directory room and does it contain files and how many? */
472 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
475 serv_getln(buf2, sizeof buf2);
476 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
478 snprintf (with_files, sizeof with_files,
479 "; <a href=\"display_room_directory\"> %d %s </a>",
481 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
484 strcpy (with_files, "");
486 stresc(sanitized_roomname, 256, WC->wc_roomname, 1, 1);
487 svprintf("ROOMNAME", WCS_STRING, "%s", sanitized_roomname);
488 svprintf("NUMMSGS", WCS_STRING,
489 _("%d new of %d messages%s"),
490 extract_int(&got[4], 1),
491 extract_int(&got[4], 2),
494 svcallback("ROOMPIC", embed_room_graphic);
495 svcallback("ROOMINFO", readinfo);
496 svcallback("VIEWOMATIC", embed_view_o_matic);
497 svcallback("SEARCHOMATIC", embed_search_o_matic);
498 svcallback("START", offer_start_page);
500 do_template("roombanner");
501 if (navbar_style != navbar_none) {
503 wprintf("<div id=\"navbar\"><ul>");
505 if (navbar_style == navbar_default) wprintf(
506 "<li class=\"ungoto\">"
507 "<a href=\"ungoto\">"
508 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
509 "<span class=\"navbar_link\">%s</span></A>"
510 "</li>\n", _("Ungoto")
513 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
515 "<li class=\"newmess\">"
516 "<a href=\"readnew\">"
517 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
518 "<span class=\"navbar_link\">%s</span></A>"
519 "</li>\n", _("Read new messages")
523 if (navbar_style == navbar_default) {
524 switch(WC->wc_view) {
525 case VIEW_ADDRESSBOOK:
527 "<li class=\"viewcontacts\">"
528 "<a href=\"readfwd\">"
529 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
531 "<span class=\"navbar_link\">"
533 "</span></a></li>\n", _("View contacts")
538 "<li class=\"staskday\">"
539 "<a href=\"readfwd?calview=day\">"
540 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
542 "<span class=\"navbar_link\">"
544 "</span></a></li>\n", _("Day view")
547 "<li class=\"monthview\">"
548 "<a href=\"readfwd?calview=month\">"
549 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
551 "<span class=\"navbar_link\">"
553 "</span></a></li>\n", _("Month view")
558 "<li class=\"monthview\">"
559 "<a href=\"readfwd?calview=month\">"
560 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
562 "<span class=\"navbar_link\">"
564 "</span></a></li>\n", _("Calendar list")
569 "<li class=\"taskmanag\">"
570 "<a href=\"readfwd\">"
571 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
573 "<span class=\"navbar_link\">"
575 "</span></a></li>\n", _("View tasks")
580 "<li class=\"viewnotes\">"
581 "<a href=\"readfwd\">"
582 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
584 "<span class=\"navbar_link\">"
586 "</span></a></li>\n", _("View notes")
591 "<li class=\"readallmess\">"
592 "<a href=\"readfwd\">"
593 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
595 "<span class=\"navbar_link\">"
597 "</span></a></li>\n", _("View message list")
602 "<li class=\"readallmess\">"
603 "<a href=\"readfwd\">"
604 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
606 "<span class=\"navbar_link\">"
608 "</span></a></li>\n", _("Wiki home")
613 "<li class=\"readallmess\">"
614 "<a href=\"readfwd\">"
615 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
617 "<span class=\"navbar_link\">"
619 "</span></a></li>\n", _("Read all messages")
625 if (navbar_style == navbar_default) {
626 switch(WC->wc_view) {
627 case VIEW_ADDRESSBOOK:
629 "<li class=\"addnewcontact\">"
630 "<a href=\"display_enter\">"
631 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
632 "border=\"0\"><span class=\"navbar_link\">"
634 "</span></a></li>\n", _("Add new contact")
639 wprintf("<li class=\"addevent\"><a href=\"display_enter");
640 if (!IsEmptyStr(bstr("year" ))) wprintf("?year=%s", bstr("year"));
641 if (!IsEmptyStr(bstr("month"))) wprintf("?month=%s", bstr("month"));
642 if (!IsEmptyStr(bstr("day" ))) wprintf("?day=%s", bstr("day"));
644 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
645 "border=\"0\"><span class=\"navbar_link\">"
647 "</span></a></li>\n", _("Add new event")
652 "<li class=\"newmess\">"
653 "<a href=\"display_enter\">"
654 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
655 "border=\"0\"><span class=\"navbar_link\">"
657 "</span></a></li>\n", _("Add new task")
662 "<li class=\"enternewnote\">"
663 "<a href=\"javascript:add_new_note();\">"
664 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
665 "border=\"0\"><span class=\"navbar_link\">"
667 "</span></a></li>\n", _("Add new note")
671 safestrncpy(buf, bstr("page"), sizeof buf);
674 "<li class=\"newmess\">"
675 "<a href=\"display_enter?wikipage=%s\">"
676 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
677 "border=\"0\"><span class=\"navbar_link\">"
679 "</span></a></li>\n", buf, _("Edit this page")
684 "<li class=\"newmess\">"
685 "<a href=\"display_enter\">"
686 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
687 "border=\"0\"><span class=\"navbar_link\">"
689 "</span></a></li>\n", _("Write mail")
694 "<li class=\"newmess\">"
695 "<a href=\"display_enter\">"
696 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
697 "border=\"0\"><span class=\"navbar_link\">"
699 "</span></a></li>\n", _("Enter a message")
705 if (navbar_style == navbar_default) wprintf(
706 "<li class=\"skipthisroom\">"
709 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
710 "<span class=\"navbar_link\">%s</span></a>"
712 _("Leave all messages marked as unread, go to next room with unread messages"),
716 if (navbar_style == navbar_default) wprintf(
717 "<li class=\"markngo\">"
718 "<a href=\"gotonext\" "
720 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
721 "<span class=\"navbar_link\">%s</span></a>"
723 _("Mark all messages as read, go to next room with unread messages"),
727 wprintf("</ul></div>\n");
734 * \brief back end routine to take the session to a new room
735 * \param gname room to go to
738 int gotoroom(char *gname)
741 static long ls = (-1L);
744 /** store ungoto information */
745 strcpy(WC->ugname, WC->wc_roomname);
748 /** move to the new room */
749 serv_printf("GOTO %s", gname);
750 serv_getln(buf, sizeof buf);
754 serv_puts("GOTO _BASEROOM_");
755 serv_getln(buf, sizeof buf);
762 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
763 WC->room_flags = extract_int(&buf[4], 4);
764 /* highest_msg_read = extract_int(&buf[4],6);
765 maxmsgnum = extract_int(&buf[4],5);
767 WC->is_mailbox = extract_int(&buf[4],7);
768 ls = extract_long(&buf[4], 6);
769 WC->wc_floor = extract_int(&buf[4], 10);
770 WC->wc_view = extract_int(&buf[4], 11);
771 WC->wc_default_view = extract_int(&buf[4], 12);
772 WC->wc_is_trash = extract_int(&buf[4], 13);
773 WC->room_flags2 = extract_int(&buf[4], 14);
776 WC->is_room_aide = WC->is_aide;
778 WC->is_room_aide = (char) extract_int(&buf[4], 8);
780 remove_march(WC->wc_roomname);
781 if (!strcasecmp(gname, "_BASEROOM_"))
789 * \brief Locate the room on the march list which we most want to go to.
791 * is measured given a "weight" of preference based on various factors.
792 * \param desired_floor the room number on the citadel server
793 * \return the roomname
795 char *pop_march(int desired_floor)
797 static char TheRoom[128];
799 int TheOrder = 32767;
802 struct march *mptr = NULL;
804 strcpy(TheRoom, "_BASEROOM_");
805 if (WC->march == NULL)
808 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
810 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
811 weight = weight + 10000;
812 if (mptr->march_floor == desired_floor)
813 weight = weight + 5000;
815 weight = weight + ((128 - (mptr->march_floor)) * 128);
816 weight = weight + (128 - (mptr->march_order));
818 if (weight > TheWeight) {
820 strcpy(TheRoom, mptr->march_name);
821 TheFloor = mptr->march_floor;
822 TheOrder = mptr->march_order;
831 *\brief Goto next room having unread messages.
832 * We want to skip over rooms that the user has already been to, and take the
833 * user back to the lobby when done. The room we end up in is placed in
834 * newroom - which is set to 0 (the lobby) initially.
835 * We start the search in the current room rather than the beginning to prevent
836 * two or more concurrent users from dragging each other back to the same room.
841 struct march *mptr, *mptr2;
846 * First check to see if the march-mode list is already allocated.
847 * If it is, pop the first room off the list and go there.
850 if (WC->march == NULL) {
852 serv_getln(buf, sizeof buf);
854 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
855 extract_token(room_name, buf, 0, '|', sizeof room_name);
856 if (strcasecmp(room_name, WC->wc_roomname)) {
857 mptr = (struct march *) malloc(sizeof(struct march));
859 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
860 mptr->march_floor = extract_int(buf, 2);
861 mptr->march_order = extract_int(buf, 3);
862 if (WC->march == NULL) {
866 while (mptr2->next != NULL)
873 * add _BASEROOM_ to the end of the march list, so the user will end up
874 * in the system base room (usually the Lobby>) at the end of the loop
876 mptr = (struct march *) malloc(sizeof(struct march));
878 mptr->march_order = 0;
879 mptr->march_floor = 0;
880 strcpy(mptr->march_name, "_BASEROOM_");
881 if (WC->march == NULL) {
885 while (mptr2->next != NULL)
890 * ...and remove the room we're currently in, so a <G>oto doesn't make us
891 * walk around in circles
893 remove_march(WC->wc_roomname);
895 if (WC->march != NULL) {
896 strcpy(next_room, pop_march(-1));
898 strcpy(next_room, "_BASEROOM_");
902 smart_goto(next_room);
907 * \brief goto next room
908 * \param next_room next room to go to
910 void smart_goto(char *next_room) {
918 * \brief mark all messages in current room as having been read
920 void slrp_highest(void)
924 serv_puts("SLRP HIGHEST");
925 serv_getln(buf, sizeof buf);
930 * \brief un-goto the previous room
936 if (!strcmp(WC->ugname, "")) {
937 smart_goto(WC->wc_roomname);
940 serv_printf("GOTO %s", WC->ugname);
941 serv_getln(buf, sizeof buf);
943 smart_goto(WC->wc_roomname);
946 if (WC->uglsn >= 0L) {
947 serv_printf("SLRP %ld", WC->uglsn);
948 serv_getln(buf, sizeof buf);
950 strcpy(buf, WC->ugname);
951 strcpy(WC->ugname, "");
955 typedef struct __room_states {
970 * \brief Set/clear/read the "self-service list subscribe" flag for a room
972 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
973 * \return return the new value.
976 int self_service(int newval) {
977 int current_value = 0;
983 int flags, floor, order, view, flags2;
986 serv_getln(buf, sizeof buf);
987 if (buf[0] != '2') return(0);
989 extract_token(name, &buf[4], 0, '|', sizeof name);
990 extract_token(password, &buf[4], 1, '|', sizeof password);
991 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
992 flags = extract_int(&buf[4], 3);
993 floor = extract_int(&buf[4], 4);
994 order = extract_int(&buf[4], 5);
995 view = extract_int(&buf[4], 6);
996 flags2 = extract_int(&buf[4], 7);
998 if (flags2 & QR2_SELFLIST) {
1006 flags2 = flags2 | QR2_SELFLIST;
1008 else if (newval == 0) {
1009 flags2 = flags2 & ~QR2_SELFLIST;
1012 return(current_value);
1015 if (newval != current_value) {
1016 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1017 name, password, dirname, flags,
1018 floor, order, view, flags2);
1019 serv_getln(buf, sizeof buf);
1027 is_selflist(room_states *RoomFlags)
1029 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1033 is_publiclist(room_states *RoomFlags)
1035 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1039 is_moderatedlist(room_states *RoomFlags)
1041 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1045 * \brief Set/clear/read the "self-service list subscribe" flag for a room
1047 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
1048 * \return return the new value.
1051 int get_roomflags(room_states *RoomOps)
1056 serv_getln(buf, sizeof buf);
1057 if (buf[0] != '2') return(0);
1059 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1060 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1061 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1062 RoomOps->flags = extract_int(&buf[4], 3);
1063 RoomOps->floor = extract_int(&buf[4], 4);
1064 RoomOps->order = extract_int(&buf[4], 5);
1065 RoomOps->view = extract_int(&buf[4], 6);
1066 RoomOps->flags2 = extract_int(&buf[4], 7);
1070 int set_roomflags(room_states *RoomOps)
1074 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1083 serv_getln(buf, sizeof buf);
1093 * \brief display the form for editing a room
1095 void display_editroom(void)
1100 char remote_room[128];
1103 char er_password[10];
1104 char er_dirname[15];
1105 char er_roomaide[26];
1112 char *not_shared_with;
1115 int floorpolicy = 0;
1117 char pop3_host[128];
1122 if (IsEmptyStr(tab)) tab = "admin";
1125 output_headers(1, 1, 1, 0, 0, 0);
1127 wprintf("<div class=\"fix_scrollbar_bug\">");
1129 /** print the tabbed dialog */
1130 wprintf("<ul class=\"tabbed_dialog\">\n");
1132 wprintf("<li class=\"tablabel ");
1133 if (!strcmp(tab, "admin")) {
1134 wprintf(" tab_cell_label\">");
1135 wprintf(_("Administration"));
1138 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1139 wprintf(_("Administration"));
1144 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1146 wprintf("<li class=\"tablabel ");
1147 if (!strcmp(tab, "config")) {
1148 wprintf(" tab_cell_label\">");
1149 wprintf(_("Configuration"));
1152 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1153 wprintf(_("Configuration"));
1158 wprintf("<li class=\"tablabel ");
1159 if (!strcmp(tab, "expire")) {
1160 wprintf(" tab_cell_label\">");
1161 wprintf(_("Message expire policy"));
1164 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1165 wprintf(_("Message expire policy"));
1170 wprintf("<li class=\"tablabel ");
1171 if (!strcmp(tab, "access")) {
1172 wprintf(" tab_cell_label\">");
1173 wprintf(_("Access controls"));
1176 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1177 wprintf(_("Access controls"));
1182 wprintf("<li class=\"tablabel ");
1183 if (!strcmp(tab, "sharing")) {
1184 wprintf(" tab_cell_label\">");
1185 wprintf(_("Sharing"));
1188 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1189 wprintf(_("Sharing"));
1194 wprintf("<li class=\"tablabel ");
1195 if (!strcmp(tab, "listserv")) {
1196 wprintf(" tab_cell_label\">");
1197 wprintf(_("Mailing list service"));
1200 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1201 wprintf(_("Mailing list service"));
1208 wprintf("<li class=\"tablabel ");
1209 if (!strcmp(tab, "feeds")) {
1210 wprintf(" tab_cell_label\">");
1211 wprintf(_("Remote retrieval"));
1214 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1215 wprintf(_("Remote retrieval"));
1221 /** end tabbed dialog */
1223 /** begin content of whatever tab is open now */
1225 if (!strcmp(tab, "admin")) {
1226 wprintf("<div class=\"tabcontent\">");
1228 "<li><a href=\"delete_room\" "
1229 "onClick=\"return confirm('");
1230 wprintf(_("Are you sure you want to delete this room?"));
1231 wprintf("');\">\n");
1232 wprintf(_("Delete this room"));
1234 "<li><a href=\"display_editroompic\">\n");
1235 wprintf(_("Set or change the icon for this room's banner"));
1237 "<li><a href=\"display_editinfo\">\n");
1238 wprintf(_("Edit this room's Info file"));
1244 if (!strcmp(tab, "config")) {
1245 wprintf("<div class=\"tabcontent\">");
1247 serv_getln(buf, sizeof buf);
1249 if (!strncmp(buf, "550", 3)) {
1250 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1251 _("Higher access is required to access this function.")
1254 else if (buf[0] != '2') {
1255 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1258 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1259 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1260 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1261 er_flags = extract_int(&buf[4], 3);
1262 er_floor = extract_int(&buf[4], 4);
1263 er_flags2 = extract_int(&buf[4], 7);
1265 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1266 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1268 wprintf("<ul><li>");
1269 wprintf(_("Name of room: "));
1270 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1276 wprintf(_("Resides on floor: "));
1277 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1278 if (er_flags & QR_MAILBOX)
1279 wprintf("disabled >\n");
1280 for (i = 0; i < 128; ++i)
1281 if (!IsEmptyStr(floorlist[i])) {
1282 wprintf("<OPTION ");
1284 wprintf("SELECTED ");
1285 wprintf("VALUE=\"%d\">", i);
1286 escputs(floorlist[i]);
1287 wprintf("</OPTION>\n");
1289 wprintf("</select>\n");
1292 wprintf(_("Type of room:"));
1295 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1296 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1297 wprintf("CHECKED ");
1298 wprintf("OnChange=\""
1299 " if (this.form.type[0].checked == true) { "
1300 " this.form.er_floor.disabled = false; "
1303 wprintf(_("Public (automatically appears to everyone)"));
1306 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1307 if ((er_flags & QR_PRIVATE) &&
1308 (er_flags & QR_GUESSNAME))
1309 wprintf("CHECKED ");
1310 wprintf(" OnChange=\""
1311 " if (this.form.type[1].checked == true) { "
1312 " this.form.er_floor.disabled = false; "
1315 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1317 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1318 if ((er_flags & QR_PRIVATE) &&
1319 (er_flags & QR_PASSWORDED))
1320 wprintf("CHECKED ");
1321 wprintf(" OnChange=\""
1322 " if (this.form.type[2].checked == true) { "
1323 " this.form.er_floor.disabled = false; "
1326 wprintf(_("Private - require password: "));
1327 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1330 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1331 if ((er_flags & QR_PRIVATE)
1332 && ((er_flags & QR_GUESSNAME) == 0)
1333 && ((er_flags & QR_PASSWORDED) == 0))
1334 wprintf("CHECKED ");
1335 wprintf(" OnChange=\""
1336 " if (this.form.type[3].checked == true) { "
1337 " this.form.er_floor.disabled = false; "
1340 wprintf(_("Private - invitation only"));
1342 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1343 if (er_flags & QR_MAILBOX)
1344 wprintf("CHECKED ");
1345 wprintf (" OnChange=\""
1346 " if (this.form.type[4].checked == true) { "
1347 " this.form.er_floor.disabled = true; "
1350 wprintf(_("Personal (mailbox for you only)"));
1352 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1354 wprintf(_("If private, cause current users to forget room"));
1356 wprintf("\n</ul>\n");
1358 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1359 if (er_flags & QR_PREFONLY)
1360 wprintf("CHECKED ");
1362 wprintf(_("Preferred users only"));
1364 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1365 if (er_flags & QR_READONLY)
1366 wprintf("CHECKED ");
1368 wprintf(_("Read-only room"));
1370 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1371 if (er_flags2 & QR2_COLLABDEL)
1372 wprintf("CHECKED ");
1374 wprintf(_("All users allowed to post may also delete messages"));
1376 /** directory stuff */
1377 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1378 if (er_flags & QR_DIRECTORY)
1379 wprintf("CHECKED ");
1381 wprintf(_("File directory room"));
1383 wprintf("\n<ul><li>");
1384 wprintf(_("Directory name: "));
1385 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1388 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1389 if (er_flags & QR_UPLOAD)
1390 wprintf("CHECKED ");
1392 wprintf(_("Uploading allowed"));
1394 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1395 if (er_flags & QR_DOWNLOAD)
1396 wprintf("CHECKED ");
1398 wprintf(_("Downloading allowed"));
1400 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1401 if (er_flags & QR_VISDIR)
1402 wprintf("CHECKED ");
1404 wprintf(_("Visible directory"));
1407 /** end of directory stuff */
1409 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1410 if (er_flags & QR_NETWORK)
1411 wprintf("CHECKED ");
1413 wprintf(_("Network shared room"));
1415 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1416 if (er_flags & QR_PERMANENT)
1417 wprintf("CHECKED ");
1419 wprintf(_("Permanent (does not auto-purge)"));
1421 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1422 if (er_flags2 & QR2_SUBJECTREQ)
1423 wprintf("CHECKED ");
1425 wprintf(_("Subject Required (Force users to specify a message subject)"));
1427 /** start of anon options */
1430 wprintf(_("Anonymous messages"));
1433 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1434 if (((er_flags & QR_ANONONLY) == 0)
1435 && ((er_flags & QR_ANONOPT) == 0))
1436 wprintf("CHECKED ");
1438 wprintf(_("No anonymous messages"));
1440 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1441 if (er_flags & QR_ANONONLY)
1442 wprintf("CHECKED ");
1444 wprintf(_("All messages are anonymous"));
1446 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1447 if (er_flags & QR_ANONOPT)
1448 wprintf("CHECKED ");
1450 wprintf(_("Prompt user when entering messages"));
1453 /* end of anon options */
1456 wprintf(_("Room aide: "));
1458 serv_getln(buf, sizeof buf);
1459 if (buf[0] != '2') {
1460 wprintf("<em>%s</em>\n", &buf[4]);
1462 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1463 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1466 wprintf("</ul><CENTER>\n");
1467 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1468 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1470 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1480 /** Sharing the room with other Citadel nodes... */
1481 if (!strcmp(tab, "sharing")) {
1482 wprintf("<div class=\"tabcontent\">");
1484 shared_with = strdup("");
1485 not_shared_with = strdup("");
1487 /** Learn the current configuration */
1488 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1489 serv_getln(buf, sizeof buf);
1490 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1491 extract_token(node, buf, 0, '|', sizeof node);
1492 not_shared_with = realloc(not_shared_with,
1493 strlen(not_shared_with) + 32);
1494 strcat(not_shared_with, node);
1495 strcat(not_shared_with, "\n");
1499 serv_getln(buf, sizeof buf);
1500 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1501 extract_token(cmd, buf, 0, '|', sizeof cmd);
1502 extract_token(node, buf, 1, '|', sizeof node);
1503 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1504 if (!strcasecmp(cmd, "ignet_push_share")) {
1505 shared_with = realloc(shared_with,
1506 strlen(shared_with) + 32);
1507 strcat(shared_with, node);
1508 if (!IsEmptyStr(remote_room)) {
1509 strcat(shared_with, "|");
1510 strcat(shared_with, remote_room);
1512 strcat(shared_with, "\n");
1516 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1517 extract_token(buf, shared_with, i, '\n', sizeof buf);
1518 extract_token(node, buf, 0, '|', sizeof node);
1519 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1520 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1521 if (!strcasecmp(node, cmd)) {
1522 remove_token(not_shared_with, j, '\n');
1527 /** Display the stuff */
1528 wprintf("<CENTER><br />"
1529 "<table border=1 cellpadding=5><tr>"
1531 wprintf(_("Shared with"));
1532 wprintf("</I></B></td>"
1534 wprintf(_("Not shared with"));
1535 wprintf("</I></B></td></tr>\n"
1536 "<tr><td VALIGN=TOP>\n");
1538 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1539 wprintf(_("Remote node name"));
1540 wprintf("</td><td>");
1541 wprintf(_("Remote room name"));
1542 wprintf("</td><td>");
1543 wprintf(_("Actions"));
1544 wprintf("</td></tr>\n");
1546 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1547 extract_token(buf, shared_with, i, '\n', sizeof buf);
1548 extract_token(node, buf, 0, '|', sizeof node);
1549 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1550 if (!IsEmptyStr(node)) {
1551 wprintf("<form method=\"POST\" action=\"netedit\">");
1552 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1553 wprintf("<tr><td>%s</td>\n", node);
1556 if (!IsEmptyStr(remote_room)) {
1557 escputs(remote_room);
1563 wprintf("<input type=\"hidden\" NAME=\"line\" "
1564 "VALUE=\"ignet_push_share|");
1566 if (!IsEmptyStr(remote_room)) {
1568 urlescputs(remote_room);
1571 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1572 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1573 wprintf("<input type=\"submit\" "
1574 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1575 wprintf("</td></tr></form>\n");
1579 wprintf("</table>\n");
1580 wprintf("</td><td VALIGN=TOP>\n");
1581 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1582 wprintf(_("Remote node name"));
1583 wprintf("</td><td>");
1584 wprintf(_("Remote room name"));
1585 wprintf("</td><td>");
1586 wprintf(_("Actions"));
1587 wprintf("</td></tr>\n");
1589 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1590 extract_token(node, not_shared_with, i, '\n', sizeof node);
1591 if (!IsEmptyStr(node)) {
1592 wprintf("<form method=\"POST\" action=\"netedit\">");
1593 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1594 wprintf("<tr><td>");
1597 "<input type=\"INPUT\" "
1601 wprintf("<input type=\"hidden\" "
1603 "VALUE=\"ignet_push_share|");
1606 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1607 "VALUE=\"sharing\">\n");
1608 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1609 "VALUE=\"add\">\n");
1610 wprintf("<input type=\"submit\" "
1611 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1612 wprintf("</td></tr></form>\n");
1616 wprintf("</table>\n");
1617 wprintf("</td></tr>"
1618 "</table></CENTER><br />\n"
1619 "<I><B>%s</B><ul><li>", _("Notes:"));
1620 wprintf(_("When sharing a room, "
1621 "it must be shared from both ends. Adding a node to "
1622 "the 'shared' list sends messages out, but in order to"
1623 " receive messages, the other nodes must be configured"
1624 " to send messages out to your system as well. "
1625 "<li>If the remote room name is blank, it is assumed "
1626 "that the room name is identical on the remote node."
1627 "<li>If the remote room name is different, the remote "
1628 "node must also configure the name of the room here."
1635 /** Mailing list management */
1636 if (!strcmp(tab, "listserv")) {
1637 room_states RoomFlags;
1638 wprintf("<div class=\"tabcontent\">");
1640 wprintf("<br /><center>"
1641 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1642 "<tr><td VALIGN=TOP>");
1644 wprintf(_("<i>The contents of this room are being "
1645 "mailed <b>as individual messages</b> "
1646 "to the following list recipients:"
1647 "</i><br /><br />\n"));
1650 serv_getln(buf, sizeof buf);
1651 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1652 extract_token(cmd, buf, 0, '|', sizeof cmd);
1653 if (!strcasecmp(cmd, "listrecp")) {
1654 extract_token(recp, buf, 1, '|', sizeof recp);
1657 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1660 wprintf(_("(remove)"));
1661 wprintf("</A><br />");
1664 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1665 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1666 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1667 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1668 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1669 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1670 wprintf("</form>\n");
1672 wprintf("</td><td VALIGN=TOP>\n");
1674 wprintf(_("<i>The contents of this room are being "
1675 "mailed <b>in digest form</b> "
1676 "to the following list recipients:"
1677 "</i><br /><br />\n"));
1680 serv_getln(buf, sizeof buf);
1681 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1682 extract_token(cmd, buf, 0, '|', sizeof cmd);
1683 if (!strcasecmp(cmd, "digestrecp")) {
1684 extract_token(recp, buf, 1, '|', sizeof recp);
1687 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1691 wprintf(_("(remove)"));
1692 wprintf("</A><br />");
1695 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1696 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1697 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1698 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1699 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1700 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1701 wprintf("</form>\n");
1703 wprintf("</td></tr></table>\n");
1705 /** Pop open an address book -- begin **/
1706 wprintf("<div align=right>"
1707 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1709 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1714 _("Add recipients from Contacts or other address books"),
1715 _("Add recipients from Contacts or other address books")
1717 /** Pop open an address book -- end **/
1719 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1721 get_roomflags (&RoomFlags);
1723 /* Self Service subscription? */
1724 wprintf("<table><tr><td>\n");
1725 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1726 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1727 " <tr><td colspan=\"2\">\n",
1728 (is_selflist(&RoomFlags))?"checked":"");
1729 wprintf(_("The URL for subscribe/unsubscribe is: "));
1730 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1731 (is_https ? "https" : "http"),
1733 /* Public posting? */
1734 wprintf("<tr><td>");
1735 wprintf(_("Allow non-subscribers to mail to this room."));
1736 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1737 (is_publiclist(&RoomFlags))?"checked":"");
1739 /* Moderated List? */
1740 wprintf("<tr><td>");
1741 wprintf(_("Room post publication needs Aide permission."));
1742 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1743 (is_moderatedlist(&RoomFlags))?"checked":"");
1746 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1747 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1748 wprintf("</table></form>");
1751 wprintf("</CENTER>\n");
1756 /** Configuration of The Dreaded Auto-Purger */
1757 if (!strcmp(tab, "expire")) {
1758 wprintf("<div class=\"tabcontent\">");
1760 serv_puts("GPEX room");
1761 serv_getln(buf, sizeof buf);
1762 if (!strncmp(buf, "550", 3)) {
1763 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1764 _("Higher access is required to access this function.")
1767 else if (buf[0] != '2') {
1768 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1771 roompolicy = extract_int(&buf[4], 0);
1772 roomvalue = extract_int(&buf[4], 1);
1774 serv_puts("GPEX floor");
1775 serv_getln(buf, sizeof buf);
1776 if (buf[0] == '2') {
1777 floorpolicy = extract_int(&buf[4], 0);
1778 floorvalue = extract_int(&buf[4], 1);
1781 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1782 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1783 wprintf("<table border=0 cellspacing=5>\n");
1784 wprintf("<tr><td>");
1785 wprintf(_("Message expire policy for this room"));
1787 escputs(WC->wc_roomname);
1788 wprintf(")</td><td>");
1789 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1790 ((roompolicy == 0) ? "CHECKED" : "") );
1791 wprintf(_("Use the default policy for this floor"));
1792 wprintf("<br />\n");
1793 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1794 ((roompolicy == 1) ? "CHECKED" : "") );
1795 wprintf(_("Never automatically expire messages"));
1796 wprintf("<br />\n");
1797 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1798 ((roompolicy == 2) ? "CHECKED" : "") );
1799 wprintf(_("Expire by message count"));
1800 wprintf("<br />\n");
1801 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1802 ((roompolicy == 3) ? "CHECKED" : "") );
1803 wprintf(_("Expire by message age"));
1805 wprintf(_("Number of messages or days: "));
1806 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1807 wprintf("</td></tr>\n");
1809 if (WC->axlevel >= 6) {
1810 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1811 wprintf("<tr><td>");
1812 wprintf(_("Message expire policy for this floor"));
1814 escputs(floorlist[WC->wc_floor]);
1815 wprintf(")</td><td>");
1816 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1817 ((floorpolicy == 0) ? "CHECKED" : "") );
1818 wprintf(_("Use the system default"));
1819 wprintf("<br />\n");
1820 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1821 ((floorpolicy == 1) ? "CHECKED" : "") );
1822 wprintf(_("Never automatically expire messages"));
1823 wprintf("<br />\n");
1824 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1825 ((floorpolicy == 2) ? "CHECKED" : "") );
1826 wprintf(_("Expire by message count"));
1827 wprintf("<br />\n");
1828 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1829 ((floorpolicy == 3) ? "CHECKED" : "") );
1830 wprintf(_("Expire by message age"));
1832 wprintf(_("Number of messages or days: "));
1833 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1837 wprintf("<CENTER>\n");
1838 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1839 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1841 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1842 wprintf("</CENTER></td><tr>\n");
1844 wprintf("</table>\n"
1845 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1853 /** Access controls */
1854 if (!strcmp(tab, "access")) {
1855 wprintf("<div class=\"tabcontent\">");
1860 /** Fetch messages from remote locations */
1861 if (!strcmp(tab, "feeds")) {
1862 wprintf("<div class=\"tabcontent\">");
1865 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1866 wprintf("</i><br />\n");
1868 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1869 "<tr class=\"even\"><th>");
1870 wprintf(_("Remote host"));
1871 wprintf("</th><th>");
1872 wprintf(_("User name"));
1873 wprintf("</th><th>");
1874 wprintf(_("Password"));
1875 wprintf("</th><th>");
1876 wprintf(_("Keep messages on server?"));
1877 wprintf("</th><th> </th></tr>");
1880 serv_getln(buf, sizeof buf);
1882 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1883 extract_token(cmd, buf, 0, '|', sizeof cmd);
1884 if (!strcasecmp(cmd, "pop3client")) {
1885 safestrncpy(recp, &buf[11], sizeof recp);
1888 wprintf("<tr class=\"%s\">",
1889 (bg ? "even" : "odd")
1893 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1898 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1902 wprintf("<td>*****</td>"); /* Don't show the password */
1904 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1906 wprintf("<td class=\"button_link\">");
1907 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1910 wprintf(_("(remove)"));
1911 wprintf("</a></td>");
1917 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1919 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1920 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1921 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1923 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1926 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1929 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1932 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1935 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1936 wprintf("</td></tr>");
1937 wprintf("</form></table>\n");
1942 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1943 wprintf("</i><br />\n");
1945 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1946 "<tr class=\"even\"><th>");
1947 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1948 wprintf(_("Feed URL"));
1949 wprintf("</th><th>");
1950 wprintf("</th></tr>");
1953 serv_getln(buf, sizeof buf);
1955 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1956 extract_token(cmd, buf, 0, '|', sizeof cmd);
1957 if (!strcasecmp(cmd, "rssclient")) {
1958 safestrncpy(recp, &buf[10], sizeof recp);
1961 wprintf("<tr class=\"%s\">",
1962 (bg ? "even" : "odd")
1966 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1970 wprintf("<td class=\"button_link\">");
1971 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=rssclient|");
1974 wprintf(_("(remove)"));
1975 wprintf("</a></td>");
1981 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1983 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1984 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
1985 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1987 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
1988 "maxlength=\"256\" name=\"line_pop3host\">\n");
1991 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
1992 wprintf("</td></tr>");
1993 wprintf("</form></table>\n");
1999 /** end content of whatever tab is open now */
2000 wprintf("</div>\n");
2002 address_book_popup();
2008 * \brief Toggle self-service list subscription
2010 void toggle_self_service(void) {
2012 room_states RoomFlags;
2014 get_roomflags (&RoomFlags);
2016 // Yank out the bits we want to change
2017 RoomFlags.flags2 = RoomFlags.flags2 &
2018 !(QR2_SELFLIST|QR2_SMTP_PUBLIC|QR2_MODERATED);
2020 if (!strcasecmp(bstr("QR2_SelfList"), "yes"))
2021 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2022 if (!strcasecmp(bstr("QR2_SMTP_PUBLIC"), "yes"))
2023 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2024 if (!strcasecmp(bstr("QR2_Moderated"), "yes"))
2025 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2027 set_roomflags (&RoomFlags);
2035 * \brief save new parameters for a room
2041 char er_password[10];
2042 char er_dirname[15];
2043 char er_roomaide[26];
2046 int er_listingorder;
2052 if (IsEmptyStr(bstr("ok_button"))) {
2053 strcpy(WC->ImportantMessage,
2054 _("Cancelled. Changes were not saved."));
2059 serv_getln(buf, sizeof buf);
2061 if (buf[0] != '2') {
2062 strcpy(WC->ImportantMessage, &buf[4]);
2066 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
2067 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
2068 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
2069 er_flags = extract_int(&buf[4], 3);
2070 er_listingorder = extract_int(&buf[4], 5);
2071 er_defaultview = extract_int(&buf[4], 6);
2072 er_flags2 = extract_int(&buf[4], 7);
2074 strcpy(er_roomaide, bstr("er_roomaide"));
2075 if (IsEmptyStr(er_roomaide)) {
2077 serv_getln(buf, sizeof buf);
2078 if (buf[0] != '2') {
2079 strcpy(er_roomaide, "");
2081 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
2084 strcpy(buf, bstr("er_name"));
2086 if (!IsEmptyStr(buf)) {
2087 strcpy(er_name, buf);
2090 strcpy(buf, bstr("er_password"));
2092 if (!IsEmptyStr(buf))
2093 strcpy(er_password, buf);
2095 strcpy(buf, bstr("er_dirname"));
2097 if (!IsEmptyStr(buf))
2098 strcpy(er_dirname, buf);
2100 strcpy(buf, bstr("type"));
2101 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2103 if (!strcmp(buf, "invonly")) {
2104 er_flags |= (QR_PRIVATE);
2106 if (!strcmp(buf, "hidden")) {
2107 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2109 if (!strcmp(buf, "passworded")) {
2110 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2112 if (!strcmp(buf, "personal")) {
2113 er_flags |= QR_MAILBOX;
2115 er_flags &= ~QR_MAILBOX;
2118 if (!strcmp(bstr("prefonly"), "yes")) {
2119 er_flags |= QR_PREFONLY;
2121 er_flags &= ~QR_PREFONLY;
2124 if (!strcmp(bstr("readonly"), "yes")) {
2125 er_flags |= QR_READONLY;
2127 er_flags &= ~QR_READONLY;
2131 if (!strcmp(bstr("collabdel"), "yes")) {
2132 er_flags2 |= QR2_COLLABDEL;
2134 er_flags2 &= ~QR2_COLLABDEL;
2137 if (!strcmp(bstr("permanent"), "yes")) {
2138 er_flags |= QR_PERMANENT;
2140 er_flags &= ~QR_PERMANENT;
2143 if (!strcmp(bstr("subjectreq"), "yes")) {
2144 er_flags2 |= QR2_SUBJECTREQ;
2146 er_flags2 &= ~QR2_SUBJECTREQ;
2149 if (!strcmp(bstr("network"), "yes")) {
2150 er_flags |= QR_NETWORK;
2152 er_flags &= ~QR_NETWORK;
2155 if (!strcmp(bstr("directory"), "yes")) {
2156 er_flags |= QR_DIRECTORY;
2158 er_flags &= ~QR_DIRECTORY;
2161 if (!strcmp(bstr("ulallowed"), "yes")) {
2162 er_flags |= QR_UPLOAD;
2164 er_flags &= ~QR_UPLOAD;
2167 if (!strcmp(bstr("dlallowed"), "yes")) {
2168 er_flags |= QR_DOWNLOAD;
2170 er_flags &= ~QR_DOWNLOAD;
2173 if (!strcmp(bstr("visdir"), "yes")) {
2174 er_flags |= QR_VISDIR;
2176 er_flags &= ~QR_VISDIR;
2179 strcpy(buf, bstr("anon"));
2181 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2182 if (!strcmp(buf, "anononly"))
2183 er_flags |= QR_ANONONLY;
2184 if (!strcmp(buf, "anon2"))
2185 er_flags |= QR_ANONOPT;
2188 if (!strcmp(bstr("bump"), "yes"))
2191 er_floor = atoi(bstr("er_floor"));
2193 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2194 er_name, er_password, er_dirname, er_flags, bump, er_floor,
2195 er_listingorder, er_defaultview, er_flags2);
2197 serv_getln(buf, sizeof buf);
2198 if (buf[0] != '2') {
2199 strcpy(WC->ImportantMessage, &buf[4]);
2205 if (!IsEmptyStr(er_roomaide)) {
2206 sprintf(buf, "SETA %s", er_roomaide);
2208 serv_getln(buf, sizeof buf);
2209 if (buf[0] != '2') {
2210 strcpy(WC->ImportantMessage, &buf[4]);
2211 display_main_menu();
2216 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2223 * \brief Display form for Invite, Kick, and show Who Knows a room
2225 void do_invt_kick(void) {
2226 char buf[SIZ], room[SIZ], username[SIZ];
2229 serv_getln(buf, sizeof buf);
2231 if (buf[0] != '2') {
2235 extract_token(room, &buf[4], 0, '|', sizeof room);
2237 strcpy(username, bstr("username"));
2239 if (!IsEmptyStr(bstr("kick_button"))) {
2240 sprintf(buf, "KICK %s", username);
2242 serv_getln(buf, sizeof buf);
2244 if (buf[0] != '2') {
2245 strcpy(WC->ImportantMessage, &buf[4]);
2247 sprintf(WC->ImportantMessage,
2248 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2253 if (!IsEmptyStr(bstr("invite_button"))) {
2254 sprintf(buf, "INVT %s", username);
2256 serv_getln(buf, sizeof buf);
2258 if (buf[0] != '2') {
2259 strcpy(WC->ImportantMessage, &buf[4]);
2261 sprintf(WC->ImportantMessage,
2262 _("<B><I>User %s invited to room %s.</I></B>\n"),
2273 * \brief Display form for Invite, Kick, and show Who Knows a room
2275 void display_whok(void)
2277 char buf[SIZ], room[SIZ], username[SIZ];
2280 serv_getln(buf, sizeof buf);
2282 if (buf[0] != '2') {
2286 extract_token(room, &buf[4], 0, '|', sizeof room);
2289 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2290 wprintf(_("The users listed below have access to this room. "
2291 "To remove a user from the access list, select the user "
2292 "name from the list and click 'Kick'."));
2293 wprintf("<br /><br />");
2295 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2296 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2297 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2298 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2300 serv_getln(buf, sizeof buf);
2301 if (buf[0] == '1') {
2302 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2303 extract_token(username, buf, 0, '|', sizeof username);
2304 wprintf("<OPTION>");
2309 wprintf("</select><br />\n");
2311 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2312 wprintf("</form></CENTER>\n");
2314 wprintf("</td><td>");
2315 wprintf(_("To grant another user access to this room, enter the "
2316 "user name in the box below and click 'Invite'."));
2317 wprintf("<br /><br />");
2319 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2320 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2321 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2322 wprintf(_("Invite:"));
2324 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2325 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2326 "<input type=\"submit\" value=\"%s\">"
2327 "</form></CENTER>\n", _("Invite"));
2328 /** Pop open an address book -- begin **/
2330 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2332 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2335 _("Users"), _("Users")
2337 /** Pop open an address book -- end **/
2339 wprintf("</td></tr></table>\n");
2340 address_book_popup();
2347 * \brief display the form for entering a new room
2349 void display_entroom(void)
2354 serv_puts("CRE8 0");
2355 serv_getln(buf, sizeof buf);
2357 if (buf[0] != '2') {
2358 strcpy(WC->ImportantMessage, &buf[4]);
2359 display_main_menu();
2363 output_headers(1, 1, 1, 0, 0, 0);
2365 svprintf("BOXTITLE", WCS_STRING, _("Create a new room"));
2366 do_template("beginbox");
2368 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2369 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2371 wprintf("<table class=\"altern\"> ");
2373 wprintf("<tr class=\"even\"><td>");
2374 wprintf(_("Name of room: "));
2375 wprintf("</td><td>");
2376 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2377 wprintf("</td></tr>");
2379 wprintf("<tr class=\"odd\"><td>");
2380 wprintf(_("Resides on floor: "));
2381 wprintf("</td><td>");
2383 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2384 for (i = 0; i < 128; ++i)
2385 if (!IsEmptyStr(floorlist[i])) {
2386 wprintf("<option ");
2387 wprintf("value=\"%d\">", i);
2388 escputs(floorlist[i]);
2389 wprintf("</option>\n");
2391 wprintf("</select>\n");
2392 wprintf("</td></tr>");
2395 * Our clever little snippet of JavaScript automatically selects
2396 * a public room if the view is set to Bulletin Board or wiki, and
2397 * it selects a mailbox room otherwise. The user can override this,
2398 * of course. We also disable the floor selector for mailboxes.
2400 wprintf("<tr class=\"even\"><td>");
2401 wprintf(_("Default view for room: "));
2402 wprintf("</td><td>");
2403 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2404 " if ( (this.form.er_view.value == 0) "
2405 " || (this.form.er_view.value == 6) ) { "
2406 " this.form.type[0].checked=true; "
2407 " this.form.er_floor.disabled = false; "
2410 " this.form.type[4].checked=true; "
2411 " this.form.er_floor.disabled = true; "
2414 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2415 if (is_view_allowed_as_default(i)) {
2416 wprintf("<option %s value=\"%d\">",
2417 ((i == 0) ? "selected" : ""), i );
2418 escputs(viewdefs[i]);
2419 wprintf("</option>\n");
2422 wprintf("</select>\n");
2423 wprintf("</td></tr>");
2425 wprintf("<tr class=\"even\"><td>");
2426 wprintf(_("Type of room:"));
2427 wprintf("</td><td>");
2428 wprintf("<ul class=\"adminlist\">\n");
2430 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2431 wprintf("CHECKED OnChange=\""
2432 " if (this.form.type[0].checked == true) { "
2433 " this.form.er_floor.disabled = false; "
2436 wprintf(_("Public (automatically appears to everyone)"));
2439 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2440 " if (this.form.type[1].checked == true) { "
2441 " this.form.er_floor.disabled = false; "
2444 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2447 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2448 " if (this.form.type[2].checked == true) { "
2449 " this.form.er_floor.disabled = false; "
2452 wprintf(_("Private - require password: "));
2453 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2456 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2457 " if (this.form.type[3].checked == true) { "
2458 " this.form.er_floor.disabled = false; "
2461 wprintf(_("Private - invitation only"));
2464 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2466 " if (this.form.type[4].checked == true) { "
2467 " this.form.er_floor.disabled = true; "
2470 wprintf(_("Personal (mailbox for you only)"));
2473 wprintf("\n</ul>\n");
2474 wprintf("</td></tr></table>\n");
2476 wprintf("<div class=\"buttons\">\n");
2477 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2479 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2480 wprintf("</div>\n");
2481 wprintf("</form>\n<hr />");
2482 serv_printf("MESG roomaccess");
2483 serv_getln(buf, sizeof buf);
2484 if (buf[0] == '1') {
2488 do_template("endbox");
2497 * \brief support function for entroom() -- sets the default view
2499 void er_set_default_view(int newview) {
2512 serv_getln(buf, sizeof buf);
2513 if (buf[0] != '2') return;
2515 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2516 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2517 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2518 rm_bits1 = extract_int(&buf[4], 3);
2519 rm_floor = extract_int(&buf[4], 4);
2520 rm_listorder = extract_int(&buf[4], 5);
2521 rm_bits2 = extract_int(&buf[4], 7);
2523 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2524 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2525 rm_listorder, newview, rm_bits2
2527 serv_getln(buf, sizeof buf);
2533 * \brief enter a new room
2540 char er_password[SIZ];
2545 if (IsEmptyStr(bstr("ok_button"))) {
2546 strcpy(WC->ImportantMessage,
2547 _("Cancelled. No new room was created."));
2548 display_main_menu();
2551 strcpy(er_name, bstr("er_name"));
2552 strcpy(er_type, bstr("type"));
2553 strcpy(er_password, bstr("er_password"));
2554 er_floor = atoi(bstr("er_floor"));
2555 er_view = atoi(bstr("er_view"));
2558 if (!strcmp(er_type, "hidden"))
2560 if (!strcmp(er_type, "passworded"))
2562 if (!strcmp(er_type, "invonly"))
2564 if (!strcmp(er_type, "personal"))
2567 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2568 er_name, er_num_type, er_password, er_floor, 0, er_view);
2570 serv_getln(buf, sizeof buf);
2571 if (buf[0] != '2') {
2572 strcpy(WC->ImportantMessage, &buf[4]);
2573 display_main_menu();
2577 do_change_view(er_view); /* Now go there */
2582 * \brief display the screen to enter a private room
2584 void display_private(char *rname, int req_pass)
2586 output_headers(1, 1, 1, 0, 0, 0);
2588 svprintf("BOXTITLE", WCS_STRING, _("Go to a hidden room"));
2589 do_template("beginbox");
2592 wprintf(_("If you know the name of a hidden (guess-name) or "
2593 "passworded room, you can enter that room by typing "
2594 "its name below. Once you gain access to a private "
2595 "room, it will appear in your regular room listings "
2596 "so you don't have to keep returning here."));
2599 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2600 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2602 wprintf("<table class=\"altern\"> "
2603 "<tr class=\"even\"><td>");
2604 wprintf(_("Enter room name:"));
2606 "<input type=\"text\" name=\"gr_name\" "
2607 "value=\"%s\" maxlength=\"128\">\n", rname);
2610 wprintf("</td></tr><tr class=\"odd\"><td>");
2611 wprintf(_("Enter room password:"));
2612 wprintf("</td><td>");
2613 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2615 wprintf("</td></tr></table>\n");
2617 wprintf("<div class=\"buttons\">\n");
2618 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2620 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2624 wprintf("</div></form>\n");
2626 do_template("endbox");
2632 * \brief goto a private room
2634 void goto_private(void)
2639 if (IsEmptyStr(bstr("ok_button"))) {
2640 display_main_menu();
2643 strcpy(hold_rm, WC->wc_roomname);
2644 strcpy(buf, "GOTO ");
2645 strcat(buf, bstr("gr_name"));
2647 strcat(buf, bstr("gr_pass"));
2649 serv_getln(buf, sizeof buf);
2651 if (buf[0] == '2') {
2652 smart_goto(bstr("gr_name"));
2655 if (!strncmp(buf, "540", 3)) {
2656 display_private(bstr("gr_name"), 1);
2659 output_headers(1, 1, 1, 0, 0, 0);
2660 wprintf("%s\n", &buf[4]);
2667 * \brief display the screen to zap a room
2669 void display_zap(void)
2671 output_headers(1, 1, 2, 0, 0, 0);
2673 wprintf("<div id=\"banner\">\n");
2675 wprintf(_("Zap (forget/unsubscribe) the current room"));
2677 wprintf("</div>\n");
2679 wprintf("<div id=\"content\" class=\"service\">\n");
2681 wprintf(_("If you select this option, <em>%s</em> will "
2682 "disappear from your room list. Is this what you wish "
2683 "to do?<br />\n"), WC->wc_roomname);
2685 wprintf("<form method=\"POST\" action=\"zap\">\n");
2686 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2687 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2689 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2690 wprintf("</form>\n");
2701 char final_destination[SIZ];
2704 * If the forget-room routine fails for any reason, we fall back
2705 * to the current room; otherwise, we go to the Lobby
2707 strcpy(final_destination, WC->wc_roomname);
2709 if (!IsEmptyStr(bstr("ok_button"))) {
2710 serv_printf("GOTO %s", WC->wc_roomname);
2711 serv_getln(buf, sizeof buf);
2712 if (buf[0] == '2') {
2714 serv_getln(buf, sizeof buf);
2715 if (buf[0] == '2') {
2716 strcpy(final_destination, "_BASEROOM_");
2720 smart_goto(final_destination);
2726 * \brief Delete the current room
2728 void delete_room(void)
2732 serv_puts("KILL 1");
2733 serv_getln(buf, sizeof buf);
2734 if (buf[0] != '2') {
2735 strcpy(WC->ImportantMessage, &buf[4]);
2736 display_main_menu();
2739 smart_goto("_BASEROOM_");
2746 * \brief Perform changes to a room's network configuration
2748 void netedit(void) {
2758 if (!IsEmptyStr(bstr("line_pop3host"))) {
2759 strcpy(line, bstr("prefix"));
2760 strcat(line, bstr("line_pop3host"));
2762 strcat(line, bstr("line_pop3user"));
2764 strcat(line, bstr("line_pop3pass"));
2766 strcat(line, atoi(bstr("line_pop3keep")) ? "1" : "0" );
2767 strcat(line, bstr("suffix"));
2769 else if (!IsEmptyStr(bstr("line"))) {
2770 strcpy(line, bstr("prefix"));
2771 strcat(line, bstr("line"));
2772 strcat(line, bstr("suffix"));
2787 serv_getln(buf, sizeof buf);
2788 if (buf[0] != '1') {
2794 /** This loop works for add *or* remove. Spiffy, eh? */
2795 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2796 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2797 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2798 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2799 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2800 if ( (strcasecmp(cmpa0, cmpb0))
2801 || (strcasecmp(cmpa1, cmpb1)) ) {
2802 fprintf(fp, "%s\n", buf);
2808 serv_getln(buf, sizeof buf);
2809 if (buf[0] != '4') {
2815 while (fgets(buf, sizeof buf, fp) != NULL) {
2816 buf[strlen(buf)-1] = 0;
2820 if (!IsEmptyStr(bstr("add_button"))) {
2821 num_addrs = num_tokens(bstr("line"), ',');
2822 if (num_addrs < 2) {
2823 /* just adding one node or address */
2827 /* adding multiple addresses separated by commas */
2828 for (i=0; i<num_addrs; ++i) {
2829 strcpy(line, bstr("prefix"));
2830 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2833 strcat(line, bstr("suffix"));
2847 * \brief Convert a room name to a folder-ish-looking name.
2848 * \param folder the folderish name
2849 * \param room the room name
2850 * \param floor the floor name
2851 * \param is_mailbox is it a mailbox?
2853 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2858 * For mailboxes, just do it straight...
2861 sprintf(folder, "My folders|%s", room);
2865 * Otherwise, prefix the floor name as a "public folders" moniker
2868 if (floor > MAX_FLOORS) {
2870 sprintf(folder, "%%%%%|%s", room);
2873 sprintf(folder, "%s|%s", floorlist[floor], room);
2878 * Replace "\" characters with "|" for pseudo-folder-delimiting
2880 len = strlen (folder);
2881 for (i=0; i<len; ++i) {
2882 if (folder[i] == '\\') folder[i] = '|';
2890 * \brief Back end for change_view()
2891 * \param newview set newview???
2893 void do_change_view(int newview) {
2896 serv_printf("VIEW %d", newview);
2897 serv_getln(buf, sizeof buf);
2898 WC->wc_view = newview;
2899 smart_goto(WC->wc_roomname);
2905 * \brief Change the view for this room
2907 void change_view(void) {
2910 view = atol(bstr("view"));
2911 do_change_view(view);
2916 * \brief One big expanded tree list view --- like a folder list
2917 * \param fold the folder to view
2918 * \param max_folders how many folders???
2919 * \param num_floors hom many floors???
2921 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2925 int has_subfolders = 0;
2928 parents = malloc(max_folders * sizeof(int));
2930 /** BEGIN TREE MENU */
2931 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2933 /** include NanoTree */
2934 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2936 /** initialize NanoTree */
2937 wprintf("<script type=\"text/javascript\"> \n"
2938 " showRootNode = false; \n"
2939 " sortNodes = false; \n"
2940 " dragable = false; \n"
2942 " function standardClick(treeNode) { \n"
2945 " var closedGif = 'static/folder_closed.gif'; \n"
2946 " var openGif = 'static/folder_open.gif'; \n"
2948 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2952 for (i=0; i<max_folders; ++i) {
2955 if ((i+1) < max_folders) {
2957 len = strlen(fold[i].name);
2958 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2959 && (fold[i+1].name[len] == '|') ) {
2964 levels = num_tokens(fold[i].name, '|');
2965 parents[levels] = i;
2967 wprintf("var node%d = new TreeNode(%d, '", i, i);
2969 if (fold[i].selectable) {
2970 wprintf("<a href=\"dotgoto?room=");
2971 urlescputs(fold[i].room);
2976 wprintf("<span class=\"roomlist_floor\">");
2978 else if (fold[i].hasnewmsgs) {
2979 wprintf("<span class=\"roomlist_new\">");
2982 wprintf("<span class=\"roomlist_old\">");
2984 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2989 if (has_subfolders) {
2990 wprintf("new Array(closedGif, openGif)");
2992 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2993 wprintf("'static/viewcontacts_16x.gif'");
2995 else if (fold[i].view == VIEW_CALENDAR) {
2996 wprintf("'static/calarea_16x.gif'");
2998 else if (fold[i].view == VIEW_CALBRIEF) {
2999 wprintf("'static/calarea_16x.gif'");
3001 else if (fold[i].view == VIEW_TASKS) {
3002 wprintf("'static/taskmanag_16x.gif'");
3004 else if (fold[i].view == VIEW_NOTES) {
3005 wprintf("'static/storenotes_16x.gif'");
3007 else if (fold[i].view == VIEW_MAILBOX) {
3008 wprintf("'static/privatemess_16x.gif'");
3011 wprintf("'static/chatrooms_16x.gif'");
3014 urlescputs(fold[i].name);
3018 wprintf("rootNode.addChild(node%d);\n", i);
3021 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3025 wprintf("container = document.getElementById('roomlist_div'); \n"
3031 /** END TREE MENU */
3035 * \brief Boxes and rooms and lists ... oh my!
3036 * \param fold the folder to view
3037 * \param max_folders how many folders???
3038 * \param num_floors hom many floors???
3040 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3042 char floor_name[256];
3043 char old_floor_name[256];
3045 int levels, oldlevels;
3048 static int columns = 3;
3049 int boxes_per_column = 0;
3050 int current_column = 0;
3053 strcpy(floor_name, "");
3054 strcpy(old_floor_name, "");
3057 while (nf % columns != 0) ++nf;
3058 boxes_per_column = (nf / columns);
3059 if (boxes_per_column < 1) boxes_per_column = 1;
3061 /** Outer table (for columnization) */
3062 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3063 "<tr><td valign=top>");
3067 for (i=0; i<max_folders; ++i) {
3069 levels = num_tokens(fold[i].name, '|');
3070 extract_token(floor_name, fold[i].name, 0,
3071 '|', sizeof floor_name);
3073 if ( (strcasecmp(floor_name, old_floor_name))
3074 && (!IsEmptyStr(old_floor_name)) ) {
3076 do_template("endbox");
3080 if ((num_boxes % boxes_per_column) == 0) {
3082 if (current_column < columns) {
3083 wprintf("</td><td valign=top>\n");
3087 strcpy(old_floor_name, floor_name);
3090 /** Begin inner box */
3091 stresc(boxtitle, 256, floor_name, 1, 0);
3092 svprintf("BOXTITLE", WCS_STRING, boxtitle);
3093 do_template("beginbox");
3100 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3101 if (fold[i].selectable) {
3102 wprintf("<a href=\"dotgoto?room=");
3103 urlescputs(fold[i].room);
3109 if (fold[i].hasnewmsgs) {
3110 wprintf("<span class=\"roomlist_new\">");
3113 wprintf("<span class=\"roomlist_old\">");
3115 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3118 if (fold[i].selectable) {
3124 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3125 wprintf(" (INBOX)");
3127 wprintf("<br />\n");
3130 /** End the final inner box */
3131 do_template("endbox");
3133 wprintf("</td></tr></table>\n");
3137 * \brief print a floor div???
3138 * \param which_floordiv name of the floordiv???
3140 void set_floordiv_expanded(char *which_floordiv) {
3141 begin_ajax_response();
3142 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
3143 end_ajax_response();
3147 * \brief view the iconbar
3148 * \param fold the folder to view
3149 * \param max_folders how many folders???
3150 * \param num_floors hom many floors???
3152 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3154 char floor_name[256];
3155 char old_floor_name[256];
3156 char floordivtitle[256];
3157 char floordiv_id[32];
3158 int levels, oldlevels;
3160 int num_drop_targets = 0;
3163 strcpy(floor_name, "");
3164 strcpy(old_floor_name, "");
3168 for (i=0; i<max_folders; ++i) {
3170 levels = num_tokens(fold[i].name, '|');
3171 extract_token(floor_name, fold[i].name, 0,
3172 '|', sizeof floor_name);
3174 if ( (strcasecmp(floor_name, old_floor_name))
3175 && (!IsEmptyStr(old_floor_name)) ) {
3176 /** End inner box */
3178 wprintf("</div>\n"); /** floordiv */
3180 strcpy(old_floor_name, floor_name);
3184 stresc(floordivtitle, 256, floor_name, 0, 0);
3185 sprintf(floordiv_id, "floordiv%d", i);
3186 wprintf("<span class=\"ib_roomlist_floor\" "
3187 "onClick=\"expand_floor('%s')\">"
3188 "%s</span><br>\n", floordiv_id, floordivtitle);
3189 wprintf("<div id=\"%s\" style=\"display:%s\">",
3191 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
3198 wprintf("<div id=\"roomdiv%d\">", i);
3200 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3202 /** choose the icon */
3203 if (fold[i].view == VIEW_ADDRESSBOOK) {
3204 icon = "viewcontacts_16x.gif" ;
3206 else if (fold[i].view == VIEW_CALENDAR) {
3207 icon = "calarea_16x.gif" ;
3209 else if (fold[i].view == VIEW_CALBRIEF) {
3210 icon = "calarea_16x.gif" ;
3212 else if (fold[i].view == VIEW_TASKS) {
3213 icon = "taskmanag_16x.gif" ;
3215 else if (fold[i].view == VIEW_NOTES) {
3216 icon = "storenotes_16x.gif" ;
3218 else if (fold[i].view == VIEW_MAILBOX) {
3219 icon = "privatemess_16x.gif" ;
3222 icon = "chatrooms_16x.gif" ;
3225 if (fold[i].selectable) {
3226 wprintf("<a href=\"dotgoto?room=");
3227 urlescputs(fold[i].room);
3229 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
3234 if (fold[i].hasnewmsgs) {
3235 wprintf("<span class=\"ib_roomlist_new\">");
3238 wprintf("<span class=\"ib_roomlist_old\">");
3240 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3242 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3243 wprintf(" (INBOX)");
3246 if (fold[i].selectable) {
3253 wprintf("</div>\n"); /** roomdiv */
3256 wprintf("</div>\n"); /** floordiv */
3259 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3260 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3262 num_drop_targets = 0;
3264 for (i=0; i<max_folders; ++i) {
3265 levels = num_tokens(fold[i].name, '|');
3267 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3268 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3269 jsescputs(fold[i].room);
3275 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3276 if ((WC->floordiv_expanded[0] != '\0')&&
3277 (WC->floordiv_expanded[1] != '\0')){
3278 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
3282 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3288 * \brief Show the room list.
3289 * (only should get called by
3290 * knrooms() because that's where output_headers() is called from)
3291 * \param viewpref the view preferences???
3294 void list_all_rooms_by_floor(char *viewpref) {
3297 struct folder *fold = NULL;
3299 int max_folders = 0;
3300 int alloc_folders = 0;
3306 int num_floors = 1; /** add an extra one for private folders */
3310 /** If our cached folder list is very old, burn it. */
3311 if (WC->cache_fold != NULL) {
3312 if ((time(NULL) - WC->cache_timestamp) > 300) {
3313 free(WC->cache_fold);
3314 WC->cache_fold = NULL;
3318 /** Can we do the iconbar roomlist from cache? */
3319 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3320 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3324 /** Grab the floor table so we know how to build the list... */
3327 /** Start with the mailboxes */
3330 fold = malloc(sizeof(struct folder));
3331 memset(fold, 0, sizeof(struct folder));
3332 strcpy(fold[0].name, "My folders");
3333 fold[0].is_mailbox = 1;
3335 /** Then add floors */
3337 serv_getln(buf, sizeof buf);
3338 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3339 if (max_folders >= alloc_folders) {
3340 alloc_folders = max_folders + 100;
3341 fold = realloc(fold,
3342 alloc_folders * sizeof(struct folder));
3344 memset(&fold[max_folders], 0, sizeof(struct folder));
3345 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3346 extract_token(buf3, buf, 0, '|', SIZ);
3347 fold[max_folders].floor = atol (buf3);
3352 for (i=0; i<num_floors; i++)
3353 if (IDMax < fold[i].floor)
3354 IDMax = fold[i].floor;
3355 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3356 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3357 for (i=0; i<num_floors; i++)
3358 floor_mapping[fold[i].floor]=i;
3360 /** refresh the messages index for this room */
3361 // serv_puts("GOTO ");
3362 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3363 /** Now add rooms */
3365 serv_getln(buf, sizeof buf);
3366 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3367 if (max_folders >= alloc_folders) {
3368 alloc_folders = max_folders + 100;
3369 fold = realloc(fold,
3370 alloc_folders * sizeof(struct folder));
3372 memset(&fold[max_folders], 0, sizeof(struct folder));
3373 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3374 ra_flags = extract_int(buf, 5);
3375 flags = extract_int(buf, 1);
3376 fold[max_folders].floor = extract_int(buf, 2);
3377 fold[max_folders].hasnewmsgs =
3378 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3379 if (flags & QR_MAILBOX) {
3380 fold[max_folders].is_mailbox = 1;
3382 fold[max_folders].view = extract_int(buf, 6);
3383 room_to_folder(fold[max_folders].name,
3384 fold[max_folders].room,
3385 fold[max_folders].floor,
3386 fold[max_folders].is_mailbox);
3387 fold[max_folders].selectable = 1;
3388 /* Increase the room count for the associtaed floor */
3389 if (fold[max_folders].is_mailbox) {
3390 fold[0].num_rooms++;
3393 i = floor_mapping[fold[max_folders].floor];
3394 fold[i].num_rooms++;
3400 * Remove any floors that don't have rooms
3402 get_preference("emptyfloors", buf2, sizeof buf2);
3403 if (buf2[0]==0 || (strcasecmp(buf2, "no") == 0))
3405 for (i=0; i<num_floors; i++)
3407 if (fold[i].num_rooms == 0) {
3408 for (j=i; j<max_folders; j++) {
3409 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3418 /** Bubble-sort the folder list */
3419 for (i=0; i<max_folders; ++i) {
3420 for (j=0; j<(max_folders-1)-i; ++j) {
3421 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3422 swap = strcasecmp(fold[j].name, fold[j+1].name);
3425 if ( (fold[j+1].is_mailbox)
3426 && (!fold[j].is_mailbox)) {
3434 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3435 memcpy(&fold[j], &fold[j+1],
3436 sizeof(struct folder));
3437 memcpy(&fold[j+1], &ftmp,
3438 sizeof(struct folder));
3444 if (!strcasecmp(viewpref, "folders")) {
3445 do_folder_view(fold, max_folders, num_floors);
3447 else if (!strcasecmp(viewpref, "hackish_view")) {
3448 for (i=0; i<max_folders; ++i) {
3449 escputs(fold[i].name);
3450 wprintf("<br />\n");
3453 else if (!strcasecmp(viewpref, "iconbar")) {
3454 do_iconbar_view(fold, max_folders, num_floors);
3457 do_rooms_view(fold, max_folders, num_floors);
3460 /* Don't free the folder list ... cache it for future use! */
3461 if (WC->cache_fold != NULL) {
3462 free(WC->cache_fold);
3464 WC->cache_fold = fold;
3465 WC->cache_max_folders = max_folders;
3466 WC->cache_num_floors = num_floors;
3467 WC->cache_timestamp = time(NULL);
3468 free(floor_mapping);
3473 * \brief Do either a known rooms list or a folders list, depending on the
3478 char listviewpref[SIZ];
3480 output_headers(1, 1, 2, 0, 0, 0);
3482 /** Determine whether the user is trying to change views */
3483 if (bstr("view") != NULL) {
3484 if (!IsEmptyStr(bstr("view"))) {
3485 set_preference("roomlistview", bstr("view"), 1);
3489 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3491 if ( (strcasecmp(listviewpref, "folders"))
3492 && (strcasecmp(listviewpref, "table")) ) {
3493 strcpy(listviewpref, "rooms");
3497 wprintf("<div id=\"banner\">\n");
3498 wprintf("<div class=\"room_banner\">");
3500 if (!strcasecmp(listviewpref, "rooms")) {
3501 wprintf(_("Room list"));
3503 if (!strcasecmp(listviewpref, "folders")) {
3504 wprintf(_("Folder list"));
3506 if (!strcasecmp(listviewpref, "table")) {
3507 wprintf(_("Room list"));
3509 wprintf("</h1></div>\n");
3511 /** offer the ability to switch views */
3512 wprintf("<ul class=\"room_actions\">\n");
3513 wprintf("<li class=\"start_page\">");
3516 wprintf("<li><form name=\"roomlistomatic\">\n"
3517 "<select name=\"newview\" size=\"1\" "
3518 "OnChange=\"location.href=roomlistomatic.newview.options"
3519 "[selectedIndex].value\">\n");
3521 wprintf("<option %s value=\"knrooms&view=rooms\">"
3524 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3527 wprintf("<option %s value=\"knrooms&view=folders\">"
3528 "View as folder list"
3530 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3533 wprintf("</select>");
3534 wprintf("</form></li>");
3535 wprintf("</ul></div>\n");
3537 wprintf("<div id=\"content\" class=\"service\">\n");
3539 /** Display the room list in the user's preferred format */
3540 list_all_rooms_by_floor(listviewpref);
3547 * \brief Set the message expire policy for this room and/or floor
3549 void set_room_policy(void) {
3552 if (IsEmptyStr(bstr("ok_button"))) {
3553 strcpy(WC->ImportantMessage,
3554 _("Cancelled. Changes were not saved."));
3559 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3560 serv_getln(buf, sizeof buf);
3561 strcpy(WC->ImportantMessage, &buf[4]);
3563 if (WC->axlevel >= 6) {
3564 strcat(WC->ImportantMessage, "<br />\n");
3565 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3566 serv_getln(buf, sizeof buf);
3567 strcat(WC->ImportantMessage, &buf[4]);