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)
276 void readinfo(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context)
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(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context) {
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(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context) {
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(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context) {
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 memset(buf, 20, '0');
457 serv_printf("GOTO %s", WC->wc_roomname);
458 serv_getln(buf, sizeof buf);
462 /** The browser needs some information for its own use */
463 wprintf("<script type=\"text/javascript\"> \n"
464 " room_is_trash = %d; \n"
470 * If the user happens to select the "make this my start page" link,
471 * we want it to remember the URL as a "/dotskip" one instead of
472 * a "skip" or "gotonext" or something like that.
474 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
477 /** Check for new mail. */
478 WC->new_mail = extract_int(&got[4], 9);
479 WC->wc_view = extract_int(&got[4], 11);
481 /* Is this a directory room and does it contain files and how many? */
482 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
485 serv_getln(buf2, sizeof buf2);
486 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
488 snprintf (with_files, sizeof with_files,
489 "; <a href=\"display_room_directory\"> %d %s </a>",
491 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
494 strcpy (with_files, "");
496 svprintf(HKEY("NUMMSGS"), WCS_STRING,
497 _("%d new of %d messages%s"),
498 extract_int(&got[4], 1),
499 extract_int(&got[4], 2),
502 svcallback("ROOMPIC", embed_room_graphic);
503 svcallback("ROOMINFO", readinfo);
504 svcallback("VIEWOMATIC", embed_view_o_matic);
505 svcallback("SEARCHOMATIC", embed_search_o_matic);
506 svcallback("START", offer_start_page);
508 do_template("roombanner", NULL);
509 // roombanner contains this for mobile
510 if (navbar_style != navbar_none && !WC->is_mobile) {
512 wprintf("<div id=\"navbar\"><ul>");
514 if (navbar_style == navbar_default) wprintf(
515 "<li class=\"ungoto\">"
516 "<a href=\"ungoto\">"
517 "<img src=\"static/ungoto2_24x.gif\" alt=\"\">"
518 "<span class=\"navbar_link\">%s</span></A>"
519 "</li>\n", _("Ungoto")
522 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
524 "<li class=\"newmess\">"
525 "<a href=\"readnew\">"
526 "<img src=\"static/newmess2_24x.gif\" alt=\"\">"
527 "<span class=\"navbar_link\">%s</span></A>"
528 "</li>\n", _("Read new messages")
532 if (navbar_style == navbar_default) {
533 switch(WC->wc_view) {
534 case VIEW_ADDRESSBOOK:
536 "<li class=\"viewcontacts\">"
537 "<a href=\"readfwd\">"
538 "<img src=\"static/viewcontacts_24x.gif\" "
540 "<span class=\"navbar_link\">"
542 "</span></a></li>\n", _("View contacts")
547 "<li class=\"staskday\">"
548 "<a href=\"readfwd?calview=day\">"
549 "<img src=\"static/taskday2_24x.gif\" "
551 "<span class=\"navbar_link\">"
553 "</span></a></li>\n", _("Day view")
556 "<li class=\"monthview\">"
557 "<a href=\"readfwd?calview=month\">"
558 "<img src=\"static/monthview2_24x.gif\" "
560 "<span class=\"navbar_link\">"
562 "</span></a></li>\n", _("Month view")
567 "<li class=\"monthview\">"
568 "<a href=\"readfwd?calview=month\">"
569 "<img src=\"static/monthview2_24x.gif\" "
571 "<span class=\"navbar_link\">"
573 "</span></a></li>\n", _("Calendar list")
578 "<li class=\"taskmanag\">"
579 "<a href=\"readfwd\">"
580 "<img src=\"static/taskmanag_24x.gif\" "
582 "<span class=\"navbar_link\">"
584 "</span></a></li>\n", _("View tasks")
589 "<li class=\"viewnotes\">"
590 "<a href=\"readfwd\">"
591 "<img src=\"static/viewnotes_24x.gif\" "
593 "<span class=\"navbar_link\">"
595 "</span></a></li>\n", _("View notes")
600 "<li class=\"readallmess\">"
601 "<a href=\"readfwd\">"
602 "<img src=\"static/readallmess3_24x.gif\" "
604 "<span class=\"navbar_link\">"
606 "</span></a></li>\n", _("View message list")
611 "<li class=\"readallmess\">"
612 "<a href=\"readfwd\">"
613 "<img src=\"static/readallmess3_24x.gif\" "
615 "<span class=\"navbar_link\">"
617 "</span></a></li>\n", _("Wiki home")
622 "<li class=\"readallmess\">"
623 "<a href=\"readfwd\">"
624 "<img src=\"static/readallmess3_24x.gif\" "
626 "<span class=\"navbar_link\">"
628 "</span></a></li>\n", _("Read all messages")
634 if (navbar_style == navbar_default) {
635 switch(WC->wc_view) {
636 case VIEW_ADDRESSBOOK:
638 "<li class=\"addnewcontact\">"
639 "<a href=\"display_enter\">"
640 "<img src=\"static/addnewcontact_24x.gif\" "
641 "alt=\"\"><span class=\"navbar_link\">"
643 "</span></a></li>\n", _("Add new contact")
648 wprintf("<li class=\"addevent\"><a href=\"display_enter");
649 if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
650 if (havebstr("month")) wprintf("?month=%s", bstr("month"));
651 if (havebstr("day" )) wprintf("?day=%s", bstr("day"));
653 "<img src=\"static/addevent_24x.gif\" "
654 "alt=\"\"><span class=\"navbar_link\">"
656 "</span></a></li>\n", _("Add new event")
661 "<li class=\"newmess\">"
662 "<a href=\"display_enter\">"
663 "<img src=\"static/newmess3_24x.gif\" "
664 "alt=\"\"><span class=\"navbar_link\">"
666 "</span></a></li>\n", _("Add new task")
671 "<li class=\"enternewnote\">"
672 "<a href=\"add_new_note\">"
673 "<img src=\"static/enternewnote_24x.gif\" "
674 "alt=\"\"><span class=\"navbar_link\">"
676 "</span></a></li>\n", _("Add new note")
680 safestrncpy(buf, bstr("page"), sizeof buf);
683 "<li class=\"newmess\">"
684 "<a href=\"display_enter?wikipage=%s\">"
685 "<img src=\"static/newmess3_24x.gif\" "
686 "alt=\"\"><span class=\"navbar_link\">"
688 "</span></a></li>\n", buf, _("Edit this page")
693 "<li class=\"newmess\">"
694 "<a href=\"display_enter\">"
695 "<img src=\"static/newmess3_24x.gif\" "
696 "alt=\"\"><span class=\"navbar_link\">"
698 "</span></a></li>\n", _("Write mail")
703 "<li class=\"newmess\">"
704 "<a href=\"display_enter\">"
705 "<img src=\"static/newmess3_24x.gif\" "
706 "alt=\"\"><span class=\"navbar_link\">"
708 "</span></a></li>\n", _("Enter a message")
714 if (navbar_style == navbar_default) wprintf(
715 "<li class=\"skipthisroom\">"
718 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\">"
719 "<span class=\"navbar_link\">%s</span></a>"
721 _("Leave all messages marked as unread, go to next room with unread messages"),
725 if (navbar_style == navbar_default) wprintf(
726 "<li class=\"markngo\">"
727 "<a href=\"gotonext\" "
729 "<img src=\"static/markngo_24x.gif\" alt=\"\">"
730 "<span class=\"navbar_link\">%s</span></a>"
732 _("Mark all messages as read, go to next room with unread messages"),
736 wprintf("</ul></div>\n");
743 * back end routine to take the session to a new room
745 int gotoroom(char *gname)
748 static long ls = (-1L);
751 /* store ungoto information */
752 strcpy(WC->ugname, WC->wc_roomname);
755 /** move to the new room */
756 serv_printf("GOTO %s", gname);
757 serv_getln(buf, sizeof buf);
761 serv_puts("GOTO _BASEROOM_");
762 serv_getln(buf, sizeof buf);
769 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
770 WC->room_flags = extract_int(&buf[4], 4);
771 /* highest_msg_read = extract_int(&buf[4],6);
772 maxmsgnum = extract_int(&buf[4],5);
774 WC->is_mailbox = extract_int(&buf[4],7);
775 ls = extract_long(&buf[4], 6);
776 WC->wc_floor = extract_int(&buf[4], 10);
777 WC->wc_view = extract_int(&buf[4], 11);
778 WC->wc_default_view = extract_int(&buf[4], 12);
779 WC->wc_is_trash = extract_int(&buf[4], 13);
780 WC->room_flags2 = extract_int(&buf[4], 14);
783 WC->is_room_aide = WC->is_aide;
785 WC->is_room_aide = (char) extract_int(&buf[4], 8);
787 remove_march(WC->wc_roomname);
788 if (!strcasecmp(gname, "_BASEROOM_"))
796 * \brief Locate the room on the march list which we most want to go to.
798 * is measured given a "weight" of preference based on various factors.
799 * \param desired_floor the room number on the citadel server
800 * \return the roomname
802 char *pop_march(int desired_floor)
804 static char TheRoom[128];
806 int TheOrder = 32767;
809 struct march *mptr = NULL;
811 strcpy(TheRoom, "_BASEROOM_");
812 if (WC->march == NULL)
815 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
817 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
818 weight = weight + 10000;
819 if (mptr->march_floor == desired_floor)
820 weight = weight + 5000;
822 weight = weight + ((128 - (mptr->march_floor)) * 128);
823 weight = weight + (128 - (mptr->march_order));
825 if (weight > TheWeight) {
827 strcpy(TheRoom, mptr->march_name);
828 TheFloor = mptr->march_floor;
829 TheOrder = mptr->march_order;
838 * Goto next room having unread messages.
840 * We want to skip over rooms that the user has already been to, and take the
841 * user back to the lobby when done. The room we end up in is placed in
842 * newroom - which is set to 0 (the lobby) initially.
843 * We start the search in the current room rather than the beginning to prevent
844 * two or more concurrent users from dragging each other back to the same room.
849 struct march *mptr = NULL;
850 struct march *mptr2 = NULL;
856 * First check to see if the march-mode list is already allocated.
857 * If it is, pop the first room off the list and go there.
860 if (WC->march == NULL) {
862 serv_getln(buf, sizeof buf);
864 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
865 if (IsEmptyStr(buf)) {
868 if (ELoop % 100 == 0)
873 extract_token(room_name, buf, 0, '|', sizeof room_name);
874 if (strcasecmp(room_name, WC->wc_roomname)) {
875 mptr = (struct march *) malloc(sizeof(struct march));
877 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
878 mptr->march_floor = extract_int(buf, 2);
879 mptr->march_order = extract_int(buf, 3);
880 if (WC->march == NULL)
889 * add _BASEROOM_ to the end of the march list, so the user will end up
890 * in the system base room (usually the Lobby>) at the end of the loop
892 mptr = (struct march *) malloc(sizeof(struct march));
894 mptr->march_order = 0;
895 mptr->march_floor = 0;
896 strcpy(mptr->march_name, "_BASEROOM_");
897 if (WC->march == NULL) {
901 while (mptr2->next != NULL)
906 * ...and remove the room we're currently in, so a <G>oto doesn't make us
907 * walk around in circles
909 remove_march(WC->wc_roomname);
911 if (WC->march != NULL) {
912 strcpy(next_room, pop_march(-1));
914 strcpy(next_room, "_BASEROOM_");
918 smart_goto(next_room);
925 void smart_goto(char *next_room) {
933 * mark all messages in current room as having been read
935 void slrp_highest(void)
939 serv_puts("SLRP HIGHEST");
940 serv_getln(buf, sizeof buf);
945 * un-goto the previous room
951 if (!strcmp(WC->ugname, "")) {
952 smart_goto(WC->wc_roomname);
955 serv_printf("GOTO %s", WC->ugname);
956 serv_getln(buf, sizeof buf);
958 smart_goto(WC->wc_roomname);
961 if (WC->uglsn >= 0L) {
962 serv_printf("SLRP %ld", WC->uglsn);
963 serv_getln(buf, sizeof buf);
965 strcpy(buf, WC->ugname);
966 strcpy(WC->ugname, "");
970 typedef struct __room_states {
985 * Set/clear/read the "self-service list subscribe" flag for a room
987 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
988 * returns the new value.
991 int self_service(int newval) {
992 int current_value = 0;
998 int flags, floor, order, view, flags2;
1001 serv_getln(buf, sizeof buf);
1002 if (buf[0] != '2') return(0);
1004 extract_token(name, &buf[4], 0, '|', sizeof name);
1005 extract_token(password, &buf[4], 1, '|', sizeof password);
1006 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1007 flags = extract_int(&buf[4], 3);
1008 floor = extract_int(&buf[4], 4);
1009 order = extract_int(&buf[4], 5);
1010 view = extract_int(&buf[4], 6);
1011 flags2 = extract_int(&buf[4], 7);
1013 if (flags2 & QR2_SELFLIST) {
1021 flags2 = flags2 | QR2_SELFLIST;
1023 else if (newval == 0) {
1024 flags2 = flags2 & ~QR2_SELFLIST;
1027 return(current_value);
1030 if (newval != current_value) {
1031 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1032 name, password, dirname, flags,
1033 floor, order, view, flags2);
1034 serv_getln(buf, sizeof buf);
1041 int is_selflist(room_states *RoomFlags)
1043 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1046 int is_publiclist(room_states *RoomFlags)
1048 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1051 int is_moderatedlist(room_states *RoomFlags)
1053 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1057 * Set/clear/read the "self-service list subscribe" flag for a room
1059 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1060 * returns the new value.
1063 int get_roomflags(room_states *RoomOps)
1068 serv_getln(buf, sizeof buf);
1069 if (buf[0] != '2') return(0);
1071 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1072 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1073 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1074 RoomOps->flags = extract_int(&buf[4], 3);
1075 RoomOps->floor = extract_int(&buf[4], 4);
1076 RoomOps->order = extract_int(&buf[4], 5);
1077 RoomOps->view = extract_int(&buf[4], 6);
1078 RoomOps->flags2 = extract_int(&buf[4], 7);
1082 int set_roomflags(room_states *RoomOps)
1086 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1095 serv_getln(buf, sizeof buf);
1105 * display the form for editing a room
1107 void display_editroom(void)
1112 char remote_room[128];
1115 char er_password[10];
1116 char er_dirname[15];
1117 char er_roomaide[26];
1124 char *not_shared_with;
1127 int floorpolicy = 0;
1129 char pop3_host[128];
1134 if (IsEmptyStr(tab)) tab = "admin";
1137 output_headers(1, 1, 1, 0, 0, 0);
1139 wprintf("<div class=\"fix_scrollbar_bug\">");
1141 wprintf("<br />\n");
1143 /* print the tabbed dialog */
1144 wprintf("<div align=\"center\">");
1145 wprintf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\""
1146 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1149 wprintf("<td class=\"");
1150 if (!strcmp(tab, "admin")) {
1151 wprintf(" tab_cell_label\">");
1152 wprintf(_("Administration"));
1155 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1156 wprintf(_("Administration"));
1160 wprintf("<td> </td>\n");
1162 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1164 wprintf("<td class=\"");
1165 if (!strcmp(tab, "config")) {
1166 wprintf(" tab_cell_label\">");
1167 wprintf(_("Configuration"));
1170 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1171 wprintf(_("Configuration"));
1175 wprintf("<td> </td>\n");
1177 wprintf("<td class=\"");
1178 if (!strcmp(tab, "expire")) {
1179 wprintf(" tab_cell_label\">");
1180 wprintf(_("Message expire policy"));
1183 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1184 wprintf(_("Message expire policy"));
1188 wprintf("<td> </td>\n");
1190 wprintf("<td class=\"");
1191 if (!strcmp(tab, "access")) {
1192 wprintf(" tab_cell_label\">");
1193 wprintf(_("Access controls"));
1196 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1197 wprintf(_("Access controls"));
1201 wprintf("<td> </td>\n");
1203 wprintf("<td class=\"");
1204 if (!strcmp(tab, "sharing")) {
1205 wprintf(" tab_cell_label\">");
1206 wprintf(_("Sharing"));
1209 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1210 wprintf(_("Sharing"));
1214 wprintf("<td> </td>\n");
1216 wprintf("<td class=\"");
1217 if (!strcmp(tab, "listserv")) {
1218 wprintf(" tab_cell_label\">");
1219 wprintf(_("Mailing list service"));
1222 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1223 wprintf(_("Mailing list service"));
1227 wprintf("<td> </td>\n");
1231 wprintf("<td class=\"");
1232 if (!strcmp(tab, "feeds")) {
1233 wprintf(" tab_cell_label\">");
1234 wprintf(_("Remote retrieval"));
1237 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1238 wprintf(_("Remote retrieval"));
1242 wprintf("<td> </td>\n");
1244 wprintf("</tr></table>\n");
1245 wprintf("</div>\n");
1246 /* end tabbed dialog */
1248 wprintf("<script type=\"text/javascript\">"
1249 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1253 /* begin content of whatever tab is open now */
1255 if (!strcmp(tab, "admin")) {
1256 wprintf("<div class=\"tabcontent\">");
1258 "<li><a href=\"delete_room\" "
1259 "onClick=\"return confirm('");
1260 wprintf(_("Are you sure you want to delete this room?"));
1261 wprintf("');\">\n");
1262 wprintf(_("Delete this room"));
1264 "<li><a href=\"display_editroompic\">\n");
1265 wprintf(_("Set or change the icon for this room's banner"));
1267 "<li><a href=\"display_editinfo\">\n");
1268 wprintf(_("Edit this room's Info file"));
1274 if (!strcmp(tab, "config")) {
1275 wprintf("<div class=\"tabcontent\">");
1277 serv_getln(buf, sizeof buf);
1279 if (!strncmp(buf, "550", 3)) {
1280 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1281 _("Higher access is required to access this function.")
1284 else if (buf[0] != '2') {
1285 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1288 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1289 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1290 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1291 er_flags = extract_int(&buf[4], 3);
1292 er_floor = extract_int(&buf[4], 4);
1293 er_flags2 = extract_int(&buf[4], 7);
1295 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1296 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1298 wprintf("<ul><li>");
1299 wprintf(_("Name of room: "));
1300 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1306 wprintf(_("Resides on floor: "));
1307 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1308 if (er_flags & QR_MAILBOX)
1309 wprintf("disabled >\n");
1310 for (i = 0; i < 128; ++i)
1311 if (!IsEmptyStr(floorlist[i])) {
1312 wprintf("<OPTION ");
1314 wprintf("SELECTED ");
1315 wprintf("VALUE=\"%d\">", i);
1316 escputs(floorlist[i]);
1317 wprintf("</OPTION>\n");
1319 wprintf("</select>\n");
1322 wprintf(_("Type of room:"));
1325 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1326 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1327 wprintf("CHECKED ");
1328 wprintf("OnChange=\""
1329 " if (this.form.type[0].checked == true) { "
1330 " this.form.er_floor.disabled = false; "
1333 wprintf(_("Public (automatically appears to everyone)"));
1336 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1337 if ((er_flags & QR_PRIVATE) &&
1338 (er_flags & QR_GUESSNAME))
1339 wprintf("CHECKED ");
1340 wprintf(" OnChange=\""
1341 " if (this.form.type[1].checked == true) { "
1342 " this.form.er_floor.disabled = false; "
1345 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1347 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1348 if ((er_flags & QR_PRIVATE) &&
1349 (er_flags & QR_PASSWORDED))
1350 wprintf("CHECKED ");
1351 wprintf(" OnChange=\""
1352 " if (this.form.type[2].checked == true) { "
1353 " this.form.er_floor.disabled = false; "
1356 wprintf(_("Private - require password: "));
1357 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1360 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1361 if ((er_flags & QR_PRIVATE)
1362 && ((er_flags & QR_GUESSNAME) == 0)
1363 && ((er_flags & QR_PASSWORDED) == 0))
1364 wprintf("CHECKED ");
1365 wprintf(" OnChange=\""
1366 " if (this.form.type[3].checked == true) { "
1367 " this.form.er_floor.disabled = false; "
1370 wprintf(_("Private - invitation only"));
1372 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1373 if (er_flags & QR_MAILBOX)
1374 wprintf("CHECKED ");
1375 wprintf (" OnChange=\""
1376 " if (this.form.type[4].checked == true) { "
1377 " this.form.er_floor.disabled = true; "
1380 wprintf(_("Personal (mailbox for you only)"));
1382 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1384 wprintf(_("If private, cause current users to forget room"));
1386 wprintf("\n</ul>\n");
1388 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1389 if (er_flags & QR_PREFONLY)
1390 wprintf("CHECKED ");
1392 wprintf(_("Preferred users only"));
1394 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1395 if (er_flags & QR_READONLY)
1396 wprintf("CHECKED ");
1398 wprintf(_("Read-only room"));
1400 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1401 if (er_flags2 & QR2_COLLABDEL)
1402 wprintf("CHECKED ");
1404 wprintf(_("All users allowed to post may also delete messages"));
1406 /** directory stuff */
1407 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1408 if (er_flags & QR_DIRECTORY)
1409 wprintf("CHECKED ");
1411 wprintf(_("File directory room"));
1413 wprintf("\n<ul><li>");
1414 wprintf(_("Directory name: "));
1415 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1418 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1419 if (er_flags & QR_UPLOAD)
1420 wprintf("CHECKED ");
1422 wprintf(_("Uploading allowed"));
1424 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1425 if (er_flags & QR_DOWNLOAD)
1426 wprintf("CHECKED ");
1428 wprintf(_("Downloading allowed"));
1430 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1431 if (er_flags & QR_VISDIR)
1432 wprintf("CHECKED ");
1434 wprintf(_("Visible directory"));
1437 /** end of directory stuff */
1439 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1440 if (er_flags & QR_NETWORK)
1441 wprintf("CHECKED ");
1443 wprintf(_("Network shared room"));
1445 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1446 if (er_flags & QR_PERMANENT)
1447 wprintf("CHECKED ");
1449 wprintf(_("Permanent (does not auto-purge)"));
1451 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1452 if (er_flags2 & QR2_SUBJECTREQ)
1453 wprintf("CHECKED ");
1455 wprintf(_("Subject Required (Force users to specify a message subject)"));
1457 /** start of anon options */
1460 wprintf(_("Anonymous messages"));
1463 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1464 if (((er_flags & QR_ANONONLY) == 0)
1465 && ((er_flags & QR_ANONOPT) == 0))
1466 wprintf("CHECKED ");
1468 wprintf(_("No anonymous messages"));
1470 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1471 if (er_flags & QR_ANONONLY)
1472 wprintf("CHECKED ");
1474 wprintf(_("All messages are anonymous"));
1476 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1477 if (er_flags & QR_ANONOPT)
1478 wprintf("CHECKED ");
1480 wprintf(_("Prompt user when entering messages"));
1483 /* end of anon options */
1486 wprintf(_("Room aide: "));
1488 serv_getln(buf, sizeof buf);
1489 if (buf[0] != '2') {
1490 wprintf("<em>%s</em>\n", &buf[4]);
1492 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1493 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1496 wprintf("</ul><CENTER>\n");
1497 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1498 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1500 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1510 /* Sharing the room with other Citadel nodes... */
1511 if (!strcmp(tab, "sharing")) {
1512 wprintf("<div class=\"tabcontent\">");
1514 shared_with = strdup("");
1515 not_shared_with = strdup("");
1517 /** Learn the current configuration */
1518 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1519 serv_getln(buf, sizeof buf);
1520 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1521 extract_token(node, buf, 0, '|', sizeof node);
1522 not_shared_with = realloc(not_shared_with,
1523 strlen(not_shared_with) + 32);
1524 strcat(not_shared_with, node);
1525 strcat(not_shared_with, "\n");
1529 serv_getln(buf, sizeof buf);
1530 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1531 extract_token(cmd, buf, 0, '|', sizeof cmd);
1532 extract_token(node, buf, 1, '|', sizeof node);
1533 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1534 if (!strcasecmp(cmd, "ignet_push_share")) {
1535 shared_with = realloc(shared_with,
1536 strlen(shared_with) + 32);
1537 strcat(shared_with, node);
1538 if (!IsEmptyStr(remote_room)) {
1539 strcat(shared_with, "|");
1540 strcat(shared_with, remote_room);
1542 strcat(shared_with, "\n");
1546 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1547 extract_token(buf, shared_with, i, '\n', sizeof buf);
1548 extract_token(node, buf, 0, '|', sizeof node);
1549 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1550 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1551 if (!strcasecmp(node, cmd)) {
1552 remove_token(not_shared_with, j, '\n');
1557 /* Display the stuff */
1558 wprintf("<CENTER><br />"
1559 "<table border=1 cellpadding=5><tr>"
1561 wprintf(_("Shared with"));
1562 wprintf("</I></B></td>"
1564 wprintf(_("Not shared with"));
1565 wprintf("</I></B></td></tr>\n"
1566 "<tr><td VALIGN=TOP>\n");
1568 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1569 wprintf(_("Remote node name"));
1570 wprintf("</td><td>");
1571 wprintf(_("Remote room name"));
1572 wprintf("</td><td>");
1573 wprintf(_("Actions"));
1574 wprintf("</td></tr>\n");
1576 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1577 extract_token(buf, shared_with, i, '\n', sizeof buf);
1578 extract_token(node, buf, 0, '|', sizeof node);
1579 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1580 if (!IsEmptyStr(node)) {
1581 wprintf("<form method=\"POST\" action=\"netedit\">");
1582 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1583 wprintf("<tr><td>%s</td>\n", node);
1586 if (!IsEmptyStr(remote_room)) {
1587 escputs(remote_room);
1593 wprintf("<input type=\"hidden\" NAME=\"line\" "
1594 "VALUE=\"ignet_push_share|");
1596 if (!IsEmptyStr(remote_room)) {
1598 urlescputs(remote_room);
1601 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1602 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1603 wprintf("<input type=\"submit\" "
1604 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1605 wprintf("</td></tr></form>\n");
1609 wprintf("</table>\n");
1610 wprintf("</td><td VALIGN=TOP>\n");
1611 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1612 wprintf(_("Remote node name"));
1613 wprintf("</td><td>");
1614 wprintf(_("Remote room name"));
1615 wprintf("</td><td>");
1616 wprintf(_("Actions"));
1617 wprintf("</td></tr>\n");
1619 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1620 extract_token(node, not_shared_with, i, '\n', sizeof node);
1621 if (!IsEmptyStr(node)) {
1622 wprintf("<form method=\"POST\" action=\"netedit\">");
1623 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1624 wprintf("<tr><td>");
1627 "<input type=\"INPUT\" "
1631 wprintf("<input type=\"hidden\" "
1633 "VALUE=\"ignet_push_share|");
1636 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1637 "VALUE=\"sharing\">\n");
1638 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1639 "VALUE=\"add\">\n");
1640 wprintf("<input type=\"submit\" "
1641 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1642 wprintf("</td></tr></form>\n");
1646 wprintf("</table>\n");
1647 wprintf("</td></tr>"
1648 "</table></CENTER><br />\n"
1649 "<I><B>%s</B><ul><li>", _("Notes:"));
1650 wprintf(_("When sharing a room, "
1651 "it must be shared from both ends. Adding a node to "
1652 "the 'shared' list sends messages out, but in order to"
1653 " receive messages, the other nodes must be configured"
1654 " to send messages out to your system as well. "
1655 "<li>If the remote room name is blank, it is assumed "
1656 "that the room name is identical on the remote node."
1657 "<li>If the remote room name is different, the remote "
1658 "node must also configure the name of the room here."
1665 /* Mailing list management */
1666 if (!strcmp(tab, "listserv")) {
1667 room_states RoomFlags;
1668 wprintf("<div class=\"tabcontent\">");
1670 wprintf("<br /><center>"
1671 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1672 "<tr><td VALIGN=TOP>");
1674 wprintf(_("<i>The contents of this room are being "
1675 "mailed <b>as individual messages</b> "
1676 "to the following list recipients:"
1677 "</i><br /><br />\n"));
1680 serv_getln(buf, sizeof buf);
1681 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1682 extract_token(cmd, buf, 0, '|', sizeof cmd);
1683 if (!strcasecmp(cmd, "listrecp")) {
1684 extract_token(recp, buf, 1, '|', sizeof recp);
1687 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1690 wprintf(_("(remove)"));
1691 wprintf("</A><br />");
1694 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1695 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1696 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1697 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1698 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1699 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1700 wprintf("</form>\n");
1702 wprintf("</td><td VALIGN=TOP>\n");
1704 wprintf(_("<i>The contents of this room are being "
1705 "mailed <b>in digest form</b> "
1706 "to the following list recipients:"
1707 "</i><br /><br />\n"));
1710 serv_getln(buf, sizeof buf);
1711 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1712 extract_token(cmd, buf, 0, '|', sizeof cmd);
1713 if (!strcasecmp(cmd, "digestrecp")) {
1714 extract_token(recp, buf, 1, '|', sizeof recp);
1717 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1721 wprintf(_("(remove)"));
1722 wprintf("</A><br />");
1725 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1726 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1727 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1728 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1729 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1730 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1731 wprintf("</form>\n");
1733 wprintf("</td></tr></table>\n");
1735 /** Pop open an address book -- begin **/
1736 wprintf("<div align=right>"
1737 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1739 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1744 _("Add recipients from Contacts or other address books"),
1745 _("Add recipients from Contacts or other address books")
1747 /* Pop open an address book -- end **/
1749 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1751 get_roomflags (&RoomFlags);
1753 /* Self Service subscription? */
1754 wprintf("<table><tr><td>\n");
1755 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1756 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1757 " <tr><td colspan=\"2\">\n",
1758 (is_selflist(&RoomFlags))?"checked":"");
1759 wprintf(_("The URL for subscribe/unsubscribe is: "));
1760 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1761 (is_https ? "https" : "http"),
1763 /* Public posting? */
1764 wprintf("<tr><td>");
1765 wprintf(_("Allow non-subscribers to mail to this room."));
1766 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1767 (is_publiclist(&RoomFlags))?"checked":"");
1769 /* Moderated List? */
1770 wprintf("<tr><td>");
1771 wprintf(_("Room post publication needs Aide permission."));
1772 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1773 (is_moderatedlist(&RoomFlags))?"checked":"");
1776 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1777 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1778 wprintf("</table></form>");
1781 wprintf("</CENTER>\n");
1786 /* Configuration of The Dreaded Auto-Purger */
1787 if (!strcmp(tab, "expire")) {
1788 wprintf("<div class=\"tabcontent\">");
1790 serv_puts("GPEX room");
1791 serv_getln(buf, sizeof buf);
1792 if (!strncmp(buf, "550", 3)) {
1793 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1794 _("Higher access is required to access this function.")
1797 else if (buf[0] != '2') {
1798 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1801 roompolicy = extract_int(&buf[4], 0);
1802 roomvalue = extract_int(&buf[4], 1);
1804 serv_puts("GPEX floor");
1805 serv_getln(buf, sizeof buf);
1806 if (buf[0] == '2') {
1807 floorpolicy = extract_int(&buf[4], 0);
1808 floorvalue = extract_int(&buf[4], 1);
1811 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1812 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1813 wprintf("<table border=0 cellspacing=5>\n");
1814 wprintf("<tr><td>");
1815 wprintf(_("Message expire policy for this room"));
1817 escputs(WC->wc_roomname);
1818 wprintf(")</td><td>");
1819 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1820 ((roompolicy == 0) ? "CHECKED" : "") );
1821 wprintf(_("Use the default policy for this floor"));
1822 wprintf("<br />\n");
1823 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1824 ((roompolicy == 1) ? "CHECKED" : "") );
1825 wprintf(_("Never automatically expire messages"));
1826 wprintf("<br />\n");
1827 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1828 ((roompolicy == 2) ? "CHECKED" : "") );
1829 wprintf(_("Expire by message count"));
1830 wprintf("<br />\n");
1831 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1832 ((roompolicy == 3) ? "CHECKED" : "") );
1833 wprintf(_("Expire by message age"));
1835 wprintf(_("Number of messages or days: "));
1836 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1837 wprintf("</td></tr>\n");
1839 if (WC->axlevel >= 6) {
1840 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1841 wprintf("<tr><td>");
1842 wprintf(_("Message expire policy for this floor"));
1844 escputs(floorlist[WC->wc_floor]);
1845 wprintf(")</td><td>");
1846 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1847 ((floorpolicy == 0) ? "CHECKED" : "") );
1848 wprintf(_("Use the system default"));
1849 wprintf("<br />\n");
1850 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1851 ((floorpolicy == 1) ? "CHECKED" : "") );
1852 wprintf(_("Never automatically expire messages"));
1853 wprintf("<br />\n");
1854 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1855 ((floorpolicy == 2) ? "CHECKED" : "") );
1856 wprintf(_("Expire by message count"));
1857 wprintf("<br />\n");
1858 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1859 ((floorpolicy == 3) ? "CHECKED" : "") );
1860 wprintf(_("Expire by message age"));
1862 wprintf(_("Number of messages or days: "));
1863 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1867 wprintf("<CENTER>\n");
1868 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1869 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1871 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1872 wprintf("</CENTER></td><tr>\n");
1874 wprintf("</table>\n"
1875 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1883 /* Access controls */
1884 if (!strcmp(tab, "access")) {
1885 wprintf("<div class=\"tabcontent\">");
1890 /* Fetch messages from remote locations */
1891 if (!strcmp(tab, "feeds")) {
1892 wprintf("<div class=\"tabcontent\">");
1895 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1896 wprintf("</i><br />\n");
1898 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1899 "<tr class=\"even\"><th>");
1900 wprintf(_("Remote host"));
1901 wprintf("</th><th>");
1902 wprintf(_("User name"));
1903 wprintf("</th><th>");
1904 wprintf(_("Password"));
1905 wprintf("</th><th>");
1906 wprintf(_("Keep messages on server?"));
1907 wprintf("</th><th>");
1908 wprintf(_("Interval"));
1909 wprintf("</th><th> </th></tr>");
1912 serv_getln(buf, sizeof buf);
1914 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1915 extract_token(cmd, buf, 0, '|', sizeof cmd);
1916 if (!strcasecmp(cmd, "pop3client")) {
1917 safestrncpy(recp, &buf[11], sizeof recp);
1920 wprintf("<tr class=\"%s\">",
1921 (bg ? "even" : "odd")
1925 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1930 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1934 wprintf("<td>*****</td>"); /* Don't show the password */
1936 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1938 wprintf("<td>%ld</td>", extract_long(buf, 5)); // Fetching interval
1940 wprintf("<td class=\"button_link\">");
1941 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1944 wprintf(_("(remove)"));
1945 wprintf("</a></td>");
1951 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1953 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1954 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1955 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1957 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1960 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1963 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1966 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1969 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
1972 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1973 wprintf("</td></tr>");
1974 wprintf("</form></table>\n");
1979 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1980 wprintf("</i><br />\n");
1982 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1983 "<tr class=\"even\"><th>");
1984 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1985 wprintf(_("Feed URL"));
1986 wprintf("</th><th>");
1987 wprintf("</th></tr>");
1990 serv_getln(buf, sizeof buf);
1992 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1993 extract_token(cmd, buf, 0, '|', sizeof cmd);
1994 if (!strcasecmp(cmd, "rssclient")) {
1995 safestrncpy(recp, &buf[10], sizeof recp);
1998 wprintf("<tr class=\"%s\">",
1999 (bg ? "even" : "odd")
2003 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2007 wprintf("<td class=\"button_link\">");
2008 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=rssclient|");
2011 wprintf(_("(remove)"));
2012 wprintf("</a></td>");
2018 wprintf("<form method=\"POST\" action=\"netedit\">\n"
2020 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2021 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2022 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2024 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2025 "maxlength=\"256\" name=\"line_pop3host\">\n");
2028 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2029 wprintf("</td></tr>");
2030 wprintf("</form></table>\n");
2036 /* end content of whatever tab is open now */
2037 wprintf("</div>\n");
2039 address_book_popup();
2045 * Toggle self-service list subscription
2047 void toggle_self_service(void) {
2048 room_states RoomFlags;
2050 get_roomflags (&RoomFlags);
2052 if (yesbstr("QR2_SelfList"))
2053 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2055 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2057 if (yesbstr("QR2_SMTP_PUBLIC"))
2058 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2060 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2062 if (yesbstr("QR2_Moderated"))
2063 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2065 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2066 if (yesbstr("QR2_SubsOnly"))
2067 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2069 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2071 set_roomflags (&RoomFlags);
2079 * save new parameters for a room
2085 char er_password[10];
2086 char er_dirname[15];
2087 char er_roomaide[26];
2090 int er_listingorder;
2096 if (!havebstr("ok_button")) {
2097 strcpy(WC->ImportantMessage,
2098 _("Cancelled. Changes were not saved."));
2103 serv_getln(buf, sizeof buf);
2105 if (buf[0] != '2') {
2106 strcpy(WC->ImportantMessage, &buf[4]);
2110 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
2111 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
2112 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
2113 er_flags = extract_int(&buf[4], 3);
2114 er_listingorder = extract_int(&buf[4], 5);
2115 er_defaultview = extract_int(&buf[4], 6);
2116 er_flags2 = extract_int(&buf[4], 7);
2118 strcpy(er_roomaide, bstr("er_roomaide"));
2119 if (IsEmptyStr(er_roomaide)) {
2121 serv_getln(buf, sizeof buf);
2122 if (buf[0] != '2') {
2123 strcpy(er_roomaide, "");
2125 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
2128 strcpy(buf, bstr("er_name"));
2130 if (!IsEmptyStr(buf)) {
2131 strcpy(er_name, buf);
2134 strcpy(buf, bstr("er_password"));
2136 if (!IsEmptyStr(buf))
2137 strcpy(er_password, buf);
2139 strcpy(buf, bstr("er_dirname"));
2141 if (!IsEmptyStr(buf))
2142 strcpy(er_dirname, buf);
2144 strcpy(buf, bstr("type"));
2145 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2147 if (!strcmp(buf, "invonly")) {
2148 er_flags |= (QR_PRIVATE);
2150 if (!strcmp(buf, "hidden")) {
2151 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2153 if (!strcmp(buf, "passworded")) {
2154 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2156 if (!strcmp(buf, "personal")) {
2157 er_flags |= QR_MAILBOX;
2159 er_flags &= ~QR_MAILBOX;
2162 if (yesbstr("prefonly")) {
2163 er_flags |= QR_PREFONLY;
2165 er_flags &= ~QR_PREFONLY;
2168 if (yesbstr("readonly")) {
2169 er_flags |= QR_READONLY;
2171 er_flags &= ~QR_READONLY;
2175 if (yesbstr("collabdel")) {
2176 er_flags2 |= QR2_COLLABDEL;
2178 er_flags2 &= ~QR2_COLLABDEL;
2181 if (yesbstr("permanent")) {
2182 er_flags |= QR_PERMANENT;
2184 er_flags &= ~QR_PERMANENT;
2187 if (yesbstr("subjectreq")) {
2188 er_flags2 |= QR2_SUBJECTREQ;
2190 er_flags2 &= ~QR2_SUBJECTREQ;
2193 if (yesbstr("network")) {
2194 er_flags |= QR_NETWORK;
2196 er_flags &= ~QR_NETWORK;
2199 if (yesbstr("directory")) {
2200 er_flags |= QR_DIRECTORY;
2202 er_flags &= ~QR_DIRECTORY;
2205 if (yesbstr("ulallowed")) {
2206 er_flags |= QR_UPLOAD;
2208 er_flags &= ~QR_UPLOAD;
2211 if (yesbstr("dlallowed")) {
2212 er_flags |= QR_DOWNLOAD;
2214 er_flags &= ~QR_DOWNLOAD;
2217 if (yesbstr("visdir")) {
2218 er_flags |= QR_VISDIR;
2220 er_flags &= ~QR_VISDIR;
2223 strcpy(buf, bstr("anon"));
2225 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2226 if (!strcmp(buf, "anononly"))
2227 er_flags |= QR_ANONONLY;
2228 if (!strcmp(buf, "anon2"))
2229 er_flags |= QR_ANONOPT;
2232 if (!strcmp(bstr("bump"), "yes"))
2235 er_floor = ibstr("er_floor");
2237 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2238 er_name, er_password, er_dirname, er_flags, bump, er_floor,
2239 er_listingorder, er_defaultview, er_flags2);
2241 serv_getln(buf, sizeof buf);
2242 if (buf[0] != '2') {
2243 strcpy(WC->ImportantMessage, &buf[4]);
2249 if (!IsEmptyStr(er_roomaide)) {
2250 sprintf(buf, "SETA %s", er_roomaide);
2252 serv_getln(buf, sizeof buf);
2253 if (buf[0] != '2') {
2254 strcpy(WC->ImportantMessage, &buf[4]);
2255 display_main_menu();
2260 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2267 * Display form for Invite, Kick, and show Who Knows a room
2269 void do_invt_kick(void) {
2270 char buf[SIZ], room[SIZ], username[SIZ];
2273 serv_getln(buf, sizeof buf);
2275 if (buf[0] != '2') {
2279 extract_token(room, &buf[4], 0, '|', sizeof room);
2281 strcpy(username, bstr("username"));
2283 if (havebstr("kick_button")) {
2284 sprintf(buf, "KICK %s", username);
2286 serv_getln(buf, sizeof buf);
2288 if (buf[0] != '2') {
2289 strcpy(WC->ImportantMessage, &buf[4]);
2291 sprintf(WC->ImportantMessage,
2292 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2297 if (havebstr("invite_button")) {
2298 sprintf(buf, "INVT %s", username);
2300 serv_getln(buf, sizeof buf);
2302 if (buf[0] != '2') {
2303 strcpy(WC->ImportantMessage, &buf[4]);
2305 sprintf(WC->ImportantMessage,
2306 _("<B><I>User %s invited to room %s.</I></B>\n"),
2317 * Display form for Invite, Kick, and show Who Knows a room
2319 void display_whok(void)
2321 char buf[SIZ], room[SIZ], username[SIZ];
2324 serv_getln(buf, sizeof buf);
2326 if (buf[0] != '2') {
2330 extract_token(room, &buf[4], 0, '|', sizeof room);
2333 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2334 wprintf(_("The users listed below have access to this room. "
2335 "To remove a user from the access list, select the user "
2336 "name from the list and click 'Kick'."));
2337 wprintf("<br /><br />");
2339 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2340 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2341 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2342 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2344 serv_getln(buf, sizeof buf);
2345 if (buf[0] == '1') {
2346 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2347 extract_token(username, buf, 0, '|', sizeof username);
2348 wprintf("<OPTION>");
2353 wprintf("</select><br />\n");
2355 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2356 wprintf("</form></CENTER>\n");
2358 wprintf("</td><td>");
2359 wprintf(_("To grant another user access to this room, enter the "
2360 "user name in the box below and click 'Invite'."));
2361 wprintf("<br /><br />");
2363 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2364 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2365 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2366 wprintf(_("Invite:"));
2368 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2369 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2370 "<input type=\"submit\" value=\"%s\">"
2371 "</form></CENTER>\n", _("Invite"));
2372 /* Pop open an address book -- begin **/
2374 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2376 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2379 _("Users"), _("Users")
2381 /* Pop open an address book -- end **/
2383 wprintf("</td></tr></table>\n");
2384 address_book_popup();
2391 * display the form for entering a new room
2393 void display_entroom(void)
2398 serv_puts("CRE8 0");
2399 serv_getln(buf, sizeof buf);
2401 if (buf[0] != '2') {
2402 strcpy(WC->ImportantMessage, &buf[4]);
2403 display_main_menu();
2407 output_headers(1, 1, 1, 0, 0, 0);
2409 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2410 do_template("beginbox", NULL);
2412 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2413 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2415 wprintf("<table class=\"altern\"> ");
2417 wprintf("<tr class=\"even\"><td>");
2418 wprintf(_("Name of room: "));
2419 wprintf("</td><td>");
2420 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2421 wprintf("</td></tr>");
2423 wprintf("<tr class=\"odd\"><td>");
2424 wprintf(_("Resides on floor: "));
2425 wprintf("</td><td>");
2427 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2428 for (i = 0; i < 128; ++i)
2429 if (!IsEmptyStr(floorlist[i])) {
2430 wprintf("<option ");
2431 wprintf("value=\"%d\">", i);
2432 escputs(floorlist[i]);
2433 wprintf("</option>\n");
2435 wprintf("</select>\n");
2436 wprintf("</td></tr>");
2439 * Our clever little snippet of JavaScript automatically selects
2440 * a public room if the view is set to Bulletin Board or wiki, and
2441 * it selects a mailbox room otherwise. The user can override this,
2442 * of course. We also disable the floor selector for mailboxes.
2444 wprintf("<tr class=\"even\"><td>");
2445 wprintf(_("Default view for room: "));
2446 wprintf("</td><td>");
2447 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2448 " if ( (this.form.er_view.value == 0) "
2449 " || (this.form.er_view.value == 6) ) { "
2450 " this.form.type[0].checked=true; "
2451 " this.form.er_floor.disabled = false; "
2454 " this.form.type[4].checked=true; "
2455 " this.form.er_floor.disabled = true; "
2458 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2459 if (is_view_allowed_as_default(i)) {
2460 wprintf("<option %s value=\"%d\">",
2461 ((i == 0) ? "selected" : ""), i );
2462 escputs(viewdefs[i]);
2463 wprintf("</option>\n");
2466 wprintf("</select>\n");
2467 wprintf("</td></tr>");
2469 wprintf("<tr class=\"even\"><td>");
2470 wprintf(_("Type of room:"));
2471 wprintf("</td><td>");
2472 wprintf("<ul class=\"adminlist\">\n");
2474 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2475 wprintf("CHECKED OnChange=\""
2476 " if (this.form.type[0].checked == true) { "
2477 " this.form.er_floor.disabled = false; "
2480 wprintf(_("Public (automatically appears to everyone)"));
2483 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2484 " if (this.form.type[1].checked == true) { "
2485 " this.form.er_floor.disabled = false; "
2488 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2491 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2492 " if (this.form.type[2].checked == true) { "
2493 " this.form.er_floor.disabled = false; "
2496 wprintf(_("Private - require password: "));
2497 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2500 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2501 " if (this.form.type[3].checked == true) { "
2502 " this.form.er_floor.disabled = false; "
2505 wprintf(_("Private - invitation only"));
2508 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2510 " if (this.form.type[4].checked == true) { "
2511 " this.form.er_floor.disabled = true; "
2514 wprintf(_("Personal (mailbox for you only)"));
2517 wprintf("\n</ul>\n");
2518 wprintf("</td></tr></table>\n");
2520 wprintf("<div class=\"buttons\">\n");
2521 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2523 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2524 wprintf("</div>\n");
2525 wprintf("</form>\n<hr />");
2526 serv_printf("MESG roomaccess");
2527 serv_getln(buf, sizeof buf);
2528 if (buf[0] == '1') {
2532 do_template("endbox", NULL);
2541 * support function for entroom() -- sets the default view
2543 void er_set_default_view(int newview) {
2556 serv_getln(buf, sizeof buf);
2557 if (buf[0] != '2') return;
2559 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2560 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2561 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2562 rm_bits1 = extract_int(&buf[4], 3);
2563 rm_floor = extract_int(&buf[4], 4);
2564 rm_listorder = extract_int(&buf[4], 5);
2565 rm_bits2 = extract_int(&buf[4], 7);
2567 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2568 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2569 rm_listorder, newview, rm_bits2
2571 serv_getln(buf, sizeof buf);
2584 char er_password[SIZ];
2589 if (!havebstr("ok_button")) {
2590 strcpy(WC->ImportantMessage,
2591 _("Cancelled. No new room was created."));
2592 display_main_menu();
2595 strcpy(er_name, bstr("er_name"));
2596 strcpy(er_type, bstr("type"));
2597 strcpy(er_password, bstr("er_password"));
2598 er_floor = ibstr("er_floor");
2599 er_view = ibstr("er_view");
2602 if (!strcmp(er_type, "hidden"))
2604 if (!strcmp(er_type, "passworded"))
2606 if (!strcmp(er_type, "invonly"))
2608 if (!strcmp(er_type, "personal"))
2611 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2612 er_name, er_num_type, er_password, er_floor, 0, er_view);
2614 serv_getln(buf, sizeof buf);
2615 if (buf[0] != '2') {
2616 strcpy(WC->ImportantMessage, &buf[4]);
2617 display_main_menu();
2620 /** TODO: Room created, now udate the left hand icon bar for this user */
2621 burn_folder_cache(0); /* burn the old folder cache */
2625 do_change_view(er_view); /* Now go there */
2630 * \brief display the screen to enter a private room
2632 void display_private(char *rname, int req_pass)
2634 output_headers(1, 1, 1, 0, 0, 0);
2636 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Go to a hidden room"));
2637 do_template("beginbox", NULL);
2640 wprintf(_("If you know the name of a hidden (guess-name) or "
2641 "passworded room, you can enter that room by typing "
2642 "its name below. Once you gain access to a private "
2643 "room, it will appear in your regular room listings "
2644 "so you don't have to keep returning here."));
2647 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2648 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2650 wprintf("<table class=\"altern\"> "
2651 "<tr class=\"even\"><td>");
2652 wprintf(_("Enter room name:"));
2654 "<input type=\"text\" name=\"gr_name\" "
2655 "value=\"%s\" maxlength=\"128\">\n", rname);
2658 wprintf("</td></tr><tr class=\"odd\"><td>");
2659 wprintf(_("Enter room password:"));
2660 wprintf("</td><td>");
2661 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2663 wprintf("</td></tr></table>\n");
2665 wprintf("<div class=\"buttons\">\n");
2666 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2668 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2672 wprintf("</div></form>\n");
2674 do_template("endbox", NULL);
2680 * \brief goto a private room
2682 void goto_private(void)
2687 if (!havebstr("ok_button")) {
2688 display_main_menu();
2691 strcpy(hold_rm, WC->wc_roomname);
2692 strcpy(buf, "GOTO ");
2693 strcat(buf, bstr("gr_name"));
2695 strcat(buf, bstr("gr_pass"));
2697 serv_getln(buf, sizeof buf);
2699 if (buf[0] == '2') {
2700 smart_goto(bstr("gr_name"));
2703 if (!strncmp(buf, "540", 3)) {
2704 display_private(bstr("gr_name"), 1);
2707 output_headers(1, 1, 1, 0, 0, 0);
2708 wprintf("%s\n", &buf[4]);
2715 * \brief display the screen to zap a room
2717 void display_zap(void)
2719 output_headers(1, 1, 2, 0, 0, 0);
2721 wprintf("<div id=\"banner\">\n");
2723 wprintf(_("Zap (forget/unsubscribe) the current room"));
2725 wprintf("</div>\n");
2727 wprintf("<div id=\"content\" class=\"service\">\n");
2729 wprintf(_("If you select this option, <em>%s</em> will "
2730 "disappear from your room list. Is this what you wish "
2731 "to do?<br />\n"), WC->wc_roomname);
2733 wprintf("<form method=\"POST\" action=\"zap\">\n");
2734 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2735 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2737 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2738 wprintf("</form>\n");
2749 char final_destination[SIZ];
2752 * If the forget-room routine fails for any reason, we fall back
2753 * to the current room; otherwise, we go to the Lobby
2755 strcpy(final_destination, WC->wc_roomname);
2757 if (havebstr("ok_button")) {
2758 serv_printf("GOTO %s", WC->wc_roomname);
2759 serv_getln(buf, sizeof buf);
2760 if (buf[0] == '2') {
2762 serv_getln(buf, sizeof buf);
2763 if (buf[0] == '2') {
2764 strcpy(final_destination, "_BASEROOM_");
2768 smart_goto(final_destination);
2774 * \brief Delete the current room
2776 void delete_room(void)
2781 serv_puts("KILL 1");
2782 serv_getln(buf, sizeof buf);
2783 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2784 if (buf[0] != '2') {
2785 strcpy(WC->ImportantMessage, &buf[4]);
2786 display_main_menu();
2789 smart_goto("_BASEROOM_");
2796 * \brief Perform changes to a room's network configuration
2798 void netedit(void) {
2807 // TODO: do line dynamic!
2808 if (havebstr("line_pop3host")) {
2809 strcpy(line, bstr("prefix"));
2810 strcat(line, bstr("line_pop3host"));
2812 strcat(line, bstr("line_pop3user"));
2814 strcat(line, bstr("line_pop3pass"));
2816 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2818 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2819 strcat(line, bstr("suffix"));
2821 else if (havebstr("line")) {
2822 strcpy(line, bstr("prefix"));
2823 strcat(line, bstr("line"));
2824 strcat(line, bstr("suffix"));
2839 serv_getln(buf, sizeof buf);
2840 if (buf[0] != '1') {
2846 /** This loop works for add *or* remove. Spiffy, eh? */
2847 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2848 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2849 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2850 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2851 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2852 if ( (strcasecmp(cmpa0, cmpb0))
2853 || (strcasecmp(cmpa1, cmpb1)) ) {
2854 fprintf(fp, "%s\n", buf);
2860 serv_getln(buf, sizeof buf);
2861 if (buf[0] != '4') {
2867 while (fgets(buf, sizeof buf, fp) != NULL) {
2868 buf[strlen(buf)-1] = 0;
2872 if (havebstr("add_button")) {
2873 num_addrs = num_tokens(bstr("line"), ',');
2874 if (num_addrs < 2) {
2875 /* just adding one node or address */
2879 /* adding multiple addresses separated by commas */
2880 for (i=0; i<num_addrs; ++i) {
2881 strcpy(line, bstr("prefix"));
2882 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2885 strcat(line, bstr("suffix"));
2899 * \brief Convert a room name to a folder-ish-looking name.
2900 * \param folder the folderish name
2901 * \param room the room name
2902 * \param floor the floor name
2903 * \param is_mailbox is it a mailbox?
2905 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2910 * For mailboxes, just do it straight...
2913 sprintf(folder, "My folders|%s", room);
2917 * Otherwise, prefix the floor name as a "public folders" moniker
2920 if (floor > MAX_FLOORS) {
2922 sprintf(folder, "%%%%%%|%s", room);
2925 sprintf(folder, "%s|%s", floorlist[floor], room);
2930 * Replace "\" characters with "|" for pseudo-folder-delimiting
2932 len = strlen (folder);
2933 for (i=0; i<len; ++i) {
2934 if (folder[i] == '\\') folder[i] = '|';
2942 * \brief Back end for change_view()
2943 * \param newview set newview???
2945 void do_change_view(int newview) {
2948 serv_printf("VIEW %d", newview);
2949 serv_getln(buf, sizeof buf);
2950 WC->wc_view = newview;
2951 smart_goto(WC->wc_roomname);
2957 * \brief Change the view for this room
2959 void change_view(void) {
2962 view = lbstr("view");
2963 do_change_view(view);
2968 * \brief One big expanded tree list view --- like a folder list
2969 * \param fold the folder to view
2970 * \param max_folders how many folders???
2971 * \param num_floors hom many floors???
2973 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2977 int has_subfolders = 0;
2980 parents = malloc(max_folders * sizeof(int));
2982 /** BEGIN TREE MENU */
2983 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2985 /** include NanoTree */
2986 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2988 /** initialize NanoTree */
2989 wprintf("<script type=\"text/javascript\"> \n"
2990 " showRootNode = false; \n"
2991 " sortNodes = false; \n"
2992 " dragable = false; \n"
2994 " function standardClick(treeNode) { \n"
2997 " var closedGif = 'static/folder_closed.gif'; \n"
2998 " var openGif = 'static/folder_open.gif'; \n"
3000 " rootNode = new TreeNode(1, 'root node - hide'); \n"
3004 for (i=0; i<max_folders; ++i) {
3007 if ((i+1) < max_folders) {
3009 len = strlen(fold[i].name);
3010 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
3011 && (fold[i+1].name[len] == '|') ) {
3016 levels = num_tokens(fold[i].name, '|');
3017 parents[levels] = i;
3019 wprintf("var node%d = new TreeNode(%d, '", i, i);
3021 if (fold[i].selectable) {
3022 wprintf("<a href=\"dotgoto?room=");
3023 urlescputs(fold[i].room);
3028 wprintf("<span class=\"roomlist_floor\">");
3030 else if (fold[i].hasnewmsgs) {
3031 wprintf("<span class=\"roomlist_new\">");
3034 wprintf("<span class=\"roomlist_old\">");
3036 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3041 if (has_subfolders) {
3042 wprintf("new Array(closedGif, openGif)");
3044 else if (fold[i].view == VIEW_ADDRESSBOOK) {
3045 wprintf("'static/viewcontacts_16x.gif'");
3047 else if (fold[i].view == VIEW_CALENDAR) {
3048 wprintf("'static/calarea_16x.gif'");
3050 else if (fold[i].view == VIEW_CALBRIEF) {
3051 wprintf("'static/calarea_16x.gif'");
3053 else if (fold[i].view == VIEW_TASKS) {
3054 wprintf("'static/taskmanag_16x.gif'");
3056 else if (fold[i].view == VIEW_NOTES) {
3057 wprintf("'static/storenotes_16x.gif'");
3059 else if (fold[i].view == VIEW_MAILBOX) {
3060 wprintf("'static/privatemess_16x.gif'");
3063 wprintf("'static/chatrooms_16x.gif'");
3066 urlescputs(fold[i].name);
3070 wprintf("rootNode.addChild(node%d);\n", i);
3073 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3077 wprintf("container = document.getElementById('roomlist_div'); \n"
3083 /** END TREE MENU */
3087 * \brief Boxes and rooms and lists ... oh my!
3088 * \param fold the folder to view
3089 * \param max_folders how many folders???
3090 * \param num_floors hom many floors???
3092 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3094 char floor_name[256];
3095 char old_floor_name[256];
3097 int levels, oldlevels;
3100 static int columns = 3;
3101 int boxes_per_column = 0;
3102 int current_column = 0;
3105 strcpy(floor_name, "");
3106 strcpy(old_floor_name, "");
3109 while (nf % columns != 0) ++nf;
3110 boxes_per_column = (nf / columns);
3111 if (boxes_per_column < 1) boxes_per_column = 1;
3113 /** Outer table (for columnization) */
3114 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3115 "<tr><td valign=top>");
3119 for (i=0; i<max_folders; ++i) {
3121 levels = num_tokens(fold[i].name, '|');
3122 extract_token(floor_name, fold[i].name, 0,
3123 '|', sizeof floor_name);
3125 if ( (strcasecmp(floor_name, old_floor_name))
3126 && (!IsEmptyStr(old_floor_name)) ) {
3128 do_template("endbox", NULL);
3132 if ((num_boxes % boxes_per_column) == 0) {
3134 if (current_column < columns) {
3135 wprintf("</td><td valign=top>\n");
3139 strcpy(old_floor_name, floor_name);
3142 /** Begin inner box */
3143 stresc(boxtitle, 256, floor_name, 1, 0);
3144 svprintf(HKEY("BOXTITLE"), WCS_STRING, boxtitle);
3145 do_template("beginbox", NULL);
3152 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3153 if (fold[i].selectable) {
3154 wprintf("<a href=\"dotgoto?room=");
3155 urlescputs(fold[i].room);
3161 if (fold[i].hasnewmsgs) {
3162 wprintf("<span class=\"roomlist_new\">");
3165 wprintf("<span class=\"roomlist_old\">");
3167 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3170 if (fold[i].selectable) {
3176 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3177 wprintf(" (INBOX)");
3179 wprintf("<br />\n");
3182 /** End the final inner box */
3183 do_template("endbox", NULL);
3185 wprintf("</td></tr></table>\n");
3189 * \brief print a floor div???
3190 * \param which_floordiv name of the floordiv???
3192 void set_floordiv_expanded(void) {
3193 struct wcsession *WCC = WC;
3196 FloorDiv = NewStrBuf();
3197 StrBufAppendBuf(FloorDiv, WCC->UrlFragment1, 0);
3198 set_preference("floordiv_expanded", FloorDiv, 1);
3199 WCC->floordiv_expanded = FloorDiv;
3203 * \brief view the iconbar
3204 * \param fold the folder to view
3205 * \param max_folders how many folders???
3206 * \param num_floors hom many floors???
3208 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3210 char floor_name[256];
3211 char old_floor_name[256];
3212 char floordivtitle[256];
3213 char floordiv_id[32];
3214 int levels, oldlevels;
3216 int num_drop_targets = 0;
3219 strcpy(floor_name, "");
3220 strcpy(old_floor_name, "");
3224 for (i=0; i<max_folders; ++i) {
3226 levels = num_tokens(fold[i].name, '|');
3227 extract_token(floor_name, fold[i].name, 0,
3228 '|', sizeof floor_name);
3230 if ( (strcasecmp(floor_name, old_floor_name))
3231 && (!IsEmptyStr(old_floor_name)) ) {
3232 /** End inner box */
3234 wprintf("</div>\n"); /** floordiv */
3236 strcpy(old_floor_name, floor_name);
3240 stresc(floordivtitle, 256, floor_name, 0, 0);
3241 sprintf(floordiv_id, "floordiv%d", i);
3242 wprintf("<span class=\"ib_roomlist_floor\" "
3243 "onClick=\"expand_floor('%s')\">"
3244 "%s</span><br>\n", floordiv_id, floordivtitle);
3245 wprintf("<div id=\"%s\" style=\"display:%s\">",
3247 (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
3254 wprintf("<div id=\"roomdiv%d\">", i);
3256 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3258 /** choose the icon */
3259 if (fold[i].view == VIEW_ADDRESSBOOK) {
3260 icon = "viewcontacts_16x.gif" ;
3262 else if (fold[i].view == VIEW_CALENDAR) {
3263 icon = "calarea_16x.gif" ;
3265 else if (fold[i].view == VIEW_CALBRIEF) {
3266 icon = "calarea_16x.gif" ;
3268 else if (fold[i].view == VIEW_TASKS) {
3269 icon = "taskmanag_16x.gif" ;
3271 else if (fold[i].view == VIEW_NOTES) {
3272 icon = "storenotes_16x.gif" ;
3274 else if (fold[i].view == VIEW_MAILBOX) {
3275 icon = "privatemess_16x.gif" ;
3278 icon = "chatrooms_16x.gif" ;
3281 if (fold[i].selectable) {
3282 wprintf("<a href=\"dotgoto?room=");
3283 urlescputs(fold[i].room);
3285 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3290 if (fold[i].hasnewmsgs) {
3291 wprintf("<span class=\"ib_roomlist_new\">");
3294 wprintf("<span class=\"ib_roomlist_old\">");
3296 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3298 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3299 wprintf(" (INBOX)");
3302 if (fold[i].selectable) {
3309 wprintf("</div>\n"); /** roomdiv */
3312 wprintf("</div>\n"); /** floordiv */
3315 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3316 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3318 num_drop_targets = 0;
3320 for (i=0; i<max_folders; ++i) {
3321 levels = num_tokens(fold[i].name, '|');
3323 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3324 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3325 jsescputs(fold[i].room);
3331 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3332 if ((ChrPtr(WC->floordiv_expanded)[0] != '\0')&&
3333 (ChrPtr(WC->floordiv_expanded)[1] != '\0')){
3334 wprintf("which_div_expanded = '%s';\n", ChrPtr(WC->floordiv_expanded));
3338 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3344 * \brief Burn the cached folder list.
3345 * \param age How old the cahce needs to be before we burn it.
3348 void burn_folder_cache(time_t age)
3350 /** If our cached folder list is very old, burn it. */
3351 if (WC->cache_fold != NULL) {
3352 if ((time(NULL) - WC->cache_timestamp) > age) {
3353 free(WC->cache_fold);
3354 WC->cache_fold = NULL;
3363 * \brief Show the room list.
3364 * (only should get called by
3365 * knrooms() because that's where output_headers() is called from)
3366 * \param viewpref the view preferences???
3369 void list_all_rooms_by_floor(const char *viewpref) {
3372 struct folder *fold = NULL;
3374 int max_folders = 0;
3375 int alloc_folders = 0;
3379 int ShowEmptyFloors;
3382 int num_floors = 1; /** add an extra one for private folders */
3385 /** If our cached folder list is very old, burn it. */
3386 burn_folder_cache(300);
3388 /** Can we do the iconbar roomlist from cache? */
3389 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3390 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3394 /** Grab the floor table so we know how to build the list... */
3397 /** Start with the mailboxes */
3400 fold = malloc(sizeof(struct folder));
3401 memset(fold, 0, sizeof(struct folder));
3402 strcpy(fold[0].name, "My folders");
3403 fold[0].is_mailbox = 1;
3405 /** Then add floors */
3407 serv_getln(buf, sizeof buf);
3408 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3409 if (max_folders >= alloc_folders) {
3410 alloc_folders = max_folders + 100;
3411 fold = realloc(fold,
3412 alloc_folders * sizeof(struct folder));
3414 memset(&fold[max_folders], 0, sizeof(struct folder));
3415 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3416 extract_token(buf3, buf, 0, '|', SIZ);
3417 fold[max_folders].floor = atol (buf3);
3422 for (i=0; i<num_floors; i++)
3423 if (IDMax < fold[i].floor)
3424 IDMax = fold[i].floor;
3425 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3426 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3427 for (i=0; i<num_floors; i++)
3428 floor_mapping[fold[i].floor]=i;
3430 /** refresh the messages index for this room */
3431 // serv_puts("GOTO ");
3432 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3433 /** Now add rooms */
3435 serv_getln(buf, sizeof buf);
3436 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3437 if (max_folders >= alloc_folders) {
3438 alloc_folders = max_folders + 100;
3439 fold = realloc(fold,
3440 alloc_folders * sizeof(struct folder));
3442 memset(&fold[max_folders], 0, sizeof(struct folder));
3443 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3444 ra_flags = extract_int(buf, 5);
3445 flags = extract_int(buf, 1);
3446 fold[max_folders].floor = extract_int(buf, 2);
3447 fold[max_folders].hasnewmsgs =
3448 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3449 if (flags & QR_MAILBOX) {
3450 fold[max_folders].is_mailbox = 1;
3452 fold[max_folders].view = extract_int(buf, 6);
3453 room_to_folder(fold[max_folders].name,
3454 fold[max_folders].room,
3455 fold[max_folders].floor,
3456 fold[max_folders].is_mailbox);
3457 fold[max_folders].selectable = 1;
3458 /* Increase the room count for the associtaed floor */
3459 if (fold[max_folders].is_mailbox) {
3460 fold[0].num_rooms++;
3463 i = floor_mapping[fold[max_folders].floor];
3464 fold[i].num_rooms++;
3470 * Remove any floors that don't have rooms
3472 get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
3473 if (ShowEmptyFloors)
3475 for (i=0; i<num_floors; i++)
3477 if (fold[i].num_rooms == 0) {
3478 for (j=i; j<max_folders; j++) {
3479 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3488 /** Bubble-sort the folder list */
3489 for (i=0; i<max_folders; ++i) {
3490 for (j=0; j<(max_folders-1)-i; ++j) {
3491 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3492 swap = strcasecmp(fold[j].name, fold[j+1].name);
3495 if ( (fold[j+1].is_mailbox)
3496 && (!fold[j].is_mailbox)) {
3504 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3505 memcpy(&fold[j], &fold[j+1],
3506 sizeof(struct folder));
3507 memcpy(&fold[j+1], &ftmp,
3508 sizeof(struct folder));
3514 if (!strcasecmp(viewpref, "folders")) {
3515 do_folder_view(fold, max_folders, num_floors);
3517 else if (!strcasecmp(viewpref, "hackish_view")) {
3518 for (i=0; i<max_folders; ++i) {
3519 escputs(fold[i].name);
3520 wprintf("<br />\n");
3523 else if (!strcasecmp(viewpref, "iconbar")) {
3524 do_iconbar_view(fold, max_folders, num_floors);
3527 do_rooms_view(fold, max_folders, num_floors);
3530 /* Don't free the folder list ... cache it for future use! */
3531 if (WC->cache_fold != NULL) {
3532 free(WC->cache_fold);
3534 WC->cache_fold = fold;
3535 WC->cache_max_folders = max_folders;
3536 WC->cache_num_floors = num_floors;
3537 WC->cache_timestamp = time(NULL);
3538 free(floor_mapping);
3543 * \brief Do either a known rooms list or a folders list, depending on the
3548 StrBuf *ListView = NULL;
3550 output_headers(1, 1, 2, 0, 0, 0);
3552 /** Determine whether the user is trying to change views */
3553 if (havebstr("view")) {
3554 ListView = NewStrBufPlain(bstr("view"), -1);
3555 set_preference("roomlistview", ListView, 1);
3557 /** Sanitize the input so its safe */
3558 if(!get_preference("roomlistview", &ListView) ||
3559 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3560 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3562 if (ListView == NULL) {
3563 ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1);
3564 set_preference("roomlistview", ListView, 0);
3567 StrBufPrintf(ListView, "rooms");
3573 wprintf("<div id=\"banner\">\n");
3574 wprintf("<div class=\"room_banner\">");
3576 if (!strcasecmp(ChrPtr(ListView), "rooms")) {
3577 wprintf(_("Room list"));
3579 else if (!strcasecmp(ChrPtr(ListView), "folders")) {
3580 wprintf(_("Folder list"));
3582 else if (!strcasecmp(ChrPtr(ListView), "table")) {
3583 wprintf(_("Room list"));
3585 wprintf("</h1></div>\n");
3587 /** offer the ability to switch views */
3588 wprintf("<ul class=\"room_actions\">\n");
3589 wprintf("<li class=\"start_page\">");
3590 offer_start_page(NULL, 0, NULL, NULL);
3592 wprintf("<li><form name=\"roomlistomatic\">\n"
3593 "<select name=\"newview\" size=\"1\" "
3594 "OnChange=\"location.href=roomlistomatic.newview.options"
3595 "[selectedIndex].value\">\n");
3597 wprintf("<option %s value=\"knrooms&view=rooms\">"
3600 ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" )
3603 wprintf("<option %s value=\"knrooms&view=folders\">"
3604 "View as folder list"
3606 ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" )
3609 wprintf("</select>");
3610 wprintf("</form></li>");
3611 wprintf("</ul></div>\n");
3613 wprintf("<div id=\"content\" class=\"service\">\n");
3615 /** Display the room list in the user's preferred format */
3616 list_all_rooms_by_floor(ChrPtr(ListView));
3623 * \brief Set the message expire policy for this room and/or floor
3625 void set_room_policy(void) {
3628 if (!havebstr("ok_button")) {
3629 strcpy(WC->ImportantMessage,
3630 _("Cancelled. Changes were not saved."));
3635 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3636 serv_getln(buf, sizeof buf);
3637 strcpy(WC->ImportantMessage, &buf[4]);
3639 if (WC->axlevel >= 6) {
3640 strcat(WC->ImportantMessage, "<br />\n");
3641 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3642 serv_getln(buf, sizeof buf);
3643 strcat(WC->ImportantMessage, &buf[4]);
3650 void tmplput_RoomName(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
3652 StrEscAppend(Target, NULL, WC->wc_roomname, 1, 1);
3655 void _gotonext(void) { slrp_highest(); gotonext(); }
3656 void dotskip(void) {smart_goto(bstr("room"));}
3657 void _display_private(void) { display_private("", 0); }
3658 void dotgoto(void) {
3659 if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3662 smart_goto(bstr("room"));
3665 void tmplput_roombanner(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
3667 wprintf("<div id=\"banner\">\n");
3668 embed_room_banner(NULL, navbar_default);
3669 wprintf("</div>\n");
3673 void tmplput_ungoto(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
3675 struct wcsession *WCC = WC;
3678 (!IsEmptyStr(WCC->ugname)))
3679 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3683 int ConditionalHaveUngoto(WCTemplateToken *Tokens, void *Context)
3685 struct wcsession *WCC = WC;
3687 return ((WCC!=NULL) &&
3688 (!IsEmptyStr(WCC->ugname)) &&
3689 (strcasecmp(WCC->ugname, WCC->wc_roomname) == 0));
3692 int ConditinalRoomHasQRVisidir(WCTemplateToken *Tokens, void *Context)
3694 struct wcsession *WCC = WC;
3696 return ((WCC!=NULL) &&
3697 ((WCC->room_flags & QR_VISDIR) != 0));
3700 int ConditionalHaveRoomeditRights(WCTemplateToken *Tokens, void *Context)
3702 struct wcsession *WCC = WC;
3704 return ( (WCC!= NULL) &&
3705 ((WCC->axlevel >= 6) ||
3706 (WCC->is_room_aide) ||
3707 (WCC->is_mailbox) ));
3714 RegisterNamespace("ROOMNAME", 0, 0, tmplput_RoomName);
3716 WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
3717 WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, 0);
3718 WebcitAddUrlHandler(HKEY("skip"), gotonext, 0);
3719 WebcitAddUrlHandler(HKEY("ungoto"), ungoto, 0);
3720 WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, 0);
3721 WebcitAddUrlHandler(HKEY("dotskip"), dotskip, 0);
3722 WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
3723 WebcitAddUrlHandler(HKEY("goto_private"), goto_private, 0);
3724 WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
3725 WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
3726 WebcitAddUrlHandler(HKEY("zap"), zap, 0);
3727 WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
3728 WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
3729 WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
3730 WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
3731 WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
3732 WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
3733 WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
3734 WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
3735 WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
3736 WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
3737 WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);
3738 RegisterNamespace("ROOMBANNER", 0, 0, tmplput_roombanner);
3739 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_VISIDIR"), 0, ConditinalRoomHasQRVisidir);
3740 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto);
3741 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights);
3743 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto);