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", NULL);
266 wprintf("<br /><br />\n");
267 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
268 do_template("endbox", NULL);
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 with_files[256];
451 * We need to have the information returned by a GOTO server command.
452 * If it isn't supplied, we fake it by issuing our own GOTO.
455 serv_printf("GOTO %s", WC->wc_roomname);
456 serv_getln(buf, sizeof buf);
460 /** The browser needs some information for its own use */
461 wprintf("<script type=\"text/javascript\"> \n"
462 " room_is_trash = %d; \n"
468 * If the user happens to select the "make this my start page" link,
469 * we want it to remember the URL as a "/dotskip" one instead of
470 * a "skip" or "gotonext" or something like that.
472 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
475 /** Check for new mail. */
476 WC->new_mail = extract_int(&got[4], 9);
477 WC->wc_view = extract_int(&got[4], 11);
479 /* Is this a directory room and does it contain files and how many? */
480 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
483 serv_getln(buf2, sizeof buf2);
484 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
486 snprintf (with_files, sizeof with_files,
487 "; <a href=\"display_room_directory\"> %d %s </a>",
489 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
492 strcpy (with_files, "");
494 svprintf(HKEY("NUMMSGS"), WCS_STRING,
495 _("%d new of %d messages%s"),
496 extract_int(&got[4], 1),
497 extract_int(&got[4], 2),
500 svcallback("ROOMPIC", embed_room_graphic);
501 svcallback("ROOMINFO", readinfo);
502 svcallback("VIEWOMATIC", embed_view_o_matic);
503 svcallback("SEARCHOMATIC", embed_search_o_matic);
504 svcallback("START", offer_start_page);
506 do_template("roombanner", NULL);
507 // roombanner contains this for mobile
508 if (navbar_style != navbar_none && !WC->is_mobile) {
510 wprintf("<div id=\"navbar\"><ul>");
512 if (navbar_style == navbar_default) wprintf(
513 "<li class=\"ungoto\">"
514 "<a href=\"ungoto\">"
515 "<img src=\"static/ungoto2_24x.gif\" alt=\"\">"
516 "<span class=\"navbar_link\">%s</span></A>"
517 "</li>\n", _("Ungoto")
520 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
522 "<li class=\"newmess\">"
523 "<a href=\"readnew\">"
524 "<img src=\"static/newmess2_24x.gif\" alt=\"\">"
525 "<span class=\"navbar_link\">%s</span></A>"
526 "</li>\n", _("Read new messages")
530 if (navbar_style == navbar_default) {
531 switch(WC->wc_view) {
532 case VIEW_ADDRESSBOOK:
534 "<li class=\"viewcontacts\">"
535 "<a href=\"readfwd\">"
536 "<img src=\"static/viewcontacts_24x.gif\" "
538 "<span class=\"navbar_link\">"
540 "</span></a></li>\n", _("View contacts")
545 "<li class=\"staskday\">"
546 "<a href=\"readfwd?calview=day\">"
547 "<img src=\"static/taskday2_24x.gif\" "
549 "<span class=\"navbar_link\">"
551 "</span></a></li>\n", _("Day view")
554 "<li class=\"monthview\">"
555 "<a href=\"readfwd?calview=month\">"
556 "<img src=\"static/monthview2_24x.gif\" "
558 "<span class=\"navbar_link\">"
560 "</span></a></li>\n", _("Month view")
565 "<li class=\"monthview\">"
566 "<a href=\"readfwd?calview=month\">"
567 "<img src=\"static/monthview2_24x.gif\" "
569 "<span class=\"navbar_link\">"
571 "</span></a></li>\n", _("Calendar list")
576 "<li class=\"taskmanag\">"
577 "<a href=\"readfwd\">"
578 "<img src=\"static/taskmanag_24x.gif\" "
580 "<span class=\"navbar_link\">"
582 "</span></a></li>\n", _("View tasks")
587 "<li class=\"viewnotes\">"
588 "<a href=\"readfwd\">"
589 "<img src=\"static/viewnotes_24x.gif\" "
591 "<span class=\"navbar_link\">"
593 "</span></a></li>\n", _("View notes")
598 "<li class=\"readallmess\">"
599 "<a href=\"readfwd\">"
600 "<img src=\"static/readallmess3_24x.gif\" "
602 "<span class=\"navbar_link\">"
604 "</span></a></li>\n", _("View message list")
609 "<li class=\"readallmess\">"
610 "<a href=\"readfwd\">"
611 "<img src=\"static/readallmess3_24x.gif\" "
613 "<span class=\"navbar_link\">"
615 "</span></a></li>\n", _("Wiki home")
620 "<li class=\"readallmess\">"
621 "<a href=\"readfwd\">"
622 "<img src=\"static/readallmess3_24x.gif\" "
624 "<span class=\"navbar_link\">"
626 "</span></a></li>\n", _("Read all messages")
632 if (navbar_style == navbar_default) {
633 switch(WC->wc_view) {
634 case VIEW_ADDRESSBOOK:
636 "<li class=\"addnewcontact\">"
637 "<a href=\"display_enter\">"
638 "<img src=\"static/addnewcontact_24x.gif\" "
639 "alt=\"\"><span class=\"navbar_link\">"
641 "</span></a></li>\n", _("Add new contact")
646 wprintf("<li class=\"addevent\"><a href=\"display_enter");
647 if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
648 if (havebstr("month")) wprintf("?month=%s", bstr("month"));
649 if (havebstr("day" )) wprintf("?day=%s", bstr("day"));
651 "<img src=\"static/addevent_24x.gif\" "
652 "alt=\"\"><span class=\"navbar_link\">"
654 "</span></a></li>\n", _("Add new event")
659 "<li class=\"newmess\">"
660 "<a href=\"display_enter\">"
661 "<img src=\"static/newmess3_24x.gif\" "
662 "alt=\"\"><span class=\"navbar_link\">"
664 "</span></a></li>\n", _("Add new task")
669 "<li class=\"enternewnote\">"
670 "<a href=\"add_new_note\">"
671 "<img src=\"static/enternewnote_24x.gif\" "
672 "alt=\"\"><span class=\"navbar_link\">"
674 "</span></a></li>\n", _("Add new note")
678 safestrncpy(buf, bstr("page"), sizeof buf);
681 "<li class=\"newmess\">"
682 "<a href=\"display_enter?wikipage=%s\">"
683 "<img src=\"static/newmess3_24x.gif\" "
684 "alt=\"\"><span class=\"navbar_link\">"
686 "</span></a></li>\n", buf, _("Edit this page")
691 "<li class=\"newmess\">"
692 "<a href=\"display_enter\">"
693 "<img src=\"static/newmess3_24x.gif\" "
694 "alt=\"\"><span class=\"navbar_link\">"
696 "</span></a></li>\n", _("Write mail")
701 "<li class=\"newmess\">"
702 "<a href=\"display_enter\">"
703 "<img src=\"static/newmess3_24x.gif\" "
704 "alt=\"\"><span class=\"navbar_link\">"
706 "</span></a></li>\n", _("Enter a message")
712 if (navbar_style == navbar_default) wprintf(
713 "<li class=\"skipthisroom\">"
716 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\">"
717 "<span class=\"navbar_link\">%s</span></a>"
719 _("Leave all messages marked as unread, go to next room with unread messages"),
723 if (navbar_style == navbar_default) wprintf(
724 "<li class=\"markngo\">"
725 "<a href=\"gotonext\" "
727 "<img src=\"static/markngo_24x.gif\" alt=\"\">"
728 "<span class=\"navbar_link\">%s</span></a>"
730 _("Mark all messages as read, go to next room with unread messages"),
734 wprintf("</ul></div>\n");
741 * back end routine to take the session to a new room
743 int gotoroom(char *gname)
746 static long ls = (-1L);
749 /* store ungoto information */
750 strcpy(WC->ugname, WC->wc_roomname);
753 /** move to the new room */
754 serv_printf("GOTO %s", gname);
755 serv_getln(buf, sizeof buf);
759 serv_puts("GOTO _BASEROOM_");
760 serv_getln(buf, sizeof buf);
767 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
768 WC->room_flags = extract_int(&buf[4], 4);
769 /* highest_msg_read = extract_int(&buf[4],6);
770 maxmsgnum = extract_int(&buf[4],5);
772 WC->is_mailbox = extract_int(&buf[4],7);
773 ls = extract_long(&buf[4], 6);
774 WC->wc_floor = extract_int(&buf[4], 10);
775 WC->wc_view = extract_int(&buf[4], 11);
776 WC->wc_default_view = extract_int(&buf[4], 12);
777 WC->wc_is_trash = extract_int(&buf[4], 13);
778 WC->room_flags2 = extract_int(&buf[4], 14);
781 WC->is_room_aide = WC->is_aide;
783 WC->is_room_aide = (char) extract_int(&buf[4], 8);
785 remove_march(WC->wc_roomname);
786 if (!strcasecmp(gname, "_BASEROOM_"))
794 * \brief Locate the room on the march list which we most want to go to.
796 * is measured given a "weight" of preference based on various factors.
797 * \param desired_floor the room number on the citadel server
798 * \return the roomname
800 char *pop_march(int desired_floor)
802 static char TheRoom[128];
804 int TheOrder = 32767;
807 struct march *mptr = NULL;
809 strcpy(TheRoom, "_BASEROOM_");
810 if (WC->march == NULL)
813 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
815 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
816 weight = weight + 10000;
817 if (mptr->march_floor == desired_floor)
818 weight = weight + 5000;
820 weight = weight + ((128 - (mptr->march_floor)) * 128);
821 weight = weight + (128 - (mptr->march_order));
823 if (weight > TheWeight) {
825 strcpy(TheRoom, mptr->march_name);
826 TheFloor = mptr->march_floor;
827 TheOrder = mptr->march_order;
836 * Goto next room having unread messages.
838 * We want to skip over rooms that the user has already been to, and take the
839 * user back to the lobby when done. The room we end up in is placed in
840 * newroom - which is set to 0 (the lobby) initially.
841 * We start the search in the current room rather than the beginning to prevent
842 * two or more concurrent users from dragging each other back to the same room.
847 struct march *mptr = NULL;
848 struct march *mptr2 = NULL;
854 * First check to see if the march-mode list is already allocated.
855 * If it is, pop the first room off the list and go there.
858 if (WC->march == NULL) {
860 serv_getln(buf, sizeof buf);
862 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
863 if (IsEmptyStr(buf)) {
866 if (ELoop % 100 == 0)
871 extract_token(room_name, buf, 0, '|', sizeof room_name);
872 if (strcasecmp(room_name, WC->wc_roomname)) {
873 mptr = (struct march *) malloc(sizeof(struct march));
875 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
876 mptr->march_floor = extract_int(buf, 2);
877 mptr->march_order = extract_int(buf, 3);
878 if (WC->march == NULL)
887 * add _BASEROOM_ to the end of the march list, so the user will end up
888 * in the system base room (usually the Lobby>) at the end of the loop
890 mptr = (struct march *) malloc(sizeof(struct march));
892 mptr->march_order = 0;
893 mptr->march_floor = 0;
894 strcpy(mptr->march_name, "_BASEROOM_");
895 if (WC->march == NULL) {
899 while (mptr2->next != NULL)
904 * ...and remove the room we're currently in, so a <G>oto doesn't make us
905 * walk around in circles
907 remove_march(WC->wc_roomname);
909 if (WC->march != NULL) {
910 strcpy(next_room, pop_march(-1));
912 strcpy(next_room, "_BASEROOM_");
916 smart_goto(next_room);
923 void smart_goto(char *next_room) {
931 * mark all messages in current room as having been read
933 void slrp_highest(void)
937 serv_puts("SLRP HIGHEST");
938 serv_getln(buf, sizeof buf);
943 * un-goto the previous room
949 if (!strcmp(WC->ugname, "")) {
950 smart_goto(WC->wc_roomname);
953 serv_printf("GOTO %s", WC->ugname);
954 serv_getln(buf, sizeof buf);
956 smart_goto(WC->wc_roomname);
959 if (WC->uglsn >= 0L) {
960 serv_printf("SLRP %ld", WC->uglsn);
961 serv_getln(buf, sizeof buf);
963 strcpy(buf, WC->ugname);
964 strcpy(WC->ugname, "");
968 typedef struct __room_states {
983 * Set/clear/read the "self-service list subscribe" flag for a room
985 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
986 * returns the new value.
989 int self_service(int newval) {
990 int current_value = 0;
996 int flags, floor, order, view, flags2;
999 serv_getln(buf, sizeof buf);
1000 if (buf[0] != '2') return(0);
1002 extract_token(name, &buf[4], 0, '|', sizeof name);
1003 extract_token(password, &buf[4], 1, '|', sizeof password);
1004 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1005 flags = extract_int(&buf[4], 3);
1006 floor = extract_int(&buf[4], 4);
1007 order = extract_int(&buf[4], 5);
1008 view = extract_int(&buf[4], 6);
1009 flags2 = extract_int(&buf[4], 7);
1011 if (flags2 & QR2_SELFLIST) {
1019 flags2 = flags2 | QR2_SELFLIST;
1021 else if (newval == 0) {
1022 flags2 = flags2 & ~QR2_SELFLIST;
1025 return(current_value);
1028 if (newval != current_value) {
1029 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1030 name, password, dirname, flags,
1031 floor, order, view, flags2);
1032 serv_getln(buf, sizeof buf);
1039 int is_selflist(room_states *RoomFlags)
1041 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1044 int is_publiclist(room_states *RoomFlags)
1046 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1049 int is_moderatedlist(room_states *RoomFlags)
1051 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1055 * Set/clear/read the "self-service list subscribe" flag for a room
1057 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1058 * returns the new value.
1061 int get_roomflags(room_states *RoomOps)
1066 serv_getln(buf, sizeof buf);
1067 if (buf[0] != '2') return(0);
1069 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1070 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1071 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1072 RoomOps->flags = extract_int(&buf[4], 3);
1073 RoomOps->floor = extract_int(&buf[4], 4);
1074 RoomOps->order = extract_int(&buf[4], 5);
1075 RoomOps->view = extract_int(&buf[4], 6);
1076 RoomOps->flags2 = extract_int(&buf[4], 7);
1080 int set_roomflags(room_states *RoomOps)
1084 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1093 serv_getln(buf, sizeof buf);
1103 * display the form for editing a room
1105 void display_editroom(void)
1110 char remote_room[128];
1113 char er_password[10];
1114 char er_dirname[15];
1115 char er_roomaide[26];
1122 char *not_shared_with;
1125 int floorpolicy = 0;
1127 char pop3_host[128];
1132 if (IsEmptyStr(tab)) tab = "admin";
1135 output_headers(1, 1, 1, 0, 0, 0);
1137 wprintf("<div class=\"fix_scrollbar_bug\">");
1139 wprintf("<br />\n");
1141 /* print the tabbed dialog */
1142 wprintf("<div align=\"center\">");
1143 wprintf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\""
1144 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1147 wprintf("<td class=\"");
1148 if (!strcmp(tab, "admin")) {
1149 wprintf(" tab_cell_label\">");
1150 wprintf(_("Administration"));
1153 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1154 wprintf(_("Administration"));
1158 wprintf("<td> </td>\n");
1160 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1162 wprintf("<td class=\"");
1163 if (!strcmp(tab, "config")) {
1164 wprintf(" tab_cell_label\">");
1165 wprintf(_("Configuration"));
1168 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1169 wprintf(_("Configuration"));
1173 wprintf("<td> </td>\n");
1175 wprintf("<td class=\"");
1176 if (!strcmp(tab, "expire")) {
1177 wprintf(" tab_cell_label\">");
1178 wprintf(_("Message expire policy"));
1181 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1182 wprintf(_("Message expire policy"));
1186 wprintf("<td> </td>\n");
1188 wprintf("<td class=\"");
1189 if (!strcmp(tab, "access")) {
1190 wprintf(" tab_cell_label\">");
1191 wprintf(_("Access controls"));
1194 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1195 wprintf(_("Access controls"));
1199 wprintf("<td> </td>\n");
1201 wprintf("<td class=\"");
1202 if (!strcmp(tab, "sharing")) {
1203 wprintf(" tab_cell_label\">");
1204 wprintf(_("Sharing"));
1207 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1208 wprintf(_("Sharing"));
1212 wprintf("<td> </td>\n");
1214 wprintf("<td class=\"");
1215 if (!strcmp(tab, "listserv")) {
1216 wprintf(" tab_cell_label\">");
1217 wprintf(_("Mailing list service"));
1220 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1221 wprintf(_("Mailing list service"));
1225 wprintf("<td> </td>\n");
1229 wprintf("<td class=\"");
1230 if (!strcmp(tab, "feeds")) {
1231 wprintf(" tab_cell_label\">");
1232 wprintf(_("Remote retrieval"));
1235 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1236 wprintf(_("Remote retrieval"));
1240 wprintf("<td> </td>\n");
1242 wprintf("</tr></table>\n");
1243 wprintf("</div>\n");
1244 /* end tabbed dialog */
1246 wprintf("<script type=\"text/javascript\">"
1247 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1251 /* begin content of whatever tab is open now */
1253 if (!strcmp(tab, "admin")) {
1254 wprintf("<div class=\"tabcontent\">");
1256 "<li><a href=\"delete_room\" "
1257 "onClick=\"return confirm('");
1258 wprintf(_("Are you sure you want to delete this room?"));
1259 wprintf("');\">\n");
1260 wprintf(_("Delete this room"));
1262 "<li><a href=\"display_editroompic\">\n");
1263 wprintf(_("Set or change the icon for this room's banner"));
1265 "<li><a href=\"display_editinfo\">\n");
1266 wprintf(_("Edit this room's Info file"));
1272 if (!strcmp(tab, "config")) {
1273 wprintf("<div class=\"tabcontent\">");
1275 serv_getln(buf, sizeof buf);
1277 if (!strncmp(buf, "550", 3)) {
1278 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1279 _("Higher access is required to access this function.")
1282 else if (buf[0] != '2') {
1283 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1286 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1287 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1288 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1289 er_flags = extract_int(&buf[4], 3);
1290 er_floor = extract_int(&buf[4], 4);
1291 er_flags2 = extract_int(&buf[4], 7);
1293 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1294 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1296 wprintf("<ul><li>");
1297 wprintf(_("Name of room: "));
1298 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1304 wprintf(_("Resides on floor: "));
1305 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1306 if (er_flags & QR_MAILBOX)
1307 wprintf("disabled >\n");
1308 for (i = 0; i < 128; ++i)
1309 if (!IsEmptyStr(floorlist[i])) {
1310 wprintf("<OPTION ");
1312 wprintf("SELECTED ");
1313 wprintf("VALUE=\"%d\">", i);
1314 escputs(floorlist[i]);
1315 wprintf("</OPTION>\n");
1317 wprintf("</select>\n");
1320 wprintf(_("Type of room:"));
1323 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1324 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1325 wprintf("CHECKED ");
1326 wprintf("OnChange=\""
1327 " if (this.form.type[0].checked == true) { "
1328 " this.form.er_floor.disabled = false; "
1331 wprintf(_("Public (automatically appears to everyone)"));
1334 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1335 if ((er_flags & QR_PRIVATE) &&
1336 (er_flags & QR_GUESSNAME))
1337 wprintf("CHECKED ");
1338 wprintf(" OnChange=\""
1339 " if (this.form.type[1].checked == true) { "
1340 " this.form.er_floor.disabled = false; "
1343 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1345 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1346 if ((er_flags & QR_PRIVATE) &&
1347 (er_flags & QR_PASSWORDED))
1348 wprintf("CHECKED ");
1349 wprintf(" OnChange=\""
1350 " if (this.form.type[2].checked == true) { "
1351 " this.form.er_floor.disabled = false; "
1354 wprintf(_("Private - require password: "));
1355 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1358 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1359 if ((er_flags & QR_PRIVATE)
1360 && ((er_flags & QR_GUESSNAME) == 0)
1361 && ((er_flags & QR_PASSWORDED) == 0))
1362 wprintf("CHECKED ");
1363 wprintf(" OnChange=\""
1364 " if (this.form.type[3].checked == true) { "
1365 " this.form.er_floor.disabled = false; "
1368 wprintf(_("Private - invitation only"));
1370 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1371 if (er_flags & QR_MAILBOX)
1372 wprintf("CHECKED ");
1373 wprintf (" OnChange=\""
1374 " if (this.form.type[4].checked == true) { "
1375 " this.form.er_floor.disabled = true; "
1378 wprintf(_("Personal (mailbox for you only)"));
1380 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1382 wprintf(_("If private, cause current users to forget room"));
1384 wprintf("\n</ul>\n");
1386 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1387 if (er_flags & QR_PREFONLY)
1388 wprintf("CHECKED ");
1390 wprintf(_("Preferred users only"));
1392 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1393 if (er_flags & QR_READONLY)
1394 wprintf("CHECKED ");
1396 wprintf(_("Read-only room"));
1398 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1399 if (er_flags2 & QR2_COLLABDEL)
1400 wprintf("CHECKED ");
1402 wprintf(_("All users allowed to post may also delete messages"));
1404 /** directory stuff */
1405 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1406 if (er_flags & QR_DIRECTORY)
1407 wprintf("CHECKED ");
1409 wprintf(_("File directory room"));
1411 wprintf("\n<ul><li>");
1412 wprintf(_("Directory name: "));
1413 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1416 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1417 if (er_flags & QR_UPLOAD)
1418 wprintf("CHECKED ");
1420 wprintf(_("Uploading allowed"));
1422 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1423 if (er_flags & QR_DOWNLOAD)
1424 wprintf("CHECKED ");
1426 wprintf(_("Downloading allowed"));
1428 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1429 if (er_flags & QR_VISDIR)
1430 wprintf("CHECKED ");
1432 wprintf(_("Visible directory"));
1435 /** end of directory stuff */
1437 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1438 if (er_flags & QR_NETWORK)
1439 wprintf("CHECKED ");
1441 wprintf(_("Network shared room"));
1443 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1444 if (er_flags & QR_PERMANENT)
1445 wprintf("CHECKED ");
1447 wprintf(_("Permanent (does not auto-purge)"));
1449 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1450 if (er_flags2 & QR2_SUBJECTREQ)
1451 wprintf("CHECKED ");
1453 wprintf(_("Subject Required (Force users to specify a message subject)"));
1455 /** start of anon options */
1458 wprintf(_("Anonymous messages"));
1461 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1462 if (((er_flags & QR_ANONONLY) == 0)
1463 && ((er_flags & QR_ANONOPT) == 0))
1464 wprintf("CHECKED ");
1466 wprintf(_("No anonymous messages"));
1468 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1469 if (er_flags & QR_ANONONLY)
1470 wprintf("CHECKED ");
1472 wprintf(_("All messages are anonymous"));
1474 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1475 if (er_flags & QR_ANONOPT)
1476 wprintf("CHECKED ");
1478 wprintf(_("Prompt user when entering messages"));
1481 /* end of anon options */
1484 wprintf(_("Room aide: "));
1486 serv_getln(buf, sizeof buf);
1487 if (buf[0] != '2') {
1488 wprintf("<em>%s</em>\n", &buf[4]);
1490 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1491 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1494 wprintf("</ul><CENTER>\n");
1495 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1496 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1498 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1508 /* Sharing the room with other Citadel nodes... */
1509 if (!strcmp(tab, "sharing")) {
1510 wprintf("<div class=\"tabcontent\">");
1512 shared_with = strdup("");
1513 not_shared_with = strdup("");
1515 /** Learn the current configuration */
1516 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1517 serv_getln(buf, sizeof buf);
1518 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1519 extract_token(node, buf, 0, '|', sizeof node);
1520 not_shared_with = realloc(not_shared_with,
1521 strlen(not_shared_with) + 32);
1522 strcat(not_shared_with, node);
1523 strcat(not_shared_with, "\n");
1527 serv_getln(buf, sizeof buf);
1528 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1529 extract_token(cmd, buf, 0, '|', sizeof cmd);
1530 extract_token(node, buf, 1, '|', sizeof node);
1531 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1532 if (!strcasecmp(cmd, "ignet_push_share")) {
1533 shared_with = realloc(shared_with,
1534 strlen(shared_with) + 32);
1535 strcat(shared_with, node);
1536 if (!IsEmptyStr(remote_room)) {
1537 strcat(shared_with, "|");
1538 strcat(shared_with, remote_room);
1540 strcat(shared_with, "\n");
1544 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1545 extract_token(buf, shared_with, i, '\n', sizeof buf);
1546 extract_token(node, buf, 0, '|', sizeof node);
1547 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1548 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1549 if (!strcasecmp(node, cmd)) {
1550 remove_token(not_shared_with, j, '\n');
1555 /* Display the stuff */
1556 wprintf("<CENTER><br />"
1557 "<table border=1 cellpadding=5><tr>"
1559 wprintf(_("Shared with"));
1560 wprintf("</I></B></td>"
1562 wprintf(_("Not shared with"));
1563 wprintf("</I></B></td></tr>\n"
1564 "<tr><td VALIGN=TOP>\n");
1566 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1567 wprintf(_("Remote node name"));
1568 wprintf("</td><td>");
1569 wprintf(_("Remote room name"));
1570 wprintf("</td><td>");
1571 wprintf(_("Actions"));
1572 wprintf("</td></tr>\n");
1574 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1575 extract_token(buf, shared_with, i, '\n', sizeof buf);
1576 extract_token(node, buf, 0, '|', sizeof node);
1577 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1578 if (!IsEmptyStr(node)) {
1579 wprintf("<form method=\"POST\" action=\"netedit\">");
1580 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1581 wprintf("<tr><td>%s</td>\n", node);
1584 if (!IsEmptyStr(remote_room)) {
1585 escputs(remote_room);
1591 wprintf("<input type=\"hidden\" NAME=\"line\" "
1592 "VALUE=\"ignet_push_share|");
1594 if (!IsEmptyStr(remote_room)) {
1596 urlescputs(remote_room);
1599 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1600 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1601 wprintf("<input type=\"submit\" "
1602 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1603 wprintf("</td></tr></form>\n");
1607 wprintf("</table>\n");
1608 wprintf("</td><td VALIGN=TOP>\n");
1609 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1610 wprintf(_("Remote node name"));
1611 wprintf("</td><td>");
1612 wprintf(_("Remote room name"));
1613 wprintf("</td><td>");
1614 wprintf(_("Actions"));
1615 wprintf("</td></tr>\n");
1617 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1618 extract_token(node, not_shared_with, i, '\n', sizeof node);
1619 if (!IsEmptyStr(node)) {
1620 wprintf("<form method=\"POST\" action=\"netedit\">");
1621 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1622 wprintf("<tr><td>");
1625 "<input type=\"INPUT\" "
1629 wprintf("<input type=\"hidden\" "
1631 "VALUE=\"ignet_push_share|");
1634 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1635 "VALUE=\"sharing\">\n");
1636 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1637 "VALUE=\"add\">\n");
1638 wprintf("<input type=\"submit\" "
1639 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1640 wprintf("</td></tr></form>\n");
1644 wprintf("</table>\n");
1645 wprintf("</td></tr>"
1646 "</table></CENTER><br />\n"
1647 "<I><B>%s</B><ul><li>", _("Notes:"));
1648 wprintf(_("When sharing a room, "
1649 "it must be shared from both ends. Adding a node to "
1650 "the 'shared' list sends messages out, but in order to"
1651 " receive messages, the other nodes must be configured"
1652 " to send messages out to your system as well. "
1653 "<li>If the remote room name is blank, it is assumed "
1654 "that the room name is identical on the remote node."
1655 "<li>If the remote room name is different, the remote "
1656 "node must also configure the name of the room here."
1663 /* Mailing list management */
1664 if (!strcmp(tab, "listserv")) {
1665 room_states RoomFlags;
1666 wprintf("<div class=\"tabcontent\">");
1668 wprintf("<br /><center>"
1669 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1670 "<tr><td VALIGN=TOP>");
1672 wprintf(_("<i>The contents of this room are being "
1673 "mailed <b>as individual messages</b> "
1674 "to the following list recipients:"
1675 "</i><br /><br />\n"));
1678 serv_getln(buf, sizeof buf);
1679 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1680 extract_token(cmd, buf, 0, '|', sizeof cmd);
1681 if (!strcasecmp(cmd, "listrecp")) {
1682 extract_token(recp, buf, 1, '|', sizeof recp);
1685 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1688 wprintf(_("(remove)"));
1689 wprintf("</A><br />");
1692 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1693 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1694 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1695 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1696 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1697 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1698 wprintf("</form>\n");
1700 wprintf("</td><td VALIGN=TOP>\n");
1702 wprintf(_("<i>The contents of this room are being "
1703 "mailed <b>in digest form</b> "
1704 "to the following list recipients:"
1705 "</i><br /><br />\n"));
1708 serv_getln(buf, sizeof buf);
1709 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1710 extract_token(cmd, buf, 0, '|', sizeof cmd);
1711 if (!strcasecmp(cmd, "digestrecp")) {
1712 extract_token(recp, buf, 1, '|', sizeof recp);
1715 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1719 wprintf(_("(remove)"));
1720 wprintf("</A><br />");
1723 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1724 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1725 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1726 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1727 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1728 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1729 wprintf("</form>\n");
1731 wprintf("</td></tr></table>\n");
1733 /** Pop open an address book -- begin **/
1734 wprintf("<div align=right>"
1735 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1737 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1742 _("Add recipients from Contacts or other address books"),
1743 _("Add recipients from Contacts or other address books")
1745 /* Pop open an address book -- end **/
1747 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1749 get_roomflags (&RoomFlags);
1751 /* Self Service subscription? */
1752 wprintf("<table><tr><td>\n");
1753 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1754 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1755 " <tr><td colspan=\"2\">\n",
1756 (is_selflist(&RoomFlags))?"checked":"");
1757 wprintf(_("The URL for subscribe/unsubscribe is: "));
1758 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1759 (is_https ? "https" : "http"),
1761 /* Public posting? */
1762 wprintf("<tr><td>");
1763 wprintf(_("Allow non-subscribers to mail to this room."));
1764 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1765 (is_publiclist(&RoomFlags))?"checked":"");
1767 /* Moderated List? */
1768 wprintf("<tr><td>");
1769 wprintf(_("Room post publication needs Aide permission."));
1770 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1771 (is_moderatedlist(&RoomFlags))?"checked":"");
1774 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1775 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1776 wprintf("</table></form>");
1779 wprintf("</CENTER>\n");
1784 /* Configuration of The Dreaded Auto-Purger */
1785 if (!strcmp(tab, "expire")) {
1786 wprintf("<div class=\"tabcontent\">");
1788 serv_puts("GPEX room");
1789 serv_getln(buf, sizeof buf);
1790 if (!strncmp(buf, "550", 3)) {
1791 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1792 _("Higher access is required to access this function.")
1795 else if (buf[0] != '2') {
1796 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1799 roompolicy = extract_int(&buf[4], 0);
1800 roomvalue = extract_int(&buf[4], 1);
1802 serv_puts("GPEX floor");
1803 serv_getln(buf, sizeof buf);
1804 if (buf[0] == '2') {
1805 floorpolicy = extract_int(&buf[4], 0);
1806 floorvalue = extract_int(&buf[4], 1);
1809 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1810 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1811 wprintf("<table border=0 cellspacing=5>\n");
1812 wprintf("<tr><td>");
1813 wprintf(_("Message expire policy for this room"));
1815 escputs(WC->wc_roomname);
1816 wprintf(")</td><td>");
1817 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1818 ((roompolicy == 0) ? "CHECKED" : "") );
1819 wprintf(_("Use the default policy for this floor"));
1820 wprintf("<br />\n");
1821 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1822 ((roompolicy == 1) ? "CHECKED" : "") );
1823 wprintf(_("Never automatically expire messages"));
1824 wprintf("<br />\n");
1825 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1826 ((roompolicy == 2) ? "CHECKED" : "") );
1827 wprintf(_("Expire by message count"));
1828 wprintf("<br />\n");
1829 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1830 ((roompolicy == 3) ? "CHECKED" : "") );
1831 wprintf(_("Expire by message age"));
1833 wprintf(_("Number of messages or days: "));
1834 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1835 wprintf("</td></tr>\n");
1837 if (WC->axlevel >= 6) {
1838 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1839 wprintf("<tr><td>");
1840 wprintf(_("Message expire policy for this floor"));
1842 escputs(floorlist[WC->wc_floor]);
1843 wprintf(")</td><td>");
1844 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1845 ((floorpolicy == 0) ? "CHECKED" : "") );
1846 wprintf(_("Use the system default"));
1847 wprintf("<br />\n");
1848 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1849 ((floorpolicy == 1) ? "CHECKED" : "") );
1850 wprintf(_("Never automatically expire messages"));
1851 wprintf("<br />\n");
1852 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1853 ((floorpolicy == 2) ? "CHECKED" : "") );
1854 wprintf(_("Expire by message count"));
1855 wprintf("<br />\n");
1856 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1857 ((floorpolicy == 3) ? "CHECKED" : "") );
1858 wprintf(_("Expire by message age"));
1860 wprintf(_("Number of messages or days: "));
1861 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1865 wprintf("<CENTER>\n");
1866 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1867 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1869 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1870 wprintf("</CENTER></td><tr>\n");
1872 wprintf("</table>\n"
1873 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1881 /* Access controls */
1882 if (!strcmp(tab, "access")) {
1883 wprintf("<div class=\"tabcontent\">");
1888 /* Fetch messages from remote locations */
1889 if (!strcmp(tab, "feeds")) {
1890 wprintf("<div class=\"tabcontent\">");
1893 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1894 wprintf("</i><br />\n");
1896 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1897 "<tr class=\"even\"><th>");
1898 wprintf(_("Remote host"));
1899 wprintf("</th><th>");
1900 wprintf(_("User name"));
1901 wprintf("</th><th>");
1902 wprintf(_("Password"));
1903 wprintf("</th><th>");
1904 wprintf(_("Keep messages on server?"));
1905 wprintf("</th><th>");
1906 wprintf(_("Interval"));
1907 wprintf("</th><th> </th></tr>");
1910 serv_getln(buf, sizeof buf);
1912 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1913 extract_token(cmd, buf, 0, '|', sizeof cmd);
1914 if (!strcasecmp(cmd, "pop3client")) {
1915 safestrncpy(recp, &buf[11], sizeof recp);
1918 wprintf("<tr class=\"%s\">",
1919 (bg ? "even" : "odd")
1923 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1928 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1932 wprintf("<td>*****</td>"); /* Don't show the password */
1934 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1936 wprintf("<td>%ld</td>", extract_long(buf, 5)); // Fetching interval
1938 wprintf("<td class=\"button_link\">");
1939 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1942 wprintf(_("(remove)"));
1943 wprintf("</a></td>");
1949 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1951 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1952 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1953 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1955 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1958 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1961 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1964 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1967 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
1970 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1971 wprintf("</td></tr>");
1972 wprintf("</form></table>\n");
1977 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1978 wprintf("</i><br />\n");
1980 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1981 "<tr class=\"even\"><th>");
1982 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1983 wprintf(_("Feed URL"));
1984 wprintf("</th><th>");
1985 wprintf("</th></tr>");
1988 serv_getln(buf, sizeof buf);
1990 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1991 extract_token(cmd, buf, 0, '|', sizeof cmd);
1992 if (!strcasecmp(cmd, "rssclient")) {
1993 safestrncpy(recp, &buf[10], sizeof recp);
1996 wprintf("<tr class=\"%s\">",
1997 (bg ? "even" : "odd")
2001 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2005 wprintf("<td class=\"button_link\">");
2006 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=rssclient|");
2009 wprintf(_("(remove)"));
2010 wprintf("</a></td>");
2016 wprintf("<form method=\"POST\" action=\"netedit\">\n"
2018 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2019 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2020 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2022 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2023 "maxlength=\"256\" name=\"line_pop3host\">\n");
2026 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2027 wprintf("</td></tr>");
2028 wprintf("</form></table>\n");
2034 /* end content of whatever tab is open now */
2035 wprintf("</div>\n");
2037 address_book_popup();
2043 * Toggle self-service list subscription
2045 void toggle_self_service(void) {
2046 room_states RoomFlags;
2048 get_roomflags (&RoomFlags);
2050 if (yesbstr("QR2_SelfList"))
2051 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2053 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2055 if (yesbstr("QR2_SMTP_PUBLIC"))
2056 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2058 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2060 if (yesbstr("QR2_Moderated"))
2061 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2063 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2064 if (yesbstr("QR2_SubsOnly"))
2065 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2067 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2069 set_roomflags (&RoomFlags);
2077 * save new parameters for a room
2083 char er_password[10];
2084 char er_dirname[15];
2085 char er_roomaide[26];
2088 int er_listingorder;
2094 if (!havebstr("ok_button")) {
2095 strcpy(WC->ImportantMessage,
2096 _("Cancelled. Changes were not saved."));
2101 serv_getln(buf, sizeof buf);
2103 if (buf[0] != '2') {
2104 strcpy(WC->ImportantMessage, &buf[4]);
2108 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
2109 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
2110 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
2111 er_flags = extract_int(&buf[4], 3);
2112 er_listingorder = extract_int(&buf[4], 5);
2113 er_defaultview = extract_int(&buf[4], 6);
2114 er_flags2 = extract_int(&buf[4], 7);
2116 strcpy(er_roomaide, bstr("er_roomaide"));
2117 if (IsEmptyStr(er_roomaide)) {
2119 serv_getln(buf, sizeof buf);
2120 if (buf[0] != '2') {
2121 strcpy(er_roomaide, "");
2123 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
2126 strcpy(buf, bstr("er_name"));
2128 if (!IsEmptyStr(buf)) {
2129 strcpy(er_name, buf);
2132 strcpy(buf, bstr("er_password"));
2134 if (!IsEmptyStr(buf))
2135 strcpy(er_password, buf);
2137 strcpy(buf, bstr("er_dirname"));
2139 if (!IsEmptyStr(buf))
2140 strcpy(er_dirname, buf);
2142 strcpy(buf, bstr("type"));
2143 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2145 if (!strcmp(buf, "invonly")) {
2146 er_flags |= (QR_PRIVATE);
2148 if (!strcmp(buf, "hidden")) {
2149 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2151 if (!strcmp(buf, "passworded")) {
2152 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2154 if (!strcmp(buf, "personal")) {
2155 er_flags |= QR_MAILBOX;
2157 er_flags &= ~QR_MAILBOX;
2160 if (yesbstr("prefonly")) {
2161 er_flags |= QR_PREFONLY;
2163 er_flags &= ~QR_PREFONLY;
2166 if (yesbstr("readonly")) {
2167 er_flags |= QR_READONLY;
2169 er_flags &= ~QR_READONLY;
2173 if (yesbstr("collabdel")) {
2174 er_flags2 |= QR2_COLLABDEL;
2176 er_flags2 &= ~QR2_COLLABDEL;
2179 if (yesbstr("permanent")) {
2180 er_flags |= QR_PERMANENT;
2182 er_flags &= ~QR_PERMANENT;
2185 if (yesbstr("subjectreq")) {
2186 er_flags2 |= QR2_SUBJECTREQ;
2188 er_flags2 &= ~QR2_SUBJECTREQ;
2191 if (yesbstr("network")) {
2192 er_flags |= QR_NETWORK;
2194 er_flags &= ~QR_NETWORK;
2197 if (yesbstr("directory")) {
2198 er_flags |= QR_DIRECTORY;
2200 er_flags &= ~QR_DIRECTORY;
2203 if (yesbstr("ulallowed")) {
2204 er_flags |= QR_UPLOAD;
2206 er_flags &= ~QR_UPLOAD;
2209 if (yesbstr("dlallowed")) {
2210 er_flags |= QR_DOWNLOAD;
2212 er_flags &= ~QR_DOWNLOAD;
2215 if (yesbstr("visdir")) {
2216 er_flags |= QR_VISDIR;
2218 er_flags &= ~QR_VISDIR;
2221 strcpy(buf, bstr("anon"));
2223 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2224 if (!strcmp(buf, "anononly"))
2225 er_flags |= QR_ANONONLY;
2226 if (!strcmp(buf, "anon2"))
2227 er_flags |= QR_ANONOPT;
2230 if (!strcmp(bstr("bump"), "yes"))
2233 er_floor = ibstr("er_floor");
2235 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2236 er_name, er_password, er_dirname, er_flags, bump, er_floor,
2237 er_listingorder, er_defaultview, er_flags2);
2239 serv_getln(buf, sizeof buf);
2240 if (buf[0] != '2') {
2241 strcpy(WC->ImportantMessage, &buf[4]);
2247 if (!IsEmptyStr(er_roomaide)) {
2248 sprintf(buf, "SETA %s", er_roomaide);
2250 serv_getln(buf, sizeof buf);
2251 if (buf[0] != '2') {
2252 strcpy(WC->ImportantMessage, &buf[4]);
2253 display_main_menu();
2258 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2265 * Display form for Invite, Kick, and show Who Knows a room
2267 void do_invt_kick(void) {
2268 char buf[SIZ], room[SIZ], username[SIZ];
2271 serv_getln(buf, sizeof buf);
2273 if (buf[0] != '2') {
2277 extract_token(room, &buf[4], 0, '|', sizeof room);
2279 strcpy(username, bstr("username"));
2281 if (havebstr("kick_button")) {
2282 sprintf(buf, "KICK %s", username);
2284 serv_getln(buf, sizeof buf);
2286 if (buf[0] != '2') {
2287 strcpy(WC->ImportantMessage, &buf[4]);
2289 sprintf(WC->ImportantMessage,
2290 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2295 if (havebstr("invite_button")) {
2296 sprintf(buf, "INVT %s", username);
2298 serv_getln(buf, sizeof buf);
2300 if (buf[0] != '2') {
2301 strcpy(WC->ImportantMessage, &buf[4]);
2303 sprintf(WC->ImportantMessage,
2304 _("<B><I>User %s invited to room %s.</I></B>\n"),
2315 * Display form for Invite, Kick, and show Who Knows a room
2317 void display_whok(void)
2319 char buf[SIZ], room[SIZ], username[SIZ];
2322 serv_getln(buf, sizeof buf);
2324 if (buf[0] != '2') {
2328 extract_token(room, &buf[4], 0, '|', sizeof room);
2331 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2332 wprintf(_("The users listed below have access to this room. "
2333 "To remove a user from the access list, select the user "
2334 "name from the list and click 'Kick'."));
2335 wprintf("<br /><br />");
2337 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2338 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2339 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2340 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2342 serv_getln(buf, sizeof buf);
2343 if (buf[0] == '1') {
2344 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2345 extract_token(username, buf, 0, '|', sizeof username);
2346 wprintf("<OPTION>");
2351 wprintf("</select><br />\n");
2353 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2354 wprintf("</form></CENTER>\n");
2356 wprintf("</td><td>");
2357 wprintf(_("To grant another user access to this room, enter the "
2358 "user name in the box below and click 'Invite'."));
2359 wprintf("<br /><br />");
2361 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2362 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2363 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2364 wprintf(_("Invite:"));
2366 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2367 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2368 "<input type=\"submit\" value=\"%s\">"
2369 "</form></CENTER>\n", _("Invite"));
2370 /* Pop open an address book -- begin **/
2372 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2374 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2377 _("Users"), _("Users")
2379 /* Pop open an address book -- end **/
2381 wprintf("</td></tr></table>\n");
2382 address_book_popup();
2389 * display the form for entering a new room
2391 void display_entroom(void)
2396 serv_puts("CRE8 0");
2397 serv_getln(buf, sizeof buf);
2399 if (buf[0] != '2') {
2400 strcpy(WC->ImportantMessage, &buf[4]);
2401 display_main_menu();
2405 output_headers(1, 1, 1, 0, 0, 0);
2407 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2408 do_template("beginbox", NULL);
2410 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2411 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2413 wprintf("<table class=\"altern\"> ");
2415 wprintf("<tr class=\"even\"><td>");
2416 wprintf(_("Name of room: "));
2417 wprintf("</td><td>");
2418 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2419 wprintf("</td></tr>");
2421 wprintf("<tr class=\"odd\"><td>");
2422 wprintf(_("Resides on floor: "));
2423 wprintf("</td><td>");
2425 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2426 for (i = 0; i < 128; ++i)
2427 if (!IsEmptyStr(floorlist[i])) {
2428 wprintf("<option ");
2429 wprintf("value=\"%d\">", i);
2430 escputs(floorlist[i]);
2431 wprintf("</option>\n");
2433 wprintf("</select>\n");
2434 wprintf("</td></tr>");
2437 * Our clever little snippet of JavaScript automatically selects
2438 * a public room if the view is set to Bulletin Board or wiki, and
2439 * it selects a mailbox room otherwise. The user can override this,
2440 * of course. We also disable the floor selector for mailboxes.
2442 wprintf("<tr class=\"even\"><td>");
2443 wprintf(_("Default view for room: "));
2444 wprintf("</td><td>");
2445 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2446 " if ( (this.form.er_view.value == 0) "
2447 " || (this.form.er_view.value == 6) ) { "
2448 " this.form.type[0].checked=true; "
2449 " this.form.er_floor.disabled = false; "
2452 " this.form.type[4].checked=true; "
2453 " this.form.er_floor.disabled = true; "
2456 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2457 if (is_view_allowed_as_default(i)) {
2458 wprintf("<option %s value=\"%d\">",
2459 ((i == 0) ? "selected" : ""), i );
2460 escputs(viewdefs[i]);
2461 wprintf("</option>\n");
2464 wprintf("</select>\n");
2465 wprintf("</td></tr>");
2467 wprintf("<tr class=\"even\"><td>");
2468 wprintf(_("Type of room:"));
2469 wprintf("</td><td>");
2470 wprintf("<ul class=\"adminlist\">\n");
2472 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2473 wprintf("CHECKED OnChange=\""
2474 " if (this.form.type[0].checked == true) { "
2475 " this.form.er_floor.disabled = false; "
2478 wprintf(_("Public (automatically appears to everyone)"));
2481 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2482 " if (this.form.type[1].checked == true) { "
2483 " this.form.er_floor.disabled = false; "
2486 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2489 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2490 " if (this.form.type[2].checked == true) { "
2491 " this.form.er_floor.disabled = false; "
2494 wprintf(_("Private - require password: "));
2495 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2498 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2499 " if (this.form.type[3].checked == true) { "
2500 " this.form.er_floor.disabled = false; "
2503 wprintf(_("Private - invitation only"));
2506 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2508 " if (this.form.type[4].checked == true) { "
2509 " this.form.er_floor.disabled = true; "
2512 wprintf(_("Personal (mailbox for you only)"));
2515 wprintf("\n</ul>\n");
2516 wprintf("</td></tr></table>\n");
2518 wprintf("<div class=\"buttons\">\n");
2519 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2521 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2522 wprintf("</div>\n");
2523 wprintf("</form>\n<hr />");
2524 serv_printf("MESG roomaccess");
2525 serv_getln(buf, sizeof buf);
2526 if (buf[0] == '1') {
2530 do_template("endbox", NULL);
2539 * support function for entroom() -- sets the default view
2541 void er_set_default_view(int newview) {
2554 serv_getln(buf, sizeof buf);
2555 if (buf[0] != '2') return;
2557 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2558 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2559 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2560 rm_bits1 = extract_int(&buf[4], 3);
2561 rm_floor = extract_int(&buf[4], 4);
2562 rm_listorder = extract_int(&buf[4], 5);
2563 rm_bits2 = extract_int(&buf[4], 7);
2565 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2566 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2567 rm_listorder, newview, rm_bits2
2569 serv_getln(buf, sizeof buf);
2582 char er_password[SIZ];
2587 if (!havebstr("ok_button")) {
2588 strcpy(WC->ImportantMessage,
2589 _("Cancelled. No new room was created."));
2590 display_main_menu();
2593 strcpy(er_name, bstr("er_name"));
2594 strcpy(er_type, bstr("type"));
2595 strcpy(er_password, bstr("er_password"));
2596 er_floor = ibstr("er_floor");
2597 er_view = ibstr("er_view");
2600 if (!strcmp(er_type, "hidden"))
2602 if (!strcmp(er_type, "passworded"))
2604 if (!strcmp(er_type, "invonly"))
2606 if (!strcmp(er_type, "personal"))
2609 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2610 er_name, er_num_type, er_password, er_floor, 0, er_view);
2612 serv_getln(buf, sizeof buf);
2613 if (buf[0] != '2') {
2614 strcpy(WC->ImportantMessage, &buf[4]);
2615 display_main_menu();
2618 /** TODO: Room created, now udate the left hand icon bar for this user */
2619 burn_folder_cache(0); /* burn the old folder cache */
2623 do_change_view(er_view); /* Now go there */
2628 * \brief display the screen to enter a private room
2630 void display_private(char *rname, int req_pass)
2632 output_headers(1, 1, 1, 0, 0, 0);
2634 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Go to a hidden room"));
2635 do_template("beginbox", NULL);
2638 wprintf(_("If you know the name of a hidden (guess-name) or "
2639 "passworded room, you can enter that room by typing "
2640 "its name below. Once you gain access to a private "
2641 "room, it will appear in your regular room listings "
2642 "so you don't have to keep returning here."));
2645 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2646 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2648 wprintf("<table class=\"altern\"> "
2649 "<tr class=\"even\"><td>");
2650 wprintf(_("Enter room name:"));
2652 "<input type=\"text\" name=\"gr_name\" "
2653 "value=\"%s\" maxlength=\"128\">\n", rname);
2656 wprintf("</td></tr><tr class=\"odd\"><td>");
2657 wprintf(_("Enter room password:"));
2658 wprintf("</td><td>");
2659 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2661 wprintf("</td></tr></table>\n");
2663 wprintf("<div class=\"buttons\">\n");
2664 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2666 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2670 wprintf("</div></form>\n");
2672 do_template("endbox", NULL);
2678 * \brief goto a private room
2680 void goto_private(void)
2685 if (!havebstr("ok_button")) {
2686 display_main_menu();
2689 strcpy(hold_rm, WC->wc_roomname);
2690 strcpy(buf, "GOTO ");
2691 strcat(buf, bstr("gr_name"));
2693 strcat(buf, bstr("gr_pass"));
2695 serv_getln(buf, sizeof buf);
2697 if (buf[0] == '2') {
2698 smart_goto(bstr("gr_name"));
2701 if (!strncmp(buf, "540", 3)) {
2702 display_private(bstr("gr_name"), 1);
2705 output_headers(1, 1, 1, 0, 0, 0);
2706 wprintf("%s\n", &buf[4]);
2713 * \brief display the screen to zap a room
2715 void display_zap(void)
2717 output_headers(1, 1, 2, 0, 0, 0);
2719 wprintf("<div id=\"banner\">\n");
2721 wprintf(_("Zap (forget/unsubscribe) the current room"));
2723 wprintf("</div>\n");
2725 wprintf("<div id=\"content\" class=\"service\">\n");
2727 wprintf(_("If you select this option, <em>%s</em> will "
2728 "disappear from your room list. Is this what you wish "
2729 "to do?<br />\n"), WC->wc_roomname);
2731 wprintf("<form method=\"POST\" action=\"zap\">\n");
2732 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2733 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2735 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2736 wprintf("</form>\n");
2747 char final_destination[SIZ];
2750 * If the forget-room routine fails for any reason, we fall back
2751 * to the current room; otherwise, we go to the Lobby
2753 strcpy(final_destination, WC->wc_roomname);
2755 if (havebstr("ok_button")) {
2756 serv_printf("GOTO %s", WC->wc_roomname);
2757 serv_getln(buf, sizeof buf);
2758 if (buf[0] == '2') {
2760 serv_getln(buf, sizeof buf);
2761 if (buf[0] == '2') {
2762 strcpy(final_destination, "_BASEROOM_");
2766 smart_goto(final_destination);
2772 * \brief Delete the current room
2774 void delete_room(void)
2779 serv_puts("KILL 1");
2780 serv_getln(buf, sizeof buf);
2781 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2782 if (buf[0] != '2') {
2783 strcpy(WC->ImportantMessage, &buf[4]);
2784 display_main_menu();
2787 smart_goto("_BASEROOM_");
2794 * \brief Perform changes to a room's network configuration
2796 void netedit(void) {
2805 // TODO: do line dynamic!
2806 if (havebstr("line_pop3host")) {
2807 strcpy(line, bstr("prefix"));
2808 strcat(line, bstr("line_pop3host"));
2810 strcat(line, bstr("line_pop3user"));
2812 strcat(line, bstr("line_pop3pass"));
2814 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2816 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2817 strcat(line, bstr("suffix"));
2819 else if (havebstr("line")) {
2820 strcpy(line, bstr("prefix"));
2821 strcat(line, bstr("line"));
2822 strcat(line, bstr("suffix"));
2837 serv_getln(buf, sizeof buf);
2838 if (buf[0] != '1') {
2844 /** This loop works for add *or* remove. Spiffy, eh? */
2845 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2846 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2847 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2848 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2849 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2850 if ( (strcasecmp(cmpa0, cmpb0))
2851 || (strcasecmp(cmpa1, cmpb1)) ) {
2852 fprintf(fp, "%s\n", buf);
2858 serv_getln(buf, sizeof buf);
2859 if (buf[0] != '4') {
2865 while (fgets(buf, sizeof buf, fp) != NULL) {
2866 buf[strlen(buf)-1] = 0;
2870 if (havebstr("add_button")) {
2871 num_addrs = num_tokens(bstr("line"), ',');
2872 if (num_addrs < 2) {
2873 /* just adding one node or address */
2877 /* adding multiple addresses separated by commas */
2878 for (i=0; i<num_addrs; ++i) {
2879 strcpy(line, bstr("prefix"));
2880 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2883 strcat(line, bstr("suffix"));
2897 * \brief Convert a room name to a folder-ish-looking name.
2898 * \param folder the folderish name
2899 * \param room the room name
2900 * \param floor the floor name
2901 * \param is_mailbox is it a mailbox?
2903 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2908 * For mailboxes, just do it straight...
2911 sprintf(folder, "My folders|%s", room);
2915 * Otherwise, prefix the floor name as a "public folders" moniker
2918 if (floor > MAX_FLOORS) {
2920 sprintf(folder, "%%%%%%|%s", room);
2923 sprintf(folder, "%s|%s", floorlist[floor], room);
2928 * Replace "\" characters with "|" for pseudo-folder-delimiting
2930 len = strlen (folder);
2931 for (i=0; i<len; ++i) {
2932 if (folder[i] == '\\') folder[i] = '|';
2940 * \brief Back end for change_view()
2941 * \param newview set newview???
2943 void do_change_view(int newview) {
2946 serv_printf("VIEW %d", newview);
2947 serv_getln(buf, sizeof buf);
2948 WC->wc_view = newview;
2949 smart_goto(WC->wc_roomname);
2955 * \brief Change the view for this room
2957 void change_view(void) {
2960 view = lbstr("view");
2961 do_change_view(view);
2966 * \brief One big expanded tree list view --- like a folder list
2967 * \param fold the folder to view
2968 * \param max_folders how many folders???
2969 * \param num_floors hom many floors???
2971 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2975 int has_subfolders = 0;
2978 parents = malloc(max_folders * sizeof(int));
2980 /** BEGIN TREE MENU */
2981 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2983 /** include NanoTree */
2984 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2986 /** initialize NanoTree */
2987 wprintf("<script type=\"text/javascript\"> \n"
2988 " showRootNode = false; \n"
2989 " sortNodes = false; \n"
2990 " dragable = false; \n"
2992 " function standardClick(treeNode) { \n"
2995 " var closedGif = 'static/folder_closed.gif'; \n"
2996 " var openGif = 'static/folder_open.gif'; \n"
2998 " rootNode = new TreeNode(1, 'root node - hide'); \n"
3002 for (i=0; i<max_folders; ++i) {
3005 if ((i+1) < max_folders) {
3007 len = strlen(fold[i].name);
3008 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
3009 && (fold[i+1].name[len] == '|') ) {
3014 levels = num_tokens(fold[i].name, '|');
3015 parents[levels] = i;
3017 wprintf("var node%d = new TreeNode(%d, '", i, i);
3019 if (fold[i].selectable) {
3020 wprintf("<a href=\"dotgoto?room=");
3021 urlescputs(fold[i].room);
3026 wprintf("<span class=\"roomlist_floor\">");
3028 else if (fold[i].hasnewmsgs) {
3029 wprintf("<span class=\"roomlist_new\">");
3032 wprintf("<span class=\"roomlist_old\">");
3034 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3039 if (has_subfolders) {
3040 wprintf("new Array(closedGif, openGif)");
3042 else if (fold[i].view == VIEW_ADDRESSBOOK) {
3043 wprintf("'static/viewcontacts_16x.gif'");
3045 else if (fold[i].view == VIEW_CALENDAR) {
3046 wprintf("'static/calarea_16x.gif'");
3048 else if (fold[i].view == VIEW_CALBRIEF) {
3049 wprintf("'static/calarea_16x.gif'");
3051 else if (fold[i].view == VIEW_TASKS) {
3052 wprintf("'static/taskmanag_16x.gif'");
3054 else if (fold[i].view == VIEW_NOTES) {
3055 wprintf("'static/storenotes_16x.gif'");
3057 else if (fold[i].view == VIEW_MAILBOX) {
3058 wprintf("'static/privatemess_16x.gif'");
3061 wprintf("'static/chatrooms_16x.gif'");
3064 urlescputs(fold[i].name);
3068 wprintf("rootNode.addChild(node%d);\n", i);
3071 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3075 wprintf("container = document.getElementById('roomlist_div'); \n"
3081 /** END TREE MENU */
3085 * \brief Boxes and rooms and lists ... oh my!
3086 * \param fold the folder to view
3087 * \param max_folders how many folders???
3088 * \param num_floors hom many floors???
3090 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3092 char floor_name[256];
3093 char old_floor_name[256];
3095 int levels, oldlevels;
3098 static int columns = 3;
3099 int boxes_per_column = 0;
3100 int current_column = 0;
3103 strcpy(floor_name, "");
3104 strcpy(old_floor_name, "");
3107 while (nf % columns != 0) ++nf;
3108 boxes_per_column = (nf / columns);
3109 if (boxes_per_column < 1) boxes_per_column = 1;
3111 /** Outer table (for columnization) */
3112 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3113 "<tr><td valign=top>");
3117 for (i=0; i<max_folders; ++i) {
3119 levels = num_tokens(fold[i].name, '|');
3120 extract_token(floor_name, fold[i].name, 0,
3121 '|', sizeof floor_name);
3123 if ( (strcasecmp(floor_name, old_floor_name))
3124 && (!IsEmptyStr(old_floor_name)) ) {
3126 do_template("endbox", NULL);
3130 if ((num_boxes % boxes_per_column) == 0) {
3132 if (current_column < columns) {
3133 wprintf("</td><td valign=top>\n");
3137 strcpy(old_floor_name, floor_name);
3140 /** Begin inner box */
3141 stresc(boxtitle, 256, floor_name, 1, 0);
3142 svprintf(HKEY("BOXTITLE"), WCS_STRING, boxtitle);
3143 do_template("beginbox", NULL);
3150 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3151 if (fold[i].selectable) {
3152 wprintf("<a href=\"dotgoto?room=");
3153 urlescputs(fold[i].room);
3159 if (fold[i].hasnewmsgs) {
3160 wprintf("<span class=\"roomlist_new\">");
3163 wprintf("<span class=\"roomlist_old\">");
3165 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3168 if (fold[i].selectable) {
3174 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3175 wprintf(" (INBOX)");
3177 wprintf("<br />\n");
3180 /** End the final inner box */
3181 do_template("endbox", NULL);
3183 wprintf("</td></tr></table>\n");
3187 * \brief print a floor div???
3188 * \param which_floordiv name of the floordiv???
3190 void set_floordiv_expanded(void) {
3191 struct wcsession *WCC = WC;
3194 FloorDiv = NewStrBuf();
3195 StrBufAppendBuf(FloorDiv, WCC->UrlFragment1, 0);
3196 set_preference("floordiv_expanded", FloorDiv, 1);
3197 WCC->floordiv_expanded = FloorDiv;
3201 * \brief view the iconbar
3202 * \param fold the folder to view
3203 * \param max_folders how many folders???
3204 * \param num_floors hom many floors???
3206 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3208 char floor_name[256];
3209 char old_floor_name[256];
3210 char floordivtitle[256];
3211 char floordiv_id[32];
3212 int levels, oldlevels;
3214 int num_drop_targets = 0;
3217 strcpy(floor_name, "");
3218 strcpy(old_floor_name, "");
3222 for (i=0; i<max_folders; ++i) {
3224 levels = num_tokens(fold[i].name, '|');
3225 extract_token(floor_name, fold[i].name, 0,
3226 '|', sizeof floor_name);
3228 if ( (strcasecmp(floor_name, old_floor_name))
3229 && (!IsEmptyStr(old_floor_name)) ) {
3230 /** End inner box */
3232 wprintf("</div>\n"); /** floordiv */
3234 strcpy(old_floor_name, floor_name);
3238 stresc(floordivtitle, 256, floor_name, 0, 0);
3239 sprintf(floordiv_id, "floordiv%d", i);
3240 wprintf("<span class=\"ib_roomlist_floor\" "
3241 "onClick=\"expand_floor('%s')\">"
3242 "%s</span><br>\n", floordiv_id, floordivtitle);
3243 wprintf("<div id=\"%s\" style=\"display:%s\">",
3245 (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
3252 wprintf("<div id=\"roomdiv%d\">", i);
3254 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3256 /** choose the icon */
3257 if (fold[i].view == VIEW_ADDRESSBOOK) {
3258 icon = "viewcontacts_16x.gif" ;
3260 else if (fold[i].view == VIEW_CALENDAR) {
3261 icon = "calarea_16x.gif" ;
3263 else if (fold[i].view == VIEW_CALBRIEF) {
3264 icon = "calarea_16x.gif" ;
3266 else if (fold[i].view == VIEW_TASKS) {
3267 icon = "taskmanag_16x.gif" ;
3269 else if (fold[i].view == VIEW_NOTES) {
3270 icon = "storenotes_16x.gif" ;
3272 else if (fold[i].view == VIEW_MAILBOX) {
3273 icon = "privatemess_16x.gif" ;
3276 icon = "chatrooms_16x.gif" ;
3279 if (fold[i].selectable) {
3280 wprintf("<a href=\"dotgoto?room=");
3281 urlescputs(fold[i].room);
3283 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3288 if (fold[i].hasnewmsgs) {
3289 wprintf("<span class=\"ib_roomlist_new\">");
3292 wprintf("<span class=\"ib_roomlist_old\">");
3294 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3296 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3297 wprintf(" (INBOX)");
3300 if (fold[i].selectable) {
3307 wprintf("</div>\n"); /** roomdiv */
3310 wprintf("</div>\n"); /** floordiv */
3313 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3314 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3316 num_drop_targets = 0;
3318 for (i=0; i<max_folders; ++i) {
3319 levels = num_tokens(fold[i].name, '|');
3321 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3322 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3323 jsescputs(fold[i].room);
3329 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3330 if ((ChrPtr(WC->floordiv_expanded)[0] != '\0')&&
3331 (ChrPtr(WC->floordiv_expanded)[1] != '\0')){
3332 wprintf("which_div_expanded = '%s';\n", ChrPtr(WC->floordiv_expanded));
3336 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3342 * \brief Burn the cached folder list.
3343 * \param age How old the cahce needs to be before we burn it.
3346 void burn_folder_cache(time_t age)
3348 /** If our cached folder list is very old, burn it. */
3349 if (WC->cache_fold != NULL) {
3350 if ((time(NULL) - WC->cache_timestamp) > age) {
3351 free(WC->cache_fold);
3352 WC->cache_fold = NULL;
3361 * \brief Show the room list.
3362 * (only should get called by
3363 * knrooms() because that's where output_headers() is called from)
3364 * \param viewpref the view preferences???
3367 void list_all_rooms_by_floor(const char *viewpref) {
3370 struct folder *fold = NULL;
3372 int max_folders = 0;
3373 int alloc_folders = 0;
3377 int ShowEmptyFloors;
3380 int num_floors = 1; /** add an extra one for private folders */
3383 /** If our cached folder list is very old, burn it. */
3384 burn_folder_cache(300);
3386 /** Can we do the iconbar roomlist from cache? */
3387 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3388 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3392 /** Grab the floor table so we know how to build the list... */
3395 /** Start with the mailboxes */
3398 fold = malloc(sizeof(struct folder));
3399 memset(fold, 0, sizeof(struct folder));
3400 strcpy(fold[0].name, "My folders");
3401 fold[0].is_mailbox = 1;
3403 /** Then add floors */
3405 serv_getln(buf, sizeof buf);
3406 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3407 if (max_folders >= alloc_folders) {
3408 alloc_folders = max_folders + 100;
3409 fold = realloc(fold,
3410 alloc_folders * sizeof(struct folder));
3412 memset(&fold[max_folders], 0, sizeof(struct folder));
3413 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3414 extract_token(buf3, buf, 0, '|', SIZ);
3415 fold[max_folders].floor = atol (buf3);
3420 for (i=0; i<num_floors; i++)
3421 if (IDMax < fold[i].floor)
3422 IDMax = fold[i].floor;
3423 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3424 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3425 for (i=0; i<num_floors; i++)
3426 floor_mapping[fold[i].floor]=i;
3428 /** refresh the messages index for this room */
3429 // serv_puts("GOTO ");
3430 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3431 /** Now add rooms */
3433 serv_getln(buf, sizeof buf);
3434 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3435 if (max_folders >= alloc_folders) {
3436 alloc_folders = max_folders + 100;
3437 fold = realloc(fold,
3438 alloc_folders * sizeof(struct folder));
3440 memset(&fold[max_folders], 0, sizeof(struct folder));
3441 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3442 ra_flags = extract_int(buf, 5);
3443 flags = extract_int(buf, 1);
3444 fold[max_folders].floor = extract_int(buf, 2);
3445 fold[max_folders].hasnewmsgs =
3446 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3447 if (flags & QR_MAILBOX) {
3448 fold[max_folders].is_mailbox = 1;
3450 fold[max_folders].view = extract_int(buf, 6);
3451 room_to_folder(fold[max_folders].name,
3452 fold[max_folders].room,
3453 fold[max_folders].floor,
3454 fold[max_folders].is_mailbox);
3455 fold[max_folders].selectable = 1;
3456 /* Increase the room count for the associtaed floor */
3457 if (fold[max_folders].is_mailbox) {
3458 fold[0].num_rooms++;
3461 i = floor_mapping[fold[max_folders].floor];
3462 fold[i].num_rooms++;
3468 * Remove any floors that don't have rooms
3470 get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
3471 if (ShowEmptyFloors)
3473 for (i=0; i<num_floors; i++)
3475 if (fold[i].num_rooms == 0) {
3476 for (j=i; j<max_folders; j++) {
3477 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3486 /** Bubble-sort the folder list */
3487 for (i=0; i<max_folders; ++i) {
3488 for (j=0; j<(max_folders-1)-i; ++j) {
3489 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3490 swap = strcasecmp(fold[j].name, fold[j+1].name);
3493 if ( (fold[j+1].is_mailbox)
3494 && (!fold[j].is_mailbox)) {
3502 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3503 memcpy(&fold[j], &fold[j+1],
3504 sizeof(struct folder));
3505 memcpy(&fold[j+1], &ftmp,
3506 sizeof(struct folder));
3512 if (!strcasecmp(viewpref, "folders")) {
3513 do_folder_view(fold, max_folders, num_floors);
3515 else if (!strcasecmp(viewpref, "hackish_view")) {
3516 for (i=0; i<max_folders; ++i) {
3517 escputs(fold[i].name);
3518 wprintf("<br />\n");
3521 else if (!strcasecmp(viewpref, "iconbar")) {
3522 do_iconbar_view(fold, max_folders, num_floors);
3525 do_rooms_view(fold, max_folders, num_floors);
3528 /* Don't free the folder list ... cache it for future use! */
3529 if (WC->cache_fold != NULL) {
3530 free(WC->cache_fold);
3532 WC->cache_fold = fold;
3533 WC->cache_max_folders = max_folders;
3534 WC->cache_num_floors = num_floors;
3535 WC->cache_timestamp = time(NULL);
3536 free(floor_mapping);
3541 * \brief Do either a known rooms list or a folders list, depending on the
3546 StrBuf *ListView = NULL;
3548 output_headers(1, 1, 2, 0, 0, 0);
3550 /** Determine whether the user is trying to change views */
3551 if (havebstr("view")) {
3552 ListView = NewStrBufPlain(bstr("view"), -1);
3553 set_preference("roomlistview", ListView, 1);
3555 /** Sanitize the input so its safe */
3556 if(!get_preference("roomlistview", &ListView) ||
3557 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3558 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3560 if (ListView == NULL) {
3561 ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1);
3562 set_preference("roomlistview", ListView, 0);
3565 StrBufPrintf(ListView, "rooms");
3571 wprintf("<div id=\"banner\">\n");
3572 wprintf("<div class=\"room_banner\">");
3574 if (!strcasecmp(ChrPtr(ListView), "rooms")) {
3575 wprintf(_("Room list"));
3577 else if (!strcasecmp(ChrPtr(ListView), "folders")) {
3578 wprintf(_("Folder list"));
3580 else if (!strcasecmp(ChrPtr(ListView), "table")) {
3581 wprintf(_("Room list"));
3583 wprintf("</h1></div>\n");
3585 /** offer the ability to switch views */
3586 wprintf("<ul class=\"room_actions\">\n");
3587 wprintf("<li class=\"start_page\">");
3590 wprintf("<li><form name=\"roomlistomatic\">\n"
3591 "<select name=\"newview\" size=\"1\" "
3592 "OnChange=\"location.href=roomlistomatic.newview.options"
3593 "[selectedIndex].value\">\n");
3595 wprintf("<option %s value=\"knrooms&view=rooms\">"
3598 ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" )
3601 wprintf("<option %s value=\"knrooms&view=folders\">"
3602 "View as folder list"
3604 ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" )
3607 wprintf("</select>");
3608 wprintf("</form></li>");
3609 wprintf("</ul></div>\n");
3611 wprintf("<div id=\"content\" class=\"service\">\n");
3613 /** Display the room list in the user's preferred format */
3614 list_all_rooms_by_floor(ChrPtr(ListView));
3621 * \brief Set the message expire policy for this room and/or floor
3623 void set_room_policy(void) {
3626 if (!havebstr("ok_button")) {
3627 strcpy(WC->ImportantMessage,
3628 _("Cancelled. Changes were not saved."));
3633 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3634 serv_getln(buf, sizeof buf);
3635 strcpy(WC->ImportantMessage, &buf[4]);
3637 if (WC->axlevel >= 6) {
3638 strcat(WC->ImportantMessage, "<br />\n");
3639 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3640 serv_getln(buf, sizeof buf);
3641 strcat(WC->ImportantMessage, &buf[4]);
3648 void tmplput_RoomName(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
3650 StrEscAppend(Target, NULL, WC->wc_roomname, 1, 1);
3653 void _gotonext(void) { slrp_highest(); gotonext(); }
3654 void dotskip(void) {smart_goto(bstr("room"));}
3655 void _display_private(void) { display_private("", 0); }
3656 void dotgoto(void) {
3657 if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3660 smart_goto(bstr("room"));
3668 RegisterNamespace("ROOMNAME", 0, 0, tmplput_RoomName);
3670 WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
3671 WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, 0);
3672 WebcitAddUrlHandler(HKEY("skip"), gotonext, 0);
3673 WebcitAddUrlHandler(HKEY("ungoto"), ungoto, 0);
3674 WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, 0);
3675 WebcitAddUrlHandler(HKEY("dotskip"), dotskip, 0);
3676 WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
3677 WebcitAddUrlHandler(HKEY("goto_private"), goto_private, 0);
3678 WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
3679 WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
3680 WebcitAddUrlHandler(HKEY("zap"), zap, 0);
3681 WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
3682 WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
3683 WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
3684 WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
3685 WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
3686 WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
3687 WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
3688 WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
3689 WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
3690 WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
3691 WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);