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 */
13 void display_whok(void);
16 * Initialize the viewdefs with localized strings
18 void initialize_viewdefs(void) {
19 viewdefs[0] = _("Bulletin Board");
20 viewdefs[1] = _("Mail Folder");
21 viewdefs[2] = _("Address Book");
22 viewdefs[3] = _("Calendar");
23 viewdefs[4] = _("Task List");
24 viewdefs[5] = _("Notes List");
25 viewdefs[6] = _("Wiki");
26 viewdefs[7] = _("Calendar List");
27 viewdefs[8] = _("Journal");
31 * Determine which views are allowed as the default for creating a new room.
33 int is_view_allowed_as_default(int which_view)
36 case VIEW_BBS: return(1);
37 case VIEW_MAILBOX: return(1);
38 case VIEW_ADDRESSBOOK: return(1);
39 case VIEW_CALENDAR: return(1);
40 case VIEW_TASKS: return(1);
41 case VIEW_NOTES: return(1);
44 case VIEW_WIKI: return(1);
45 #else /* TECH_PREVIEW */
46 case VIEW_WIKI: return(0); /* because it isn't finished yet */
47 #endif /* TECH_PREVIEW */
49 case VIEW_CALBRIEF: return(0);
50 case VIEW_JOURNAL: return(0);
51 default: return(0); /* should never get here */
57 * load the list of floors
59 void load_floorlist(void)
64 for (a = 0; a < MAX_FLOORS; ++a)
68 serv_getln(buf, sizeof buf);
70 strcpy(floorlist[0], "Main Floor");
73 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
74 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
80 * Free a session's march list
82 void free_march_list(struct wcsession *wcf)
86 while (wcf->march != NULL) {
87 mptr = wcf->march->next;
97 * remove a room from the march list
99 void remove_march(char *aaa)
101 struct march *mptr, *mptr2;
103 if (WC->march == NULL)
106 if (!strcasecmp(WC->march->march_name, aaa)) {
107 mptr = WC->march->next;
113 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
114 if (!strcasecmp(mptr->march_name, aaa)) {
115 mptr2->next = mptr->next;
128 * display rooms in tree structure
130 void room_tree_list(struct roomlisting *rp)
139 room_tree_list(rp->lnext);
141 strcpy(rmname, rp->rlname);
144 wprintf("<a href=\"dotgoto&room=");
148 escputs1(rmname, 1, 1);
149 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
151 else if (f & QR_DIRECTORY)
153 else if (f & QR_NETWORK)
157 wprintf("</a><tt> </tt>\n");
159 room_tree_list(rp->rnext);
165 * \brief Room ordering stuff (compare first by floor, then by order)
166 * \param r1 first roomlist to compare
167 * \param r2 second roomlist co compare
168 * \return are they the same???
170 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
172 if ((r1 == NULL) && (r2 == NULL))
178 if (r1->rlfloor < r2->rlfloor)
180 if (r1->rlfloor > r2->rlfloor)
182 if (r1->rlorder < r2->rlorder)
184 if (r1->rlorder > r2->rlorder)
191 * \brief Common code for all room listings
192 * \param variety what???
194 void listrms(char *variety)
199 struct roomlisting *rl = NULL;
200 struct roomlisting *rp;
201 struct roomlisting *rs;
203 /** Ask the server for a room list */
205 serv_getln(buf, sizeof buf);
211 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
213 rp = malloc(sizeof(struct roomlisting));
214 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
215 rp->rlflags = extract_int(buf, 1);
216 rp->rlfloor = extract_int(buf, 2);
217 rp->rlorder = extract_int(buf, 3);
226 if (rordercmp(rp, rs) < 0) {
227 if (rs->lnext == NULL) {
234 if (rs->rnext == NULL) {
247 * If no rooms were listed, print an nbsp to make the cell
248 * borders show up anyway.
250 if (num_rooms == 0) wprintf(" ");
255 * \brief list all forgotten rooms
257 void zapped_list(void)
259 output_headers(1, 1, 1, 0, 0, 0);
261 svput("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
262 do_template("beginbox");
266 wprintf("<br /><br />\n");
267 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
268 do_template("endbox");
274 * \brief read this room's info file (set v to 1 for verbose mode)
281 int fullinfo_len = 0;
284 serv_getln(buf, sizeof buf);
287 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
288 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
289 strcpy(&fullinfo[fullinfo_len], buf);
290 fullinfo_len += strlen(buf);
294 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
295 strcpy(&briefinfo[50], "...");
297 wprintf("<div class=\"infos\" "
298 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
301 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
302 wprintf("<img class=\"close_infos\" "
303 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
304 "src=\"static/closewindow.gif\" alt=\"%s\">",
319 * \brief Display room banner icon.
320 * The server doesn't actually
321 * need the room name, but we supply it in order to
322 * keep the browser from using a cached icon from
325 void embed_room_graphic(void) {
328 serv_puts("OIMG _roompic_");
329 serv_getln(buf, sizeof buf);
331 wprintf("<img height=\"64px\" src=\"image&name=_roompic_&room=");
332 urlescputs(WC->wc_roomname);
335 serv_getln(buf, sizeof buf);
337 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
338 wprintf("<img class=\"roompic\" alt=\"\" src=\""
339 "static/viewcontacts_48x.gif"
343 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
344 wprintf("<img class=\"roompic\" alt=\"\" src=\""
345 "static/calarea_48x.gif"
349 else if (WC->wc_view == VIEW_TASKS) {
350 wprintf("<img class=\"roompic\" alt=\"\" src=\""
351 "static/taskmanag_48x.gif"
355 else if (WC->wc_view == VIEW_NOTES) {
356 wprintf("<img class=\"roompic\" alt=\"\" src=\""
357 "static/storenotes_48x.gif"
361 else if (WC->wc_view == VIEW_MAILBOX) {
362 wprintf("<img class=\"roompic\" alt=\"\" src=\""
363 "static/privatemess_48x.gif"
368 wprintf("<img class=\"roompic\" alt=\"\" src=\""
369 "static/chatrooms_48x.gif"
379 * \brief Display the current view and offer an option to change it
381 void embed_view_o_matic(void) {
384 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
385 wprintf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
386 wprintf("<label for=\"view_name\">");
387 wprintf(_("View as:"));
389 "<select name=\"newview\" size=\"1\" "
390 "id=\"view_name\" class=\"selectbox\" "
391 "OnChange=\"location.href=viewomatic.newview.options"
392 "[selectedIndex].value\">\n");
394 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
396 * Only offer the views that make sense, given the default
397 * view for the room. For example, don't offer a Calendar
398 * view in a non-Calendar room.
402 || (i == WC->wc_default_view) /**< default */
403 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
404 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
405 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
408 wprintf("<option %s value=\"changeview?view=%d\">",
409 ((i == WC->wc_view) ? "selected" : ""),
411 escputs(viewdefs[i]);
412 wprintf("</option>\n");
415 wprintf("</select></div></form>\n");
420 * \brief Display a search box
422 void embed_search_o_matic(void) {
423 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
424 wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
425 wprintf("<label for=\"search_name\">");
426 wprintf(_("Search: "));
427 wprintf("</label><input ");
428 wprintf("%s", serv_info.serv_fulltext_enabled ? "" : "disabled ");
429 wprintf("type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
430 "id=\"search_name\" class=\"inputbox\">\n"
432 wprintf("</div></form>\n");
437 * \brief Embed the room banner
439 * \param got The information returned from a GOTO server command
440 * \param navbar_style Determines which navigation buttons to display
444 void embed_room_banner(char *got, int navbar_style) {
447 char sanitized_roomname[256];
448 char with_files[256];
452 * We need to have the information returned by a GOTO server command.
453 * If it isn't supplied, we fake it by issuing our own GOTO.
456 serv_printf("GOTO %s", WC->wc_roomname);
457 serv_getln(buf, sizeof buf);
461 /** The browser needs some information for its own use */
462 wprintf("<script type=\"text/javascript\"> \n"
463 " room_is_trash = %d; \n"
469 * If the user happens to select the "make this my start page" link,
470 * we want it to remember the URL as a "/dotskip" one instead of
471 * a "skip" or "gotonext" or something like that.
473 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
476 /** Check for new mail. */
477 WC->new_mail = extract_int(&got[4], 9);
478 WC->wc_view = extract_int(&got[4], 11);
480 /* Is this a directory room and does it contain files and how many? */
481 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
484 serv_getln(buf2, sizeof buf2);
485 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
487 snprintf (with_files, sizeof with_files,
488 "; <a href=\"display_room_directory\"> %d %s </a>",
490 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
493 strcpy (with_files, "");
495 stresc(sanitized_roomname, 256, WC->wc_roomname, 1, 1);
496 svprintf(HKEY("ROOMNAME"), WCS_STRING, "%s", sanitized_roomname);
497 svprintf(HKEY("NUMMSGS"), WCS_STRING,
498 _("%d new of %d messages%s"),
499 extract_int(&got[4], 1),
500 extract_int(&got[4], 2),
503 svcallback("ROOMPIC", embed_room_graphic);
504 svcallback("ROOMINFO", readinfo);
505 svcallback("VIEWOMATIC", embed_view_o_matic);
506 svcallback("SEARCHOMATIC", embed_search_o_matic);
507 svcallback("START", offer_start_page);
509 do_template("roombanner");
510 // roombanner contains this for mobile
511 if (navbar_style != navbar_none && !WC->is_mobile) {
513 wprintf("<div id=\"navbar\"><ul>");
515 if (navbar_style == navbar_default) wprintf(
516 "<li class=\"ungoto\">"
517 "<a href=\"ungoto\">"
518 "<img src=\"static/ungoto2_24x.gif\" alt=\"\">"
519 "<span class=\"navbar_link\">%s</span></A>"
520 "</li>\n", _("Ungoto")
523 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
525 "<li class=\"newmess\">"
526 "<a href=\"readnew\">"
527 "<img src=\"static/newmess2_24x.gif\" alt=\"\">"
528 "<span class=\"navbar_link\">%s</span></A>"
529 "</li>\n", _("Read new messages")
533 if (navbar_style == navbar_default) {
534 switch(WC->wc_view) {
535 case VIEW_ADDRESSBOOK:
537 "<li class=\"viewcontacts\">"
538 "<a href=\"readfwd\">"
539 "<img src=\"static/viewcontacts_24x.gif\" "
541 "<span class=\"navbar_link\">"
543 "</span></a></li>\n", _("View contacts")
548 "<li class=\"staskday\">"
549 "<a href=\"readfwd?calview=day\">"
550 "<img src=\"static/taskday2_24x.gif\" "
552 "<span class=\"navbar_link\">"
554 "</span></a></li>\n", _("Day view")
557 "<li class=\"monthview\">"
558 "<a href=\"readfwd?calview=month\">"
559 "<img src=\"static/monthview2_24x.gif\" "
561 "<span class=\"navbar_link\">"
563 "</span></a></li>\n", _("Month view")
568 "<li class=\"monthview\">"
569 "<a href=\"readfwd?calview=month\">"
570 "<img src=\"static/monthview2_24x.gif\" "
572 "<span class=\"navbar_link\">"
574 "</span></a></li>\n", _("Calendar list")
579 "<li class=\"taskmanag\">"
580 "<a href=\"readfwd\">"
581 "<img src=\"static/taskmanag_24x.gif\" "
583 "<span class=\"navbar_link\">"
585 "</span></a></li>\n", _("View tasks")
590 "<li class=\"viewnotes\">"
591 "<a href=\"readfwd\">"
592 "<img src=\"static/viewnotes_24x.gif\" "
594 "<span class=\"navbar_link\">"
596 "</span></a></li>\n", _("View notes")
601 "<li class=\"readallmess\">"
602 "<a href=\"readfwd\">"
603 "<img src=\"static/readallmess3_24x.gif\" "
605 "<span class=\"navbar_link\">"
607 "</span></a></li>\n", _("View message list")
612 "<li class=\"readallmess\">"
613 "<a href=\"readfwd\">"
614 "<img src=\"static/readallmess3_24x.gif\" "
616 "<span class=\"navbar_link\">"
618 "</span></a></li>\n", _("Wiki home")
623 "<li class=\"readallmess\">"
624 "<a href=\"readfwd\">"
625 "<img src=\"static/readallmess3_24x.gif\" "
627 "<span class=\"navbar_link\">"
629 "</span></a></li>\n", _("Read all messages")
635 if (navbar_style == navbar_default) {
636 switch(WC->wc_view) {
637 case VIEW_ADDRESSBOOK:
639 "<li class=\"addnewcontact\">"
640 "<a href=\"display_enter\">"
641 "<img src=\"static/addnewcontact_24x.gif\" "
642 "alt=\"\"><span class=\"navbar_link\">"
644 "</span></a></li>\n", _("Add new contact")
649 wprintf("<li class=\"addevent\"><a href=\"display_enter");
650 if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
651 if (havebstr("month")) wprintf("?month=%s", bstr("month"));
652 if (havebstr("day" )) wprintf("?day=%s", bstr("day"));
654 "<img src=\"static/addevent_24x.gif\" "
655 "alt=\"\"><span class=\"navbar_link\">"
657 "</span></a></li>\n", _("Add new event")
662 "<li class=\"newmess\">"
663 "<a href=\"display_enter\">"
664 "<img src=\"static/newmess3_24x.gif\" "
665 "alt=\"\"><span class=\"navbar_link\">"
667 "</span></a></li>\n", _("Add new task")
672 "<li class=\"enternewnote\">"
673 "<a href=\"add_new_note\">"
674 "<img src=\"static/enternewnote_24x.gif\" "
675 "alt=\"\"><span class=\"navbar_link\">"
677 "</span></a></li>\n", _("Add new note")
681 safestrncpy(buf, bstr("page"), sizeof buf);
684 "<li class=\"newmess\">"
685 "<a href=\"display_enter?wikipage=%s\">"
686 "<img src=\"static/newmess3_24x.gif\" "
687 "alt=\"\"><span class=\"navbar_link\">"
689 "</span></a></li>\n", buf, _("Edit this page")
694 "<li class=\"newmess\">"
695 "<a href=\"display_enter\">"
696 "<img src=\"static/newmess3_24x.gif\" "
697 "alt=\"\"><span class=\"navbar_link\">"
699 "</span></a></li>\n", _("Write mail")
704 "<li class=\"newmess\">"
705 "<a href=\"display_enter\">"
706 "<img src=\"static/newmess3_24x.gif\" "
707 "alt=\"\"><span class=\"navbar_link\">"
709 "</span></a></li>\n", _("Enter a message")
715 if (navbar_style == navbar_default) wprintf(
716 "<li class=\"skipthisroom\">"
719 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\">"
720 "<span class=\"navbar_link\">%s</span></a>"
722 _("Leave all messages marked as unread, go to next room with unread messages"),
726 if (navbar_style == navbar_default) wprintf(
727 "<li class=\"markngo\">"
728 "<a href=\"gotonext\" "
730 "<img src=\"static/markngo_24x.gif\" alt=\"\">"
731 "<span class=\"navbar_link\">%s</span></a>"
733 _("Mark all messages as read, go to next room with unread messages"),
737 wprintf("</ul></div>\n");
744 * back end routine to take the session to a new room
746 int gotoroom(char *gname)
749 static long ls = (-1L);
752 /* store ungoto information */
753 strcpy(WC->ugname, WC->wc_roomname);
756 /** move to the new room */
757 serv_printf("GOTO %s", gname);
758 serv_getln(buf, sizeof buf);
762 serv_puts("GOTO _BASEROOM_");
763 serv_getln(buf, sizeof buf);
770 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
771 WC->room_flags = extract_int(&buf[4], 4);
772 /* highest_msg_read = extract_int(&buf[4],6);
773 maxmsgnum = extract_int(&buf[4],5);
775 WC->is_mailbox = extract_int(&buf[4],7);
776 ls = extract_long(&buf[4], 6);
777 WC->wc_floor = extract_int(&buf[4], 10);
778 WC->wc_view = extract_int(&buf[4], 11);
779 WC->wc_default_view = extract_int(&buf[4], 12);
780 WC->wc_is_trash = extract_int(&buf[4], 13);
781 WC->room_flags2 = extract_int(&buf[4], 14);
784 WC->is_room_aide = WC->is_aide;
786 WC->is_room_aide = (char) extract_int(&buf[4], 8);
788 remove_march(WC->wc_roomname);
789 if (!strcasecmp(gname, "_BASEROOM_"))
797 * \brief Locate the room on the march list which we most want to go to.
799 * is measured given a "weight" of preference based on various factors.
800 * \param desired_floor the room number on the citadel server
801 * \return the roomname
803 char *pop_march(int desired_floor)
805 static char TheRoom[128];
807 int TheOrder = 32767;
810 struct march *mptr = NULL;
812 strcpy(TheRoom, "_BASEROOM_");
813 if (WC->march == NULL)
816 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
818 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
819 weight = weight + 10000;
820 if (mptr->march_floor == desired_floor)
821 weight = weight + 5000;
823 weight = weight + ((128 - (mptr->march_floor)) * 128);
824 weight = weight + (128 - (mptr->march_order));
826 if (weight > TheWeight) {
828 strcpy(TheRoom, mptr->march_name);
829 TheFloor = mptr->march_floor;
830 TheOrder = mptr->march_order;
839 * Goto next room having unread messages.
841 * We want to skip over rooms that the user has already been to, and take the
842 * user back to the lobby when done. The room we end up in is placed in
843 * newroom - which is set to 0 (the lobby) initially.
844 * We start the search in the current room rather than the beginning to prevent
845 * two or more concurrent users from dragging each other back to the same room.
850 struct march *mptr = NULL;
851 struct march *mptr2 = NULL;
857 * First check to see if the march-mode list is already allocated.
858 * If it is, pop the first room off the list and go there.
861 if (WC->march == NULL) {
863 serv_getln(buf, sizeof buf);
865 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
866 if (IsEmptyStr(buf)) {
869 if (ELoop % 100 == 0)
874 extract_token(room_name, buf, 0, '|', sizeof room_name);
875 if (strcasecmp(room_name, WC->wc_roomname)) {
876 mptr = (struct march *) malloc(sizeof(struct march));
878 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
879 mptr->march_floor = extract_int(buf, 2);
880 mptr->march_order = extract_int(buf, 3);
881 if (WC->march == NULL)
890 * add _BASEROOM_ to the end of the march list, so the user will end up
891 * in the system base room (usually the Lobby>) at the end of the loop
893 mptr = (struct march *) malloc(sizeof(struct march));
895 mptr->march_order = 0;
896 mptr->march_floor = 0;
897 strcpy(mptr->march_name, "_BASEROOM_");
898 if (WC->march == NULL) {
902 while (mptr2->next != NULL)
907 * ...and remove the room we're currently in, so a <G>oto doesn't make us
908 * walk around in circles
910 remove_march(WC->wc_roomname);
912 if (WC->march != NULL) {
913 strcpy(next_room, pop_march(-1));
915 strcpy(next_room, "_BASEROOM_");
919 smart_goto(next_room);
926 void smart_goto(char *next_room) {
934 * mark all messages in current room as having been read
936 void slrp_highest(void)
940 serv_puts("SLRP HIGHEST");
941 serv_getln(buf, sizeof buf);
946 * un-goto the previous room
952 if (!strcmp(WC->ugname, "")) {
953 smart_goto(WC->wc_roomname);
956 serv_printf("GOTO %s", WC->ugname);
957 serv_getln(buf, sizeof buf);
959 smart_goto(WC->wc_roomname);
962 if (WC->uglsn >= 0L) {
963 serv_printf("SLRP %ld", WC->uglsn);
964 serv_getln(buf, sizeof buf);
966 strcpy(buf, WC->ugname);
967 strcpy(WC->ugname, "");
971 typedef struct __room_states {
986 * Set/clear/read the "self-service list subscribe" flag for a room
988 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
989 * returns the new value.
992 int self_service(int newval) {
993 int current_value = 0;
999 int flags, floor, order, view, flags2;
1002 serv_getln(buf, sizeof buf);
1003 if (buf[0] != '2') return(0);
1005 extract_token(name, &buf[4], 0, '|', sizeof name);
1006 extract_token(password, &buf[4], 1, '|', sizeof password);
1007 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1008 flags = extract_int(&buf[4], 3);
1009 floor = extract_int(&buf[4], 4);
1010 order = extract_int(&buf[4], 5);
1011 view = extract_int(&buf[4], 6);
1012 flags2 = extract_int(&buf[4], 7);
1014 if (flags2 & QR2_SELFLIST) {
1022 flags2 = flags2 | QR2_SELFLIST;
1024 else if (newval == 0) {
1025 flags2 = flags2 & ~QR2_SELFLIST;
1028 return(current_value);
1031 if (newval != current_value) {
1032 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1033 name, password, dirname, flags,
1034 floor, order, view, flags2);
1035 serv_getln(buf, sizeof buf);
1042 int is_selflist(room_states *RoomFlags)
1044 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1047 int is_publiclist(room_states *RoomFlags)
1049 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1052 int is_moderatedlist(room_states *RoomFlags)
1054 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1058 * Set/clear/read the "self-service list subscribe" flag for a room
1060 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1061 * returns the new value.
1064 int get_roomflags(room_states *RoomOps)
1069 serv_getln(buf, sizeof buf);
1070 if (buf[0] != '2') return(0);
1072 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1073 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1074 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1075 RoomOps->flags = extract_int(&buf[4], 3);
1076 RoomOps->floor = extract_int(&buf[4], 4);
1077 RoomOps->order = extract_int(&buf[4], 5);
1078 RoomOps->view = extract_int(&buf[4], 6);
1079 RoomOps->flags2 = extract_int(&buf[4], 7);
1083 int set_roomflags(room_states *RoomOps)
1087 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1096 serv_getln(buf, sizeof buf);
1106 * display the form for editing a room
1108 void display_editroom(void)
1113 char remote_room[128];
1116 char er_password[10];
1117 char er_dirname[15];
1118 char er_roomaide[26];
1125 char *not_shared_with;
1128 int floorpolicy = 0;
1130 char pop3_host[128];
1135 if (IsEmptyStr(tab)) tab = "admin";
1138 output_headers(1, 1, 1, 0, 0, 0);
1140 wprintf("<div class=\"fix_scrollbar_bug\">");
1142 wprintf("<br />\n");
1144 /* print the tabbed dialog */
1145 wprintf("<div align=\"center\">");
1146 wprintf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\""
1147 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1150 wprintf("<td class=\"");
1151 if (!strcmp(tab, "admin")) {
1152 wprintf(" tab_cell_label\">");
1153 wprintf(_("Administration"));
1156 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1157 wprintf(_("Administration"));
1161 wprintf("<td> </td>\n");
1163 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1165 wprintf("<td class=\"");
1166 if (!strcmp(tab, "config")) {
1167 wprintf(" tab_cell_label\">");
1168 wprintf(_("Configuration"));
1171 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1172 wprintf(_("Configuration"));
1176 wprintf("<td> </td>\n");
1178 wprintf("<td class=\"");
1179 if (!strcmp(tab, "expire")) {
1180 wprintf(" tab_cell_label\">");
1181 wprintf(_("Message expire policy"));
1184 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1185 wprintf(_("Message expire policy"));
1189 wprintf("<td> </td>\n");
1191 wprintf("<td class=\"");
1192 if (!strcmp(tab, "access")) {
1193 wprintf(" tab_cell_label\">");
1194 wprintf(_("Access controls"));
1197 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1198 wprintf(_("Access controls"));
1202 wprintf("<td> </td>\n");
1204 wprintf("<td class=\"");
1205 if (!strcmp(tab, "sharing")) {
1206 wprintf(" tab_cell_label\">");
1207 wprintf(_("Sharing"));
1210 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1211 wprintf(_("Sharing"));
1215 wprintf("<td> </td>\n");
1217 wprintf("<td class=\"");
1218 if (!strcmp(tab, "listserv")) {
1219 wprintf(" tab_cell_label\">");
1220 wprintf(_("Mailing list service"));
1223 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1224 wprintf(_("Mailing list service"));
1228 wprintf("<td> </td>\n");
1232 wprintf("<td class=\"");
1233 if (!strcmp(tab, "feeds")) {
1234 wprintf(" tab_cell_label\">");
1235 wprintf(_("Remote retrieval"));
1238 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1239 wprintf(_("Remote retrieval"));
1243 wprintf("<td> </td>\n");
1245 wprintf("</tr></table>\n");
1246 wprintf("</div>\n");
1247 /* end tabbed dialog */
1249 wprintf("<script type=\"text/javascript\">"
1250 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1254 /* begin content of whatever tab is open now */
1256 if (!strcmp(tab, "admin")) {
1257 wprintf("<div class=\"tabcontent\">");
1259 "<li><a href=\"delete_room\" "
1260 "onClick=\"return confirm('");
1261 wprintf(_("Are you sure you want to delete this room?"));
1262 wprintf("');\">\n");
1263 wprintf(_("Delete this room"));
1265 "<li><a href=\"display_editroompic\">\n");
1266 wprintf(_("Set or change the icon for this room's banner"));
1268 "<li><a href=\"display_editinfo\">\n");
1269 wprintf(_("Edit this room's Info file"));
1275 if (!strcmp(tab, "config")) {
1276 wprintf("<div class=\"tabcontent\">");
1278 serv_getln(buf, sizeof buf);
1280 if (!strncmp(buf, "550", 3)) {
1281 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1282 _("Higher access is required to access this function.")
1285 else if (buf[0] != '2') {
1286 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1289 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1290 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1291 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1292 er_flags = extract_int(&buf[4], 3);
1293 er_floor = extract_int(&buf[4], 4);
1294 er_flags2 = extract_int(&buf[4], 7);
1296 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1297 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1299 wprintf("<ul><li>");
1300 wprintf(_("Name of room: "));
1301 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1307 wprintf(_("Resides on floor: "));
1308 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1309 if (er_flags & QR_MAILBOX)
1310 wprintf("disabled >\n");
1311 for (i = 0; i < 128; ++i)
1312 if (!IsEmptyStr(floorlist[i])) {
1313 wprintf("<OPTION ");
1315 wprintf("SELECTED ");
1316 wprintf("VALUE=\"%d\">", i);
1317 escputs(floorlist[i]);
1318 wprintf("</OPTION>\n");
1320 wprintf("</select>\n");
1323 wprintf(_("Type of room:"));
1326 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1327 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1328 wprintf("CHECKED ");
1329 wprintf("OnChange=\""
1330 " if (this.form.type[0].checked == true) { "
1331 " this.form.er_floor.disabled = false; "
1334 wprintf(_("Public (automatically appears to everyone)"));
1337 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1338 if ((er_flags & QR_PRIVATE) &&
1339 (er_flags & QR_GUESSNAME))
1340 wprintf("CHECKED ");
1341 wprintf(" OnChange=\""
1342 " if (this.form.type[1].checked == true) { "
1343 " this.form.er_floor.disabled = false; "
1346 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1348 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1349 if ((er_flags & QR_PRIVATE) &&
1350 (er_flags & QR_PASSWORDED))
1351 wprintf("CHECKED ");
1352 wprintf(" OnChange=\""
1353 " if (this.form.type[2].checked == true) { "
1354 " this.form.er_floor.disabled = false; "
1357 wprintf(_("Private - require password: "));
1358 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1361 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1362 if ((er_flags & QR_PRIVATE)
1363 && ((er_flags & QR_GUESSNAME) == 0)
1364 && ((er_flags & QR_PASSWORDED) == 0))
1365 wprintf("CHECKED ");
1366 wprintf(" OnChange=\""
1367 " if (this.form.type[3].checked == true) { "
1368 " this.form.er_floor.disabled = false; "
1371 wprintf(_("Private - invitation only"));
1373 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1374 if (er_flags & QR_MAILBOX)
1375 wprintf("CHECKED ");
1376 wprintf (" OnChange=\""
1377 " if (this.form.type[4].checked == true) { "
1378 " this.form.er_floor.disabled = true; "
1381 wprintf(_("Personal (mailbox for you only)"));
1383 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1385 wprintf(_("If private, cause current users to forget room"));
1387 wprintf("\n</ul>\n");
1389 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1390 if (er_flags & QR_PREFONLY)
1391 wprintf("CHECKED ");
1393 wprintf(_("Preferred users only"));
1395 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1396 if (er_flags & QR_READONLY)
1397 wprintf("CHECKED ");
1399 wprintf(_("Read-only room"));
1401 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1402 if (er_flags2 & QR2_COLLABDEL)
1403 wprintf("CHECKED ");
1405 wprintf(_("All users allowed to post may also delete messages"));
1407 /** directory stuff */
1408 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1409 if (er_flags & QR_DIRECTORY)
1410 wprintf("CHECKED ");
1412 wprintf(_("File directory room"));
1414 wprintf("\n<ul><li>");
1415 wprintf(_("Directory name: "));
1416 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1419 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1420 if (er_flags & QR_UPLOAD)
1421 wprintf("CHECKED ");
1423 wprintf(_("Uploading allowed"));
1425 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1426 if (er_flags & QR_DOWNLOAD)
1427 wprintf("CHECKED ");
1429 wprintf(_("Downloading allowed"));
1431 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1432 if (er_flags & QR_VISDIR)
1433 wprintf("CHECKED ");
1435 wprintf(_("Visible directory"));
1438 /** end of directory stuff */
1440 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1441 if (er_flags & QR_NETWORK)
1442 wprintf("CHECKED ");
1444 wprintf(_("Network shared room"));
1446 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1447 if (er_flags & QR_PERMANENT)
1448 wprintf("CHECKED ");
1450 wprintf(_("Permanent (does not auto-purge)"));
1452 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1453 if (er_flags2 & QR2_SUBJECTREQ)
1454 wprintf("CHECKED ");
1456 wprintf(_("Subject Required (Force users to specify a message subject)"));
1458 /** start of anon options */
1461 wprintf(_("Anonymous messages"));
1464 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1465 if (((er_flags & QR_ANONONLY) == 0)
1466 && ((er_flags & QR_ANONOPT) == 0))
1467 wprintf("CHECKED ");
1469 wprintf(_("No anonymous messages"));
1471 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1472 if (er_flags & QR_ANONONLY)
1473 wprintf("CHECKED ");
1475 wprintf(_("All messages are anonymous"));
1477 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1478 if (er_flags & QR_ANONOPT)
1479 wprintf("CHECKED ");
1481 wprintf(_("Prompt user when entering messages"));
1484 /* end of anon options */
1487 wprintf(_("Room aide: "));
1489 serv_getln(buf, sizeof buf);
1490 if (buf[0] != '2') {
1491 wprintf("<em>%s</em>\n", &buf[4]);
1493 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1494 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1497 wprintf("</ul><CENTER>\n");
1498 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1499 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1501 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1511 /* Sharing the room with other Citadel nodes... */
1512 if (!strcmp(tab, "sharing")) {
1513 wprintf("<div class=\"tabcontent\">");
1515 shared_with = strdup("");
1516 not_shared_with = strdup("");
1518 /** Learn the current configuration */
1519 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1520 serv_getln(buf, sizeof buf);
1521 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1522 extract_token(node, buf, 0, '|', sizeof node);
1523 not_shared_with = realloc(not_shared_with,
1524 strlen(not_shared_with) + 32);
1525 strcat(not_shared_with, node);
1526 strcat(not_shared_with, "\n");
1530 serv_getln(buf, sizeof buf);
1531 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1532 extract_token(cmd, buf, 0, '|', sizeof cmd);
1533 extract_token(node, buf, 1, '|', sizeof node);
1534 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1535 if (!strcasecmp(cmd, "ignet_push_share")) {
1536 shared_with = realloc(shared_with,
1537 strlen(shared_with) + 32);
1538 strcat(shared_with, node);
1539 if (!IsEmptyStr(remote_room)) {
1540 strcat(shared_with, "|");
1541 strcat(shared_with, remote_room);
1543 strcat(shared_with, "\n");
1547 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1548 extract_token(buf, shared_with, i, '\n', sizeof buf);
1549 extract_token(node, buf, 0, '|', sizeof node);
1550 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1551 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1552 if (!strcasecmp(node, cmd)) {
1553 remove_token(not_shared_with, j, '\n');
1558 /* Display the stuff */
1559 wprintf("<CENTER><br />"
1560 "<table border=1 cellpadding=5><tr>"
1562 wprintf(_("Shared with"));
1563 wprintf("</I></B></td>"
1565 wprintf(_("Not shared with"));
1566 wprintf("</I></B></td></tr>\n"
1567 "<tr><td VALIGN=TOP>\n");
1569 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1570 wprintf(_("Remote node name"));
1571 wprintf("</td><td>");
1572 wprintf(_("Remote room name"));
1573 wprintf("</td><td>");
1574 wprintf(_("Actions"));
1575 wprintf("</td></tr>\n");
1577 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1578 extract_token(buf, shared_with, i, '\n', sizeof buf);
1579 extract_token(node, buf, 0, '|', sizeof node);
1580 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1581 if (!IsEmptyStr(node)) {
1582 wprintf("<form method=\"POST\" action=\"netedit\">");
1583 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1584 wprintf("<tr><td>%s</td>\n", node);
1587 if (!IsEmptyStr(remote_room)) {
1588 escputs(remote_room);
1594 wprintf("<input type=\"hidden\" NAME=\"line\" "
1595 "VALUE=\"ignet_push_share|");
1597 if (!IsEmptyStr(remote_room)) {
1599 urlescputs(remote_room);
1602 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1603 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1604 wprintf("<input type=\"submit\" "
1605 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1606 wprintf("</td></tr></form>\n");
1610 wprintf("</table>\n");
1611 wprintf("</td><td VALIGN=TOP>\n");
1612 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1613 wprintf(_("Remote node name"));
1614 wprintf("</td><td>");
1615 wprintf(_("Remote room name"));
1616 wprintf("</td><td>");
1617 wprintf(_("Actions"));
1618 wprintf("</td></tr>\n");
1620 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1621 extract_token(node, not_shared_with, i, '\n', sizeof node);
1622 if (!IsEmptyStr(node)) {
1623 wprintf("<form method=\"POST\" action=\"netedit\">");
1624 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1625 wprintf("<tr><td>");
1628 "<input type=\"INPUT\" "
1632 wprintf("<input type=\"hidden\" "
1634 "VALUE=\"ignet_push_share|");
1637 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1638 "VALUE=\"sharing\">\n");
1639 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1640 "VALUE=\"add\">\n");
1641 wprintf("<input type=\"submit\" "
1642 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1643 wprintf("</td></tr></form>\n");
1647 wprintf("</table>\n");
1648 wprintf("</td></tr>"
1649 "</table></CENTER><br />\n"
1650 "<I><B>%s</B><ul><li>", _("Notes:"));
1651 wprintf(_("When sharing a room, "
1652 "it must be shared from both ends. Adding a node to "
1653 "the 'shared' list sends messages out, but in order to"
1654 " receive messages, the other nodes must be configured"
1655 " to send messages out to your system as well. "
1656 "<li>If the remote room name is blank, it is assumed "
1657 "that the room name is identical on the remote node."
1658 "<li>If the remote room name is different, the remote "
1659 "node must also configure the name of the room here."
1666 /* Mailing list management */
1667 if (!strcmp(tab, "listserv")) {
1668 room_states RoomFlags;
1669 wprintf("<div class=\"tabcontent\">");
1671 wprintf("<br /><center>"
1672 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1673 "<tr><td VALIGN=TOP>");
1675 wprintf(_("<i>The contents of this room are being "
1676 "mailed <b>as individual messages</b> "
1677 "to the following list recipients:"
1678 "</i><br /><br />\n"));
1681 serv_getln(buf, sizeof buf);
1682 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1683 extract_token(cmd, buf, 0, '|', sizeof cmd);
1684 if (!strcasecmp(cmd, "listrecp")) {
1685 extract_token(recp, buf, 1, '|', sizeof recp);
1688 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
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=\"listrecp|\">\n");
1698 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1699 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1700 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1701 wprintf("</form>\n");
1703 wprintf("</td><td VALIGN=TOP>\n");
1705 wprintf(_("<i>The contents of this room are being "
1706 "mailed <b>in digest form</b> "
1707 "to the following list recipients:"
1708 "</i><br /><br />\n"));
1711 serv_getln(buf, sizeof buf);
1712 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1713 extract_token(cmd, buf, 0, '|', sizeof cmd);
1714 if (!strcasecmp(cmd, "digestrecp")) {
1715 extract_token(recp, buf, 1, '|', sizeof recp);
1718 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1722 wprintf(_("(remove)"));
1723 wprintf("</A><br />");
1726 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1727 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1728 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1729 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1730 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1731 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1732 wprintf("</form>\n");
1734 wprintf("</td></tr></table>\n");
1736 /** Pop open an address book -- begin **/
1737 wprintf("<div align=right>"
1738 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1740 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1745 _("Add recipients from Contacts or other address books"),
1746 _("Add recipients from Contacts or other address books")
1748 /* Pop open an address book -- end **/
1750 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1752 get_roomflags (&RoomFlags);
1754 /* Self Service subscription? */
1755 wprintf("<table><tr><td>\n");
1756 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1757 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1758 " <tr><td colspan=\"2\">\n",
1759 (is_selflist(&RoomFlags))?"checked":"");
1760 wprintf(_("The URL for subscribe/unsubscribe is: "));
1761 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1762 (is_https ? "https" : "http"),
1764 /* Public posting? */
1765 wprintf("<tr><td>");
1766 wprintf(_("Allow non-subscribers to mail to this room."));
1767 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1768 (is_publiclist(&RoomFlags))?"checked":"");
1770 /* Moderated List? */
1771 wprintf("<tr><td>");
1772 wprintf(_("Room post publication needs Aide permission."));
1773 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1774 (is_moderatedlist(&RoomFlags))?"checked":"");
1777 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1778 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1779 wprintf("</table></form>");
1782 wprintf("</CENTER>\n");
1787 /* Configuration of The Dreaded Auto-Purger */
1788 if (!strcmp(tab, "expire")) {
1789 wprintf("<div class=\"tabcontent\">");
1791 serv_puts("GPEX room");
1792 serv_getln(buf, sizeof buf);
1793 if (!strncmp(buf, "550", 3)) {
1794 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1795 _("Higher access is required to access this function.")
1798 else if (buf[0] != '2') {
1799 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1802 roompolicy = extract_int(&buf[4], 0);
1803 roomvalue = extract_int(&buf[4], 1);
1805 serv_puts("GPEX floor");
1806 serv_getln(buf, sizeof buf);
1807 if (buf[0] == '2') {
1808 floorpolicy = extract_int(&buf[4], 0);
1809 floorvalue = extract_int(&buf[4], 1);
1812 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1813 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1814 wprintf("<table border=0 cellspacing=5>\n");
1815 wprintf("<tr><td>");
1816 wprintf(_("Message expire policy for this room"));
1818 escputs(WC->wc_roomname);
1819 wprintf(")</td><td>");
1820 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1821 ((roompolicy == 0) ? "CHECKED" : "") );
1822 wprintf(_("Use the default policy for this floor"));
1823 wprintf("<br />\n");
1824 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1825 ((roompolicy == 1) ? "CHECKED" : "") );
1826 wprintf(_("Never automatically expire messages"));
1827 wprintf("<br />\n");
1828 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1829 ((roompolicy == 2) ? "CHECKED" : "") );
1830 wprintf(_("Expire by message count"));
1831 wprintf("<br />\n");
1832 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1833 ((roompolicy == 3) ? "CHECKED" : "") );
1834 wprintf(_("Expire by message age"));
1836 wprintf(_("Number of messages or days: "));
1837 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1838 wprintf("</td></tr>\n");
1840 if (WC->axlevel >= 6) {
1841 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1842 wprintf("<tr><td>");
1843 wprintf(_("Message expire policy for this floor"));
1845 escputs(floorlist[WC->wc_floor]);
1846 wprintf(")</td><td>");
1847 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1848 ((floorpolicy == 0) ? "CHECKED" : "") );
1849 wprintf(_("Use the system default"));
1850 wprintf("<br />\n");
1851 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1852 ((floorpolicy == 1) ? "CHECKED" : "") );
1853 wprintf(_("Never automatically expire messages"));
1854 wprintf("<br />\n");
1855 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1856 ((floorpolicy == 2) ? "CHECKED" : "") );
1857 wprintf(_("Expire by message count"));
1858 wprintf("<br />\n");
1859 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1860 ((floorpolicy == 3) ? "CHECKED" : "") );
1861 wprintf(_("Expire by message age"));
1863 wprintf(_("Number of messages or days: "));
1864 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1868 wprintf("<CENTER>\n");
1869 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1870 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1872 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1873 wprintf("</CENTER></td><tr>\n");
1875 wprintf("</table>\n"
1876 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1884 /* Access controls */
1885 if (!strcmp(tab, "access")) {
1886 wprintf("<div class=\"tabcontent\">");
1891 /* Fetch messages from remote locations */
1892 if (!strcmp(tab, "feeds")) {
1893 wprintf("<div class=\"tabcontent\">");
1896 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1897 wprintf("</i><br />\n");
1899 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1900 "<tr class=\"even\"><th>");
1901 wprintf(_("Remote host"));
1902 wprintf("</th><th>");
1903 wprintf(_("User name"));
1904 wprintf("</th><th>");
1905 wprintf(_("Password"));
1906 wprintf("</th><th>");
1907 wprintf(_("Keep messages on server?"));
1908 wprintf("</th><th>");
1909 wprintf(_("Interval"));
1910 wprintf("</th><th> </th></tr>");
1913 serv_getln(buf, sizeof buf);
1915 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1916 extract_token(cmd, buf, 0, '|', sizeof cmd);
1917 if (!strcasecmp(cmd, "pop3client")) {
1918 safestrncpy(recp, &buf[11], sizeof recp);
1921 wprintf("<tr class=\"%s\">",
1922 (bg ? "even" : "odd")
1926 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1931 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1935 wprintf("<td>*****</td>"); /* Don't show the password */
1937 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1939 wprintf("<td>%ld</td>", extract_long(buf, 5)); // Fetching interval
1941 wprintf("<td class=\"button_link\">");
1942 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1945 wprintf(_("(remove)"));
1946 wprintf("</a></td>");
1952 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1954 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1955 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1956 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1958 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1961 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1964 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1967 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1970 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
1973 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1974 wprintf("</td></tr>");
1975 wprintf("</form></table>\n");
1980 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1981 wprintf("</i><br />\n");
1983 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1984 "<tr class=\"even\"><th>");
1985 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1986 wprintf(_("Feed URL"));
1987 wprintf("</th><th>");
1988 wprintf("</th></tr>");
1991 serv_getln(buf, sizeof buf);
1993 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1994 extract_token(cmd, buf, 0, '|', sizeof cmd);
1995 if (!strcasecmp(cmd, "rssclient")) {
1996 safestrncpy(recp, &buf[10], sizeof recp);
1999 wprintf("<tr class=\"%s\">",
2000 (bg ? "even" : "odd")
2004 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2008 wprintf("<td class=\"button_link\">");
2009 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=rssclient|");
2012 wprintf(_("(remove)"));
2013 wprintf("</a></td>");
2019 wprintf("<form method=\"POST\" action=\"netedit\">\n"
2021 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2022 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2023 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2025 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2026 "maxlength=\"256\" name=\"line_pop3host\">\n");
2029 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2030 wprintf("</td></tr>");
2031 wprintf("</form></table>\n");
2037 /* end content of whatever tab is open now */
2038 wprintf("</div>\n");
2040 address_book_popup();
2046 * Toggle self-service list subscription
2048 void toggle_self_service(void) {
2049 room_states RoomFlags;
2051 get_roomflags (&RoomFlags);
2053 if (yesbstr("QR2_SelfList"))
2054 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2056 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2058 if (yesbstr("QR2_SMTP_PUBLIC"))
2059 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2061 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2063 if (yesbstr("QR2_Moderated"))
2064 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2066 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2067 if (yesbstr("QR2_SubsOnly"))
2068 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2070 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2072 set_roomflags (&RoomFlags);
2080 * save new parameters for a room
2086 char er_password[10];
2087 char er_dirname[15];
2088 char er_roomaide[26];
2091 int er_listingorder;
2097 if (!havebstr("ok_button")) {
2098 strcpy(WC->ImportantMessage,
2099 _("Cancelled. Changes were not saved."));
2104 serv_getln(buf, sizeof buf);
2106 if (buf[0] != '2') {
2107 strcpy(WC->ImportantMessage, &buf[4]);
2111 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
2112 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
2113 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
2114 er_flags = extract_int(&buf[4], 3);
2115 er_listingorder = extract_int(&buf[4], 5);
2116 er_defaultview = extract_int(&buf[4], 6);
2117 er_flags2 = extract_int(&buf[4], 7);
2119 strcpy(er_roomaide, bstr("er_roomaide"));
2120 if (IsEmptyStr(er_roomaide)) {
2122 serv_getln(buf, sizeof buf);
2123 if (buf[0] != '2') {
2124 strcpy(er_roomaide, "");
2126 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
2129 strcpy(buf, bstr("er_name"));
2131 if (!IsEmptyStr(buf)) {
2132 strcpy(er_name, buf);
2135 strcpy(buf, bstr("er_password"));
2137 if (!IsEmptyStr(buf))
2138 strcpy(er_password, buf);
2140 strcpy(buf, bstr("er_dirname"));
2142 if (!IsEmptyStr(buf))
2143 strcpy(er_dirname, buf);
2145 strcpy(buf, bstr("type"));
2146 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2148 if (!strcmp(buf, "invonly")) {
2149 er_flags |= (QR_PRIVATE);
2151 if (!strcmp(buf, "hidden")) {
2152 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2154 if (!strcmp(buf, "passworded")) {
2155 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2157 if (!strcmp(buf, "personal")) {
2158 er_flags |= QR_MAILBOX;
2160 er_flags &= ~QR_MAILBOX;
2163 if (yesbstr("prefonly")) {
2164 er_flags |= QR_PREFONLY;
2166 er_flags &= ~QR_PREFONLY;
2169 if (yesbstr("readonly")) {
2170 er_flags |= QR_READONLY;
2172 er_flags &= ~QR_READONLY;
2176 if (yesbstr("collabdel")) {
2177 er_flags2 |= QR2_COLLABDEL;
2179 er_flags2 &= ~QR2_COLLABDEL;
2182 if (yesbstr("permanent")) {
2183 er_flags |= QR_PERMANENT;
2185 er_flags &= ~QR_PERMANENT;
2188 if (yesbstr("subjectreq")) {
2189 er_flags2 |= QR2_SUBJECTREQ;
2191 er_flags2 &= ~QR2_SUBJECTREQ;
2194 if (yesbstr("network")) {
2195 er_flags |= QR_NETWORK;
2197 er_flags &= ~QR_NETWORK;
2200 if (yesbstr("directory")) {
2201 er_flags |= QR_DIRECTORY;
2203 er_flags &= ~QR_DIRECTORY;
2206 if (yesbstr("ulallowed")) {
2207 er_flags |= QR_UPLOAD;
2209 er_flags &= ~QR_UPLOAD;
2212 if (yesbstr("dlallowed")) {
2213 er_flags |= QR_DOWNLOAD;
2215 er_flags &= ~QR_DOWNLOAD;
2218 if (yesbstr("visdir")) {
2219 er_flags |= QR_VISDIR;
2221 er_flags &= ~QR_VISDIR;
2224 strcpy(buf, bstr("anon"));
2226 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2227 if (!strcmp(buf, "anononly"))
2228 er_flags |= QR_ANONONLY;
2229 if (!strcmp(buf, "anon2"))
2230 er_flags |= QR_ANONOPT;
2233 if (!strcmp(bstr("bump"), "yes"))
2236 er_floor = ibstr("er_floor");
2238 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2239 er_name, er_password, er_dirname, er_flags, bump, er_floor,
2240 er_listingorder, er_defaultview, er_flags2);
2242 serv_getln(buf, sizeof buf);
2243 if (buf[0] != '2') {
2244 strcpy(WC->ImportantMessage, &buf[4]);
2250 if (!IsEmptyStr(er_roomaide)) {
2251 sprintf(buf, "SETA %s", er_roomaide);
2253 serv_getln(buf, sizeof buf);
2254 if (buf[0] != '2') {
2255 strcpy(WC->ImportantMessage, &buf[4]);
2256 display_main_menu();
2261 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2268 * Display form for Invite, Kick, and show Who Knows a room
2270 void do_invt_kick(void) {
2271 char buf[SIZ], room[SIZ], username[SIZ];
2274 serv_getln(buf, sizeof buf);
2276 if (buf[0] != '2') {
2280 extract_token(room, &buf[4], 0, '|', sizeof room);
2282 strcpy(username, bstr("username"));
2284 if (havebstr("kick_button")) {
2285 sprintf(buf, "KICK %s", username);
2287 serv_getln(buf, sizeof buf);
2289 if (buf[0] != '2') {
2290 strcpy(WC->ImportantMessage, &buf[4]);
2292 sprintf(WC->ImportantMessage,
2293 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2298 if (havebstr("invite_button")) {
2299 sprintf(buf, "INVT %s", username);
2301 serv_getln(buf, sizeof buf);
2303 if (buf[0] != '2') {
2304 strcpy(WC->ImportantMessage, &buf[4]);
2306 sprintf(WC->ImportantMessage,
2307 _("<B><I>User %s invited to room %s.</I></B>\n"),
2318 * Display form for Invite, Kick, and show Who Knows a room
2320 void display_whok(void)
2322 char buf[SIZ], room[SIZ], username[SIZ];
2325 serv_getln(buf, sizeof buf);
2327 if (buf[0] != '2') {
2331 extract_token(room, &buf[4], 0, '|', sizeof room);
2334 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2335 wprintf(_("The users listed below have access to this room. "
2336 "To remove a user from the access list, select the user "
2337 "name from the list and click 'Kick'."));
2338 wprintf("<br /><br />");
2340 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2341 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2342 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2343 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2345 serv_getln(buf, sizeof buf);
2346 if (buf[0] == '1') {
2347 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2348 extract_token(username, buf, 0, '|', sizeof username);
2349 wprintf("<OPTION>");
2354 wprintf("</select><br />\n");
2356 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2357 wprintf("</form></CENTER>\n");
2359 wprintf("</td><td>");
2360 wprintf(_("To grant another user access to this room, enter the "
2361 "user name in the box below and click 'Invite'."));
2362 wprintf("<br /><br />");
2364 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2365 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2366 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2367 wprintf(_("Invite:"));
2369 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2370 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2371 "<input type=\"submit\" value=\"%s\">"
2372 "</form></CENTER>\n", _("Invite"));
2373 /* Pop open an address book -- begin **/
2375 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2377 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2380 _("Users"), _("Users")
2382 /* Pop open an address book -- end **/
2384 wprintf("</td></tr></table>\n");
2385 address_book_popup();
2392 * display the form for entering a new room
2394 void display_entroom(void)
2399 serv_puts("CRE8 0");
2400 serv_getln(buf, sizeof buf);
2402 if (buf[0] != '2') {
2403 strcpy(WC->ImportantMessage, &buf[4]);
2404 display_main_menu();
2408 output_headers(1, 1, 1, 0, 0, 0);
2410 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2411 do_template("beginbox");
2413 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2414 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2416 wprintf("<table class=\"altern\"> ");
2418 wprintf("<tr class=\"even\"><td>");
2419 wprintf(_("Name of room: "));
2420 wprintf("</td><td>");
2421 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2422 wprintf("</td></tr>");
2424 wprintf("<tr class=\"odd\"><td>");
2425 wprintf(_("Resides on floor: "));
2426 wprintf("</td><td>");
2428 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2429 for (i = 0; i < 128; ++i)
2430 if (!IsEmptyStr(floorlist[i])) {
2431 wprintf("<option ");
2432 wprintf("value=\"%d\">", i);
2433 escputs(floorlist[i]);
2434 wprintf("</option>\n");
2436 wprintf("</select>\n");
2437 wprintf("</td></tr>");
2440 * Our clever little snippet of JavaScript automatically selects
2441 * a public room if the view is set to Bulletin Board or wiki, and
2442 * it selects a mailbox room otherwise. The user can override this,
2443 * of course. We also disable the floor selector for mailboxes.
2445 wprintf("<tr class=\"even\"><td>");
2446 wprintf(_("Default view for room: "));
2447 wprintf("</td><td>");
2448 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2449 " if ( (this.form.er_view.value == 0) "
2450 " || (this.form.er_view.value == 6) ) { "
2451 " this.form.type[0].checked=true; "
2452 " this.form.er_floor.disabled = false; "
2455 " this.form.type[4].checked=true; "
2456 " this.form.er_floor.disabled = true; "
2459 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2460 if (is_view_allowed_as_default(i)) {
2461 wprintf("<option %s value=\"%d\">",
2462 ((i == 0) ? "selected" : ""), i );
2463 escputs(viewdefs[i]);
2464 wprintf("</option>\n");
2467 wprintf("</select>\n");
2468 wprintf("</td></tr>");
2470 wprintf("<tr class=\"even\"><td>");
2471 wprintf(_("Type of room:"));
2472 wprintf("</td><td>");
2473 wprintf("<ul class=\"adminlist\">\n");
2475 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2476 wprintf("CHECKED OnChange=\""
2477 " if (this.form.type[0].checked == true) { "
2478 " this.form.er_floor.disabled = false; "
2481 wprintf(_("Public (automatically appears to everyone)"));
2484 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2485 " if (this.form.type[1].checked == true) { "
2486 " this.form.er_floor.disabled = false; "
2489 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2492 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2493 " if (this.form.type[2].checked == true) { "
2494 " this.form.er_floor.disabled = false; "
2497 wprintf(_("Private - require password: "));
2498 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2501 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2502 " if (this.form.type[3].checked == true) { "
2503 " this.form.er_floor.disabled = false; "
2506 wprintf(_("Private - invitation only"));
2509 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2511 " if (this.form.type[4].checked == true) { "
2512 " this.form.er_floor.disabled = true; "
2515 wprintf(_("Personal (mailbox for you only)"));
2518 wprintf("\n</ul>\n");
2519 wprintf("</td></tr></table>\n");
2521 wprintf("<div class=\"buttons\">\n");
2522 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2524 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2525 wprintf("</div>\n");
2526 wprintf("</form>\n<hr />");
2527 serv_printf("MESG roomaccess");
2528 serv_getln(buf, sizeof buf);
2529 if (buf[0] == '1') {
2533 do_template("endbox");
2542 * support function for entroom() -- sets the default view
2544 void er_set_default_view(int newview) {
2557 serv_getln(buf, sizeof buf);
2558 if (buf[0] != '2') return;
2560 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2561 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2562 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2563 rm_bits1 = extract_int(&buf[4], 3);
2564 rm_floor = extract_int(&buf[4], 4);
2565 rm_listorder = extract_int(&buf[4], 5);
2566 rm_bits2 = extract_int(&buf[4], 7);
2568 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2569 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2570 rm_listorder, newview, rm_bits2
2572 serv_getln(buf, sizeof buf);
2585 char er_password[SIZ];
2590 if (!havebstr("ok_button")) {
2591 strcpy(WC->ImportantMessage,
2592 _("Cancelled. No new room was created."));
2593 display_main_menu();
2596 strcpy(er_name, bstr("er_name"));
2597 strcpy(er_type, bstr("type"));
2598 strcpy(er_password, bstr("er_password"));
2599 er_floor = ibstr("er_floor");
2600 er_view = ibstr("er_view");
2603 if (!strcmp(er_type, "hidden"))
2605 if (!strcmp(er_type, "passworded"))
2607 if (!strcmp(er_type, "invonly"))
2609 if (!strcmp(er_type, "personal"))
2612 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2613 er_name, er_num_type, er_password, er_floor, 0, er_view);
2615 serv_getln(buf, sizeof buf);
2616 if (buf[0] != '2') {
2617 strcpy(WC->ImportantMessage, &buf[4]);
2618 display_main_menu();
2621 /** TODO: Room created, now udate the left hand icon bar for this user */
2622 burn_folder_cache(0); /* burn the old folder cache */
2626 do_change_view(er_view); /* Now go there */
2631 * \brief display the screen to enter a private room
2633 void display_private(char *rname, int req_pass)
2635 output_headers(1, 1, 1, 0, 0, 0);
2637 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Go to a hidden room"));
2638 do_template("beginbox");
2641 wprintf(_("If you know the name of a hidden (guess-name) or "
2642 "passworded room, you can enter that room by typing "
2643 "its name below. Once you gain access to a private "
2644 "room, it will appear in your regular room listings "
2645 "so you don't have to keep returning here."));
2648 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2649 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2651 wprintf("<table class=\"altern\"> "
2652 "<tr class=\"even\"><td>");
2653 wprintf(_("Enter room name:"));
2655 "<input type=\"text\" name=\"gr_name\" "
2656 "value=\"%s\" maxlength=\"128\">\n", rname);
2659 wprintf("</td></tr><tr class=\"odd\"><td>");
2660 wprintf(_("Enter room password:"));
2661 wprintf("</td><td>");
2662 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2664 wprintf("</td></tr></table>\n");
2666 wprintf("<div class=\"buttons\">\n");
2667 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2669 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2673 wprintf("</div></form>\n");
2675 do_template("endbox");
2681 * \brief goto a private room
2683 void goto_private(void)
2688 if (!havebstr("ok_button")) {
2689 display_main_menu();
2692 strcpy(hold_rm, WC->wc_roomname);
2693 strcpy(buf, "GOTO ");
2694 strcat(buf, bstr("gr_name"));
2696 strcat(buf, bstr("gr_pass"));
2698 serv_getln(buf, sizeof buf);
2700 if (buf[0] == '2') {
2701 smart_goto(bstr("gr_name"));
2704 if (!strncmp(buf, "540", 3)) {
2705 display_private(bstr("gr_name"), 1);
2708 output_headers(1, 1, 1, 0, 0, 0);
2709 wprintf("%s\n", &buf[4]);
2716 * \brief display the screen to zap a room
2718 void display_zap(void)
2720 output_headers(1, 1, 2, 0, 0, 0);
2722 wprintf("<div id=\"banner\">\n");
2724 wprintf(_("Zap (forget/unsubscribe) the current room"));
2726 wprintf("</div>\n");
2728 wprintf("<div id=\"content\" class=\"service\">\n");
2730 wprintf(_("If you select this option, <em>%s</em> will "
2731 "disappear from your room list. Is this what you wish "
2732 "to do?<br />\n"), WC->wc_roomname);
2734 wprintf("<form method=\"POST\" action=\"zap\">\n");
2735 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2736 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2738 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2739 wprintf("</form>\n");
2750 char final_destination[SIZ];
2753 * If the forget-room routine fails for any reason, we fall back
2754 * to the current room; otherwise, we go to the Lobby
2756 strcpy(final_destination, WC->wc_roomname);
2758 if (havebstr("ok_button")) {
2759 serv_printf("GOTO %s", WC->wc_roomname);
2760 serv_getln(buf, sizeof buf);
2761 if (buf[0] == '2') {
2763 serv_getln(buf, sizeof buf);
2764 if (buf[0] == '2') {
2765 strcpy(final_destination, "_BASEROOM_");
2769 smart_goto(final_destination);
2775 * \brief Delete the current room
2777 void delete_room(void)
2782 serv_puts("KILL 1");
2783 serv_getln(buf, sizeof buf);
2784 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2785 if (buf[0] != '2') {
2786 strcpy(WC->ImportantMessage, &buf[4]);
2787 display_main_menu();
2790 smart_goto("_BASEROOM_");
2797 * \brief Perform changes to a room's network configuration
2799 void netedit(void) {
2808 // TODO: do line dynamic!
2809 if (havebstr("line_pop3host")) {
2810 strcpy(line, bstr("prefix"));
2811 strcat(line, bstr("line_pop3host"));
2813 strcat(line, bstr("line_pop3user"));
2815 strcat(line, bstr("line_pop3pass"));
2817 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2819 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2820 strcat(line, bstr("suffix"));
2822 else if (havebstr("line")) {
2823 strcpy(line, bstr("prefix"));
2824 strcat(line, bstr("line"));
2825 strcat(line, bstr("suffix"));
2840 serv_getln(buf, sizeof buf);
2841 if (buf[0] != '1') {
2847 /** This loop works for add *or* remove. Spiffy, eh? */
2848 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2849 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2850 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2851 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2852 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2853 if ( (strcasecmp(cmpa0, cmpb0))
2854 || (strcasecmp(cmpa1, cmpb1)) ) {
2855 fprintf(fp, "%s\n", buf);
2861 serv_getln(buf, sizeof buf);
2862 if (buf[0] != '4') {
2868 while (fgets(buf, sizeof buf, fp) != NULL) {
2869 buf[strlen(buf)-1] = 0;
2873 if (havebstr("add_button")) {
2874 num_addrs = num_tokens(bstr("line"), ',');
2875 if (num_addrs < 2) {
2876 /* just adding one node or address */
2880 /* adding multiple addresses separated by commas */
2881 for (i=0; i<num_addrs; ++i) {
2882 strcpy(line, bstr("prefix"));
2883 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2886 strcat(line, bstr("suffix"));
2900 * \brief Convert a room name to a folder-ish-looking name.
2901 * \param folder the folderish name
2902 * \param room the room name
2903 * \param floor the floor name
2904 * \param is_mailbox is it a mailbox?
2906 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2911 * For mailboxes, just do it straight...
2914 sprintf(folder, "My folders|%s", room);
2918 * Otherwise, prefix the floor name as a "public folders" moniker
2921 if (floor > MAX_FLOORS) {
2923 sprintf(folder, "%%%%%%|%s", room);
2926 sprintf(folder, "%s|%s", floorlist[floor], room);
2931 * Replace "\" characters with "|" for pseudo-folder-delimiting
2933 len = strlen (folder);
2934 for (i=0; i<len; ++i) {
2935 if (folder[i] == '\\') folder[i] = '|';
2943 * \brief Back end for change_view()
2944 * \param newview set newview???
2946 void do_change_view(int newview) {
2949 serv_printf("VIEW %d", newview);
2950 serv_getln(buf, sizeof buf);
2951 WC->wc_view = newview;
2952 smart_goto(WC->wc_roomname);
2958 * \brief Change the view for this room
2960 void change_view(void) {
2963 view = lbstr("view");
2964 do_change_view(view);
2969 * \brief One big expanded tree list view --- like a folder list
2970 * \param fold the folder to view
2971 * \param max_folders how many folders???
2972 * \param num_floors hom many floors???
2974 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2978 int has_subfolders = 0;
2981 parents = malloc(max_folders * sizeof(int));
2983 /** BEGIN TREE MENU */
2984 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2986 /** include NanoTree */
2987 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2989 /** initialize NanoTree */
2990 wprintf("<script type=\"text/javascript\"> \n"
2991 " showRootNode = false; \n"
2992 " sortNodes = false; \n"
2993 " dragable = false; \n"
2995 " function standardClick(treeNode) { \n"
2998 " var closedGif = 'static/folder_closed.gif'; \n"
2999 " var openGif = 'static/folder_open.gif'; \n"
3001 " rootNode = new TreeNode(1, 'root node - hide'); \n"
3005 for (i=0; i<max_folders; ++i) {
3008 if ((i+1) < max_folders) {
3010 len = strlen(fold[i].name);
3011 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
3012 && (fold[i+1].name[len] == '|') ) {
3017 levels = num_tokens(fold[i].name, '|');
3018 parents[levels] = i;
3020 wprintf("var node%d = new TreeNode(%d, '", i, i);
3022 if (fold[i].selectable) {
3023 wprintf("<a href=\"dotgoto?room=");
3024 urlescputs(fold[i].room);
3029 wprintf("<span class=\"roomlist_floor\">");
3031 else if (fold[i].hasnewmsgs) {
3032 wprintf("<span class=\"roomlist_new\">");
3035 wprintf("<span class=\"roomlist_old\">");
3037 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3042 if (has_subfolders) {
3043 wprintf("new Array(closedGif, openGif)");
3045 else if (fold[i].view == VIEW_ADDRESSBOOK) {
3046 wprintf("'static/viewcontacts_16x.gif'");
3048 else if (fold[i].view == VIEW_CALENDAR) {
3049 wprintf("'static/calarea_16x.gif'");
3051 else if (fold[i].view == VIEW_CALBRIEF) {
3052 wprintf("'static/calarea_16x.gif'");
3054 else if (fold[i].view == VIEW_TASKS) {
3055 wprintf("'static/taskmanag_16x.gif'");
3057 else if (fold[i].view == VIEW_NOTES) {
3058 wprintf("'static/storenotes_16x.gif'");
3060 else if (fold[i].view == VIEW_MAILBOX) {
3061 wprintf("'static/privatemess_16x.gif'");
3064 wprintf("'static/chatrooms_16x.gif'");
3067 urlescputs(fold[i].name);
3071 wprintf("rootNode.addChild(node%d);\n", i);
3074 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3078 wprintf("container = document.getElementById('roomlist_div'); \n"
3084 /** END TREE MENU */
3088 * \brief Boxes and rooms and lists ... oh my!
3089 * \param fold the folder to view
3090 * \param max_folders how many folders???
3091 * \param num_floors hom many floors???
3093 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3095 char floor_name[256];
3096 char old_floor_name[256];
3098 int levels, oldlevels;
3101 static int columns = 3;
3102 int boxes_per_column = 0;
3103 int current_column = 0;
3106 strcpy(floor_name, "");
3107 strcpy(old_floor_name, "");
3110 while (nf % columns != 0) ++nf;
3111 boxes_per_column = (nf / columns);
3112 if (boxes_per_column < 1) boxes_per_column = 1;
3114 /** Outer table (for columnization) */
3115 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3116 "<tr><td valign=top>");
3120 for (i=0; i<max_folders; ++i) {
3122 levels = num_tokens(fold[i].name, '|');
3123 extract_token(floor_name, fold[i].name, 0,
3124 '|', sizeof floor_name);
3126 if ( (strcasecmp(floor_name, old_floor_name))
3127 && (!IsEmptyStr(old_floor_name)) ) {
3129 do_template("endbox");
3133 if ((num_boxes % boxes_per_column) == 0) {
3135 if (current_column < columns) {
3136 wprintf("</td><td valign=top>\n");
3140 strcpy(old_floor_name, floor_name);
3143 /** Begin inner box */
3144 stresc(boxtitle, 256, floor_name, 1, 0);
3145 svprintf(HKEY("BOXTITLE"), WCS_STRING, boxtitle);
3146 do_template("beginbox");
3153 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3154 if (fold[i].selectable) {
3155 wprintf("<a href=\"dotgoto?room=");
3156 urlescputs(fold[i].room);
3162 if (fold[i].hasnewmsgs) {
3163 wprintf("<span class=\"roomlist_new\">");
3166 wprintf("<span class=\"roomlist_old\">");
3168 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3171 if (fold[i].selectable) {
3177 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3178 wprintf(" (INBOX)");
3180 wprintf("<br />\n");
3183 /** End the final inner box */
3184 do_template("endbox");
3186 wprintf("</td></tr></table>\n");
3190 * \brief print a floor div???
3191 * \param which_floordiv name of the floordiv???
3193 void set_floordiv_expanded(void) {
3194 struct wcsession *WCC = WC;
3196 if (WCC->floordiv_expanded == NULL)
3197 WCC->floordiv_expanded = NewStrBuf();
3199 FlushStrBuf(WC->floordiv_expanded);
3200 StrBufAppendBuf(WC->floordiv_expanded, WC->UrlFragment1, 0);
3204 * \brief view the iconbar
3205 * \param fold the folder to view
3206 * \param max_folders how many folders???
3207 * \param num_floors hom many floors???
3209 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3211 char floor_name[256];
3212 char old_floor_name[256];
3213 char floordivtitle[256];
3214 char floordiv_id[32];
3215 int levels, oldlevels;
3217 int num_drop_targets = 0;
3220 strcpy(floor_name, "");
3221 strcpy(old_floor_name, "");
3225 for (i=0; i<max_folders; ++i) {
3227 levels = num_tokens(fold[i].name, '|');
3228 extract_token(floor_name, fold[i].name, 0,
3229 '|', sizeof floor_name);
3231 if ( (strcasecmp(floor_name, old_floor_name))
3232 && (!IsEmptyStr(old_floor_name)) ) {
3233 /** End inner box */
3235 wprintf("</div>\n"); /** floordiv */
3237 strcpy(old_floor_name, floor_name);
3241 stresc(floordivtitle, 256, floor_name, 0, 0);
3242 sprintf(floordiv_id, "floordiv%d", i);
3243 wprintf("<span class=\"ib_roomlist_floor\" "
3244 "onClick=\"expand_floor('%s')\">"
3245 "%s</span><br>\n", floordiv_id, floordivtitle);
3246 wprintf("<div id=\"%s\" style=\"display:%s\">",
3248 (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
3255 wprintf("<div id=\"roomdiv%d\">", i);
3257 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3259 /** choose the icon */
3260 if (fold[i].view == VIEW_ADDRESSBOOK) {
3261 icon = "viewcontacts_16x.gif" ;
3263 else if (fold[i].view == VIEW_CALENDAR) {
3264 icon = "calarea_16x.gif" ;
3266 else if (fold[i].view == VIEW_CALBRIEF) {
3267 icon = "calarea_16x.gif" ;
3269 else if (fold[i].view == VIEW_TASKS) {
3270 icon = "taskmanag_16x.gif" ;
3272 else if (fold[i].view == VIEW_NOTES) {
3273 icon = "storenotes_16x.gif" ;
3275 else if (fold[i].view == VIEW_MAILBOX) {
3276 icon = "privatemess_16x.gif" ;
3279 icon = "chatrooms_16x.gif" ;
3282 if (fold[i].selectable) {
3283 wprintf("<a href=\"dotgoto?room=");
3284 urlescputs(fold[i].room);
3286 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3291 if (fold[i].hasnewmsgs) {
3292 wprintf("<span class=\"ib_roomlist_new\">");
3295 wprintf("<span class=\"ib_roomlist_old\">");
3297 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3299 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3300 wprintf(" (INBOX)");
3303 if (fold[i].selectable) {
3310 wprintf("</div>\n"); /** roomdiv */
3313 wprintf("</div>\n"); /** floordiv */
3316 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3317 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3319 num_drop_targets = 0;
3321 for (i=0; i<max_folders; ++i) {
3322 levels = num_tokens(fold[i].name, '|');
3324 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3325 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3326 jsescputs(fold[i].room);
3332 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3333 if ((ChrPtr(WC->floordiv_expanded)[0] != '\0')&&
3334 (ChrPtr(WC->floordiv_expanded)[1] != '\0')){
3335 wprintf("which_div_expanded = '%s';\n", ChrPtr(WC->floordiv_expanded));
3339 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3345 * \brief Burn the cached folder list.
3346 * \param age How old the cahce needs to be before we burn it.
3349 void burn_folder_cache(time_t age)
3351 /** If our cached folder list is very old, burn it. */
3352 if (WC->cache_fold != NULL) {
3353 if ((time(NULL) - WC->cache_timestamp) > age) {
3354 free(WC->cache_fold);
3355 WC->cache_fold = NULL;
3364 * \brief Show the room list.
3365 * (only should get called by
3366 * knrooms() because that's where output_headers() is called from)
3367 * \param viewpref the view preferences???
3370 void list_all_rooms_by_floor(const char *viewpref) {
3373 struct folder *fold = NULL;
3375 int max_folders = 0;
3376 int alloc_folders = 0;
3380 int ShowEmptyFloors;
3383 int num_floors = 1; /** add an extra one for private folders */
3386 /** If our cached folder list is very old, burn it. */
3387 burn_folder_cache(300);
3389 /** Can we do the iconbar roomlist from cache? */
3390 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3391 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3395 /** Grab the floor table so we know how to build the list... */
3398 /** Start with the mailboxes */
3401 fold = malloc(sizeof(struct folder));
3402 memset(fold, 0, sizeof(struct folder));
3403 strcpy(fold[0].name, "My folders");
3404 fold[0].is_mailbox = 1;
3406 /** Then add floors */
3408 serv_getln(buf, sizeof buf);
3409 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3410 if (max_folders >= alloc_folders) {
3411 alloc_folders = max_folders + 100;
3412 fold = realloc(fold,
3413 alloc_folders * sizeof(struct folder));
3415 memset(&fold[max_folders], 0, sizeof(struct folder));
3416 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3417 extract_token(buf3, buf, 0, '|', SIZ);
3418 fold[max_folders].floor = atol (buf3);
3423 for (i=0; i<num_floors; i++)
3424 if (IDMax < fold[i].floor)
3425 IDMax = fold[i].floor;
3426 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3427 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3428 for (i=0; i<num_floors; i++)
3429 floor_mapping[fold[i].floor]=i;
3431 /** refresh the messages index for this room */
3432 // serv_puts("GOTO ");
3433 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3434 /** Now add rooms */
3436 serv_getln(buf, sizeof buf);
3437 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3438 if (max_folders >= alloc_folders) {
3439 alloc_folders = max_folders + 100;
3440 fold = realloc(fold,
3441 alloc_folders * sizeof(struct folder));
3443 memset(&fold[max_folders], 0, sizeof(struct folder));
3444 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3445 ra_flags = extract_int(buf, 5);
3446 flags = extract_int(buf, 1);
3447 fold[max_folders].floor = extract_int(buf, 2);
3448 fold[max_folders].hasnewmsgs =
3449 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3450 if (flags & QR_MAILBOX) {
3451 fold[max_folders].is_mailbox = 1;
3453 fold[max_folders].view = extract_int(buf, 6);
3454 room_to_folder(fold[max_folders].name,
3455 fold[max_folders].room,
3456 fold[max_folders].floor,
3457 fold[max_folders].is_mailbox);
3458 fold[max_folders].selectable = 1;
3459 /* Increase the room count for the associtaed floor */
3460 if (fold[max_folders].is_mailbox) {
3461 fold[0].num_rooms++;
3464 i = floor_mapping[fold[max_folders].floor];
3465 fold[i].num_rooms++;
3471 * Remove any floors that don't have rooms
3473 get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
3474 if (ShowEmptyFloors)
3476 for (i=0; i<num_floors; i++)
3478 if (fold[i].num_rooms == 0) {
3479 for (j=i; j<max_folders; j++) {
3480 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3489 /** Bubble-sort the folder list */
3490 for (i=0; i<max_folders; ++i) {
3491 for (j=0; j<(max_folders-1)-i; ++j) {
3492 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3493 swap = strcasecmp(fold[j].name, fold[j+1].name);
3496 if ( (fold[j+1].is_mailbox)
3497 && (!fold[j].is_mailbox)) {
3505 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3506 memcpy(&fold[j], &fold[j+1],
3507 sizeof(struct folder));
3508 memcpy(&fold[j+1], &ftmp,
3509 sizeof(struct folder));
3515 if (!strcasecmp(viewpref, "folders")) {
3516 do_folder_view(fold, max_folders, num_floors);
3518 else if (!strcasecmp(viewpref, "hackish_view")) {
3519 for (i=0; i<max_folders; ++i) {
3520 escputs(fold[i].name);
3521 wprintf("<br />\n");
3524 else if (!strcasecmp(viewpref, "iconbar")) {
3525 do_iconbar_view(fold, max_folders, num_floors);
3528 do_rooms_view(fold, max_folders, num_floors);
3531 /* Don't free the folder list ... cache it for future use! */
3532 if (WC->cache_fold != NULL) {
3533 free(WC->cache_fold);
3535 WC->cache_fold = fold;
3536 WC->cache_max_folders = max_folders;
3537 WC->cache_num_floors = num_floors;
3538 WC->cache_timestamp = time(NULL);
3539 free(floor_mapping);
3544 * \brief Do either a known rooms list or a folders list, depending on the
3549 StrBuf *ListView = NULL;
3551 output_headers(1, 1, 2, 0, 0, 0);
3553 /** Determine whether the user is trying to change views */
3554 if (havebstr("view")) {
3555 ListView = NewStrBufPlain(bstr("view"), -1);
3556 set_preference("roomlistview", ListView, 1);
3558 /** Sanitize the input so its safe */
3559 if(!get_preference("roomlistview", &ListView) ||
3560 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3561 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3563 if (ListView == NULL) {
3564 ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1);
3565 set_preference("roomlistview", ListView, 0);
3568 StrBufPrintf(ListView, "rooms");
3574 wprintf("<div id=\"banner\">\n");
3575 wprintf("<div class=\"room_banner\">");
3577 if (!strcasecmp(ChrPtr(ListView), "rooms")) {
3578 wprintf(_("Room list"));
3580 else if (!strcasecmp(ChrPtr(ListView), "folders")) {
3581 wprintf(_("Folder list"));
3583 else if (!strcasecmp(ChrPtr(ListView), "table")) {
3584 wprintf(_("Room list"));
3586 wprintf("</h1></div>\n");
3588 /** offer the ability to switch views */
3589 wprintf("<ul class=\"room_actions\">\n");
3590 wprintf("<li class=\"start_page\">");
3593 wprintf("<li><form name=\"roomlistomatic\">\n"
3594 "<select name=\"newview\" size=\"1\" "
3595 "OnChange=\"location.href=roomlistomatic.newview.options"
3596 "[selectedIndex].value\">\n");
3598 wprintf("<option %s value=\"knrooms&view=rooms\">"
3601 ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" )
3604 wprintf("<option %s value=\"knrooms&view=folders\">"
3605 "View as folder list"
3607 ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" )
3610 wprintf("</select>");
3611 wprintf("</form></li>");
3612 wprintf("</ul></div>\n");
3614 wprintf("<div id=\"content\" class=\"service\">\n");
3616 /** Display the room list in the user's preferred format */
3617 list_all_rooms_by_floor(ChrPtr(ListView));
3624 * \brief Set the message expire policy for this room and/or floor
3626 void set_room_policy(void) {
3629 if (!havebstr("ok_button")) {
3630 strcpy(WC->ImportantMessage,
3631 _("Cancelled. Changes were not saved."));
3636 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3637 serv_getln(buf, sizeof buf);
3638 strcpy(WC->ImportantMessage, &buf[4]);
3640 if (WC->axlevel >= 6) {
3641 strcat(WC->ImportantMessage, "<br />\n");
3642 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3643 serv_getln(buf, sizeof buf);
3644 strcat(WC->ImportantMessage, &buf[4]);
3651 void _gotonext(void) { slrp_highest(); gotonext(); }
3652 void dotskip(void) {smart_goto(bstr("room"));}
3653 void _display_private(void) { display_private("", 0); }
3654 void dotgoto(void) {
3655 if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3658 smart_goto(bstr("room"));
3666 WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
3667 WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, 0);
3668 WebcitAddUrlHandler(HKEY("skip"), gotonext, 0);
3669 WebcitAddUrlHandler(HKEY("ungoto"), ungoto, 0);
3670 WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, 0);
3671 WebcitAddUrlHandler(HKEY("dotskip"), dotskip, 0);
3672 WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
3673 WebcitAddUrlHandler(HKEY("goto_private"), goto_private, 0);
3674 WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
3675 WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
3676 WebcitAddUrlHandler(HKEY("zap"), zap, 0);
3677 WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
3678 WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
3679 WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
3680 WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
3681 WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
3682 WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
3683 WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
3684 WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
3685 WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
3686 WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
3687 WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);