3 * Lots of different room-related operations.
8 char floorlist[128][SIZ]; /**< list of our floor names */
10 char *viewdefs[9]; /**< the different kinds of available views */
13 * Initialize the viewdefs with localized strings
15 void initialize_viewdefs(void) {
16 viewdefs[0] = _("Bulletin Board");
17 viewdefs[1] = _("Mail Folder");
18 viewdefs[2] = _("Address Book");
19 viewdefs[3] = _("Calendar");
20 viewdefs[4] = _("Task List");
21 viewdefs[5] = _("Notes List");
22 viewdefs[6] = _("Wiki");
23 viewdefs[7] = _("Calendar List");
24 viewdefs[8] = _("Journal");
28 * Determine which views are allowed as the default for creating a new room.
30 int is_view_allowed_as_default(int which_view)
33 case VIEW_BBS: return(1);
34 case VIEW_MAILBOX: return(1);
35 case VIEW_ADDRESSBOOK: return(1);
36 case VIEW_CALENDAR: return(1);
37 case VIEW_TASKS: return(1);
38 case VIEW_NOTES: return(1);
39 case VIEW_WIKI: return(0); /**< because it isn't finished yet */
40 case VIEW_CALBRIEF: return(0);
41 case VIEW_JOURNAL: return(0);
42 default: return(0); /**< should never get here */
48 * load the list of floors
50 void load_floorlist(void)
55 for (a = 0; a < 128; ++a)
59 serv_getln(buf, sizeof buf);
61 strcpy(floorlist[0], "Main Floor");
64 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
65 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
71 * Free a session's march list
73 void free_march_list(struct wcsession *wcf)
77 while (wcf->march != NULL) {
78 mptr = wcf->march->next;
88 * remove a room from the march list
90 void remove_march(char *aaa)
92 struct march *mptr, *mptr2;
94 if (WC->march == NULL)
97 if (!strcasecmp(WC->march->march_name, aaa)) {
98 mptr = WC->march->next;
104 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
105 if (!strcasecmp(mptr->march_name, aaa)) {
106 mptr2->next = mptr->next;
119 * display rooms in tree structure
121 void room_tree_list(struct roomlisting *rp)
130 room_tree_list(rp->lnext);
132 strcpy(rmname, rp->rlname);
135 wprintf("<a href=\"dotgoto&room=");
139 escputs1(rmname, 1, 1);
140 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
142 else if (f & QR_DIRECTORY)
144 else if (f & QR_NETWORK)
148 wprintf("</a><tt> </tt>\n");
150 room_tree_list(rp->rnext);
156 * \brief Room ordering stuff (compare first by floor, then by order)
157 * \param r1 first roomlist to compare
158 * \param r2 second roomlist co compare
159 * \return are they the same???
161 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
163 if ((r1 == NULL) && (r2 == NULL))
169 if (r1->rlfloor < r2->rlfloor)
171 if (r1->rlfloor > r2->rlfloor)
173 if (r1->rlorder < r2->rlorder)
175 if (r1->rlorder > r2->rlorder)
182 * \brief Common code for all room listings
183 * \param variety what???
185 void listrms(char *variety)
190 struct roomlisting *rl = NULL;
191 struct roomlisting *rp;
192 struct roomlisting *rs;
194 /** Ask the server for a room list */
196 serv_getln(buf, sizeof buf);
202 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
204 rp = malloc(sizeof(struct roomlisting));
205 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
206 rp->rlflags = extract_int(buf, 1);
207 rp->rlfloor = extract_int(buf, 2);
208 rp->rlorder = extract_int(buf, 3);
217 if (rordercmp(rp, rs) < 0) {
218 if (rs->lnext == NULL) {
225 if (rs->rnext == NULL) {
238 * If no rooms were listed, print an nbsp to make the cell
239 * borders show up anyway.
241 if (num_rooms == 0) wprintf(" ");
246 * \brief list all forgotten rooms
248 void zapped_list(void)
250 output_headers(1, 1, 1, 0, 0, 0);
252 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
253 do_template("beginbox");
257 wprintf("<br /><br />\n");
258 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
259 do_template("endbox");
265 * \brief read this room's info file (set v to 1 for verbose mode)
272 int fullinfo_len = 0;
275 serv_getln(buf, sizeof buf);
278 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
279 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
280 strcpy(&fullinfo[fullinfo_len], buf);
281 fullinfo_len += strlen(buf);
285 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
286 strcpy(&briefinfo[50], "...");
288 wprintf("<div class=\"infos\" "
289 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
292 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
293 wprintf("<img class=\"close_infos\" "
294 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
295 "src=\"static/closewindow.gif\" alt=\"%s\">",
310 * \brief Display room banner icon.
311 * The server doesn't actually
312 * need the room name, but we supply it in order to
313 * keep the browser from using a cached icon from
316 void embed_room_graphic(void) {
319 serv_puts("OIMG _roompic_");
320 serv_getln(buf, sizeof buf);
322 wprintf("<img height=\"64px\" src=\"image&name=_roompic_&room=");
323 urlescputs(WC->wc_roomname);
326 serv_getln(buf, sizeof buf);
328 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
329 wprintf("<img height=48 width=48 src=\""
330 "static/viewcontacts_48x.gif"
334 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
335 wprintf("<img height=48 width=48 src=\""
336 "static/calarea_48x.gif"
340 else if (WC->wc_view == VIEW_TASKS) {
341 wprintf("<img height=48 width=48 src=\""
342 "static/taskmanag_48x.gif"
346 else if (WC->wc_view == VIEW_NOTES) {
347 wprintf("<img height=48 width=48 src=\""
348 "static/storenotes_48x.gif"
352 else if (WC->wc_view == VIEW_MAILBOX) {
353 wprintf("<img height=48 width=48 src=\""
354 "static/privatemess_48x.gif"
359 wprintf("<img height=48 width=48 src=\""
360 "static/chatrooms_48x.gif"
370 * \brief Display the current view and offer an option to change it
372 void embed_view_o_matic(void) {
375 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
376 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
377 wprintf("<label for=\"view_name\">");
378 wprintf(_("View as:"));
380 "<select name=\"newview\" size=\"1\" "
381 "id=\"view_name\" class=\"selectbox\" "
382 "OnChange=\"location.href=viewomatic.newview.options"
383 "[selectedIndex].value\">\n");
385 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
387 * Only offer the views that make sense, given the default
388 * view for the room. For example, don't offer a Calendar
389 * view in a non-Calendar room.
393 || (i == WC->wc_default_view) /**< default */
394 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
395 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
396 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
399 wprintf("<option %s value=\"changeview?view=%d\">",
400 ((i == WC->wc_view) ? "selected" : ""),
402 escputs(viewdefs[i]);
403 wprintf("</option>\n");
406 wprintf("</select></form>\n");
411 * \brief Display a search box
413 void embed_search_o_matic(void) {
414 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
415 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
416 wprintf("<label for=\"search_name\">");
417 wprintf(_("Search: "));
418 wprintf("</label> <input "
419 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
420 "id=\"search_name\" class=\"inputbox\">\n"
422 wprintf("</form>\n");
427 * \brief Embed the room banner
429 * \param got The information returned from a GOTO server command
430 * \param navbar_style Determines which navigation buttons to display
434 void embed_room_banner(char *got, int navbar_style) {
437 char sanitized_roomname[256];
438 char with_files[256];
442 * We need to have the information returned by a GOTO server command.
443 * If it isn't supplied, we fake it by issuing our own GOTO.
446 serv_printf("GOTO %s", WC->wc_roomname);
447 serv_getln(buf, sizeof buf);
451 /** The browser needs some information for its own use */
452 wprintf("<script type=\"text/javascript\"> \n"
453 " room_is_trash = %d; \n"
459 * If the user happens to select the "make this my start page" link,
460 * we want it to remember the URL as a "/dotskip" one instead of
461 * a "skip" or "gotonext" or something like that.
463 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
466 /** Check for new mail. */
467 WC->new_mail = extract_int(&got[4], 9);
468 WC->wc_view = extract_int(&got[4], 11);
470 /* Is this a directory room and does it contain files and how many? */
471 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
474 serv_getln(buf2, sizeof buf2);
475 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
477 snprintf (with_files, sizeof with_files,
478 "; <a href=\"display_room_directory\"> %d %s </a>",
480 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
483 strcpy (with_files, "");
485 stresc(sanitized_roomname, 256, WC->wc_roomname, 1, 1);
486 svprintf("ROOMNAME", WCS_STRING, "%s", sanitized_roomname);
487 svprintf("NUMMSGS", WCS_STRING,
488 _("%d new of %d messages%s"),
489 extract_int(&got[4], 1),
490 extract_int(&got[4], 2),
493 svcallback("ROOMPIC", embed_room_graphic);
494 svcallback("ROOMINFO", readinfo);
495 svcallback("VIEWOMATIC", embed_view_o_matic);
496 svcallback("SEARCHOMATIC", embed_search_o_matic);
497 svcallback("START", offer_start_page);
499 do_template("roombanner");
500 if (navbar_style != navbar_none) {
502 wprintf("<div id=\"navbar\"><ul>");
504 if (navbar_style == navbar_default) wprintf(
505 "<li class=\"ungoto\">"
506 "<a href=\"ungoto\">"
507 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
508 "<span class=\"navbar_link\">%s</span></A>"
509 "</li>\n", _("Ungoto")
512 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
514 "<li class=\"newmess\">"
515 "<a href=\"readnew\">"
516 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
517 "<span class=\"navbar_link\">%s</span></A>"
518 "</li>\n", _("Read new messages")
522 if (navbar_style == navbar_default) {
523 switch(WC->wc_view) {
524 case VIEW_ADDRESSBOOK:
526 "<li class=\"viewcontacts\">"
527 "<a href=\"readfwd\">"
528 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
530 "<span class=\"navbar_link\">"
532 "</span></a></li>\n", _("View contacts")
537 "<li class=\"staskday\">"
538 "<a href=\"readfwd?calview=day\">"
539 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
541 "<span class=\"navbar_link\">"
543 "</span></a></li>\n", _("Day view")
546 "<li class=\"monthview\">"
547 "<a href=\"readfwd?calview=month\">"
548 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
550 "<span class=\"navbar_link\">"
552 "</span></a></li>\n", _("Month view")
557 "<li class=\"monthview\">"
558 "<a href=\"readfwd?calview=month\">"
559 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
561 "<span class=\"navbar_link\">"
563 "</span></a></li>\n", _("Calendar list")
568 "<li class=\"taskmanag\">"
569 "<a href=\"readfwd\">"
570 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
572 "<span class=\"navbar_link\">"
574 "</span></a></li>\n", _("View tasks")
579 "<li class=\"viewnotes\">"
580 "<a href=\"readfwd\">"
581 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
583 "<span class=\"navbar_link\">"
585 "</span></a></li>\n", _("View notes")
590 "<li class=\"readallmess\">"
591 "<a href=\"readfwd\">"
592 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
594 "<span class=\"navbar_link\">"
596 "</span></a></li>\n", _("View message list")
601 "<li class=\"readallmess\">"
602 "<a href=\"readfwd\">"
603 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
605 "<span class=\"navbar_link\">"
607 "</span></a></li>\n", _("Wiki home")
612 "<li class=\"readallmess\">"
613 "<a href=\"readfwd\">"
614 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
616 "<span class=\"navbar_link\">"
618 "</span></a></li>\n", _("Read all messages")
624 if (navbar_style == navbar_default) {
625 switch(WC->wc_view) {
626 case VIEW_ADDRESSBOOK:
628 "<li class=\"addnewcontact\">"
629 "<a href=\"display_enter\">"
630 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
631 "border=\"0\"><span class=\"navbar_link\">"
633 "</span></a></li>\n", _("Add new contact")
638 wprintf("<li class=\"addevent\"><a href=\"display_enter");
639 if (!IsEmptyStr(bstr("year" ))) wprintf("?year=%s", bstr("year"));
640 if (!IsEmptyStr(bstr("month"))) wprintf("?month=%s", bstr("month"));
641 if (!IsEmptyStr(bstr("day" ))) wprintf("?day=%s", bstr("day"));
643 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
644 "border=\"0\"><span class=\"navbar_link\">"
646 "</span></a></li>\n", _("Add new event")
651 "<li class=\"newmess\">"
652 "<a href=\"display_enter\">"
653 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
654 "border=\"0\"><span class=\"navbar_link\">"
656 "</span></a></li>\n", _("Add new task")
661 "<li class=\"enternewnote\">"
662 "<a href=\"javascript:add_new_note();\">"
663 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
664 "border=\"0\"><span class=\"navbar_link\">"
666 "</span></a></li>\n", _("Add new note")
670 safestrncpy(buf, bstr("page"), sizeof buf);
673 "<li class=\"newmess\">"
674 "<a href=\"display_enter?wikipage=%s\">"
675 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
676 "border=\"0\"><span class=\"navbar_link\">"
678 "</span></a></li>\n", buf, _("Edit this page")
683 "<li class=\"newmess\">"
684 "<a href=\"display_enter\">"
685 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
686 "border=\"0\"><span class=\"navbar_link\">"
688 "</span></a></li>\n", _("Write mail")
693 "<li class=\"newmess\">"
694 "<a href=\"display_enter\">"
695 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
696 "border=\"0\"><span class=\"navbar_link\">"
698 "</span></a></li>\n", _("Enter a message")
704 if (navbar_style == navbar_default) wprintf(
705 "<li class=\"skipthisroom\">"
708 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
709 "<span class=\"navbar_link\">%s</span></a>"
711 _("Leave all messages marked as unread, go to next room with unread messages"),
715 if (navbar_style == navbar_default) wprintf(
716 "<li class=\"markngo\">"
717 "<a href=\"gotonext\" "
719 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
720 "<span class=\"navbar_link\">%s</span></a>"
722 _("Mark all messages as read, go to next room with unread messages"),
726 wprintf("</ul></div>\n");
733 * \brief back end routine to take the session to a new room
734 * \param gname room to go to
737 int gotoroom(char *gname)
740 static long ls = (-1L);
743 /** store ungoto information */
744 strcpy(WC->ugname, WC->wc_roomname);
747 /** move to the new room */
748 serv_printf("GOTO %s", gname);
749 serv_getln(buf, sizeof buf);
753 serv_puts("GOTO _BASEROOM_");
754 serv_getln(buf, sizeof buf);
761 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
762 WC->room_flags = extract_int(&buf[4], 4);
763 /* highest_msg_read = extract_int(&buf[4],6);
764 maxmsgnum = extract_int(&buf[4],5);
766 WC->is_mailbox = extract_int(&buf[4],7);
767 ls = extract_long(&buf[4], 6);
768 WC->wc_floor = extract_int(&buf[4], 10);
769 WC->wc_view = extract_int(&buf[4], 11);
770 WC->wc_default_view = extract_int(&buf[4], 12);
771 WC->wc_is_trash = extract_int(&buf[4], 13);
772 WC->room_flags2 = extract_int(&buf[4], 14);
775 WC->is_room_aide = WC->is_aide;
777 WC->is_room_aide = (char) extract_int(&buf[4], 8);
779 remove_march(WC->wc_roomname);
780 if (!strcasecmp(gname, "_BASEROOM_"))
788 * \brief Locate the room on the march list which we most want to go to.
790 * is measured given a "weight" of preference based on various factors.
791 * \param desired_floor the room number on the citadel server
792 * \return the roomname
794 char *pop_march(int desired_floor)
796 static char TheRoom[128];
798 int TheOrder = 32767;
801 struct march *mptr = NULL;
803 strcpy(TheRoom, "_BASEROOM_");
804 if (WC->march == NULL)
807 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
809 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
810 weight = weight + 10000;
811 if (mptr->march_floor == desired_floor)
812 weight = weight + 5000;
814 weight = weight + ((128 - (mptr->march_floor)) * 128);
815 weight = weight + (128 - (mptr->march_order));
817 if (weight > TheWeight) {
819 strcpy(TheRoom, mptr->march_name);
820 TheFloor = mptr->march_floor;
821 TheOrder = mptr->march_order;
830 *\brief Goto next room having unread messages.
831 * We want to skip over rooms that the user has already been to, and take the
832 * user back to the lobby when done. The room we end up in is placed in
833 * newroom - which is set to 0 (the lobby) initially.
834 * We start the search in the current room rather than the beginning to prevent
835 * two or more concurrent users from dragging each other back to the same room.
840 struct march *mptr, *mptr2;
845 * First check to see if the march-mode list is already allocated.
846 * If it is, pop the first room off the list and go there.
849 if (WC->march == NULL) {
851 serv_getln(buf, sizeof buf);
853 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
854 extract_token(room_name, buf, 0, '|', sizeof room_name);
855 if (strcasecmp(room_name, WC->wc_roomname)) {
856 mptr = (struct march *) malloc(sizeof(struct march));
858 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
859 mptr->march_floor = extract_int(buf, 2);
860 mptr->march_order = extract_int(buf, 3);
861 if (WC->march == NULL) {
865 while (mptr2->next != NULL)
872 * add _BASEROOM_ to the end of the march list, so the user will end up
873 * in the system base room (usually the Lobby>) at the end of the loop
875 mptr = (struct march *) malloc(sizeof(struct march));
877 mptr->march_order = 0;
878 mptr->march_floor = 0;
879 strcpy(mptr->march_name, "_BASEROOM_");
880 if (WC->march == NULL) {
884 while (mptr2->next != NULL)
889 * ...and remove the room we're currently in, so a <G>oto doesn't make us
890 * walk around in circles
892 remove_march(WC->wc_roomname);
894 if (WC->march != NULL) {
895 strcpy(next_room, pop_march(-1));
897 strcpy(next_room, "_BASEROOM_");
901 smart_goto(next_room);
906 * \brief goto next room
907 * \param next_room next room to go to
909 void smart_goto(char *next_room) {
917 * \brief mark all messages in current room as having been read
919 void slrp_highest(void)
923 serv_puts("SLRP HIGHEST");
924 serv_getln(buf, sizeof buf);
929 * \brief un-goto the previous room
935 if (!strcmp(WC->ugname, "")) {
936 smart_goto(WC->wc_roomname);
939 serv_printf("GOTO %s", WC->ugname);
940 serv_getln(buf, sizeof buf);
942 smart_goto(WC->wc_roomname);
945 if (WC->uglsn >= 0L) {
946 serv_printf("SLRP %ld", WC->uglsn);
947 serv_getln(buf, sizeof buf);
949 strcpy(buf, WC->ugname);
950 strcpy(WC->ugname, "");
954 typedef struct __room_states {
969 * \brief Set/clear/read the "self-service list subscribe" flag for a room
971 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
972 * \return return the new value.
975 int self_service(int newval) {
976 int current_value = 0;
982 int flags, floor, order, view, flags2;
985 serv_getln(buf, sizeof buf);
986 if (buf[0] != '2') return(0);
988 extract_token(name, &buf[4], 0, '|', sizeof name);
989 extract_token(password, &buf[4], 1, '|', sizeof password);
990 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
991 flags = extract_int(&buf[4], 3);
992 floor = extract_int(&buf[4], 4);
993 order = extract_int(&buf[4], 5);
994 view = extract_int(&buf[4], 6);
995 flags2 = extract_int(&buf[4], 7);
997 if (flags2 & QR2_SELFLIST) {
1005 flags2 = flags2 | QR2_SELFLIST;
1007 else if (newval == 0) {
1008 flags2 = flags2 & ~QR2_SELFLIST;
1011 return(current_value);
1014 if (newval != current_value) {
1015 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1016 name, password, dirname, flags,
1017 floor, order, view, flags2);
1018 serv_getln(buf, sizeof buf);
1026 is_selflist(room_states *RoomFlags)
1028 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1032 is_publiclist(room_states *RoomFlags)
1034 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1038 is_moderatedlist(room_states *RoomFlags)
1040 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1044 * \brief Set/clear/read the "self-service list subscribe" flag for a room
1046 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
1047 * \return return the new value.
1050 int get_roomflags(room_states *RoomOps)
1055 serv_getln(buf, sizeof buf);
1056 if (buf[0] != '2') return(0);
1058 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1059 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1060 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1061 RoomOps->flags = extract_int(&buf[4], 3);
1062 RoomOps->floor = extract_int(&buf[4], 4);
1063 RoomOps->order = extract_int(&buf[4], 5);
1064 RoomOps->view = extract_int(&buf[4], 6);
1065 RoomOps->flags2 = extract_int(&buf[4], 7);
1069 int set_roomflags(room_states *RoomOps)
1073 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1082 serv_getln(buf, sizeof buf);
1092 * \brief display the form for editing a room
1094 void display_editroom(void)
1099 char remote_room[128];
1102 char er_password[10];
1103 char er_dirname[15];
1104 char er_roomaide[26];
1111 char *not_shared_with;
1114 int floorpolicy = 0;
1116 char pop3_host[128];
1121 if (IsEmptyStr(tab)) tab = "admin";
1124 output_headers(1, 1, 1, 0, 0, 0);
1126 wprintf("<div class=\"fix_scrollbar_bug\">");
1128 /** print the tabbed dialog */
1129 wprintf("<ul class=\"tabbed_dialog\">\n");
1131 wprintf("<li class=\"tablabel ");
1132 if (!strcmp(tab, "admin")) {
1133 wprintf(" tab_cell_label\">");
1134 wprintf(_("Administration"));
1137 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1138 wprintf(_("Administration"));
1143 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1145 wprintf("<li class=\"tablabel ");
1146 if (!strcmp(tab, "config")) {
1147 wprintf(" tab_cell_label\">");
1148 wprintf(_("Configuration"));
1151 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1152 wprintf(_("Configuration"));
1157 wprintf("<li class=\"tablabel ");
1158 if (!strcmp(tab, "expire")) {
1159 wprintf(" tab_cell_label\">");
1160 wprintf(_("Message expire policy"));
1163 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1164 wprintf(_("Message expire policy"));
1169 wprintf("<li class=\"tablabel ");
1170 if (!strcmp(tab, "access")) {
1171 wprintf(" tab_cell_label\">");
1172 wprintf(_("Access controls"));
1175 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1176 wprintf(_("Access controls"));
1181 wprintf("<li class=\"tablabel ");
1182 if (!strcmp(tab, "sharing")) {
1183 wprintf(" tab_cell_label\">");
1184 wprintf(_("Sharing"));
1187 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1188 wprintf(_("Sharing"));
1193 wprintf("<li class=\"tablabel ");
1194 if (!strcmp(tab, "listserv")) {
1195 wprintf(" tab_cell_label\">");
1196 wprintf(_("Mailing list service"));
1199 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1200 wprintf(_("Mailing list service"));
1207 wprintf("<li class=\"tablabel ");
1208 if (!strcmp(tab, "feeds")) {
1209 wprintf(" tab_cell_label\">");
1210 wprintf(_("Remote retrieval"));
1213 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1214 wprintf(_("Remote retrieval"));
1220 /** end tabbed dialog */
1222 /** begin content of whatever tab is open now */
1224 if (!strcmp(tab, "admin")) {
1225 wprintf("<div class=\"tabcontent\">");
1227 "<li><a href=\"delete_room\" "
1228 "onClick=\"return confirm('");
1229 wprintf(_("Are you sure you want to delete this room?"));
1230 wprintf("');\">\n");
1231 wprintf(_("Delete this room"));
1233 "<li><a href=\"display_editroompic\">\n");
1234 wprintf(_("Set or change the icon for this room's banner"));
1236 "<li><a href=\"display_editinfo\">\n");
1237 wprintf(_("Edit this room's Info file"));
1243 if (!strcmp(tab, "config")) {
1244 wprintf("<div class=\"tabcontent\">");
1246 serv_getln(buf, sizeof buf);
1248 if (!strncmp(buf, "550", 3)) {
1249 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1250 _("Higher access is required to access this function.")
1253 else if (buf[0] != '2') {
1254 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1257 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1258 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1259 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1260 er_flags = extract_int(&buf[4], 3);
1261 er_floor = extract_int(&buf[4], 4);
1262 er_flags2 = extract_int(&buf[4], 7);
1264 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1265 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1267 wprintf("<ul><li>");
1268 wprintf(_("Name of room: "));
1269 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1275 wprintf(_("Resides on floor: "));
1276 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1277 if (er_flags & QR_MAILBOX)
1278 wprintf("disabled >\n");
1279 for (i = 0; i < 128; ++i)
1280 if (!IsEmptyStr(floorlist[i])) {
1281 wprintf("<OPTION ");
1283 wprintf("SELECTED ");
1284 wprintf("VALUE=\"%d\">", i);
1285 escputs(floorlist[i]);
1286 wprintf("</OPTION>\n");
1288 wprintf("</select>\n");
1291 wprintf(_("Type of room:"));
1294 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1295 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1296 wprintf("CHECKED ");
1297 wprintf("OnChange=\""
1298 " if (this.form.type[0].checked == true) { "
1299 " this.form.er_floor.disabled = false; "
1302 wprintf(_("Public (automatically appears to everyone)"));
1305 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1306 if ((er_flags & QR_PRIVATE) &&
1307 (er_flags & QR_GUESSNAME))
1308 wprintf("CHECKED ");
1309 wprintf(" OnChange=\""
1310 " if (this.form.type[1].checked == true) { "
1311 " this.form.er_floor.disabled = false; "
1314 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1316 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1317 if ((er_flags & QR_PRIVATE) &&
1318 (er_flags & QR_PASSWORDED))
1319 wprintf("CHECKED ");
1320 wprintf(" OnChange=\""
1321 " if (this.form.type[2].checked == true) { "
1322 " this.form.er_floor.disabled = false; "
1325 wprintf(_("Private - require password: "));
1326 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1329 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1330 if ((er_flags & QR_PRIVATE)
1331 && ((er_flags & QR_GUESSNAME) == 0)
1332 && ((er_flags & QR_PASSWORDED) == 0))
1333 wprintf("CHECKED ");
1334 wprintf(" OnChange=\""
1335 " if (this.form.type[3].checked == true) { "
1336 " this.form.er_floor.disabled = false; "
1339 wprintf(_("Private - invitation only"));
1341 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1342 if (er_flags & QR_MAILBOX)
1343 wprintf("CHECKED ");
1344 wprintf (" OnChange=\""
1345 " if (this.form.type[4].checked == true) { "
1346 " this.form.er_floor.disabled = true; "
1349 wprintf(_("Personal (mailbox for you only)"));
1351 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1353 wprintf(_("If private, cause current users to forget room"));
1355 wprintf("\n</ul>\n");
1357 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1358 if (er_flags & QR_PREFONLY)
1359 wprintf("CHECKED ");
1361 wprintf(_("Preferred users only"));
1363 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1364 if (er_flags & QR_READONLY)
1365 wprintf("CHECKED ");
1367 wprintf(_("Read-only room"));
1369 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1370 if (er_flags2 & QR2_COLLABDEL)
1371 wprintf("CHECKED ");
1373 wprintf(_("All users allowed to post may also delete messages"));
1375 /** directory stuff */
1376 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1377 if (er_flags & QR_DIRECTORY)
1378 wprintf("CHECKED ");
1380 wprintf(_("File directory room"));
1382 wprintf("\n<ul><li>");
1383 wprintf(_("Directory name: "));
1384 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1387 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1388 if (er_flags & QR_UPLOAD)
1389 wprintf("CHECKED ");
1391 wprintf(_("Uploading allowed"));
1393 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1394 if (er_flags & QR_DOWNLOAD)
1395 wprintf("CHECKED ");
1397 wprintf(_("Downloading allowed"));
1399 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1400 if (er_flags & QR_VISDIR)
1401 wprintf("CHECKED ");
1403 wprintf(_("Visible directory"));
1406 /** end of directory stuff */
1408 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1409 if (er_flags & QR_NETWORK)
1410 wprintf("CHECKED ");
1412 wprintf(_("Network shared room"));
1414 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1415 if (er_flags & QR_PERMANENT)
1416 wprintf("CHECKED ");
1418 wprintf(_("Permanent (does not auto-purge)"));
1420 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1421 if (er_flags2 & QR2_SUBJECTREQ)
1422 wprintf("CHECKED ");
1424 wprintf(_("Subject Required (Force users to specify a message subject)"));
1426 /** start of anon options */
1429 wprintf(_("Anonymous messages"));
1432 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1433 if (((er_flags & QR_ANONONLY) == 0)
1434 && ((er_flags & QR_ANONOPT) == 0))
1435 wprintf("CHECKED ");
1437 wprintf(_("No anonymous messages"));
1439 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1440 if (er_flags & QR_ANONONLY)
1441 wprintf("CHECKED ");
1443 wprintf(_("All messages are anonymous"));
1445 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1446 if (er_flags & QR_ANONOPT)
1447 wprintf("CHECKED ");
1449 wprintf(_("Prompt user when entering messages"));
1452 /* end of anon options */
1455 wprintf(_("Room aide: "));
1457 serv_getln(buf, sizeof buf);
1458 if (buf[0] != '2') {
1459 wprintf("<em>%s</em>\n", &buf[4]);
1461 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1462 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1465 wprintf("</ul><CENTER>\n");
1466 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1467 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1469 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1479 /** Sharing the room with other Citadel nodes... */
1480 if (!strcmp(tab, "sharing")) {
1481 wprintf("<div class=\"tabcontent\">");
1483 shared_with = strdup("");
1484 not_shared_with = strdup("");
1486 /** Learn the current configuration */
1487 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1488 serv_getln(buf, sizeof buf);
1489 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1490 extract_token(node, buf, 0, '|', sizeof node);
1491 not_shared_with = realloc(not_shared_with,
1492 strlen(not_shared_with) + 32);
1493 strcat(not_shared_with, node);
1494 strcat(not_shared_with, "\n");
1498 serv_getln(buf, sizeof buf);
1499 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1500 extract_token(cmd, buf, 0, '|', sizeof cmd);
1501 extract_token(node, buf, 1, '|', sizeof node);
1502 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1503 if (!strcasecmp(cmd, "ignet_push_share")) {
1504 shared_with = realloc(shared_with,
1505 strlen(shared_with) + 32);
1506 strcat(shared_with, node);
1507 if (!IsEmptyStr(remote_room)) {
1508 strcat(shared_with, "|");
1509 strcat(shared_with, remote_room);
1511 strcat(shared_with, "\n");
1515 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1516 extract_token(buf, shared_with, i, '\n', sizeof buf);
1517 extract_token(node, buf, 0, '|', sizeof node);
1518 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1519 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1520 if (!strcasecmp(node, cmd)) {
1521 remove_token(not_shared_with, j, '\n');
1526 /** Display the stuff */
1527 wprintf("<CENTER><br />"
1528 "<table border=1 cellpadding=5><tr>"
1530 wprintf(_("Shared with"));
1531 wprintf("</I></B></td>"
1533 wprintf(_("Not shared with"));
1534 wprintf("</I></B></td></tr>\n"
1535 "<tr><td VALIGN=TOP>\n");
1537 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1538 wprintf(_("Remote node name"));
1539 wprintf("</td><td>");
1540 wprintf(_("Remote room name"));
1541 wprintf("</td><td>");
1542 wprintf(_("Actions"));
1543 wprintf("</td></tr>\n");
1545 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1546 extract_token(buf, shared_with, i, '\n', sizeof buf);
1547 extract_token(node, buf, 0, '|', sizeof node);
1548 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1549 if (!IsEmptyStr(node)) {
1550 wprintf("<form method=\"POST\" action=\"netedit\">");
1551 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1552 wprintf("<tr><td>%s</td>\n", node);
1555 if (!IsEmptyStr(remote_room)) {
1556 escputs(remote_room);
1562 wprintf("<input type=\"hidden\" NAME=\"line\" "
1563 "VALUE=\"ignet_push_share|");
1565 if (!IsEmptyStr(remote_room)) {
1567 urlescputs(remote_room);
1570 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1571 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1572 wprintf("<input type=\"submit\" "
1573 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1574 wprintf("</td></tr></form>\n");
1578 wprintf("</table>\n");
1579 wprintf("</td><td VALIGN=TOP>\n");
1580 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1581 wprintf(_("Remote node name"));
1582 wprintf("</td><td>");
1583 wprintf(_("Remote room name"));
1584 wprintf("</td><td>");
1585 wprintf(_("Actions"));
1586 wprintf("</td></tr>\n");
1588 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1589 extract_token(node, not_shared_with, i, '\n', sizeof node);
1590 if (!IsEmptyStr(node)) {
1591 wprintf("<form method=\"POST\" action=\"netedit\">");
1592 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1593 wprintf("<tr><td>");
1596 "<input type=\"INPUT\" "
1600 wprintf("<input type=\"hidden\" "
1602 "VALUE=\"ignet_push_share|");
1605 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1606 "VALUE=\"sharing\">\n");
1607 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1608 "VALUE=\"add\">\n");
1609 wprintf("<input type=\"submit\" "
1610 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1611 wprintf("</td></tr></form>\n");
1615 wprintf("</table>\n");
1616 wprintf("</td></tr>"
1617 "</table></CENTER><br />\n"
1618 "<I><B>%s</B><ul><li>", _("Notes:"));
1619 wprintf(_("When sharing a room, "
1620 "it must be shared from both ends. Adding a node to "
1621 "the 'shared' list sends messages out, but in order to"
1622 " receive messages, the other nodes must be configured"
1623 " to send messages out to your system as well. "
1624 "<li>If the remote room name is blank, it is assumed "
1625 "that the room name is identical on the remote node."
1626 "<li>If the remote room name is different, the remote "
1627 "node must also configure the name of the room here."
1634 /** Mailing list management */
1635 if (!strcmp(tab, "listserv")) {
1636 room_states RoomFlags;
1637 wprintf("<div class=\"tabcontent\">");
1639 wprintf("<br /><center>"
1640 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1641 "<tr><td VALIGN=TOP>");
1643 wprintf(_("<i>The contents of this room are being "
1644 "mailed <b>as individual messages</b> "
1645 "to the following list recipients:"
1646 "</i><br /><br />\n"));
1649 serv_getln(buf, sizeof buf);
1650 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1651 extract_token(cmd, buf, 0, '|', sizeof cmd);
1652 if (!strcasecmp(cmd, "listrecp")) {
1653 extract_token(recp, buf, 1, '|', sizeof recp);
1656 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1659 wprintf(_("(remove)"));
1660 wprintf("</A><br />");
1663 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1664 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1665 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1666 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1667 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1668 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1669 wprintf("</form>\n");
1671 wprintf("</td><td VALIGN=TOP>\n");
1673 wprintf(_("<i>The contents of this room are being "
1674 "mailed <b>in digest form</b> "
1675 "to the following list recipients:"
1676 "</i><br /><br />\n"));
1679 serv_getln(buf, sizeof buf);
1680 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1681 extract_token(cmd, buf, 0, '|', sizeof cmd);
1682 if (!strcasecmp(cmd, "digestrecp")) {
1683 extract_token(recp, buf, 1, '|', sizeof recp);
1686 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1690 wprintf(_("(remove)"));
1691 wprintf("</A><br />");
1694 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1695 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1696 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1697 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1698 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1699 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1700 wprintf("</form>\n");
1702 wprintf("</td></tr></table>\n");
1704 /** Pop open an address book -- begin **/
1705 wprintf("<div align=right>"
1706 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1708 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1713 _("Add recipients from Contacts or other address books"),
1714 _("Add recipients from Contacts or other address books")
1716 /** Pop open an address book -- end **/
1718 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1720 get_roomflags (&RoomFlags);
1722 /* Self Service subscription? */
1723 wprintf("<table><tr><td>\n");
1724 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1725 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1726 " <tr><td colspan=\"2\">\n",
1727 (is_selflist(&RoomFlags))?"checked":"");
1728 wprintf(_("The URL for subscribe/unsubscribe is: "));
1729 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1730 (is_https ? "https" : "http"),
1732 /* Public posting? */
1733 wprintf("<tr><td>");
1734 wprintf(_("Allow non-subscribers to mail to this room."));
1735 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1736 (is_publiclist(&RoomFlags))?"checked":"");
1738 /* Moderated List? */
1739 wprintf("<tr><td>");
1740 wprintf(_("Room post publication needs Aide permission."));
1741 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1742 (is_moderatedlist(&RoomFlags))?"checked":"");
1745 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1746 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1747 wprintf("</table></form>");
1750 wprintf("</CENTER>\n");
1755 /** Configuration of The Dreaded Auto-Purger */
1756 if (!strcmp(tab, "expire")) {
1757 wprintf("<div class=\"tabcontent\">");
1759 serv_puts("GPEX room");
1760 serv_getln(buf, sizeof buf);
1761 if (!strncmp(buf, "550", 3)) {
1762 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1763 _("Higher access is required to access this function.")
1766 else if (buf[0] != '2') {
1767 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1770 roompolicy = extract_int(&buf[4], 0);
1771 roomvalue = extract_int(&buf[4], 1);
1773 serv_puts("GPEX floor");
1774 serv_getln(buf, sizeof buf);
1775 if (buf[0] == '2') {
1776 floorpolicy = extract_int(&buf[4], 0);
1777 floorvalue = extract_int(&buf[4], 1);
1780 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1781 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1782 wprintf("<table border=0 cellspacing=5>\n");
1783 wprintf("<tr><td>");
1784 wprintf(_("Message expire policy for this room"));
1786 escputs(WC->wc_roomname);
1787 wprintf(")</td><td>");
1788 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1789 ((roompolicy == 0) ? "CHECKED" : "") );
1790 wprintf(_("Use the default policy for this floor"));
1791 wprintf("<br />\n");
1792 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1793 ((roompolicy == 1) ? "CHECKED" : "") );
1794 wprintf(_("Never automatically expire messages"));
1795 wprintf("<br />\n");
1796 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1797 ((roompolicy == 2) ? "CHECKED" : "") );
1798 wprintf(_("Expire by message count"));
1799 wprintf("<br />\n");
1800 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1801 ((roompolicy == 3) ? "CHECKED" : "") );
1802 wprintf(_("Expire by message age"));
1804 wprintf(_("Number of messages or days: "));
1805 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1806 wprintf("</td></tr>\n");
1808 if (WC->axlevel >= 6) {
1809 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1810 wprintf("<tr><td>");
1811 wprintf(_("Message expire policy for this floor"));
1813 escputs(floorlist[WC->wc_floor]);
1814 wprintf(")</td><td>");
1815 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1816 ((floorpolicy == 0) ? "CHECKED" : "") );
1817 wprintf(_("Use the system default"));
1818 wprintf("<br />\n");
1819 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1820 ((floorpolicy == 1) ? "CHECKED" : "") );
1821 wprintf(_("Never automatically expire messages"));
1822 wprintf("<br />\n");
1823 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1824 ((floorpolicy == 2) ? "CHECKED" : "") );
1825 wprintf(_("Expire by message count"));
1826 wprintf("<br />\n");
1827 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1828 ((floorpolicy == 3) ? "CHECKED" : "") );
1829 wprintf(_("Expire by message age"));
1831 wprintf(_("Number of messages or days: "));
1832 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1836 wprintf("<CENTER>\n");
1837 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1838 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1840 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1841 wprintf("</CENTER></td><tr>\n");
1843 wprintf("</table>\n"
1844 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1852 /** Access controls */
1853 if (!strcmp(tab, "access")) {
1854 wprintf("<div class=\"tabcontent\">");
1859 /** Fetch messages from remote locations */
1860 if (!strcmp(tab, "feeds")) {
1861 wprintf("<div class=\"tabcontent\">");
1864 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1865 wprintf("</i><br />\n");
1867 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1868 "<tr class=\"even\"><th>");
1869 wprintf(_("Remote host"));
1870 wprintf("</th><th>");
1871 wprintf(_("User name"));
1872 wprintf("</th><th>");
1873 wprintf(_("Password"));
1874 wprintf("</th><th>");
1875 wprintf(_("Keep messages on server?"));
1876 wprintf("</th><th> </th></tr>");
1879 serv_getln(buf, sizeof buf);
1881 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1882 extract_token(cmd, buf, 0, '|', sizeof cmd);
1883 if (!strcasecmp(cmd, "pop3client")) {
1884 safestrncpy(recp, &buf[11], sizeof recp);
1887 wprintf("<tr class=\"%s\">",
1888 (bg ? "even" : "odd")
1892 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1897 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1901 wprintf("<td>*****</td>"); /* Don't show the password */
1903 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1905 wprintf("<td class=\"button_link\">");
1906 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1909 wprintf(_("(remove)"));
1910 wprintf("</a></td>");
1916 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1918 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1919 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1920 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1922 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1925 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1928 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1931 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1934 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1935 wprintf("</td></tr>");
1936 wprintf("</form></table>\n");
1941 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1942 wprintf("</i><br />\n");
1944 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1945 "<tr class=\"even\"><th>");
1946 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1947 wprintf(_("Feed URL"));
1948 wprintf("</th><th>");
1949 wprintf("</th></tr>");
1952 serv_getln(buf, sizeof buf);
1954 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1955 extract_token(cmd, buf, 0, '|', sizeof cmd);
1956 if (!strcasecmp(cmd, "rssclient")) {
1957 safestrncpy(recp, &buf[10], sizeof recp);
1960 wprintf("<tr class=\"%s\">",
1961 (bg ? "even" : "odd")
1965 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1969 wprintf("<td class=\"button_link\">");
1970 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=rssclient|");
1973 wprintf(_("(remove)"));
1974 wprintf("</a></td>");
1980 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1982 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1983 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
1984 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1986 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
1987 "maxlength=\"256\" name=\"line_pop3host\">\n");
1990 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
1991 wprintf("</td></tr>");
1992 wprintf("</form></table>\n");
1998 /** end content of whatever tab is open now */
1999 wprintf("</div>\n");
2001 address_book_popup();
2007 * \brief Toggle self-service list subscription
2009 void toggle_self_service(void) {
2011 room_states RoomFlags;
2013 get_roomflags (&RoomFlags);
2015 // Yank out the bits we want to change
2016 RoomFlags.flags2 = RoomFlags.flags2 &
2017 !(QR2_SELFLIST|QR2_SMTP_PUBLIC|QR2_MODERATED);
2019 if (!strcasecmp(bstr("QR2_SelfList"), "yes"))
2020 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2021 if (!strcasecmp(bstr("QR2_SMTP_PUBLIC"), "yes"))
2022 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2023 if (!strcasecmp(bstr("QR2_Moderated"), "yes"))
2024 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2026 set_roomflags (&RoomFlags);
2034 * \brief save new parameters for a room
2040 char er_password[10];
2041 char er_dirname[15];
2042 char er_roomaide[26];
2045 int er_listingorder;
2051 if (IsEmptyStr(bstr("ok_button"))) {
2052 strcpy(WC->ImportantMessage,
2053 _("Cancelled. Changes were not saved."));
2058 serv_getln(buf, sizeof buf);
2060 if (buf[0] != '2') {
2061 strcpy(WC->ImportantMessage, &buf[4]);
2065 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
2066 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
2067 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
2068 er_flags = extract_int(&buf[4], 3);
2069 er_listingorder = extract_int(&buf[4], 5);
2070 er_defaultview = extract_int(&buf[4], 6);
2071 er_flags2 = extract_int(&buf[4], 7);
2073 strcpy(er_roomaide, bstr("er_roomaide"));
2074 if (IsEmptyStr(er_roomaide)) {
2076 serv_getln(buf, sizeof buf);
2077 if (buf[0] != '2') {
2078 strcpy(er_roomaide, "");
2080 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
2083 strcpy(buf, bstr("er_name"));
2085 if (!IsEmptyStr(buf)) {
2086 strcpy(er_name, buf);
2089 strcpy(buf, bstr("er_password"));
2091 if (!IsEmptyStr(buf))
2092 strcpy(er_password, buf);
2094 strcpy(buf, bstr("er_dirname"));
2096 if (!IsEmptyStr(buf))
2097 strcpy(er_dirname, buf);
2099 strcpy(buf, bstr("type"));
2100 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2102 if (!strcmp(buf, "invonly")) {
2103 er_flags |= (QR_PRIVATE);
2105 if (!strcmp(buf, "hidden")) {
2106 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2108 if (!strcmp(buf, "passworded")) {
2109 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2111 if (!strcmp(buf, "personal")) {
2112 er_flags |= QR_MAILBOX;
2114 er_flags &= ~QR_MAILBOX;
2117 if (!strcmp(bstr("prefonly"), "yes")) {
2118 er_flags |= QR_PREFONLY;
2120 er_flags &= ~QR_PREFONLY;
2123 if (!strcmp(bstr("readonly"), "yes")) {
2124 er_flags |= QR_READONLY;
2126 er_flags &= ~QR_READONLY;
2130 if (!strcmp(bstr("collabdel"), "yes")) {
2131 er_flags2 |= QR2_COLLABDEL;
2133 er_flags2 &= ~QR2_COLLABDEL;
2136 if (!strcmp(bstr("permanent"), "yes")) {
2137 er_flags |= QR_PERMANENT;
2139 er_flags &= ~QR_PERMANENT;
2142 if (!strcmp(bstr("subjectreq"), "yes")) {
2143 er_flags2 |= QR2_SUBJECTREQ;
2145 er_flags2 &= ~QR2_SUBJECTREQ;
2148 if (!strcmp(bstr("network"), "yes")) {
2149 er_flags |= QR_NETWORK;
2151 er_flags &= ~QR_NETWORK;
2154 if (!strcmp(bstr("directory"), "yes")) {
2155 er_flags |= QR_DIRECTORY;
2157 er_flags &= ~QR_DIRECTORY;
2160 if (!strcmp(bstr("ulallowed"), "yes")) {
2161 er_flags |= QR_UPLOAD;
2163 er_flags &= ~QR_UPLOAD;
2166 if (!strcmp(bstr("dlallowed"), "yes")) {
2167 er_flags |= QR_DOWNLOAD;
2169 er_flags &= ~QR_DOWNLOAD;
2172 if (!strcmp(bstr("visdir"), "yes")) {
2173 er_flags |= QR_VISDIR;
2175 er_flags &= ~QR_VISDIR;
2178 strcpy(buf, bstr("anon"));
2180 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2181 if (!strcmp(buf, "anononly"))
2182 er_flags |= QR_ANONONLY;
2183 if (!strcmp(buf, "anon2"))
2184 er_flags |= QR_ANONOPT;
2187 if (!strcmp(bstr("bump"), "yes"))
2190 er_floor = atoi(bstr("er_floor"));
2192 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2193 er_name, er_password, er_dirname, er_flags, bump, er_floor,
2194 er_listingorder, er_defaultview, er_flags2);
2196 serv_getln(buf, sizeof buf);
2197 if (buf[0] != '2') {
2198 strcpy(WC->ImportantMessage, &buf[4]);
2204 if (!IsEmptyStr(er_roomaide)) {
2205 sprintf(buf, "SETA %s", er_roomaide);
2207 serv_getln(buf, sizeof buf);
2208 if (buf[0] != '2') {
2209 strcpy(WC->ImportantMessage, &buf[4]);
2210 display_main_menu();
2215 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2222 * \brief Display form for Invite, Kick, and show Who Knows a room
2224 void do_invt_kick(void) {
2225 char buf[SIZ], room[SIZ], username[SIZ];
2228 serv_getln(buf, sizeof buf);
2230 if (buf[0] != '2') {
2234 extract_token(room, &buf[4], 0, '|', sizeof room);
2236 strcpy(username, bstr("username"));
2238 if (!IsEmptyStr(bstr("kick_button"))) {
2239 sprintf(buf, "KICK %s", username);
2241 serv_getln(buf, sizeof buf);
2243 if (buf[0] != '2') {
2244 strcpy(WC->ImportantMessage, &buf[4]);
2246 sprintf(WC->ImportantMessage,
2247 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2252 if (!IsEmptyStr(bstr("invite_button"))) {
2253 sprintf(buf, "INVT %s", username);
2255 serv_getln(buf, sizeof buf);
2257 if (buf[0] != '2') {
2258 strcpy(WC->ImportantMessage, &buf[4]);
2260 sprintf(WC->ImportantMessage,
2261 _("<B><I>User %s invited to room %s.</I></B>\n"),
2272 * \brief Display form for Invite, Kick, and show Who Knows a room
2274 void display_whok(void)
2276 char buf[SIZ], room[SIZ], username[SIZ];
2279 serv_getln(buf, sizeof buf);
2281 if (buf[0] != '2') {
2285 extract_token(room, &buf[4], 0, '|', sizeof room);
2288 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2289 wprintf(_("The users listed below have access to this room. "
2290 "To remove a user from the access list, select the user "
2291 "name from the list and click 'Kick'."));
2292 wprintf("<br /><br />");
2294 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2295 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2296 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2297 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2299 serv_getln(buf, sizeof buf);
2300 if (buf[0] == '1') {
2301 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2302 extract_token(username, buf, 0, '|', sizeof username);
2303 wprintf("<OPTION>");
2308 wprintf("</select><br />\n");
2310 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2311 wprintf("</form></CENTER>\n");
2313 wprintf("</td><td>");
2314 wprintf(_("To grant another user access to this room, enter the "
2315 "user name in the box below and click 'Invite'."));
2316 wprintf("<br /><br />");
2318 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2319 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2320 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2321 wprintf(_("Invite:"));
2323 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2324 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2325 "<input type=\"submit\" value=\"%s\">"
2326 "</form></CENTER>\n", _("Invite"));
2327 /** Pop open an address book -- begin **/
2329 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2331 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2334 _("Users"), _("Users")
2336 /** Pop open an address book -- end **/
2338 wprintf("</td></tr></table>\n");
2339 address_book_popup();
2346 * \brief display the form for entering a new room
2348 void display_entroom(void)
2353 serv_puts("CRE8 0");
2354 serv_getln(buf, sizeof buf);
2356 if (buf[0] != '2') {
2357 strcpy(WC->ImportantMessage, &buf[4]);
2358 display_main_menu();
2362 output_headers(1, 1, 1, 0, 0, 0);
2364 svprintf("BOXTITLE", WCS_STRING, _("Create a new room"));
2365 do_template("beginbox");
2367 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2368 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2370 wprintf("<table class=\"altern\"> ");
2372 wprintf("<tr class=\"even\"><td>");
2373 wprintf(_("Name of room: "));
2374 wprintf("</td><td>");
2375 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2376 wprintf("</td></tr>");
2378 wprintf("<tr class=\"odd\"><td>");
2379 wprintf(_("Resides on floor: "));
2380 wprintf("</td><td>");
2382 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2383 for (i = 0; i < 128; ++i)
2384 if (!IsEmptyStr(floorlist[i])) {
2385 wprintf("<option ");
2386 wprintf("value=\"%d\">", i);
2387 escputs(floorlist[i]);
2388 wprintf("</option>\n");
2390 wprintf("</select>\n");
2391 wprintf("</td></tr>");
2394 * Our clever little snippet of JavaScript automatically selects
2395 * a public room if the view is set to Bulletin Board or wiki, and
2396 * it selects a mailbox room otherwise. The user can override this,
2397 * of course. We also disable the floor selector for mailboxes.
2399 wprintf("<tr class=\"even\"><td>");
2400 wprintf(_("Default view for room: "));
2401 wprintf("</td><td>");
2402 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2403 " if ( (this.form.er_view.value == 0) "
2404 " || (this.form.er_view.value == 6) ) { "
2405 " this.form.type[0].checked=true; "
2406 " this.form.er_floor.disabled = false; "
2409 " this.form.type[4].checked=true; "
2410 " this.form.er_floor.disabled = true; "
2413 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2414 if (is_view_allowed_as_default(i)) {
2415 wprintf("<option %s value=\"%d\">",
2416 ((i == 0) ? "selected" : ""), i );
2417 escputs(viewdefs[i]);
2418 wprintf("</option>\n");
2421 wprintf("</select>\n");
2422 wprintf("</td></tr>");
2424 wprintf("<tr class=\"even\"><td>");
2425 wprintf(_("Type of room:"));
2426 wprintf("</td><td>");
2427 wprintf("<ul class=\"adminlist\">\n");
2429 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2430 wprintf("CHECKED OnChange=\""
2431 " if (this.form.type[0].checked == true) { "
2432 " this.form.er_floor.disabled = false; "
2435 wprintf(_("Public (automatically appears to everyone)"));
2438 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2439 " if (this.form.type[1].checked == true) { "
2440 " this.form.er_floor.disabled = false; "
2443 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2446 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2447 " if (this.form.type[2].checked == true) { "
2448 " this.form.er_floor.disabled = false; "
2451 wprintf(_("Private - require password: "));
2452 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2455 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2456 " if (this.form.type[3].checked == true) { "
2457 " this.form.er_floor.disabled = false; "
2460 wprintf(_("Private - invitation only"));
2463 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2465 " if (this.form.type[4].checked == true) { "
2466 " this.form.er_floor.disabled = true; "
2469 wprintf(_("Personal (mailbox for you only)"));
2472 wprintf("\n</ul>\n");
2473 wprintf("</td></tr></table>\n");
2475 wprintf("<div class=\"buttons\">\n");
2476 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2478 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2479 wprintf("</div>\n");
2480 wprintf("</form>\n<hr />");
2481 serv_printf("MESG roomaccess");
2482 serv_getln(buf, sizeof buf);
2483 if (buf[0] == '1') {
2487 do_template("endbox");
2496 * \brief support function for entroom() -- sets the default view
2498 void er_set_default_view(int newview) {
2511 serv_getln(buf, sizeof buf);
2512 if (buf[0] != '2') return;
2514 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2515 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2516 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2517 rm_bits1 = extract_int(&buf[4], 3);
2518 rm_floor = extract_int(&buf[4], 4);
2519 rm_listorder = extract_int(&buf[4], 5);
2520 rm_bits2 = extract_int(&buf[4], 7);
2522 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2523 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2524 rm_listorder, newview, rm_bits2
2526 serv_getln(buf, sizeof buf);
2532 * \brief enter a new room
2539 char er_password[SIZ];
2544 if (IsEmptyStr(bstr("ok_button"))) {
2545 strcpy(WC->ImportantMessage,
2546 _("Cancelled. No new room was created."));
2547 display_main_menu();
2550 strcpy(er_name, bstr("er_name"));
2551 strcpy(er_type, bstr("type"));
2552 strcpy(er_password, bstr("er_password"));
2553 er_floor = atoi(bstr("er_floor"));
2554 er_view = atoi(bstr("er_view"));
2557 if (!strcmp(er_type, "hidden"))
2559 if (!strcmp(er_type, "passworded"))
2561 if (!strcmp(er_type, "invonly"))
2563 if (!strcmp(er_type, "personal"))
2566 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2567 er_name, er_num_type, er_password, er_floor, 0, er_view);
2569 serv_getln(buf, sizeof buf);
2570 if (buf[0] != '2') {
2571 strcpy(WC->ImportantMessage, &buf[4]);
2572 display_main_menu();
2576 do_change_view(er_view); /* Now go there */
2581 * \brief display the screen to enter a private room
2583 void display_private(char *rname, int req_pass)
2585 output_headers(1, 1, 1, 0, 0, 0);
2587 svprintf("BOXTITLE", WCS_STRING, _("Go to a hidden room"));
2588 do_template("beginbox");
2591 wprintf(_("If you know the name of a hidden (guess-name) or "
2592 "passworded room, you can enter that room by typing "
2593 "its name below. Once you gain access to a private "
2594 "room, it will appear in your regular room listings "
2595 "so you don't have to keep returning here."));
2598 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2599 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2601 wprintf("<table class=\"altern\"> "
2602 "<tr class=\"even\"><td>");
2603 wprintf(_("Enter room name:"));
2605 "<input type=\"text\" name=\"gr_name\" "
2606 "value=\"%s\" maxlength=\"128\">\n", rname);
2609 wprintf("</td></tr><tr class=\"odd\"><td>");
2610 wprintf(_("Enter room password:"));
2611 wprintf("</td><td>");
2612 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2614 wprintf("</td></tr></table>\n");
2616 wprintf("<div class=\"buttons\">\n");
2617 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2619 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2623 wprintf("</div></form>\n");
2625 do_template("endbox");
2631 * \brief goto a private room
2633 void goto_private(void)
2638 if (IsEmptyStr(bstr("ok_button"))) {
2639 display_main_menu();
2642 strcpy(hold_rm, WC->wc_roomname);
2643 strcpy(buf, "GOTO ");
2644 strcat(buf, bstr("gr_name"));
2646 strcat(buf, bstr("gr_pass"));
2648 serv_getln(buf, sizeof buf);
2650 if (buf[0] == '2') {
2651 smart_goto(bstr("gr_name"));
2654 if (!strncmp(buf, "540", 3)) {
2655 display_private(bstr("gr_name"), 1);
2658 output_headers(1, 1, 1, 0, 0, 0);
2659 wprintf("%s\n", &buf[4]);
2666 * \brief display the screen to zap a room
2668 void display_zap(void)
2670 output_headers(1, 1, 2, 0, 0, 0);
2672 wprintf("<div id=\"banner\">\n");
2674 wprintf(_("Zap (forget/unsubscribe) the current room"));
2676 wprintf("</div>\n");
2678 wprintf("<div id=\"content\" class=\"service\">\n");
2680 wprintf(_("If you select this option, <em>%s</em> will "
2681 "disappear from your room list. Is this what you wish "
2682 "to do?<br />\n"), WC->wc_roomname);
2684 wprintf("<form method=\"POST\" action=\"zap\">\n");
2685 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2686 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2688 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2689 wprintf("</form>\n");
2700 char final_destination[SIZ];
2703 * If the forget-room routine fails for any reason, we fall back
2704 * to the current room; otherwise, we go to the Lobby
2706 strcpy(final_destination, WC->wc_roomname);
2708 if (!IsEmptyStr(bstr("ok_button"))) {
2709 serv_printf("GOTO %s", WC->wc_roomname);
2710 serv_getln(buf, sizeof buf);
2711 if (buf[0] == '2') {
2713 serv_getln(buf, sizeof buf);
2714 if (buf[0] == '2') {
2715 strcpy(final_destination, "_BASEROOM_");
2719 smart_goto(final_destination);
2725 * \brief Delete the current room
2727 void delete_room(void)
2731 serv_puts("KILL 1");
2732 serv_getln(buf, sizeof buf);
2733 if (buf[0] != '2') {
2734 strcpy(WC->ImportantMessage, &buf[4]);
2735 display_main_menu();
2738 smart_goto("_BASEROOM_");
2745 * \brief Perform changes to a room's network configuration
2747 void netedit(void) {
2757 if (!IsEmptyStr(bstr("line_pop3host"))) {
2758 strcpy(line, bstr("prefix"));
2759 strcat(line, bstr("line_pop3host"));
2761 strcat(line, bstr("line_pop3user"));
2763 strcat(line, bstr("line_pop3pass"));
2765 strcat(line, atoi(bstr("line_pop3keep")) ? "1" : "0" );
2766 strcat(line, bstr("suffix"));
2768 else if (!IsEmptyStr(bstr("line"))) {
2769 strcpy(line, bstr("prefix"));
2770 strcat(line, bstr("line"));
2771 strcat(line, bstr("suffix"));
2786 serv_getln(buf, sizeof buf);
2787 if (buf[0] != '1') {
2793 /** This loop works for add *or* remove. Spiffy, eh? */
2794 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2795 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2796 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2797 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2798 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2799 if ( (strcasecmp(cmpa0, cmpb0))
2800 || (strcasecmp(cmpa1, cmpb1)) ) {
2801 fprintf(fp, "%s\n", buf);
2807 serv_getln(buf, sizeof buf);
2808 if (buf[0] != '4') {
2814 while (fgets(buf, sizeof buf, fp) != NULL) {
2815 buf[strlen(buf)-1] = 0;
2819 if (!IsEmptyStr(bstr("add_button"))) {
2820 num_addrs = num_tokens(bstr("line"), ',');
2821 if (num_addrs < 2) {
2822 /* just adding one node or address */
2826 /* adding multiple addresses separated by commas */
2827 for (i=0; i<num_addrs; ++i) {
2828 strcpy(line, bstr("prefix"));
2829 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2832 strcat(line, bstr("suffix"));
2846 * \brief Convert a room name to a folder-ish-looking name.
2847 * \param folder the folderish name
2848 * \param room the room name
2849 * \param floor the floor name
2850 * \param is_mailbox is it a mailbox?
2852 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2857 * For mailboxes, just do it straight...
2860 sprintf(folder, "My folders|%s", room);
2864 * Otherwise, prefix the floor name as a "public folders" moniker
2867 sprintf(folder, "%s|%s", floorlist[floor], room);
2871 * Replace "\" characters with "|" for pseudo-folder-delimiting
2873 len = strlen (folder);
2874 for (i=0; i<len; ++i) {
2875 if (folder[i] == '\\') folder[i] = '|';
2883 * \brief Back end for change_view()
2884 * \param newview set newview???
2886 void do_change_view(int newview) {
2889 serv_printf("VIEW %d", newview);
2890 serv_getln(buf, sizeof buf);
2891 WC->wc_view = newview;
2892 smart_goto(WC->wc_roomname);
2898 * \brief Change the view for this room
2900 void change_view(void) {
2903 view = atol(bstr("view"));
2904 do_change_view(view);
2909 * \brief One big expanded tree list view --- like a folder list
2910 * \param fold the folder to view
2911 * \param max_folders how many folders???
2912 * \param num_floors hom many floors???
2914 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2918 int has_subfolders = 0;
2921 parents = malloc(max_folders * sizeof(int));
2923 /** BEGIN TREE MENU */
2924 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2926 /** include NanoTree */
2927 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2929 /** initialize NanoTree */
2930 wprintf("<script type=\"text/javascript\"> \n"
2931 " showRootNode = false; \n"
2932 " sortNodes = false; \n"
2933 " dragable = false; \n"
2935 " function standardClick(treeNode) { \n"
2938 " var closedGif = 'static/folder_closed.gif'; \n"
2939 " var openGif = 'static/folder_open.gif'; \n"
2941 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2945 for (i=0; i<max_folders; ++i) {
2948 if ((i+1) < max_folders) {
2950 len = strlen(fold[i].name);
2951 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2952 && (fold[i+1].name[len] == '|') ) {
2957 levels = num_tokens(fold[i].name, '|');
2958 parents[levels] = i;
2960 wprintf("var node%d = new TreeNode(%d, '", i, i);
2962 if (fold[i].selectable) {
2963 wprintf("<a href=\"dotgoto?room=");
2964 urlescputs(fold[i].room);
2969 wprintf("<span class=\"roomlist_floor\">");
2971 else if (fold[i].hasnewmsgs) {
2972 wprintf("<span class=\"roomlist_new\">");
2975 wprintf("<span class=\"roomlist_old\">");
2977 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2982 if (has_subfolders) {
2983 wprintf("new Array(closedGif, openGif)");
2985 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2986 wprintf("'static/viewcontacts_16x.gif'");
2988 else if (fold[i].view == VIEW_CALENDAR) {
2989 wprintf("'static/calarea_16x.gif'");
2991 else if (fold[i].view == VIEW_CALBRIEF) {
2992 wprintf("'static/calarea_16x.gif'");
2994 else if (fold[i].view == VIEW_TASKS) {
2995 wprintf("'static/taskmanag_16x.gif'");
2997 else if (fold[i].view == VIEW_NOTES) {
2998 wprintf("'static/storenotes_16x.gif'");
3000 else if (fold[i].view == VIEW_MAILBOX) {
3001 wprintf("'static/privatemess_16x.gif'");
3004 wprintf("'static/chatrooms_16x.gif'");
3007 urlescputs(fold[i].name);
3011 wprintf("rootNode.addChild(node%d);\n", i);
3014 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3018 wprintf("container = document.getElementById('roomlist_div'); \n"
3024 /** END TREE MENU */
3028 * \brief Boxes and rooms and lists ... oh my!
3029 * \param fold the folder to view
3030 * \param max_folders how many folders???
3031 * \param num_floors hom many floors???
3033 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3035 char floor_name[256];
3036 char old_floor_name[256];
3038 int levels, oldlevels;
3041 static int columns = 3;
3042 int boxes_per_column = 0;
3043 int current_column = 0;
3046 strcpy(floor_name, "");
3047 strcpy(old_floor_name, "");
3050 while (nf % columns != 0) ++nf;
3051 boxes_per_column = (nf / columns);
3052 if (boxes_per_column < 1) boxes_per_column = 1;
3054 /** Outer table (for columnization) */
3055 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3056 "<tr><td valign=top>");
3060 for (i=0; i<max_folders; ++i) {
3062 levels = num_tokens(fold[i].name, '|');
3063 extract_token(floor_name, fold[i].name, 0,
3064 '|', sizeof floor_name);
3066 if ( (strcasecmp(floor_name, old_floor_name))
3067 && (!IsEmptyStr(old_floor_name)) ) {
3069 do_template("endbox");
3073 if ((num_boxes % boxes_per_column) == 0) {
3075 if (current_column < columns) {
3076 wprintf("</td><td valign=top>\n");
3080 strcpy(old_floor_name, floor_name);
3083 /** Begin inner box */
3084 stresc(boxtitle, 256, floor_name, 1, 0);
3085 svprintf("BOXTITLE", WCS_STRING, boxtitle);
3086 do_template("beginbox");
3093 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3094 if (fold[i].selectable) {
3095 wprintf("<a href=\"dotgoto?room=");
3096 urlescputs(fold[i].room);
3102 if (fold[i].hasnewmsgs) {
3103 wprintf("<span class=\"roomlist_new\">");
3106 wprintf("<span class=\"roomlist_old\">");
3108 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3111 if (fold[i].selectable) {
3117 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3118 wprintf(" (INBOX)");
3120 wprintf("<br />\n");
3123 /** End the final inner box */
3124 do_template("endbox");
3126 wprintf("</td></tr></table>\n");
3130 * \brief print a floor div???
3131 * \param which_floordiv name of the floordiv???
3133 void set_floordiv_expanded(char *which_floordiv) {
3134 begin_ajax_response();
3135 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
3136 end_ajax_response();
3140 * \brief view the iconbar
3141 * \param fold the folder to view
3142 * \param max_folders how many folders???
3143 * \param num_floors hom many floors???
3145 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3147 char floor_name[256];
3148 char old_floor_name[256];
3149 char floordivtitle[256];
3150 char floordiv_id[32];
3151 int levels, oldlevels;
3153 int num_drop_targets = 0;
3156 strcpy(floor_name, "");
3157 strcpy(old_floor_name, "");
3161 for (i=0; i<max_folders; ++i) {
3163 levels = num_tokens(fold[i].name, '|');
3164 extract_token(floor_name, fold[i].name, 0,
3165 '|', sizeof floor_name);
3167 if ( (strcasecmp(floor_name, old_floor_name))
3168 && (!IsEmptyStr(old_floor_name)) ) {
3169 /** End inner box */
3171 wprintf("</div>\n"); /** floordiv */
3173 strcpy(old_floor_name, floor_name);
3177 stresc(floordivtitle, 256, floor_name, 0, 0);
3178 sprintf(floordiv_id, "floordiv%d", i);
3179 wprintf("<span class=\"ib_roomlist_floor\" "
3180 "onClick=\"expand_floor('%s')\">"
3181 "%s</span><br>\n", floordiv_id, floordivtitle);
3182 wprintf("<div id=\"%s\" style=\"display:%s\">",
3184 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
3191 wprintf("<div id=\"roomdiv%d\">", i);
3193 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3195 /** choose the icon */
3196 if (fold[i].view == VIEW_ADDRESSBOOK) {
3197 icon = "viewcontacts_16x.gif" ;
3199 else if (fold[i].view == VIEW_CALENDAR) {
3200 icon = "calarea_16x.gif" ;
3202 else if (fold[i].view == VIEW_CALBRIEF) {
3203 icon = "calarea_16x.gif" ;
3205 else if (fold[i].view == VIEW_TASKS) {
3206 icon = "taskmanag_16x.gif" ;
3208 else if (fold[i].view == VIEW_NOTES) {
3209 icon = "storenotes_16x.gif" ;
3211 else if (fold[i].view == VIEW_MAILBOX) {
3212 icon = "privatemess_16x.gif" ;
3215 icon = "chatrooms_16x.gif" ;
3218 if (fold[i].selectable) {
3219 wprintf("<a href=\"dotgoto?room=");
3220 urlescputs(fold[i].room);
3222 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
3227 if (fold[i].hasnewmsgs) {
3228 wprintf("<span class=\"ib_roomlist_new\">");
3231 wprintf("<span class=\"ib_roomlist_old\">");
3233 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3235 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3236 wprintf(" (INBOX)");
3239 if (fold[i].selectable) {
3246 wprintf("</div>\n"); /** roomdiv */
3249 wprintf("</div>\n"); /** floordiv */
3252 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3253 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3255 num_drop_targets = 0;
3257 for (i=0; i<max_folders; ++i) {
3258 levels = num_tokens(fold[i].name, '|');
3260 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3261 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3262 jsescputs(fold[i].room);
3268 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3269 if ((WC->floordiv_expanded[0] != '\0')&&
3270 (WC->floordiv_expanded[1] != '\0')){
3271 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
3275 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3281 * \brief Show the room list.
3282 * (only should get called by
3283 * knrooms() because that's where output_headers() is called from)
3284 * \param viewpref the view preferences???
3287 void list_all_rooms_by_floor(char *viewpref) {
3290 struct folder *fold = NULL;
3292 int max_folders = 0;
3293 int alloc_folders = 0;
3299 int num_floors = 1; /** add an extra one for private folders */
3303 /** If our cached folder list is very old, burn it. */
3304 if (WC->cache_fold != NULL) {
3305 if ((time(NULL) - WC->cache_timestamp) > 300) {
3306 free(WC->cache_fold);
3307 WC->cache_fold = NULL;
3311 /** Can we do the iconbar roomlist from cache? */
3312 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3313 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3317 /** Grab the floor table so we know how to build the list... */
3320 /** Start with the mailboxes */
3323 fold = malloc(sizeof(struct folder));
3324 memset(fold, 0, sizeof(struct folder));
3325 strcpy(fold[0].name, "My folders");
3326 fold[0].is_mailbox = 1;
3328 /** Then add floors */
3330 serv_getln(buf, sizeof buf);
3331 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3332 if (max_folders >= alloc_folders) {
3333 alloc_folders = max_folders + 100;
3334 fold = realloc(fold,
3335 alloc_folders * sizeof(struct folder));
3337 memset(&fold[max_folders], 0, sizeof(struct folder));
3338 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3339 extract_token(buf3, buf, 0, '|', SIZ);
3340 fold[max_folders].floor = atol (buf3);
3345 for (i=0; i<num_floors; i++)
3346 if (IDMax < fold[i].floor)
3347 IDMax = fold[i].floor;
3348 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3349 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3350 for (i=0; i<num_floors; i++)
3351 floor_mapping[fold[i].floor]=i;
3353 /** refresh the messages index for this room */
3354 // serv_puts("GOTO ");
3355 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3356 /** Now add rooms */
3358 serv_getln(buf, sizeof buf);
3359 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3360 if (max_folders >= alloc_folders) {
3361 alloc_folders = max_folders + 100;
3362 fold = realloc(fold,
3363 alloc_folders * sizeof(struct folder));
3365 memset(&fold[max_folders], 0, sizeof(struct folder));
3366 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3367 ra_flags = extract_int(buf, 5);
3368 flags = extract_int(buf, 1);
3369 fold[max_folders].floor = extract_int(buf, 2);
3370 fold[max_folders].hasnewmsgs =
3371 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3372 if (flags & QR_MAILBOX) {
3373 fold[max_folders].is_mailbox = 1;
3375 fold[max_folders].view = extract_int(buf, 6);
3376 room_to_folder(fold[max_folders].name,
3377 fold[max_folders].room,
3378 fold[max_folders].floor,
3379 fold[max_folders].is_mailbox);
3380 fold[max_folders].selectable = 1;
3381 /* Increase the room count for the associtaed floor */
3382 if (fold[max_folders].is_mailbox) {
3383 fold[0].num_rooms++;
3386 i = floor_mapping[fold[max_folders].floor];
3387 fold[i].num_rooms++;
3393 * Remove any floors that don't have rooms
3395 get_preference("emptyfloors", buf2, sizeof buf2);
3396 if (buf2[0]==0 || (strcasecmp(buf2, "no") == 0))
3398 for (i=0; i<num_floors; i++)
3400 if (fold[i].num_rooms == 0) {
3401 for (j=i; j<max_folders; j++) {
3402 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3411 /** Bubble-sort the folder list */
3412 for (i=0; i<max_folders; ++i) {
3413 for (j=0; j<(max_folders-1)-i; ++j) {
3414 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3415 swap = strcasecmp(fold[j].name, fold[j+1].name);
3418 if ( (fold[j+1].is_mailbox)
3419 && (!fold[j].is_mailbox)) {
3427 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3428 memcpy(&fold[j], &fold[j+1],
3429 sizeof(struct folder));
3430 memcpy(&fold[j+1], &ftmp,
3431 sizeof(struct folder));
3437 if (!strcasecmp(viewpref, "folders")) {
3438 do_folder_view(fold, max_folders, num_floors);
3440 else if (!strcasecmp(viewpref, "hackish_view")) {
3441 for (i=0; i<max_folders; ++i) {
3442 escputs(fold[i].name);
3443 wprintf("<br />\n");
3446 else if (!strcasecmp(viewpref, "iconbar")) {
3447 do_iconbar_view(fold, max_folders, num_floors);
3450 do_rooms_view(fold, max_folders, num_floors);
3453 /* Don't free the folder list ... cache it for future use! */
3454 if (WC->cache_fold != NULL) {
3455 free(WC->cache_fold);
3457 WC->cache_fold = fold;
3458 WC->cache_max_folders = max_folders;
3459 WC->cache_num_floors = num_floors;
3460 WC->cache_timestamp = time(NULL);
3461 free(floor_mapping);
3466 * \brief Do either a known rooms list or a folders list, depending on the
3471 char listviewpref[SIZ];
3473 output_headers(1, 1, 2, 0, 0, 0);
3475 /** Determine whether the user is trying to change views */
3476 if (bstr("view") != NULL) {
3477 if (!IsEmptyStr(bstr("view"))) {
3478 set_preference("roomlistview", bstr("view"), 1);
3482 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3484 if ( (strcasecmp(listviewpref, "folders"))
3485 && (strcasecmp(listviewpref, "table")) ) {
3486 strcpy(listviewpref, "rooms");
3490 wprintf("<div id=\"banner\">\n");
3491 wprintf("<div class=\"room_banner\">");
3493 if (!strcasecmp(listviewpref, "rooms")) {
3494 wprintf(_("Room list"));
3496 if (!strcasecmp(listviewpref, "folders")) {
3497 wprintf(_("Folder list"));
3499 if (!strcasecmp(listviewpref, "table")) {
3500 wprintf(_("Room list"));
3502 wprintf("</h1></div>\n");
3504 /** offer the ability to switch views */
3505 wprintf("<ul class=\"room_actions\">\n");
3506 wprintf("<li class=\"start_page\">");
3509 wprintf("<li><form name=\"roomlistomatic\">\n"
3510 "<select name=\"newview\" size=\"1\" "
3511 "OnChange=\"location.href=roomlistomatic.newview.options"
3512 "[selectedIndex].value\">\n");
3514 wprintf("<option %s value=\"knrooms&view=rooms\">"
3517 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3520 wprintf("<option %s value=\"knrooms&view=folders\">"
3521 "View as folder list"
3523 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3526 wprintf("</select>");
3527 wprintf("</form></li>");
3528 wprintf("</ul></div>\n");
3530 wprintf("<div id=\"content\" class=\"service\">\n");
3532 /** Display the room list in the user's preferred format */
3533 list_all_rooms_by_floor(listviewpref);
3540 * \brief Set the message expire policy for this room and/or floor
3542 void set_room_policy(void) {
3545 if (IsEmptyStr(bstr("ok_button"))) {
3546 strcpy(WC->ImportantMessage,
3547 _("Cancelled. Changes were not saved."));
3552 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3553 serv_getln(buf, sizeof buf);
3554 strcpy(WC->ImportantMessage, &buf[4]);
3556 if (WC->axlevel >= 6) {
3557 strcat(WC->ImportantMessage, "<br />\n");
3558 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3559 serv_getln(buf, sizeof buf);
3560 strcat(WC->ImportantMessage, &buf[4]);