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)
260 output_headers(1, 1, 1, 0, 0, 0);
262 Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
263 DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF);
269 wprintf("<br /><br />\n");
270 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
271 do_template("endbox", NULL);
277 * \brief read this room's info file (set v to 1 for verbose mode)
279 void readinfo(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
284 int fullinfo_len = 0;
287 serv_getln(buf, sizeof buf);
290 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
291 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
292 strcpy(&fullinfo[fullinfo_len], buf);
293 fullinfo_len += strlen(buf);
297 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
298 strcpy(&briefinfo[50], "...");
300 wprintf("<div class=\"infos\" "
301 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
304 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
305 wprintf("<img class=\"close_infos\" "
306 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
307 "src=\"static/closewindow.gif\" alt=\"%s\">",
322 * \brief Display room banner icon.
323 * The server doesn't actually
324 * need the room name, but we supply it in order to
325 * keep the browser from using a cached icon from
328 void embed_room_graphic(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) {
331 serv_puts("OIMG _roompic_");
332 serv_getln(buf, sizeof buf);
334 wprintf("<img height=\"64px\" src=\"image&name=_roompic_&room=");
335 urlescputs(WC->wc_roomname);
338 serv_getln(buf, sizeof buf);
340 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
341 wprintf("<img class=\"roompic\" alt=\"\" src=\""
342 "static/viewcontacts_48x.gif"
346 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
347 wprintf("<img class=\"roompic\" alt=\"\" src=\""
348 "static/calarea_48x.gif"
352 else if (WC->wc_view == VIEW_TASKS) {
353 wprintf("<img class=\"roompic\" alt=\"\" src=\""
354 "static/taskmanag_48x.gif"
358 else if (WC->wc_view == VIEW_NOTES) {
359 wprintf("<img class=\"roompic\" alt=\"\" src=\""
360 "static/storenotes_48x.gif"
364 else if (WC->wc_view == VIEW_MAILBOX) {
365 wprintf("<img class=\"roompic\" alt=\"\" src=\""
366 "static/privatemess_48x.gif"
371 wprintf("<img class=\"roompic\" alt=\"\" src=\""
372 "static/chatrooms_48x.gif"
382 * \brief Display the current view and offer an option to change it
384 void embed_view_o_matic(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) {
387 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
388 wprintf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
389 wprintf("<label for=\"view_name\">");
390 wprintf(_("View as:"));
392 "<select name=\"newview\" size=\"1\" "
393 "id=\"view_name\" class=\"selectbox\" "
394 "OnChange=\"location.href=viewomatic.newview.options"
395 "[selectedIndex].value\">\n");
397 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
399 * Only offer the views that make sense, given the default
400 * view for the room. For example, don't offer a Calendar
401 * view in a non-Calendar room.
405 || (i == WC->wc_default_view) /**< default */
406 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
407 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
408 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
411 wprintf("<option %s value=\"changeview?view=%d\">",
412 ((i == WC->wc_view) ? "selected" : ""),
414 escputs(viewdefs[i]);
415 wprintf("</option>\n");
418 wprintf("</select></div></form>\n");
423 * \brief Display a search box
425 void embed_search_o_matic(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) {
426 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
427 wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
428 wprintf("<label for=\"search_name\">");
429 wprintf(_("Search: "));
430 wprintf("</label><input ");
431 wprintf("%s", serv_info.serv_fulltext_enabled ? "" : "disabled ");
432 wprintf("type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
433 "id=\"search_name\" class=\"inputbox\">\n"
435 wprintf("</div></form>\n");
440 * \brief Embed the room banner
442 * \param got The information returned from a GOTO server command
443 * \param navbar_style Determines which navigation buttons to display
447 void embed_room_banner(char *got, int navbar_style) {
450 char with_files[256];
454 * We need to have the information returned by a GOTO server command.
455 * If it isn't supplied, we fake it by issuing our own GOTO.
458 memset(buf, 20, '0');
460 serv_printf("GOTO %s", WC->wc_roomname);
461 serv_getln(buf, sizeof buf);
465 /** The browser needs some information for its own use */
466 wprintf("<script type=\"text/javascript\"> \n"
467 " room_is_trash = %d; \n"
473 * If the user happens to select the "make this my start page" link,
474 * we want it to remember the URL as a "/dotskip" one instead of
475 * a "skip" or "gotonext" or something like that.
477 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
480 /** Check for new mail. */
481 WC->new_mail = extract_int(&got[4], 9);
482 WC->wc_view = extract_int(&got[4], 11);
484 /* Is this a directory room and does it contain files and how many? */
485 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
488 serv_getln(buf2, sizeof buf2);
489 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
491 snprintf (with_files, sizeof with_files,
492 "; <a href=\"display_room_directory\"> %d %s </a>",
494 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
497 strcpy (with_files, "");
499 svprintf(HKEY("NUMMSGS"), WCS_STRING,
500 _("%d new of %d messages%s"),
501 extract_int(&got[4], 1),
502 extract_int(&got[4], 2),
505 svcallback("ROOMPIC", embed_room_graphic);
506 svcallback("ROOMINFO", readinfo);
507 svcallback("VIEWOMATIC", embed_view_o_matic);
508 svcallback("SEARCHOMATIC", embed_search_o_matic);
509 svcallback("START", offer_start_page);
511 do_template("roombanner", NULL);
512 // roombanner contains this for mobile
513 if (navbar_style != navbar_none && !WC->is_mobile) {
515 wprintf("<div id=\"navbar\"><ul>");
517 if (navbar_style == navbar_default) wprintf(
518 "<li class=\"ungoto\">"
519 "<a href=\"ungoto\">"
520 "<img src=\"static/ungoto2_24x.gif\" alt=\"\">"
521 "<span class=\"navbar_link\">%s</span></A>"
522 "</li>\n", _("Ungoto")
525 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
527 "<li class=\"newmess\">"
528 "<a href=\"readnew\">"
529 "<img src=\"static/newmess2_24x.gif\" alt=\"\">"
530 "<span class=\"navbar_link\">%s</span></A>"
531 "</li>\n", _("Read new messages")
535 if (navbar_style == navbar_default) {
536 switch(WC->wc_view) {
537 case VIEW_ADDRESSBOOK:
539 "<li class=\"viewcontacts\">"
540 "<a href=\"readfwd\">"
541 "<img src=\"static/viewcontacts_24x.gif\" "
543 "<span class=\"navbar_link\">"
545 "</span></a></li>\n", _("View contacts")
550 "<li class=\"staskday\">"
551 "<a href=\"readfwd?calview=day\">"
552 "<img src=\"static/taskday2_24x.gif\" "
554 "<span class=\"navbar_link\">"
556 "</span></a></li>\n", _("Day view")
559 "<li class=\"monthview\">"
560 "<a href=\"readfwd?calview=month\">"
561 "<img src=\"static/monthview2_24x.gif\" "
563 "<span class=\"navbar_link\">"
565 "</span></a></li>\n", _("Month view")
570 "<li class=\"monthview\">"
571 "<a href=\"readfwd?calview=month\">"
572 "<img src=\"static/monthview2_24x.gif\" "
574 "<span class=\"navbar_link\">"
576 "</span></a></li>\n", _("Calendar list")
581 "<li class=\"taskmanag\">"
582 "<a href=\"readfwd\">"
583 "<img src=\"static/taskmanag_24x.gif\" "
585 "<span class=\"navbar_link\">"
587 "</span></a></li>\n", _("View tasks")
592 "<li class=\"viewnotes\">"
593 "<a href=\"readfwd\">"
594 "<img src=\"static/viewnotes_24x.gif\" "
596 "<span class=\"navbar_link\">"
598 "</span></a></li>\n", _("View notes")
603 "<li class=\"readallmess\">"
604 "<a href=\"readfwd\">"
605 "<img src=\"static/readallmess3_24x.gif\" "
607 "<span class=\"navbar_link\">"
609 "</span></a></li>\n", _("View message list")
614 "<li class=\"readallmess\">"
615 "<a href=\"readfwd\">"
616 "<img src=\"static/readallmess3_24x.gif\" "
618 "<span class=\"navbar_link\">"
620 "</span></a></li>\n", _("Wiki home")
625 "<li class=\"readallmess\">"
626 "<a href=\"readfwd\">"
627 "<img src=\"static/readallmess3_24x.gif\" "
629 "<span class=\"navbar_link\">"
631 "</span></a></li>\n", _("Read all messages")
637 if (navbar_style == navbar_default) {
638 switch(WC->wc_view) {
639 case VIEW_ADDRESSBOOK:
641 "<li class=\"addnewcontact\">"
642 "<a href=\"display_enter\">"
643 "<img src=\"static/addnewcontact_24x.gif\" "
644 "alt=\"\"><span class=\"navbar_link\">"
646 "</span></a></li>\n", _("Add new contact")
651 wprintf("<li class=\"addevent\"><a href=\"display_enter");
652 if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
653 if (havebstr("month")) wprintf("?month=%s", bstr("month"));
654 if (havebstr("day" )) wprintf("?day=%s", bstr("day"));
656 "<img src=\"static/addevent_24x.gif\" "
657 "alt=\"\"><span class=\"navbar_link\">"
659 "</span></a></li>\n", _("Add new event")
664 "<li class=\"newmess\">"
665 "<a href=\"display_enter\">"
666 "<img src=\"static/newmess3_24x.gif\" "
667 "alt=\"\"><span class=\"navbar_link\">"
669 "</span></a></li>\n", _("Add new task")
674 "<li class=\"enternewnote\">"
675 "<a href=\"add_new_note\">"
676 "<img src=\"static/enternewnote_24x.gif\" "
677 "alt=\"\"><span class=\"navbar_link\">"
679 "</span></a></li>\n", _("Add new note")
683 safestrncpy(buf, bstr("page"), sizeof buf);
686 "<li class=\"newmess\">"
687 "<a href=\"display_enter?wikipage=%s\">"
688 "<img src=\"static/newmess3_24x.gif\" "
689 "alt=\"\"><span class=\"navbar_link\">"
691 "</span></a></li>\n", buf, _("Edit this page")
696 "<li class=\"newmess\">"
697 "<a href=\"display_enter\">"
698 "<img src=\"static/newmess3_24x.gif\" "
699 "alt=\"\"><span class=\"navbar_link\">"
701 "</span></a></li>\n", _("Write mail")
706 "<li class=\"newmess\">"
707 "<a href=\"display_enter\">"
708 "<img src=\"static/newmess3_24x.gif\" "
709 "alt=\"\"><span class=\"navbar_link\">"
711 "</span></a></li>\n", _("Enter a message")
717 if (navbar_style == navbar_default) wprintf(
718 "<li class=\"skipthisroom\">"
721 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\">"
722 "<span class=\"navbar_link\">%s</span></a>"
724 _("Leave all messages marked as unread, go to next room with unread messages"),
728 if (navbar_style == navbar_default) wprintf(
729 "<li class=\"markngo\">"
730 "<a href=\"gotonext\" "
732 "<img src=\"static/markngo_24x.gif\" alt=\"\">"
733 "<span class=\"navbar_link\">%s</span></a>"
735 _("Mark all messages as read, go to next room with unread messages"),
739 wprintf("</ul></div>\n");
746 * back end routine to take the session to a new room
748 int gotoroom(char *gname)
751 static long ls = (-1L);
754 /* store ungoto information */
755 strcpy(WC->ugname, WC->wc_roomname);
758 /** move to the new room */
759 serv_printf("GOTO %s", gname);
760 serv_getln(buf, sizeof buf);
764 serv_puts("GOTO _BASEROOM_");
765 serv_getln(buf, sizeof buf);
772 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
773 WC->room_flags = extract_int(&buf[4], 4);
774 /* highest_msg_read = extract_int(&buf[4],6);
775 maxmsgnum = extract_int(&buf[4],5);
777 WC->is_mailbox = extract_int(&buf[4],7);
778 ls = extract_long(&buf[4], 6);
779 WC->wc_floor = extract_int(&buf[4], 10);
780 WC->wc_view = extract_int(&buf[4], 11);
781 WC->wc_default_view = extract_int(&buf[4], 12);
782 WC->wc_is_trash = extract_int(&buf[4], 13);
783 WC->room_flags2 = extract_int(&buf[4], 14);
786 WC->is_room_aide = WC->is_aide;
788 WC->is_room_aide = (char) extract_int(&buf[4], 8);
790 remove_march(WC->wc_roomname);
791 if (!strcasecmp(gname, "_BASEROOM_"))
799 * \brief Locate the room on the march list which we most want to go to.
801 * is measured given a "weight" of preference based on various factors.
802 * \param desired_floor the room number on the citadel server
803 * \return the roomname
805 char *pop_march(int desired_floor)
807 static char TheRoom[128];
809 int TheOrder = 32767;
812 struct march *mptr = NULL;
814 strcpy(TheRoom, "_BASEROOM_");
815 if (WC->march == NULL)
818 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
820 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
821 weight = weight + 10000;
822 if (mptr->march_floor == desired_floor)
823 weight = weight + 5000;
825 weight = weight + ((128 - (mptr->march_floor)) * 128);
826 weight = weight + (128 - (mptr->march_order));
828 if (weight > TheWeight) {
830 strcpy(TheRoom, mptr->march_name);
831 TheFloor = mptr->march_floor;
832 TheOrder = mptr->march_order;
841 * Goto next room having unread messages.
843 * We want to skip over rooms that the user has already been to, and take the
844 * user back to the lobby when done. The room we end up in is placed in
845 * newroom - which is set to 0 (the lobby) initially.
846 * We start the search in the current room rather than the beginning to prevent
847 * two or more concurrent users from dragging each other back to the same room.
852 struct march *mptr = NULL;
853 struct march *mptr2 = NULL;
859 * First check to see if the march-mode list is already allocated.
860 * If it is, pop the first room off the list and go there.
863 if (WC->march == NULL) {
865 serv_getln(buf, sizeof buf);
867 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
868 if (IsEmptyStr(buf)) {
871 if (ELoop % 100 == 0)
876 extract_token(room_name, buf, 0, '|', sizeof room_name);
877 if (strcasecmp(room_name, WC->wc_roomname)) {
878 mptr = (struct march *) malloc(sizeof(struct march));
880 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
881 mptr->march_floor = extract_int(buf, 2);
882 mptr->march_order = extract_int(buf, 3);
883 if (WC->march == NULL)
892 * add _BASEROOM_ to the end of the march list, so the user will end up
893 * in the system base room (usually the Lobby>) at the end of the loop
895 mptr = (struct march *) malloc(sizeof(struct march));
897 mptr->march_order = 0;
898 mptr->march_floor = 0;
899 strcpy(mptr->march_name, "_BASEROOM_");
900 if (WC->march == NULL) {
904 while (mptr2->next != NULL)
909 * ...and remove the room we're currently in, so a <G>oto doesn't make us
910 * walk around in circles
912 remove_march(WC->wc_roomname);
914 if (WC->march != NULL) {
915 strcpy(next_room, pop_march(-1));
917 strcpy(next_room, "_BASEROOM_");
921 smart_goto(next_room);
928 void smart_goto(char *next_room) {
936 * mark all messages in current room as having been read
938 void slrp_highest(void)
942 serv_puts("SLRP HIGHEST");
943 serv_getln(buf, sizeof buf);
948 * un-goto the previous room
954 if (!strcmp(WC->ugname, "")) {
955 smart_goto(WC->wc_roomname);
958 serv_printf("GOTO %s", WC->ugname);
959 serv_getln(buf, sizeof buf);
961 smart_goto(WC->wc_roomname);
964 if (WC->uglsn >= 0L) {
965 serv_printf("SLRP %ld", WC->uglsn);
966 serv_getln(buf, sizeof buf);
968 strcpy(buf, WC->ugname);
969 strcpy(WC->ugname, "");
973 typedef struct __room_states {
988 * Set/clear/read the "self-service list subscribe" flag for a room
990 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
991 * returns the new value.
994 int self_service(int newval) {
995 int current_value = 0;
1001 int flags, floor, order, view, flags2;
1004 serv_getln(buf, sizeof buf);
1005 if (buf[0] != '2') return(0);
1007 extract_token(name, &buf[4], 0, '|', sizeof name);
1008 extract_token(password, &buf[4], 1, '|', sizeof password);
1009 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1010 flags = extract_int(&buf[4], 3);
1011 floor = extract_int(&buf[4], 4);
1012 order = extract_int(&buf[4], 5);
1013 view = extract_int(&buf[4], 6);
1014 flags2 = extract_int(&buf[4], 7);
1016 if (flags2 & QR2_SELFLIST) {
1024 flags2 = flags2 | QR2_SELFLIST;
1026 else if (newval == 0) {
1027 flags2 = flags2 & ~QR2_SELFLIST;
1030 return(current_value);
1033 if (newval != current_value) {
1034 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1035 name, password, dirname, flags,
1036 floor, order, view, flags2);
1037 serv_getln(buf, sizeof buf);
1044 int is_selflist(room_states *RoomFlags)
1046 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1049 int is_publiclist(room_states *RoomFlags)
1051 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1054 int is_moderatedlist(room_states *RoomFlags)
1056 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1060 * Set/clear/read the "self-service list subscribe" flag for a room
1062 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1063 * returns the new value.
1066 int get_roomflags(room_states *RoomOps)
1071 serv_getln(buf, sizeof buf);
1072 if (buf[0] != '2') return(0);
1074 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1075 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1076 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1077 RoomOps->flags = extract_int(&buf[4], 3);
1078 RoomOps->floor = extract_int(&buf[4], 4);
1079 RoomOps->order = extract_int(&buf[4], 5);
1080 RoomOps->view = extract_int(&buf[4], 6);
1081 RoomOps->flags2 = extract_int(&buf[4], 7);
1085 int set_roomflags(room_states *RoomOps)
1089 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1098 serv_getln(buf, sizeof buf);
1108 * display the form for editing a room
1110 void display_editroom(void)
1115 char remote_room[128];
1118 char er_password[10];
1119 char er_dirname[15];
1120 char er_roomaide[26];
1127 char *not_shared_with;
1130 int floorpolicy = 0;
1132 char pop3_host[128];
1137 if (IsEmptyStr(tab)) tab = "admin";
1140 output_headers(1, 1, 1, 0, 0, 0);
1142 wprintf("<div class=\"fix_scrollbar_bug\">");
1144 wprintf("<br />\n");
1146 /* print the tabbed dialog */
1147 wprintf("<div align=\"center\">");
1148 wprintf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\""
1149 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1152 wprintf("<td class=\"");
1153 if (!strcmp(tab, "admin")) {
1154 wprintf(" tab_cell_label\">");
1155 wprintf(_("Administration"));
1158 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1159 wprintf(_("Administration"));
1163 wprintf("<td> </td>\n");
1165 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1167 wprintf("<td class=\"");
1168 if (!strcmp(tab, "config")) {
1169 wprintf(" tab_cell_label\">");
1170 wprintf(_("Configuration"));
1173 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1174 wprintf(_("Configuration"));
1178 wprintf("<td> </td>\n");
1180 wprintf("<td class=\"");
1181 if (!strcmp(tab, "expire")) {
1182 wprintf(" tab_cell_label\">");
1183 wprintf(_("Message expire policy"));
1186 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1187 wprintf(_("Message expire policy"));
1191 wprintf("<td> </td>\n");
1193 wprintf("<td class=\"");
1194 if (!strcmp(tab, "access")) {
1195 wprintf(" tab_cell_label\">");
1196 wprintf(_("Access controls"));
1199 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1200 wprintf(_("Access controls"));
1204 wprintf("<td> </td>\n");
1206 wprintf("<td class=\"");
1207 if (!strcmp(tab, "sharing")) {
1208 wprintf(" tab_cell_label\">");
1209 wprintf(_("Sharing"));
1212 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1213 wprintf(_("Sharing"));
1217 wprintf("<td> </td>\n");
1219 wprintf("<td class=\"");
1220 if (!strcmp(tab, "listserv")) {
1221 wprintf(" tab_cell_label\">");
1222 wprintf(_("Mailing list service"));
1225 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1226 wprintf(_("Mailing list service"));
1230 wprintf("<td> </td>\n");
1234 wprintf("<td class=\"");
1235 if (!strcmp(tab, "feeds")) {
1236 wprintf(" tab_cell_label\">");
1237 wprintf(_("Remote retrieval"));
1240 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1241 wprintf(_("Remote retrieval"));
1245 wprintf("<td> </td>\n");
1247 wprintf("</tr></table>\n");
1248 wprintf("</div>\n");
1249 /* end tabbed dialog */
1251 wprintf("<script type=\"text/javascript\">"
1252 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1256 /* begin content of whatever tab is open now */
1258 if (!strcmp(tab, "admin")) {
1259 wprintf("<div class=\"tabcontent\">");
1261 "<li><a href=\"delete_room\" "
1262 "onClick=\"return confirm('");
1263 wprintf(_("Are you sure you want to delete this room?"));
1264 wprintf("');\">\n");
1265 wprintf(_("Delete this room"));
1267 "<li><a href=\"display_editroompic\">\n");
1268 wprintf(_("Set or change the icon for this room's banner"));
1270 "<li><a href=\"display_editinfo\">\n");
1271 wprintf(_("Edit this room's Info file"));
1277 if (!strcmp(tab, "config")) {
1278 wprintf("<div class=\"tabcontent\">");
1280 serv_getln(buf, sizeof buf);
1282 if (!strncmp(buf, "550", 3)) {
1283 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1284 _("Higher access is required to access this function.")
1287 else if (buf[0] != '2') {
1288 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1291 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1292 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1293 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1294 er_flags = extract_int(&buf[4], 3);
1295 er_floor = extract_int(&buf[4], 4);
1296 er_flags2 = extract_int(&buf[4], 7);
1298 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1299 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1301 wprintf("<ul><li>");
1302 wprintf(_("Name of room: "));
1303 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1309 wprintf(_("Resides on floor: "));
1310 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1311 if (er_flags & QR_MAILBOX)
1312 wprintf("disabled >\n");
1313 for (i = 0; i < 128; ++i)
1314 if (!IsEmptyStr(floorlist[i])) {
1315 wprintf("<OPTION ");
1317 wprintf("SELECTED ");
1318 wprintf("VALUE=\"%d\">", i);
1319 escputs(floorlist[i]);
1320 wprintf("</OPTION>\n");
1322 wprintf("</select>\n");
1325 wprintf(_("Type of room:"));
1328 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1329 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1330 wprintf("CHECKED ");
1331 wprintf("OnChange=\""
1332 " if (this.form.type[0].checked == true) { "
1333 " this.form.er_floor.disabled = false; "
1336 wprintf(_("Public (automatically appears to everyone)"));
1339 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1340 if ((er_flags & QR_PRIVATE) &&
1341 (er_flags & QR_GUESSNAME))
1342 wprintf("CHECKED ");
1343 wprintf(" OnChange=\""
1344 " if (this.form.type[1].checked == true) { "
1345 " this.form.er_floor.disabled = false; "
1348 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1350 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1351 if ((er_flags & QR_PRIVATE) &&
1352 (er_flags & QR_PASSWORDED))
1353 wprintf("CHECKED ");
1354 wprintf(" OnChange=\""
1355 " if (this.form.type[2].checked == true) { "
1356 " this.form.er_floor.disabled = false; "
1359 wprintf(_("Private - require password: "));
1360 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1363 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1364 if ((er_flags & QR_PRIVATE)
1365 && ((er_flags & QR_GUESSNAME) == 0)
1366 && ((er_flags & QR_PASSWORDED) == 0))
1367 wprintf("CHECKED ");
1368 wprintf(" OnChange=\""
1369 " if (this.form.type[3].checked == true) { "
1370 " this.form.er_floor.disabled = false; "
1373 wprintf(_("Private - invitation only"));
1375 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1376 if (er_flags & QR_MAILBOX)
1377 wprintf("CHECKED ");
1378 wprintf (" OnChange=\""
1379 " if (this.form.type[4].checked == true) { "
1380 " this.form.er_floor.disabled = true; "
1383 wprintf(_("Personal (mailbox for you only)"));
1385 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1387 wprintf(_("If private, cause current users to forget room"));
1389 wprintf("\n</ul>\n");
1391 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1392 if (er_flags & QR_PREFONLY)
1393 wprintf("CHECKED ");
1395 wprintf(_("Preferred users only"));
1397 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1398 if (er_flags & QR_READONLY)
1399 wprintf("CHECKED ");
1401 wprintf(_("Read-only room"));
1403 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1404 if (er_flags2 & QR2_COLLABDEL)
1405 wprintf("CHECKED ");
1407 wprintf(_("All users allowed to post may also delete messages"));
1409 /** directory stuff */
1410 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1411 if (er_flags & QR_DIRECTORY)
1412 wprintf("CHECKED ");
1414 wprintf(_("File directory room"));
1416 wprintf("\n<ul><li>");
1417 wprintf(_("Directory name: "));
1418 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1421 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1422 if (er_flags & QR_UPLOAD)
1423 wprintf("CHECKED ");
1425 wprintf(_("Uploading allowed"));
1427 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1428 if (er_flags & QR_DOWNLOAD)
1429 wprintf("CHECKED ");
1431 wprintf(_("Downloading allowed"));
1433 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1434 if (er_flags & QR_VISDIR)
1435 wprintf("CHECKED ");
1437 wprintf(_("Visible directory"));
1440 /** end of directory stuff */
1442 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1443 if (er_flags & QR_NETWORK)
1444 wprintf("CHECKED ");
1446 wprintf(_("Network shared room"));
1448 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1449 if (er_flags & QR_PERMANENT)
1450 wprintf("CHECKED ");
1452 wprintf(_("Permanent (does not auto-purge)"));
1454 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1455 if (er_flags2 & QR2_SUBJECTREQ)
1456 wprintf("CHECKED ");
1458 wprintf(_("Subject Required (Force users to specify a message subject)"));
1460 /** start of anon options */
1463 wprintf(_("Anonymous messages"));
1466 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1467 if (((er_flags & QR_ANONONLY) == 0)
1468 && ((er_flags & QR_ANONOPT) == 0))
1469 wprintf("CHECKED ");
1471 wprintf(_("No anonymous messages"));
1473 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1474 if (er_flags & QR_ANONONLY)
1475 wprintf("CHECKED ");
1477 wprintf(_("All messages are anonymous"));
1479 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1480 if (er_flags & QR_ANONOPT)
1481 wprintf("CHECKED ");
1483 wprintf(_("Prompt user when entering messages"));
1486 /* end of anon options */
1489 wprintf(_("Room aide: "));
1491 serv_getln(buf, sizeof buf);
1492 if (buf[0] != '2') {
1493 wprintf("<em>%s</em>\n", &buf[4]);
1495 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1496 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1499 wprintf("</ul><CENTER>\n");
1500 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1501 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1503 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1513 /* Sharing the room with other Citadel nodes... */
1514 if (!strcmp(tab, "sharing")) {
1515 wprintf("<div class=\"tabcontent\">");
1517 shared_with = strdup("");
1518 not_shared_with = strdup("");
1520 /** Learn the current configuration */
1521 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1522 serv_getln(buf, sizeof buf);
1523 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1524 extract_token(node, buf, 0, '|', sizeof node);
1525 not_shared_with = realloc(not_shared_with,
1526 strlen(not_shared_with) + 32);
1527 strcat(not_shared_with, node);
1528 strcat(not_shared_with, "\n");
1532 serv_getln(buf, sizeof buf);
1533 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1534 extract_token(cmd, buf, 0, '|', sizeof cmd);
1535 extract_token(node, buf, 1, '|', sizeof node);
1536 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1537 if (!strcasecmp(cmd, "ignet_push_share")) {
1538 shared_with = realloc(shared_with,
1539 strlen(shared_with) + 32);
1540 strcat(shared_with, node);
1541 if (!IsEmptyStr(remote_room)) {
1542 strcat(shared_with, "|");
1543 strcat(shared_with, remote_room);
1545 strcat(shared_with, "\n");
1549 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1550 extract_token(buf, shared_with, i, '\n', sizeof buf);
1551 extract_token(node, buf, 0, '|', sizeof node);
1552 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1553 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1554 if (!strcasecmp(node, cmd)) {
1555 remove_token(not_shared_with, j, '\n');
1560 /* Display the stuff */
1561 wprintf("<CENTER><br />"
1562 "<table border=1 cellpadding=5><tr>"
1564 wprintf(_("Shared with"));
1565 wprintf("</I></B></td>"
1567 wprintf(_("Not shared with"));
1568 wprintf("</I></B></td></tr>\n"
1569 "<tr><td VALIGN=TOP>\n");
1571 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1572 wprintf(_("Remote node name"));
1573 wprintf("</td><td>");
1574 wprintf(_("Remote room name"));
1575 wprintf("</td><td>");
1576 wprintf(_("Actions"));
1577 wprintf("</td></tr>\n");
1579 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1580 extract_token(buf, shared_with, i, '\n', sizeof buf);
1581 extract_token(node, buf, 0, '|', sizeof node);
1582 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1583 if (!IsEmptyStr(node)) {
1584 wprintf("<form method=\"POST\" action=\"netedit\">");
1585 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1586 wprintf("<tr><td>%s</td>\n", node);
1589 if (!IsEmptyStr(remote_room)) {
1590 escputs(remote_room);
1596 wprintf("<input type=\"hidden\" NAME=\"line\" "
1597 "VALUE=\"ignet_push_share|");
1599 if (!IsEmptyStr(remote_room)) {
1601 urlescputs(remote_room);
1604 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1605 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1606 wprintf("<input type=\"submit\" "
1607 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1608 wprintf("</td></tr></form>\n");
1612 wprintf("</table>\n");
1613 wprintf("</td><td VALIGN=TOP>\n");
1614 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1615 wprintf(_("Remote node name"));
1616 wprintf("</td><td>");
1617 wprintf(_("Remote room name"));
1618 wprintf("</td><td>");
1619 wprintf(_("Actions"));
1620 wprintf("</td></tr>\n");
1622 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1623 extract_token(node, not_shared_with, i, '\n', sizeof node);
1624 if (!IsEmptyStr(node)) {
1625 wprintf("<form method=\"POST\" action=\"netedit\">");
1626 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1627 wprintf("<tr><td>");
1630 "<input type=\"INPUT\" "
1634 wprintf("<input type=\"hidden\" "
1636 "VALUE=\"ignet_push_share|");
1639 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1640 "VALUE=\"sharing\">\n");
1641 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1642 "VALUE=\"add\">\n");
1643 wprintf("<input type=\"submit\" "
1644 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1645 wprintf("</td></tr></form>\n");
1649 wprintf("</table>\n");
1650 wprintf("</td></tr>"
1651 "</table></CENTER><br />\n"
1652 "<I><B>%s</B><ul><li>", _("Notes:"));
1653 wprintf(_("When sharing a room, "
1654 "it must be shared from both ends. Adding a node to "
1655 "the 'shared' list sends messages out, but in order to"
1656 " receive messages, the other nodes must be configured"
1657 " to send messages out to your system as well. "
1658 "<li>If the remote room name is blank, it is assumed "
1659 "that the room name is identical on the remote node."
1660 "<li>If the remote room name is different, the remote "
1661 "node must also configure the name of the room here."
1668 /* Mailing list management */
1669 if (!strcmp(tab, "listserv")) {
1670 room_states RoomFlags;
1671 wprintf("<div class=\"tabcontent\">");
1673 wprintf("<br /><center>"
1674 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1675 "<tr><td VALIGN=TOP>");
1677 wprintf(_("<i>The contents of this room are being "
1678 "mailed <b>as individual messages</b> "
1679 "to the following list recipients:"
1680 "</i><br /><br />\n"));
1683 serv_getln(buf, sizeof buf);
1684 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1685 extract_token(cmd, buf, 0, '|', sizeof cmd);
1686 if (!strcasecmp(cmd, "listrecp")) {
1687 extract_token(recp, buf, 1, '|', sizeof recp);
1690 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1693 wprintf(_("(remove)"));
1694 wprintf("</A><br />");
1697 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1698 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1699 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1700 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1701 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1702 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1703 wprintf("</form>\n");
1705 wprintf("</td><td VALIGN=TOP>\n");
1707 wprintf(_("<i>The contents of this room are being "
1708 "mailed <b>in digest form</b> "
1709 "to the following list recipients:"
1710 "</i><br /><br />\n"));
1713 serv_getln(buf, sizeof buf);
1714 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1715 extract_token(cmd, buf, 0, '|', sizeof cmd);
1716 if (!strcasecmp(cmd, "digestrecp")) {
1717 extract_token(recp, buf, 1, '|', sizeof recp);
1720 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1724 wprintf(_("(remove)"));
1725 wprintf("</A><br />");
1728 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1729 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1730 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1731 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1732 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1733 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1734 wprintf("</form>\n");
1736 wprintf("</td></tr></table>\n");
1738 /** Pop open an address book -- begin **/
1739 wprintf("<div align=right>"
1740 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1742 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1747 _("Add recipients from Contacts or other address books"),
1748 _("Add recipients from Contacts or other address books")
1750 /* Pop open an address book -- end **/
1752 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1754 get_roomflags (&RoomFlags);
1756 /* Self Service subscription? */
1757 wprintf("<table><tr><td>\n");
1758 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1759 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1760 " <tr><td colspan=\"2\">\n",
1761 (is_selflist(&RoomFlags))?"checked":"");
1762 wprintf(_("The URL for subscribe/unsubscribe is: "));
1763 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1764 (is_https ? "https" : "http"),
1766 /* Public posting? */
1767 wprintf("<tr><td>");
1768 wprintf(_("Allow non-subscribers to mail to this room."));
1769 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1770 (is_publiclist(&RoomFlags))?"checked":"");
1772 /* Moderated List? */
1773 wprintf("<tr><td>");
1774 wprintf(_("Room post publication needs Aide permission."));
1775 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1776 (is_moderatedlist(&RoomFlags))?"checked":"");
1779 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1780 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1781 wprintf("</table></form>");
1784 wprintf("</CENTER>\n");
1789 /* Configuration of The Dreaded Auto-Purger */
1790 if (!strcmp(tab, "expire")) {
1791 wprintf("<div class=\"tabcontent\">");
1793 serv_puts("GPEX room");
1794 serv_getln(buf, sizeof buf);
1795 if (!strncmp(buf, "550", 3)) {
1796 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1797 _("Higher access is required to access this function.")
1800 else if (buf[0] != '2') {
1801 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1804 roompolicy = extract_int(&buf[4], 0);
1805 roomvalue = extract_int(&buf[4], 1);
1807 serv_puts("GPEX floor");
1808 serv_getln(buf, sizeof buf);
1809 if (buf[0] == '2') {
1810 floorpolicy = extract_int(&buf[4], 0);
1811 floorvalue = extract_int(&buf[4], 1);
1814 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1815 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1816 wprintf("<table border=0 cellspacing=5>\n");
1817 wprintf("<tr><td>");
1818 wprintf(_("Message expire policy for this room"));
1820 escputs(WC->wc_roomname);
1821 wprintf(")</td><td>");
1822 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1823 ((roompolicy == 0) ? "CHECKED" : "") );
1824 wprintf(_("Use the default policy for this floor"));
1825 wprintf("<br />\n");
1826 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1827 ((roompolicy == 1) ? "CHECKED" : "") );
1828 wprintf(_("Never automatically expire messages"));
1829 wprintf("<br />\n");
1830 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1831 ((roompolicy == 2) ? "CHECKED" : "") );
1832 wprintf(_("Expire by message count"));
1833 wprintf("<br />\n");
1834 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1835 ((roompolicy == 3) ? "CHECKED" : "") );
1836 wprintf(_("Expire by message age"));
1838 wprintf(_("Number of messages or days: "));
1839 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1840 wprintf("</td></tr>\n");
1842 if (WC->axlevel >= 6) {
1843 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1844 wprintf("<tr><td>");
1845 wprintf(_("Message expire policy for this floor"));
1847 escputs(floorlist[WC->wc_floor]);
1848 wprintf(")</td><td>");
1849 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1850 ((floorpolicy == 0) ? "CHECKED" : "") );
1851 wprintf(_("Use the system default"));
1852 wprintf("<br />\n");
1853 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1854 ((floorpolicy == 1) ? "CHECKED" : "") );
1855 wprintf(_("Never automatically expire messages"));
1856 wprintf("<br />\n");
1857 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1858 ((floorpolicy == 2) ? "CHECKED" : "") );
1859 wprintf(_("Expire by message count"));
1860 wprintf("<br />\n");
1861 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1862 ((floorpolicy == 3) ? "CHECKED" : "") );
1863 wprintf(_("Expire by message age"));
1865 wprintf(_("Number of messages or days: "));
1866 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1870 wprintf("<CENTER>\n");
1871 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1872 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1874 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1875 wprintf("</CENTER></td><tr>\n");
1877 wprintf("</table>\n"
1878 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1886 /* Access controls */
1887 if (!strcmp(tab, "access")) {
1888 wprintf("<div class=\"tabcontent\">");
1893 /* Fetch messages from remote locations */
1894 if (!strcmp(tab, "feeds")) {
1895 wprintf("<div class=\"tabcontent\">");
1898 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1899 wprintf("</i><br />\n");
1901 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1902 "<tr class=\"even\"><th>");
1903 wprintf(_("Remote host"));
1904 wprintf("</th><th>");
1905 wprintf(_("User name"));
1906 wprintf("</th><th>");
1907 wprintf(_("Password"));
1908 wprintf("</th><th>");
1909 wprintf(_("Keep messages on server?"));
1910 wprintf("</th><th>");
1911 wprintf(_("Interval"));
1912 wprintf("</th><th> </th></tr>");
1915 serv_getln(buf, sizeof buf);
1917 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1918 extract_token(cmd, buf, 0, '|', sizeof cmd);
1919 if (!strcasecmp(cmd, "pop3client")) {
1920 safestrncpy(recp, &buf[11], sizeof recp);
1923 wprintf("<tr class=\"%s\">",
1924 (bg ? "even" : "odd")
1928 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1933 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1937 wprintf("<td>*****</td>"); /* Don't show the password */
1939 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1941 wprintf("<td>%ld</td>", extract_long(buf, 5)); // Fetching interval
1943 wprintf("<td class=\"button_link\">");
1944 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1947 wprintf(_("(remove)"));
1948 wprintf("</a></td>");
1954 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1956 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1957 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1958 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1960 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1963 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1966 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1969 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1972 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
1975 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1976 wprintf("</td></tr>");
1977 wprintf("</form></table>\n");
1982 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1983 wprintf("</i><br />\n");
1985 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1986 "<tr class=\"even\"><th>");
1987 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1988 wprintf(_("Feed URL"));
1989 wprintf("</th><th>");
1990 wprintf("</th></tr>");
1993 serv_getln(buf, sizeof buf);
1995 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1996 extract_token(cmd, buf, 0, '|', sizeof cmd);
1997 if (!strcasecmp(cmd, "rssclient")) {
1998 safestrncpy(recp, &buf[10], sizeof recp);
2001 wprintf("<tr class=\"%s\">",
2002 (bg ? "even" : "odd")
2006 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2010 wprintf("<td class=\"button_link\">");
2011 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=rssclient|");
2014 wprintf(_("(remove)"));
2015 wprintf("</a></td>");
2021 wprintf("<form method=\"POST\" action=\"netedit\">\n"
2023 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2024 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2025 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2027 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2028 "maxlength=\"256\" name=\"line_pop3host\">\n");
2031 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2032 wprintf("</td></tr>");
2033 wprintf("</form></table>\n");
2039 /* end content of whatever tab is open now */
2040 wprintf("</div>\n");
2042 address_book_popup();
2048 * Toggle self-service list subscription
2050 void toggle_self_service(void) {
2051 room_states RoomFlags;
2053 get_roomflags (&RoomFlags);
2055 if (yesbstr("QR2_SelfList"))
2056 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2058 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2060 if (yesbstr("QR2_SMTP_PUBLIC"))
2061 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2063 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2065 if (yesbstr("QR2_Moderated"))
2066 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2068 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2069 if (yesbstr("QR2_SubsOnly"))
2070 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2072 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2074 set_roomflags (&RoomFlags);
2082 * save new parameters for a room
2088 char er_password[10];
2089 char er_dirname[15];
2090 char er_roomaide[26];
2093 int er_listingorder;
2099 if (!havebstr("ok_button")) {
2100 strcpy(WC->ImportantMessage,
2101 _("Cancelled. Changes were not saved."));
2106 serv_getln(buf, sizeof buf);
2108 if (buf[0] != '2') {
2109 strcpy(WC->ImportantMessage, &buf[4]);
2113 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
2114 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
2115 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
2116 er_flags = extract_int(&buf[4], 3);
2117 er_listingorder = extract_int(&buf[4], 5);
2118 er_defaultview = extract_int(&buf[4], 6);
2119 er_flags2 = extract_int(&buf[4], 7);
2121 strcpy(er_roomaide, bstr("er_roomaide"));
2122 if (IsEmptyStr(er_roomaide)) {
2124 serv_getln(buf, sizeof buf);
2125 if (buf[0] != '2') {
2126 strcpy(er_roomaide, "");
2128 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
2131 strcpy(buf, bstr("er_name"));
2133 if (!IsEmptyStr(buf)) {
2134 strcpy(er_name, buf);
2137 strcpy(buf, bstr("er_password"));
2139 if (!IsEmptyStr(buf))
2140 strcpy(er_password, buf);
2142 strcpy(buf, bstr("er_dirname"));
2144 if (!IsEmptyStr(buf))
2145 strcpy(er_dirname, buf);
2147 strcpy(buf, bstr("type"));
2148 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2150 if (!strcmp(buf, "invonly")) {
2151 er_flags |= (QR_PRIVATE);
2153 if (!strcmp(buf, "hidden")) {
2154 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2156 if (!strcmp(buf, "passworded")) {
2157 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2159 if (!strcmp(buf, "personal")) {
2160 er_flags |= QR_MAILBOX;
2162 er_flags &= ~QR_MAILBOX;
2165 if (yesbstr("prefonly")) {
2166 er_flags |= QR_PREFONLY;
2168 er_flags &= ~QR_PREFONLY;
2171 if (yesbstr("readonly")) {
2172 er_flags |= QR_READONLY;
2174 er_flags &= ~QR_READONLY;
2178 if (yesbstr("collabdel")) {
2179 er_flags2 |= QR2_COLLABDEL;
2181 er_flags2 &= ~QR2_COLLABDEL;
2184 if (yesbstr("permanent")) {
2185 er_flags |= QR_PERMANENT;
2187 er_flags &= ~QR_PERMANENT;
2190 if (yesbstr("subjectreq")) {
2191 er_flags2 |= QR2_SUBJECTREQ;
2193 er_flags2 &= ~QR2_SUBJECTREQ;
2196 if (yesbstr("network")) {
2197 er_flags |= QR_NETWORK;
2199 er_flags &= ~QR_NETWORK;
2202 if (yesbstr("directory")) {
2203 er_flags |= QR_DIRECTORY;
2205 er_flags &= ~QR_DIRECTORY;
2208 if (yesbstr("ulallowed")) {
2209 er_flags |= QR_UPLOAD;
2211 er_flags &= ~QR_UPLOAD;
2214 if (yesbstr("dlallowed")) {
2215 er_flags |= QR_DOWNLOAD;
2217 er_flags &= ~QR_DOWNLOAD;
2220 if (yesbstr("visdir")) {
2221 er_flags |= QR_VISDIR;
2223 er_flags &= ~QR_VISDIR;
2226 strcpy(buf, bstr("anon"));
2228 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2229 if (!strcmp(buf, "anononly"))
2230 er_flags |= QR_ANONONLY;
2231 if (!strcmp(buf, "anon2"))
2232 er_flags |= QR_ANONOPT;
2235 if (!strcmp(bstr("bump"), "yes"))
2238 er_floor = ibstr("er_floor");
2240 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2241 er_name, er_password, er_dirname, er_flags, bump, er_floor,
2242 er_listingorder, er_defaultview, er_flags2);
2244 serv_getln(buf, sizeof buf);
2245 if (buf[0] != '2') {
2246 strcpy(WC->ImportantMessage, &buf[4]);
2252 if (!IsEmptyStr(er_roomaide)) {
2253 sprintf(buf, "SETA %s", er_roomaide);
2255 serv_getln(buf, sizeof buf);
2256 if (buf[0] != '2') {
2257 strcpy(WC->ImportantMessage, &buf[4]);
2258 display_main_menu();
2263 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2270 * Display form for Invite, Kick, and show Who Knows a room
2272 void do_invt_kick(void) {
2273 char buf[SIZ], room[SIZ], username[SIZ];
2276 serv_getln(buf, sizeof buf);
2278 if (buf[0] != '2') {
2282 extract_token(room, &buf[4], 0, '|', sizeof room);
2284 strcpy(username, bstr("username"));
2286 if (havebstr("kick_button")) {
2287 sprintf(buf, "KICK %s", username);
2289 serv_getln(buf, sizeof buf);
2291 if (buf[0] != '2') {
2292 strcpy(WC->ImportantMessage, &buf[4]);
2294 sprintf(WC->ImportantMessage,
2295 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2300 if (havebstr("invite_button")) {
2301 sprintf(buf, "INVT %s", username);
2303 serv_getln(buf, sizeof buf);
2305 if (buf[0] != '2') {
2306 strcpy(WC->ImportantMessage, &buf[4]);
2308 sprintf(WC->ImportantMessage,
2309 _("<B><I>User %s invited to room %s.</I></B>\n"),
2320 * Display form for Invite, Kick, and show Who Knows a room
2322 void display_whok(void)
2324 char buf[SIZ], room[SIZ], username[SIZ];
2327 serv_getln(buf, sizeof buf);
2329 if (buf[0] != '2') {
2333 extract_token(room, &buf[4], 0, '|', sizeof room);
2336 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2337 wprintf(_("The users listed below have access to this room. "
2338 "To remove a user from the access list, select the user "
2339 "name from the list and click 'Kick'."));
2340 wprintf("<br /><br />");
2342 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2343 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2344 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2345 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2347 serv_getln(buf, sizeof buf);
2348 if (buf[0] == '1') {
2349 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2350 extract_token(username, buf, 0, '|', sizeof username);
2351 wprintf("<OPTION>");
2356 wprintf("</select><br />\n");
2358 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2359 wprintf("</form></CENTER>\n");
2361 wprintf("</td><td>");
2362 wprintf(_("To grant another user access to this room, enter the "
2363 "user name in the box below and click 'Invite'."));
2364 wprintf("<br /><br />");
2366 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2367 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2368 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2369 wprintf(_("Invite:"));
2371 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2372 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2373 "<input type=\"submit\" value=\"%s\">"
2374 "</form></CENTER>\n", _("Invite"));
2375 /* Pop open an address book -- begin **/
2377 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2379 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2382 _("Users"), _("Users")
2384 /* Pop open an address book -- end **/
2386 wprintf("</td></tr></table>\n");
2387 address_book_popup();
2394 * display the form for entering a new room
2396 void display_entroom(void)
2401 serv_puts("CRE8 0");
2402 serv_getln(buf, sizeof buf);
2404 if (buf[0] != '2') {
2405 strcpy(WC->ImportantMessage, &buf[4]);
2406 display_main_menu();
2410 output_headers(1, 1, 1, 0, 0, 0);
2412 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2413 do_template("beginbox", NULL);
2415 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2416 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2418 wprintf("<table class=\"altern\"> ");
2420 wprintf("<tr class=\"even\"><td>");
2421 wprintf(_("Name of room: "));
2422 wprintf("</td><td>");
2423 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2424 wprintf("</td></tr>");
2426 wprintf("<tr class=\"odd\"><td>");
2427 wprintf(_("Resides on floor: "));
2428 wprintf("</td><td>");
2430 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2431 for (i = 0; i < 128; ++i)
2432 if (!IsEmptyStr(floorlist[i])) {
2433 wprintf("<option ");
2434 wprintf("value=\"%d\">", i);
2435 escputs(floorlist[i]);
2436 wprintf("</option>\n");
2438 wprintf("</select>\n");
2439 wprintf("</td></tr>");
2442 * Our clever little snippet of JavaScript automatically selects
2443 * a public room if the view is set to Bulletin Board or wiki, and
2444 * it selects a mailbox room otherwise. The user can override this,
2445 * of course. We also disable the floor selector for mailboxes.
2447 wprintf("<tr class=\"even\"><td>");
2448 wprintf(_("Default view for room: "));
2449 wprintf("</td><td>");
2450 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2451 " if ( (this.form.er_view.value == 0) "
2452 " || (this.form.er_view.value == 6) ) { "
2453 " this.form.type[0].checked=true; "
2454 " this.form.er_floor.disabled = false; "
2457 " this.form.type[4].checked=true; "
2458 " this.form.er_floor.disabled = true; "
2461 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2462 if (is_view_allowed_as_default(i)) {
2463 wprintf("<option %s value=\"%d\">",
2464 ((i == 0) ? "selected" : ""), i );
2465 escputs(viewdefs[i]);
2466 wprintf("</option>\n");
2469 wprintf("</select>\n");
2470 wprintf("</td></tr>");
2472 wprintf("<tr class=\"even\"><td>");
2473 wprintf(_("Type of room:"));
2474 wprintf("</td><td>");
2475 wprintf("<ul class=\"adminlist\">\n");
2477 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2478 wprintf("CHECKED OnChange=\""
2479 " if (this.form.type[0].checked == true) { "
2480 " this.form.er_floor.disabled = false; "
2483 wprintf(_("Public (automatically appears to everyone)"));
2486 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2487 " if (this.form.type[1].checked == true) { "
2488 " this.form.er_floor.disabled = false; "
2491 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2494 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2495 " if (this.form.type[2].checked == true) { "
2496 " this.form.er_floor.disabled = false; "
2499 wprintf(_("Private - require password: "));
2500 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2503 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2504 " if (this.form.type[3].checked == true) { "
2505 " this.form.er_floor.disabled = false; "
2508 wprintf(_("Private - invitation only"));
2511 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2513 " if (this.form.type[4].checked == true) { "
2514 " this.form.er_floor.disabled = true; "
2517 wprintf(_("Personal (mailbox for you only)"));
2520 wprintf("\n</ul>\n");
2521 wprintf("</td></tr></table>\n");
2523 wprintf("<div class=\"buttons\">\n");
2524 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2526 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2527 wprintf("</div>\n");
2528 wprintf("</form>\n<hr />");
2529 serv_printf("MESG roomaccess");
2530 serv_getln(buf, sizeof buf);
2531 if (buf[0] == '1') {
2535 do_template("endbox", NULL);
2544 * support function for entroom() -- sets the default view
2546 void er_set_default_view(int newview) {
2559 serv_getln(buf, sizeof buf);
2560 if (buf[0] != '2') return;
2562 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2563 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2564 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2565 rm_bits1 = extract_int(&buf[4], 3);
2566 rm_floor = extract_int(&buf[4], 4);
2567 rm_listorder = extract_int(&buf[4], 5);
2568 rm_bits2 = extract_int(&buf[4], 7);
2570 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2571 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2572 rm_listorder, newview, rm_bits2
2574 serv_getln(buf, sizeof buf);
2587 char er_password[SIZ];
2592 if (!havebstr("ok_button")) {
2593 strcpy(WC->ImportantMessage,
2594 _("Cancelled. No new room was created."));
2595 display_main_menu();
2598 strcpy(er_name, bstr("er_name"));
2599 strcpy(er_type, bstr("type"));
2600 strcpy(er_password, bstr("er_password"));
2601 er_floor = ibstr("er_floor");
2602 er_view = ibstr("er_view");
2605 if (!strcmp(er_type, "hidden"))
2607 if (!strcmp(er_type, "passworded"))
2609 if (!strcmp(er_type, "invonly"))
2611 if (!strcmp(er_type, "personal"))
2614 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2615 er_name, er_num_type, er_password, er_floor, 0, er_view);
2617 serv_getln(buf, sizeof buf);
2618 if (buf[0] != '2') {
2619 strcpy(WC->ImportantMessage, &buf[4]);
2620 display_main_menu();
2623 /** TODO: Room created, now udate the left hand icon bar for this user */
2624 burn_folder_cache(0); /* burn the old folder cache */
2628 do_change_view(er_view); /* Now go there */
2633 * \brief display the screen to enter a private room
2635 void display_private(char *rname, int req_pass)
2638 output_headers(1, 1, 1, 0, 0, 0);
2640 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2641 DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF);
2646 wprintf(_("If you know the name of a hidden (guess-name) or "
2647 "passworded room, you can enter that room by typing "
2648 "its name below. Once you gain access to a private "
2649 "room, it will appear in your regular room listings "
2650 "so you don't have to keep returning here."));
2653 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2654 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2656 wprintf("<table class=\"altern\"> "
2657 "<tr class=\"even\"><td>");
2658 wprintf(_("Enter room name:"));
2660 "<input type=\"text\" name=\"gr_name\" "
2661 "value=\"%s\" maxlength=\"128\">\n", rname);
2664 wprintf("</td></tr><tr class=\"odd\"><td>");
2665 wprintf(_("Enter room password:"));
2666 wprintf("</td><td>");
2667 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2669 wprintf("</td></tr></table>\n");
2671 wprintf("<div class=\"buttons\">\n");
2672 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2674 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2678 wprintf("</div></form>\n");
2680 do_template("endbox", NULL);
2686 * \brief goto a private room
2688 void goto_private(void)
2693 if (!havebstr("ok_button")) {
2694 display_main_menu();
2697 strcpy(hold_rm, WC->wc_roomname);
2698 strcpy(buf, "GOTO ");
2699 strcat(buf, bstr("gr_name"));
2701 strcat(buf, bstr("gr_pass"));
2703 serv_getln(buf, sizeof buf);
2705 if (buf[0] == '2') {
2706 smart_goto(bstr("gr_name"));
2709 if (!strncmp(buf, "540", 3)) {
2710 display_private(bstr("gr_name"), 1);
2713 output_headers(1, 1, 1, 0, 0, 0);
2714 wprintf("%s\n", &buf[4]);
2721 * \brief display the screen to zap a room
2723 void display_zap(void)
2725 output_headers(1, 1, 2, 0, 0, 0);
2727 wprintf("<div id=\"banner\">\n");
2729 wprintf(_("Zap (forget/unsubscribe) the current room"));
2731 wprintf("</div>\n");
2733 wprintf("<div id=\"content\" class=\"service\">\n");
2735 wprintf(_("If you select this option, <em>%s</em> will "
2736 "disappear from your room list. Is this what you wish "
2737 "to do?<br />\n"), WC->wc_roomname);
2739 wprintf("<form method=\"POST\" action=\"zap\">\n");
2740 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2741 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2743 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2744 wprintf("</form>\n");
2755 char final_destination[SIZ];
2758 * If the forget-room routine fails for any reason, we fall back
2759 * to the current room; otherwise, we go to the Lobby
2761 strcpy(final_destination, WC->wc_roomname);
2763 if (havebstr("ok_button")) {
2764 serv_printf("GOTO %s", WC->wc_roomname);
2765 serv_getln(buf, sizeof buf);
2766 if (buf[0] == '2') {
2768 serv_getln(buf, sizeof buf);
2769 if (buf[0] == '2') {
2770 strcpy(final_destination, "_BASEROOM_");
2774 smart_goto(final_destination);
2780 * \brief Delete the current room
2782 void delete_room(void)
2787 serv_puts("KILL 1");
2788 serv_getln(buf, sizeof buf);
2789 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2790 if (buf[0] != '2') {
2791 strcpy(WC->ImportantMessage, &buf[4]);
2792 display_main_menu();
2795 smart_goto("_BASEROOM_");
2802 * \brief Perform changes to a room's network configuration
2804 void netedit(void) {
2813 // TODO: do line dynamic!
2814 if (havebstr("line_pop3host")) {
2815 strcpy(line, bstr("prefix"));
2816 strcat(line, bstr("line_pop3host"));
2818 strcat(line, bstr("line_pop3user"));
2820 strcat(line, bstr("line_pop3pass"));
2822 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2824 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2825 strcat(line, bstr("suffix"));
2827 else if (havebstr("line")) {
2828 strcpy(line, bstr("prefix"));
2829 strcat(line, bstr("line"));
2830 strcat(line, bstr("suffix"));
2845 serv_getln(buf, sizeof buf);
2846 if (buf[0] != '1') {
2852 /** This loop works for add *or* remove. Spiffy, eh? */
2853 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2854 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2855 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2856 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2857 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2858 if ( (strcasecmp(cmpa0, cmpb0))
2859 || (strcasecmp(cmpa1, cmpb1)) ) {
2860 fprintf(fp, "%s\n", buf);
2866 serv_getln(buf, sizeof buf);
2867 if (buf[0] != '4') {
2873 while (fgets(buf, sizeof buf, fp) != NULL) {
2874 buf[strlen(buf)-1] = 0;
2878 if (havebstr("add_button")) {
2879 num_addrs = num_tokens(bstr("line"), ',');
2880 if (num_addrs < 2) {
2881 /* just adding one node or address */
2885 /* adding multiple addresses separated by commas */
2886 for (i=0; i<num_addrs; ++i) {
2887 strcpy(line, bstr("prefix"));
2888 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2891 strcat(line, bstr("suffix"));
2905 * \brief Convert a room name to a folder-ish-looking name.
2906 * \param folder the folderish name
2907 * \param room the room name
2908 * \param floor the floor name
2909 * \param is_mailbox is it a mailbox?
2911 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2916 * For mailboxes, just do it straight...
2919 sprintf(folder, "My folders|%s", room);
2923 * Otherwise, prefix the floor name as a "public folders" moniker
2926 if (floor > MAX_FLOORS) {
2928 sprintf(folder, "%%%%%%|%s", room);
2931 sprintf(folder, "%s|%s", floorlist[floor], room);
2936 * Replace "\" characters with "|" for pseudo-folder-delimiting
2938 len = strlen (folder);
2939 for (i=0; i<len; ++i) {
2940 if (folder[i] == '\\') folder[i] = '|';
2948 * \brief Back end for change_view()
2949 * \param newview set newview???
2951 void do_change_view(int newview) {
2954 serv_printf("VIEW %d", newview);
2955 serv_getln(buf, sizeof buf);
2956 WC->wc_view = newview;
2957 smart_goto(WC->wc_roomname);
2963 * \brief Change the view for this room
2965 void change_view(void) {
2968 view = lbstr("view");
2969 do_change_view(view);
2974 * \brief One big expanded tree list view --- like a folder list
2975 * \param fold the folder to view
2976 * \param max_folders how many folders???
2977 * \param num_floors hom many floors???
2979 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2983 int has_subfolders = 0;
2986 parents = malloc(max_folders * sizeof(int));
2988 /** BEGIN TREE MENU */
2989 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2991 /** include NanoTree */
2992 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2994 /** initialize NanoTree */
2995 wprintf("<script type=\"text/javascript\"> \n"
2996 " showRootNode = false; \n"
2997 " sortNodes = false; \n"
2998 " dragable = false; \n"
3000 " function standardClick(treeNode) { \n"
3003 " var closedGif = 'static/folder_closed.gif'; \n"
3004 " var openGif = 'static/folder_open.gif'; \n"
3006 " rootNode = new TreeNode(1, 'root node - hide'); \n"
3010 for (i=0; i<max_folders; ++i) {
3013 if ((i+1) < max_folders) {
3015 len = strlen(fold[i].name);
3016 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
3017 && (fold[i+1].name[len] == '|') ) {
3022 levels = num_tokens(fold[i].name, '|');
3023 parents[levels] = i;
3025 wprintf("var node%d = new TreeNode(%d, '", i, i);
3027 if (fold[i].selectable) {
3028 wprintf("<a href=\"dotgoto?room=");
3029 urlescputs(fold[i].room);
3034 wprintf("<span class=\"roomlist_floor\">");
3036 else if (fold[i].hasnewmsgs) {
3037 wprintf("<span class=\"roomlist_new\">");
3040 wprintf("<span class=\"roomlist_old\">");
3042 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3047 if (has_subfolders) {
3048 wprintf("new Array(closedGif, openGif)");
3050 else if (fold[i].view == VIEW_ADDRESSBOOK) {
3051 wprintf("'static/viewcontacts_16x.gif'");
3053 else if (fold[i].view == VIEW_CALENDAR) {
3054 wprintf("'static/calarea_16x.gif'");
3056 else if (fold[i].view == VIEW_CALBRIEF) {
3057 wprintf("'static/calarea_16x.gif'");
3059 else if (fold[i].view == VIEW_TASKS) {
3060 wprintf("'static/taskmanag_16x.gif'");
3062 else if (fold[i].view == VIEW_NOTES) {
3063 wprintf("'static/storenotes_16x.gif'");
3065 else if (fold[i].view == VIEW_MAILBOX) {
3066 wprintf("'static/privatemess_16x.gif'");
3069 wprintf("'static/chatrooms_16x.gif'");
3072 urlescputs(fold[i].name);
3076 wprintf("rootNode.addChild(node%d);\n", i);
3079 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3083 wprintf("container = document.getElementById('roomlist_div'); \n"
3089 /** END TREE MENU */
3093 * \brief Boxes and rooms and lists ... oh my!
3094 * \param fold the folder to view
3095 * \param max_folders how many folders???
3096 * \param num_floors hom many floors???
3098 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3100 char floor_name[256];
3101 char old_floor_name[256];
3102 int levels, oldlevels;
3105 static int columns = 3;
3106 int boxes_per_column = 0;
3107 int current_column = 0;
3110 strcpy(floor_name, "");
3111 strcpy(old_floor_name, "");
3114 while (nf % columns != 0) ++nf;
3115 boxes_per_column = (nf / columns);
3116 if (boxes_per_column < 1) boxes_per_column = 1;
3118 /** Outer table (for columnization) */
3119 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3120 "<tr><td valign=top>");
3124 for (i=0; i<max_folders; ++i) {
3126 levels = num_tokens(fold[i].name, '|');
3127 extract_token(floor_name, fold[i].name, 0,
3128 '|', sizeof floor_name);
3130 if ( (strcasecmp(floor_name, old_floor_name))
3131 && (!IsEmptyStr(old_floor_name)) ) {
3133 do_template("endbox", NULL);
3137 if ((num_boxes % boxes_per_column) == 0) {
3139 if (current_column < columns) {
3140 wprintf("</td><td valign=top>\n");
3144 strcpy(old_floor_name, floor_name);
3149 Buf = NewStrBufPlain(floor_name, -1);
3150 DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF);
3159 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3160 if (fold[i].selectable) {
3161 wprintf("<a href=\"dotgoto?room=");
3162 urlescputs(fold[i].room);
3168 if (fold[i].hasnewmsgs) {
3169 wprintf("<span class=\"roomlist_new\">");
3172 wprintf("<span class=\"roomlist_old\">");
3174 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3177 if (fold[i].selectable) {
3183 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3184 wprintf(" (INBOX)");
3186 wprintf("<br />\n");
3189 /** End the final inner box */
3190 do_template("endbox", NULL);
3192 wprintf("</td></tr></table>\n");
3196 * \brief print a floor div???
3197 * \param which_floordiv name of the floordiv???
3199 void set_floordiv_expanded(void) {
3200 struct wcsession *WCC = WC;
3203 FloorDiv = NewStrBuf();
3204 StrBufAppendBuf(FloorDiv, WCC->UrlFragment1, 0);
3205 set_preference("floordiv_expanded", FloorDiv, 1);
3206 WCC->floordiv_expanded = FloorDiv;
3210 * \brief view the iconbar
3211 * \param fold the folder to view
3212 * \param max_folders how many folders???
3213 * \param num_floors hom many floors???
3215 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3217 char floor_name[256];
3218 char old_floor_name[256];
3219 char floordivtitle[256];
3220 char floordiv_id[32];
3221 int levels, oldlevels;
3223 int num_drop_targets = 0;
3226 strcpy(floor_name, "");
3227 strcpy(old_floor_name, "");
3231 for (i=0; i<max_folders; ++i) {
3233 levels = num_tokens(fold[i].name, '|');
3234 extract_token(floor_name, fold[i].name, 0,
3235 '|', sizeof floor_name);
3237 if ( (strcasecmp(floor_name, old_floor_name))
3238 && (!IsEmptyStr(old_floor_name)) ) {
3239 /** End inner box */
3241 wprintf("</div>\n"); /** floordiv */
3243 strcpy(old_floor_name, floor_name);
3247 stresc(floordivtitle, 256, floor_name, 0, 0);
3248 sprintf(floordiv_id, "floordiv%d", i);
3249 wprintf("<span class=\"ib_roomlist_floor\" "
3250 "onClick=\"expand_floor('%s')\">"
3251 "%s</span><br>\n", floordiv_id, floordivtitle);
3252 wprintf("<div id=\"%s\" style=\"display:%s\">",
3254 (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
3261 wprintf("<div id=\"roomdiv%d\">", i);
3263 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3265 /** choose the icon */
3266 if (fold[i].view == VIEW_ADDRESSBOOK) {
3267 icon = "viewcontacts_16x.gif" ;
3269 else if (fold[i].view == VIEW_CALENDAR) {
3270 icon = "calarea_16x.gif" ;
3272 else if (fold[i].view == VIEW_CALBRIEF) {
3273 icon = "calarea_16x.gif" ;
3275 else if (fold[i].view == VIEW_TASKS) {
3276 icon = "taskmanag_16x.gif" ;
3278 else if (fold[i].view == VIEW_NOTES) {
3279 icon = "storenotes_16x.gif" ;
3281 else if (fold[i].view == VIEW_MAILBOX) {
3282 icon = "privatemess_16x.gif" ;
3285 icon = "chatrooms_16x.gif" ;
3288 if (fold[i].selectable) {
3289 wprintf("<a href=\"dotgoto?room=");
3290 urlescputs(fold[i].room);
3292 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3297 if (fold[i].hasnewmsgs) {
3298 wprintf("<span class=\"ib_roomlist_new\">");
3301 wprintf("<span class=\"ib_roomlist_old\">");
3303 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3305 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3306 wprintf(" (INBOX)");
3309 if (fold[i].selectable) {
3316 wprintf("</div>\n"); /** roomdiv */
3319 wprintf("</div>\n"); /** floordiv */
3322 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3323 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3325 num_drop_targets = 0;
3327 for (i=0; i<max_folders; ++i) {
3328 levels = num_tokens(fold[i].name, '|');
3330 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3331 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3332 jsescputs(fold[i].room);
3338 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3339 if ((ChrPtr(WC->floordiv_expanded)[0] != '\0')&&
3340 (ChrPtr(WC->floordiv_expanded)[1] != '\0')){
3341 wprintf("which_div_expanded = '%s';\n", ChrPtr(WC->floordiv_expanded));
3345 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3351 * \brief Burn the cached folder list.
3352 * \param age How old the cahce needs to be before we burn it.
3355 void burn_folder_cache(time_t age)
3357 /** If our cached folder list is very old, burn it. */
3358 if (WC->cache_fold != NULL) {
3359 if ((time(NULL) - WC->cache_timestamp) > age) {
3360 free(WC->cache_fold);
3361 WC->cache_fold = NULL;
3370 * \brief Show the room list.
3371 * (only should get called by
3372 * knrooms() because that's where output_headers() is called from)
3373 * \param viewpref the view preferences???
3376 void list_all_rooms_by_floor(const char *viewpref) {
3379 struct folder *fold = NULL;
3381 int max_folders = 0;
3382 int alloc_folders = 0;
3386 int ShowEmptyFloors;
3389 int num_floors = 1; /** add an extra one for private folders */
3392 /** If our cached folder list is very old, burn it. */
3393 burn_folder_cache(300);
3395 /** Can we do the iconbar roomlist from cache? */
3396 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3397 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3401 /** Grab the floor table so we know how to build the list... */
3404 /** Start with the mailboxes */
3407 fold = malloc(sizeof(struct folder));
3408 memset(fold, 0, sizeof(struct folder));
3409 strcpy(fold[0].name, "My folders");
3410 fold[0].is_mailbox = 1;
3412 /** Then add floors */
3414 serv_getln(buf, sizeof buf);
3415 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3416 if (max_folders >= alloc_folders) {
3417 alloc_folders = max_folders + 100;
3418 fold = realloc(fold,
3419 alloc_folders * sizeof(struct folder));
3421 memset(&fold[max_folders], 0, sizeof(struct folder));
3422 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3423 extract_token(buf3, buf, 0, '|', SIZ);
3424 fold[max_folders].floor = atol (buf3);
3429 for (i=0; i<num_floors; i++)
3430 if (IDMax < fold[i].floor)
3431 IDMax = fold[i].floor;
3432 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3433 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3434 for (i=0; i<num_floors; i++)
3435 floor_mapping[fold[i].floor]=i;
3437 /** refresh the messages index for this room */
3438 // serv_puts("GOTO ");
3439 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3440 /** Now add rooms */
3442 serv_getln(buf, sizeof buf);
3443 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3444 if (max_folders >= alloc_folders) {
3445 alloc_folders = max_folders + 100;
3446 fold = realloc(fold,
3447 alloc_folders * sizeof(struct folder));
3449 memset(&fold[max_folders], 0, sizeof(struct folder));
3450 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3451 ra_flags = extract_int(buf, 5);
3452 flags = extract_int(buf, 1);
3453 fold[max_folders].floor = extract_int(buf, 2);
3454 fold[max_folders].hasnewmsgs =
3455 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3456 if (flags & QR_MAILBOX) {
3457 fold[max_folders].is_mailbox = 1;
3459 fold[max_folders].view = extract_int(buf, 6);
3460 room_to_folder(fold[max_folders].name,
3461 fold[max_folders].room,
3462 fold[max_folders].floor,
3463 fold[max_folders].is_mailbox);
3464 fold[max_folders].selectable = 1;
3465 /* Increase the room count for the associtaed floor */
3466 if (fold[max_folders].is_mailbox) {
3467 fold[0].num_rooms++;
3470 i = floor_mapping[fold[max_folders].floor];
3471 fold[i].num_rooms++;
3477 * Remove any floors that don't have rooms
3479 get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
3480 if (ShowEmptyFloors)
3482 for (i=0; i<num_floors; i++)
3484 if (fold[i].num_rooms == 0) {
3485 for (j=i; j<max_folders; j++) {
3486 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3495 /** Bubble-sort the folder list */
3496 for (i=0; i<max_folders; ++i) {
3497 for (j=0; j<(max_folders-1)-i; ++j) {
3498 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3499 swap = strcasecmp(fold[j].name, fold[j+1].name);
3502 if ( (fold[j+1].is_mailbox)
3503 && (!fold[j].is_mailbox)) {
3511 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3512 memcpy(&fold[j], &fold[j+1],
3513 sizeof(struct folder));
3514 memcpy(&fold[j+1], &ftmp,
3515 sizeof(struct folder));
3521 if (!strcasecmp(viewpref, "folders")) {
3522 do_folder_view(fold, max_folders, num_floors);
3524 else if (!strcasecmp(viewpref, "hackish_view")) {
3525 for (i=0; i<max_folders; ++i) {
3526 escputs(fold[i].name);
3527 wprintf("<br />\n");
3530 else if (!strcasecmp(viewpref, "iconbar")) {
3531 do_iconbar_view(fold, max_folders, num_floors);
3534 do_rooms_view(fold, max_folders, num_floors);
3537 /* Don't free the folder list ... cache it for future use! */
3538 if (WC->cache_fold != NULL) {
3539 free(WC->cache_fold);
3541 WC->cache_fold = fold;
3542 WC->cache_max_folders = max_folders;
3543 WC->cache_num_floors = num_floors;
3544 WC->cache_timestamp = time(NULL);
3545 free(floor_mapping);
3550 * \brief Do either a known rooms list or a folders list, depending on the
3555 StrBuf *ListView = NULL;
3557 output_headers(1, 1, 2, 0, 0, 0);
3559 /** Determine whether the user is trying to change views */
3560 if (havebstr("view")) {
3561 ListView = NewStrBufPlain(bstr("view"), -1);
3562 set_preference("roomlistview", ListView, 1);
3564 /** Sanitize the input so its safe */
3565 if(!get_preference("roomlistview", &ListView) ||
3566 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3567 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3569 if (ListView == NULL) {
3570 ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1);
3571 set_preference("roomlistview", ListView, 0);
3574 StrBufPrintf(ListView, "rooms");
3580 wprintf("<div id=\"banner\">\n");
3581 wprintf("<div class=\"room_banner\">");
3583 if (!strcasecmp(ChrPtr(ListView), "rooms")) {
3584 wprintf(_("Room list"));
3586 else if (!strcasecmp(ChrPtr(ListView), "folders")) {
3587 wprintf(_("Folder list"));
3589 else if (!strcasecmp(ChrPtr(ListView), "table")) {
3590 wprintf(_("Room list"));
3592 wprintf("</h1></div>\n");
3594 /** offer the ability to switch views */
3595 wprintf("<ul class=\"room_actions\">\n");
3596 wprintf("<li class=\"start_page\">");
3597 offer_start_page(NULL, 0, NULL, NULL, CTX_NONE);
3599 wprintf("<li><form name=\"roomlistomatic\">\n"
3600 "<select name=\"newview\" size=\"1\" "
3601 "OnChange=\"location.href=roomlistomatic.newview.options"
3602 "[selectedIndex].value\">\n");
3604 wprintf("<option %s value=\"knrooms&view=rooms\">"
3607 ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" )
3610 wprintf("<option %s value=\"knrooms&view=folders\">"
3611 "View as folder list"
3613 ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" )
3616 wprintf("</select>");
3617 wprintf("</form></li>");
3618 wprintf("</ul></div>\n");
3620 wprintf("<div id=\"content\" class=\"service\">\n");
3622 /** Display the room list in the user's preferred format */
3623 list_all_rooms_by_floor(ChrPtr(ListView));
3630 * \brief Set the message expire policy for this room and/or floor
3632 void set_room_policy(void) {
3635 if (!havebstr("ok_button")) {
3636 strcpy(WC->ImportantMessage,
3637 _("Cancelled. Changes were not saved."));
3642 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3643 serv_getln(buf, sizeof buf);
3644 strcpy(WC->ImportantMessage, &buf[4]);
3646 if (WC->axlevel >= 6) {
3647 strcat(WC->ImportantMessage, "<br />\n");
3648 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3649 serv_getln(buf, sizeof buf);
3650 strcat(WC->ImportantMessage, &buf[4]);
3657 void tmplput_RoomName(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
3660 tmp = NewStrBufPlain(WC->wc_roomname, -1);;
3661 StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, tmp, 0);
3664 void _gotonext(void) { slrp_highest(); gotonext(); }
3665 void dotskip(void) {smart_goto(bstr("room"));}
3666 void _display_private(void) { display_private("", 0); }
3667 void dotgoto(void) {
3668 if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3671 smart_goto(bstr("room"));
3674 void tmplput_roombanner(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
3676 wprintf("<div id=\"banner\">\n");
3677 embed_room_banner(NULL, navbar_default);
3678 wprintf("</div>\n");
3682 void tmplput_ungoto(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
3684 struct wcsession *WCC = WC;
3687 (!IsEmptyStr(WCC->ugname)))
3688 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3692 int ConditionalHaveUngoto(WCTemplateToken *Tokens, void *Context, int ContextType)
3694 struct wcsession *WCC = WC;
3696 return ((WCC!=NULL) &&
3697 (!IsEmptyStr(WCC->ugname)) &&
3698 (strcasecmp(WCC->ugname, WCC->wc_roomname) == 0));
3704 int ConditionalRoomHas_QR_PERMANENT(WCTemplateToken *Tokens, void *Context, int ContextType)
3706 struct wcsession *WCC = WC;
3708 return ((WCC!=NULL) &&
3709 ((WCC->room_flags & QR_PERMANENT) != 0));
3712 int ConditionalRoomHas_QR_INUSE(WCTemplateToken *Tokens, void *Context, int ContextType)
3714 struct wcsession *WCC = WC;
3716 return ((WCC!=NULL) &&
3717 ((WCC->room_flags & QR_INUSE) != 0));
3720 int ConditionalRoomHas_QR_PRIVATE(WCTemplateToken *Tokens, void *Context, int ContextType)
3722 struct wcsession *WCC = WC;
3724 return ((WCC!=NULL) &&
3725 ((WCC->room_flags & QR_PRIVATE) != 0));
3728 int ConditionalRoomHas_QR_PASSWORDED(WCTemplateToken *Tokens, void *Context, int ContextType)
3730 struct wcsession *WCC = WC;
3732 return ((WCC!=NULL) &&
3733 ((WCC->room_flags & QR_PASSWORDED) != 0));
3736 int ConditionalRoomHas_QR_GUESSNAME(WCTemplateToken *Tokens, void *Context, int ContextType)
3738 struct wcsession *WCC = WC;
3740 return ((WCC!=NULL) &&
3741 ((WCC->room_flags & QR_GUESSNAME) != 0));
3744 int ConditionalRoomHas_QR_DIRECTORY(WCTemplateToken *Tokens, void *Context, int ContextType)
3746 struct wcsession *WCC = WC;
3748 return ((WCC!=NULL) &&
3749 ((WCC->room_flags & QR_DIRECTORY) != 0));
3752 int ConditionalRoomHas_QR_UPLOAD(WCTemplateToken *Tokens, void *Context, int ContextType)
3754 struct wcsession *WCC = WC;
3756 return ((WCC!=NULL) &&
3757 ((WCC->room_flags & QR_UPLOAD) != 0));
3760 int ConditionalRoomHas_QR_DOWNLOAD(WCTemplateToken *Tokens, void *Context, int ContextType)
3762 struct wcsession *WCC = WC;
3764 return ((WCC!=NULL) &&
3765 ((WCC->room_flags & QR_DOWNLOAD) != 0));
3768 int ConditionalRoomHas_QR_VISDIR(WCTemplateToken *Tokens, void *Context, int ContextType)
3770 struct wcsession *WCC = WC;
3772 return ((WCC!=NULL) &&
3773 ((WCC->room_flags & QR_VISDIR) != 0));
3776 int ConditionalRoomHas_QR_ANONONLY(WCTemplateToken *Tokens, void *Context, int ContextType)
3778 struct wcsession *WCC = WC;
3780 return ((WCC!=NULL) &&
3781 ((WCC->room_flags & QR_ANONONLY) != 0));
3784 int ConditionalRoomHas_QR_ANONOPT(WCTemplateToken *Tokens, void *Context, int ContextType)
3786 struct wcsession *WCC = WC;
3788 return ((WCC!=NULL) &&
3789 ((WCC->room_flags & QR_ANONOPT) != 0));
3792 int ConditionalRoomHas_QR_NETWORK(WCTemplateToken *Tokens, void *Context, int ContextType)
3794 struct wcsession *WCC = WC;
3796 return ((WCC!=NULL) &&
3797 ((WCC->room_flags & QR_NETWORK) != 0));
3800 int ConditionalRoomHas_QR_PREFONLY(WCTemplateToken *Tokens, void *Context, int ContextType)
3802 struct wcsession *WCC = WC;
3804 return ((WCC!=NULL) &&
3805 ((WCC->room_flags & QR_PREFONLY) != 0));
3808 int ConditionalRoomHas_QR_READONLY(WCTemplateToken *Tokens, void *Context, int ContextType)
3810 struct wcsession *WCC = WC;
3812 return ((WCC!=NULL) &&
3813 ((WCC->room_flags & QR_READONLY) != 0));
3816 int ConditionalRoomHas_QR_MAILBOX(WCTemplateToken *Tokens, void *Context, int ContextType)
3818 struct wcsession *WCC = WC;
3820 return ((WCC!=NULL) &&
3821 ((WCC->room_flags & QR_MAILBOX) != 0));
3829 int ConditionalHaveRoomeditRights(WCTemplateToken *Tokens, void *Context, int ContextType)
3831 struct wcsession *WCC = WC;
3833 return ( (WCC!= NULL) &&
3834 ((WCC->axlevel >= 6) ||
3835 (WCC->is_room_aide) ||
3836 (WCC->is_mailbox) ));
3843 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, 0);
3845 WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
3846 WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, 0);
3847 WebcitAddUrlHandler(HKEY("skip"), gotonext, 0);
3848 WebcitAddUrlHandler(HKEY("ungoto"), ungoto, 0);
3849 WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, 0);
3850 WebcitAddUrlHandler(HKEY("dotskip"), dotskip, 0);
3851 WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
3852 WebcitAddUrlHandler(HKEY("goto_private"), goto_private, 0);
3853 WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
3854 WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
3855 WebcitAddUrlHandler(HKEY("zap"), zap, 0);
3856 WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
3857 WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
3858 WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
3859 WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
3860 WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
3861 WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
3862 WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
3863 WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
3864 WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
3865 WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
3866 WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);
3867 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, 0);
3869 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PERMANENT"), 0, ConditionalRoomHas_QR_PERMANENT, CTX_NONE);
3870 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_INUSE"), 0, ConditionalRoomHas_QR_INUSE, CTX_NONE);
3871 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PRIVATE"), 0, ConditionalRoomHas_QR_PRIVATE, CTX_NONE);
3872 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PASSWORDED"), 0, ConditionalRoomHas_QR_PASSWORDED, CTX_NONE);
3873 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_GUESSNAME"), 0, ConditionalRoomHas_QR_GUESSNAME, CTX_NONE);
3874 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DIRECTORY"), 0, ConditionalRoomHas_QR_DIRECTORY, CTX_NONE);
3875 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_UPLOAD"), 0, ConditionalRoomHas_QR_UPLOAD, CTX_NONE);
3876 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DOWNLOAD"), 0, ConditionalRoomHas_QR_DOWNLOAD, CTX_NONE);
3877 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_VISIDIR"), 0, ConditionalRoomHas_QR_VISDIR, CTX_NONE);
3878 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONONLY"), 0, ConditionalRoomHas_QR_ANONONLY, CTX_NONE);
3879 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONOPT"), 0, ConditionalRoomHas_QR_ANONOPT, CTX_NONE);
3880 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_NETWORK"), 0, ConditionalRoomHas_QR_NETWORK, CTX_NONE);
3881 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PREFONLY"), 0, ConditionalRoomHas_QR_PREFONLY, CTX_NONE);
3882 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_READONLY"), 0, ConditionalRoomHas_QR_READONLY, CTX_NONE);
3883 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_MAILBOX"), 0, ConditionalRoomHas_QR_MAILBOX, CTX_NONE);
3885 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3886 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3888 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, 0);