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(wcsession *wcf)
86 while (wcf->march != NULL) {
87 mptr = wcf->march->next;
97 * remove a room from the march list
99 void remove_march(const StrBuf *aaa)
101 struct march *mptr, *mptr2;
103 if (WC->march == NULL)
106 if (!strcasecmp(WC->march->march_name, ChrPtr(aaa))) {
107 mptr = WC->march->next;
113 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
114 if (!strcasecmp(mptr->march_name, ChrPtr(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 WCTemplputParams SubTP;
262 output_headers(1, 1, 1, 0, 0, 0);
263 memset(&SubTP, 0, sizeof(WCTemplputParams));
264 Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
265 SubTP.ContextType = CTX_STRBUF;
267 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
273 wprintf("<br /><br />\n");
274 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
275 do_template("endbox", NULL);
281 * \brief read this room's info file (set v to 1 for verbose mode)
283 void readinfo(StrBuf *Target, WCTemplputParams *TP)
288 int fullinfo_len = 0;
291 serv_getln(buf, sizeof buf);
294 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
295 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
296 strcpy(&fullinfo[fullinfo_len], buf);
297 fullinfo_len += strlen(buf);
301 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
302 strcpy(&briefinfo[50], "...");
304 wprintf("<div class=\"infos\" "
305 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
308 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
309 wprintf("<img class=\"close_infos\" "
310 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
311 "src=\"static/closewindow.gif\" alt=\"%s\">",
326 * \brief Display room banner icon.
327 * The server doesn't actually
328 * need the room name, but we supply it in order to
329 * keep the browser from using a cached icon from
332 void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP)
336 serv_puts("OIMG _roompic_");
337 serv_getln(buf, sizeof buf);
339 wprintf("<img height=\"64px\" src=\"image&name=_roompic_&room=");
340 urlescputs(ChrPtr(WC->wc_roomname));
343 serv_getln(buf, sizeof buf);
345 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
346 wprintf("<img class=\"roompic\" alt=\"\" src=\""
347 "static/viewcontacts_48x.gif"
351 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
352 wprintf("<img class=\"roompic\" alt=\"\" src=\""
353 "static/calarea_48x.gif"
357 else if (WC->wc_view == VIEW_TASKS) {
358 wprintf("<img class=\"roompic\" alt=\"\" src=\""
359 "static/taskmanag_48x.gif"
363 else if (WC->wc_view == VIEW_NOTES) {
364 wprintf("<img class=\"roompic\" alt=\"\" src=\""
365 "static/storenotes_48x.gif"
369 else if (WC->wc_view == VIEW_MAILBOX) {
370 wprintf("<img class=\"roompic\" alt=\"\" src=\""
371 "static/privatemess_48x.gif"
376 wprintf("<img class=\"roompic\" alt=\"\" src=\""
377 "static/chatrooms_48x.gif"
387 * \brief Display the current view and offer an option to change it
389 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
393 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
394 wprintf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
395 wprintf("<label for=\"view_name\">");
396 wprintf(_("View as:"));
398 "<select name=\"newview\" size=\"1\" "
399 "id=\"view_name\" class=\"selectbox\" "
400 "OnChange=\"location.href=viewomatic.newview.options"
401 "[selectedIndex].value\">\n");
403 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
405 * Only offer the views that make sense, given the default
406 * view for the room. For example, don't offer a Calendar
407 * view in a non-Calendar room.
411 || (i == WC->wc_default_view) /**< default */
412 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
413 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
414 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
417 wprintf("<option %s value=\"changeview?view=%d\">",
418 ((i == WC->wc_view) ? "selected" : ""),
420 escputs(viewdefs[i]);
421 wprintf("</option>\n");
424 wprintf("</select></div></form>\n");
429 * \brief Display a search box
431 void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP)
433 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
434 wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
435 wprintf("<label for=\"search_name\">");
436 wprintf(_("Search: "));
437 wprintf("</label><input ");
438 wprintf("%s", serv_info.serv_fulltext_enabled ? "" : "disabled ");
439 wprintf("type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
440 "id=\"search_name\" class=\"inputbox\">\n"
442 wprintf("</div></form>\n");
447 * \brief Embed the room banner
449 * \param got The information returned from a GOTO server command
450 * \param navbar_style Determines which navigation buttons to display
454 void embed_room_banner(char *got, int navbar_style) {
457 char with_files[256];
461 * We need to have the information returned by a GOTO server command.
462 * If it isn't supplied, we fake it by issuing our own GOTO.
465 memset(buf, '0', 20);
467 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
468 serv_getln(buf, sizeof buf);
472 /** The browser needs some information for its own use */
473 wprintf("<script type=\"text/javascript\"> \n"
474 " room_is_trash = %d; \n"
480 * If the user happens to select the "make this my start page" link,
481 * we want it to remember the URL as a "/dotskip" one instead of
482 * a "skip" or "gotonext" or something like that.
484 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
485 ChrPtr(WC->wc_roomname));
487 /** Check for new mail. */
488 WC->new_mail = extract_int(&got[4], 9);
489 WC->wc_view = extract_int(&got[4], 11);
491 /* Is this a directory room and does it contain files and how many? */
492 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
495 serv_getln(buf2, sizeof buf2);
496 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
498 snprintf (with_files, sizeof with_files,
499 "; <a href=\"do_template?template=files\"> %d %s </a>",
501 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
504 strcpy (with_files, "");
506 svprintf(HKEY("NUMMSGS"), WCS_STRING,
507 _("%d new of %d messages%s"),
508 extract_int(&got[4], 1),
509 extract_int(&got[4], 2),
512 svcallback("ROOMPIC", embed_room_graphic);
513 svcallback("ROOMINFO", readinfo);
514 svcallback("VIEWOMATIC", embed_view_o_matic);
515 svcallback("SEARCHOMATIC", embed_search_o_matic);
516 svcallback("START", offer_start_page);
518 do_template("roombanner", NULL);
519 /* roombanner contains this for mobile */
520 if (navbar_style != navbar_none && !WC->is_mobile) {
522 wprintf("<div id=\"navbar\"><ul>");
524 if (navbar_style == navbar_default) wprintf(
525 "<li class=\"ungoto\">"
526 "<a href=\"ungoto\">"
527 "<img src=\"static/ungoto2_24x.gif\" alt=\"\">"
528 "<span class=\"navbar_link\">%s</span></A>"
529 "</li>\n", _("Ungoto")
532 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
534 "<li class=\"newmess\">"
535 "<a href=\"readnew\">"
536 "<img src=\"static/newmess2_24x.gif\" alt=\"\">"
537 "<span class=\"navbar_link\">%s</span></A>"
538 "</li>\n", _("Read new messages")
542 if (navbar_style == navbar_default) {
543 switch(WC->wc_view) {
544 case VIEW_ADDRESSBOOK:
546 "<li class=\"viewcontacts\">"
547 "<a href=\"readfwd\">"
548 "<img src=\"static/viewcontacts_24x.gif\" "
550 "<span class=\"navbar_link\">"
552 "</span></a></li>\n", _("View contacts")
557 "<li class=\"staskday\">"
558 "<a href=\"readfwd?calview=day\">"
559 "<img src=\"static/taskday2_24x.gif\" "
561 "<span class=\"navbar_link\">"
563 "</span></a></li>\n", _("Day view")
566 "<li class=\"monthview\">"
567 "<a href=\"readfwd?calview=month\">"
568 "<img src=\"static/monthview2_24x.gif\" "
570 "<span class=\"navbar_link\">"
572 "</span></a></li>\n", _("Month view")
577 "<li class=\"monthview\">"
578 "<a href=\"readfwd?calview=month\">"
579 "<img src=\"static/monthview2_24x.gif\" "
581 "<span class=\"navbar_link\">"
583 "</span></a></li>\n", _("Calendar list")
588 "<li class=\"taskmanag\">"
589 "<a href=\"readfwd\">"
590 "<img src=\"static/taskmanag_24x.gif\" "
592 "<span class=\"navbar_link\">"
594 "</span></a></li>\n", _("View tasks")
599 "<li class=\"viewnotes\">"
600 "<a href=\"readfwd\">"
601 "<img src=\"static/viewnotes_24x.gif\" "
603 "<span class=\"navbar_link\">"
605 "</span></a></li>\n", _("View notes")
610 "<li class=\"readallmess\">"
611 "<a href=\"readfwd\">"
612 "<img src=\"static/readallmess3_24x.gif\" "
614 "<span class=\"navbar_link\">"
616 "</span></a></li>\n", _("View message list")
621 "<li class=\"readallmess\">"
622 "<a href=\"readfwd\">"
623 "<img src=\"static/readallmess3_24x.gif\" "
625 "<span class=\"navbar_link\">"
627 "</span></a></li>\n", _("Wiki home")
632 "<li class=\"readallmess\">"
633 "<a href=\"readfwd\">"
634 "<img src=\"static/readallmess3_24x.gif\" "
636 "<span class=\"navbar_link\">"
638 "</span></a></li>\n", _("Read all messages")
644 if (navbar_style == navbar_default) {
645 switch(WC->wc_view) {
646 case VIEW_ADDRESSBOOK:
648 "<li class=\"addnewcontact\">"
649 "<a href=\"display_enter\">"
650 "<img src=\"static/addnewcontact_24x.gif\" "
651 "alt=\"\"><span class=\"navbar_link\">"
653 "</span></a></li>\n", _("Add new contact")
658 wprintf("<li class=\"addevent\"><a href=\"display_enter");
659 if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
660 if (havebstr("month")) wprintf("?month=%s", bstr("month"));
661 if (havebstr("day" )) wprintf("?day=%s", bstr("day"));
663 "<img src=\"static/addevent_24x.gif\" "
664 "alt=\"\"><span class=\"navbar_link\">"
666 "</span></a></li>\n", _("Add new event")
671 "<li class=\"newmess\">"
672 "<a href=\"display_enter\">"
673 "<img src=\"static/newmess3_24x.gif\" "
674 "alt=\"\"><span class=\"navbar_link\">"
676 "</span></a></li>\n", _("Add new task")
681 "<li class=\"enternewnote\">"
682 "<a href=\"add_new_note\">"
683 "<img src=\"static/enternewnote_24x.gif\" "
684 "alt=\"\"><span class=\"navbar_link\">"
686 "</span></a></li>\n", _("Add new note")
690 safestrncpy(buf, bstr("page"), sizeof buf);
693 "<li class=\"newmess\">"
694 "<a href=\"display_enter?wikipage=%s\">"
695 "<img src=\"static/newmess3_24x.gif\" "
696 "alt=\"\"><span class=\"navbar_link\">"
698 "</span></a></li>\n", buf, _("Edit this page")
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", _("Write mail")
713 "<li class=\"newmess\">"
714 "<a href=\"display_enter\">"
715 "<img src=\"static/newmess3_24x.gif\" "
716 "alt=\"\"><span class=\"navbar_link\">"
718 "</span></a></li>\n", _("Enter a message")
724 if (navbar_style == navbar_default) wprintf(
725 "<li class=\"skipthisroom\">"
728 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\">"
729 "<span class=\"navbar_link\">%s</span></a>"
731 _("Leave all messages marked as unread, go to next room with unread messages"),
735 if (navbar_style == navbar_default) wprintf(
736 "<li class=\"markngo\">"
737 "<a href=\"gotonext\" "
739 "<img src=\"static/markngo_24x.gif\" alt=\"\">"
740 "<span class=\"navbar_link\">%s</span></a>"
742 _("Mark all messages as read, go to next room with unread messages"),
746 wprintf("</ul></div>\n");
753 * back end routine to take the session to a new room
755 long gotoroom(const StrBuf *gname)
758 static long ls = (-1L);
761 /* store ungoto information */
762 strcpy(WC->ugname, ChrPtr(WC->wc_roomname));
765 /** move to the new room */
766 serv_printf("GOTO %s", ChrPtr(gname));
767 StrBuf_ServGetln(Buf);
768 if (GetServerStatus(Buf, &err) != 2) {
769 serv_puts("GOTO _BASEROOM_");
770 StrBuf_ServGetln(Buf);
771 if (GetServerStatus(Buf, &err) != 2) {
777 if (WC->wc_roomname == NULL)
778 WC->wc_roomname = NewStrBuf();
780 FlushStrBuf(WC->wc_roomname);
782 StrBufExtract_token(WC->wc_roomname, Buf, 0, '|');
783 StrBufCutLeft(WC->wc_roomname, 4);
784 WC->room_flags = StrBufExtract_int(Buf, 4, '|');
785 /* highest_msg_read = extract_int(&buf[4],6);
786 maxmsgnum = extract_int(&buf[4],5);
788 WC->is_mailbox = StrBufExtract_int(Buf, 7, '|');
789 ls = StrBufExtract_long(Buf, 6, '|');
790 WC->wc_floor = StrBufExtract_int(Buf, 10, '|');
791 WC->wc_view = StrBufExtract_int(Buf, 11, '|');
792 WC->wc_default_view = StrBufExtract_int(Buf, 12, '|');
793 WC->wc_is_trash = StrBufExtract_int(Buf, 13, '|');
794 WC->room_flags2 = StrBufExtract_int(Buf, 14, '|');
797 WC->is_room_aide = WC->is_aide;
799 WC->is_room_aide = (char) StrBufExtract_int(Buf, 8, '|');
801 remove_march(WC->wc_roomname);
802 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
811 * \brief Locate the room on the march list which we most want to go to.
813 * is measured given a "weight" of preference based on various factors.
814 * \param desired_floor the room number on the citadel server
815 * \return the roomname
817 char *pop_march(int desired_floor)
819 static char TheRoom[128];
821 int TheOrder = 32767;
824 struct march *mptr = NULL;
826 strcpy(TheRoom, "_BASEROOM_");
827 if (WC->march == NULL)
830 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
832 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
833 weight = weight + 10000;
834 if (mptr->march_floor == desired_floor)
835 weight = weight + 5000;
837 weight = weight + ((128 - (mptr->march_floor)) * 128);
838 weight = weight + (128 - (mptr->march_order));
840 if (weight > TheWeight) {
842 strcpy(TheRoom, mptr->march_name);
843 TheFloor = mptr->march_floor;
844 TheOrder = mptr->march_order;
853 * Goto next room having unread messages.
855 * We want to skip over rooms that the user has already been to, and take the
856 * user back to the lobby when done. The room we end up in is placed in
857 * newroom - which is set to 0 (the lobby) initially.
858 * We start the search in the current room rather than the beginning to prevent
859 * two or more concurrent users from dragging each other back to the same room.
864 struct march *mptr = NULL;
865 struct march *mptr2 = NULL;
871 * First check to see if the march-mode list is already allocated.
872 * If it is, pop the first room off the list and go there.
875 if (WC->march == NULL) {
877 serv_getln(buf, sizeof buf);
879 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
880 if (IsEmptyStr(buf)) {
883 if (ELoop % 100 == 0)
888 extract_token(room_name, buf, 0, '|', sizeof room_name);
889 if (strcasecmp(room_name, ChrPtr(WC->wc_roomname))) {
890 mptr = (struct march *) malloc(sizeof(struct march));
892 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
893 mptr->march_floor = extract_int(buf, 2);
894 mptr->march_order = extract_int(buf, 3);
895 if (WC->march == NULL)
904 * add _BASEROOM_ to the end of the march list, so the user will end up
905 * in the system base room (usually the Lobby>) at the end of the loop
907 mptr = (struct march *) malloc(sizeof(struct march));
909 mptr->march_order = 0;
910 mptr->march_floor = 0;
911 strcpy(mptr->march_name, "_BASEROOM_");
912 if (WC->march == NULL) {
916 while (mptr2->next != NULL)
921 * ...and remove the room we're currently in, so a <G>oto doesn't make us
922 * walk around in circles
924 remove_march(WC->wc_roomname);
926 if (WC->march != NULL) {
927 next_room = NewStrBufPlain(pop_march(-1), -1);/*TODO: migrate march to strbuf */
929 next_room = NewStrBufPlain(HKEY("_BASEROOM_"));
933 smart_goto(next_room);
934 FreeStrBuf(&next_room);
941 void smart_goto(const StrBuf *next_room) {
949 * mark all messages in current room as having been read
951 void slrp_highest(void)
955 serv_puts("SLRP HIGHEST");
956 serv_getln(buf, sizeof buf);
961 * un-goto the previous room
967 if (!strcmp(WC->ugname, "")) {
968 smart_goto(WC->wc_roomname);
971 serv_printf("GOTO %s", WC->ugname);
973 StrBuf_ServGetln(Buf);
974 if (GetServerStatus(Buf, NULL) != 2) {
975 smart_goto(WC->wc_roomname);
979 if (WC->uglsn >= 0L) {
980 serv_printf("SLRP %ld", WC->uglsn);
981 StrBuf_ServGetln(Buf);
984 StrBufAppendBufPlain(Buf, WC->ugname, -1, 0);
985 strcpy(WC->ugname, "");
990 typedef struct __room_states {
1005 * Set/clear/read the "self-service list subscribe" flag for a room
1007 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1008 * returns the new value.
1011 int self_service(int newval) {
1012 int current_value = 0;
1018 int flags, floor, order, view, flags2;
1021 serv_getln(buf, sizeof buf);
1022 if (buf[0] != '2') return(0);
1024 extract_token(name, &buf[4], 0, '|', sizeof name);
1025 extract_token(password, &buf[4], 1, '|', sizeof password);
1026 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1027 flags = extract_int(&buf[4], 3);
1028 floor = extract_int(&buf[4], 4);
1029 order = extract_int(&buf[4], 5);
1030 view = extract_int(&buf[4], 6);
1031 flags2 = extract_int(&buf[4], 7);
1033 if (flags2 & QR2_SELFLIST) {
1041 flags2 = flags2 | QR2_SELFLIST;
1043 else if (newval == 0) {
1044 flags2 = flags2 & ~QR2_SELFLIST;
1047 return(current_value);
1050 if (newval != current_value) {
1051 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1052 name, password, dirname, flags,
1053 floor, order, view, flags2);
1054 serv_getln(buf, sizeof buf);
1061 int is_selflist(room_states *RoomFlags)
1063 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1066 int is_publiclist(room_states *RoomFlags)
1068 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1071 int is_moderatedlist(room_states *RoomFlags)
1073 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1077 * Set/clear/read the "self-service list subscribe" flag for a room
1079 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1080 * returns the new value.
1083 int get_roomflags(room_states *RoomOps)
1088 serv_getln(buf, sizeof buf);
1089 if (buf[0] != '2') return(0);
1091 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1092 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1093 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1094 RoomOps->flags = extract_int(&buf[4], 3);
1095 RoomOps->floor = extract_int(&buf[4], 4);
1096 RoomOps->order = extract_int(&buf[4], 5);
1097 RoomOps->view = extract_int(&buf[4], 6);
1098 RoomOps->flags2 = extract_int(&buf[4], 7);
1102 int set_roomflags(room_states *RoomOps)
1106 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1115 serv_getln(buf, sizeof buf);
1125 * display the form for editing a room
1127 void display_editroom(void)
1132 char remote_room[128];
1134 char er_name[128] = "";
1135 char er_password[10];
1136 char er_dirname[15];
1137 char er_roomaide[26];
1144 char *not_shared_with;
1147 int floorpolicy = 0;
1149 char pop3_host[128];
1154 if (IsEmptyStr(tab)) tab = "admin";
1157 output_headers(1, 1, 1, 0, 0, 0);
1159 wprintf("<div class=\"fix_scrollbar_bug\">");
1161 wprintf("<br />\n");
1163 /* print the tabbed dialog */
1164 wprintf("<div align=\"center\">");
1165 wprintf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\""
1166 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1169 wprintf("<td class=\"");
1170 if (!strcmp(tab, "admin")) {
1171 wprintf(" tab_cell_label\">");
1172 wprintf(_("Administration"));
1175 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1176 wprintf(_("Administration"));
1180 wprintf("<td> </td>\n");
1182 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1184 wprintf("<td class=\"");
1185 if (!strcmp(tab, "config")) {
1186 wprintf(" tab_cell_label\">");
1187 wprintf(_("Configuration"));
1190 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1191 wprintf(_("Configuration"));
1195 wprintf("<td> </td>\n");
1197 wprintf("<td class=\"");
1198 if (!strcmp(tab, "expire")) {
1199 wprintf(" tab_cell_label\">");
1200 wprintf(_("Message expire policy"));
1203 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1204 wprintf(_("Message expire policy"));
1208 wprintf("<td> </td>\n");
1210 wprintf("<td class=\"");
1211 if (!strcmp(tab, "access")) {
1212 wprintf(" tab_cell_label\">");
1213 wprintf(_("Access controls"));
1216 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1217 wprintf(_("Access controls"));
1221 wprintf("<td> </td>\n");
1223 wprintf("<td class=\"");
1224 if (!strcmp(tab, "sharing")) {
1225 wprintf(" tab_cell_label\">");
1226 wprintf(_("Sharing"));
1229 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1230 wprintf(_("Sharing"));
1234 wprintf("<td> </td>\n");
1236 wprintf("<td class=\"");
1237 if (!strcmp(tab, "listserv")) {
1238 wprintf(" tab_cell_label\">");
1239 wprintf(_("Mailing list service"));
1242 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1243 wprintf(_("Mailing list service"));
1247 wprintf("<td> </td>\n");
1251 wprintf("<td class=\"");
1252 if (!strcmp(tab, "feeds")) {
1253 wprintf(" tab_cell_label\">");
1254 wprintf(_("Remote retrieval"));
1257 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1258 wprintf(_("Remote retrieval"));
1262 wprintf("<td> </td>\n");
1264 wprintf("</tr></table>\n");
1265 wprintf("</div>\n");
1266 /* end tabbed dialog */
1268 wprintf("<script type=\"text/javascript\">"
1269 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1273 /* begin content of whatever tab is open now */
1275 if (!strcmp(tab, "admin")) {
1276 wprintf("<div class=\"tabcontent\">");
1278 "<li><a href=\"delete_room\" "
1279 "onClick=\"return confirm('");
1280 wprintf(_("Are you sure you want to delete this room?"));
1281 wprintf("');\">\n");
1282 wprintf(_("Delete this room"));
1284 "<li><a href=\"display_editroompic\">\n");
1285 wprintf(_("Set or change the icon for this room's banner"));
1287 "<li><a href=\"display_editinfo\">\n");
1288 wprintf(_("Edit this room's Info file"));
1294 if (!strcmp(tab, "config")) {
1295 wprintf("<div class=\"tabcontent\">");
1297 serv_getln(buf, sizeof buf);
1299 if (!strncmp(buf, "550", 3)) {
1300 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1301 _("Higher access is required to access this function.")
1304 else if (buf[0] != '2') {
1305 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1308 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1309 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1310 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1311 er_flags = extract_int(&buf[4], 3);
1312 er_floor = extract_int(&buf[4], 4);
1313 er_flags2 = extract_int(&buf[4], 7);
1315 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1316 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1318 wprintf("<ul><li>");
1319 wprintf(_("Name of room: "));
1320 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1326 wprintf(_("Resides on floor: "));
1327 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1328 if (er_flags & QR_MAILBOX)
1329 wprintf("disabled >\n");
1330 for (i = 0; i < 128; ++i)
1331 if (!IsEmptyStr(floorlist[i])) {
1332 wprintf("<OPTION ");
1334 wprintf("SELECTED ");
1335 wprintf("VALUE=\"%d\">", i);
1336 escputs(floorlist[i]);
1337 wprintf("</OPTION>\n");
1339 wprintf("</select>\n");
1342 wprintf(_("Type of room:"));
1345 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1346 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1347 wprintf("CHECKED ");
1348 wprintf("OnChange=\""
1349 " if (this.form.type[0].checked == true) { "
1350 " this.form.er_floor.disabled = false; "
1353 wprintf(_("Public (automatically appears to everyone)"));
1356 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1357 if ((er_flags & QR_PRIVATE) &&
1358 (er_flags & QR_GUESSNAME))
1359 wprintf("CHECKED ");
1360 wprintf(" OnChange=\""
1361 " if (this.form.type[1].checked == true) { "
1362 " this.form.er_floor.disabled = false; "
1365 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1367 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1368 if ((er_flags & QR_PRIVATE) &&
1369 (er_flags & QR_PASSWORDED))
1370 wprintf("CHECKED ");
1371 wprintf(" OnChange=\""
1372 " if (this.form.type[2].checked == true) { "
1373 " this.form.er_floor.disabled = false; "
1376 wprintf(_("Private - require password: "));
1377 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1380 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1381 if ((er_flags & QR_PRIVATE)
1382 && ((er_flags & QR_GUESSNAME) == 0)
1383 && ((er_flags & QR_PASSWORDED) == 0))
1384 wprintf("CHECKED ");
1385 wprintf(" OnChange=\""
1386 " if (this.form.type[3].checked == true) { "
1387 " this.form.er_floor.disabled = false; "
1390 wprintf(_("Private - invitation only"));
1392 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1393 if (er_flags & QR_MAILBOX)
1394 wprintf("CHECKED ");
1395 wprintf (" OnChange=\""
1396 " if (this.form.type[4].checked == true) { "
1397 " this.form.er_floor.disabled = true; "
1400 wprintf(_("Personal (mailbox for you only)"));
1402 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1404 wprintf(_("If private, cause current users to forget room"));
1406 wprintf("\n</ul>\n");
1408 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1409 if (er_flags & QR_PREFONLY)
1410 wprintf("CHECKED ");
1412 wprintf(_("Preferred users only"));
1414 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1415 if (er_flags & QR_READONLY)
1416 wprintf("CHECKED ");
1418 wprintf(_("Read-only room"));
1420 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1421 if (er_flags2 & QR2_COLLABDEL)
1422 wprintf("CHECKED ");
1424 wprintf(_("All users allowed to post may also delete messages"));
1426 /** directory stuff */
1427 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1428 if (er_flags & QR_DIRECTORY)
1429 wprintf("CHECKED ");
1431 wprintf(_("File directory room"));
1433 wprintf("\n<ul><li>");
1434 wprintf(_("Directory name: "));
1435 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1438 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1439 if (er_flags & QR_UPLOAD)
1440 wprintf("CHECKED ");
1442 wprintf(_("Uploading allowed"));
1444 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1445 if (er_flags & QR_DOWNLOAD)
1446 wprintf("CHECKED ");
1448 wprintf(_("Downloading allowed"));
1450 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1451 if (er_flags & QR_VISDIR)
1452 wprintf("CHECKED ");
1454 wprintf(_("Visible directory"));
1457 /** end of directory stuff */
1459 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1460 if (er_flags & QR_NETWORK)
1461 wprintf("CHECKED ");
1463 wprintf(_("Network shared room"));
1465 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1466 if (er_flags & QR_PERMANENT)
1467 wprintf("CHECKED ");
1469 wprintf(_("Permanent (does not auto-purge)"));
1471 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1472 if (er_flags2 & QR2_SUBJECTREQ)
1473 wprintf("CHECKED ");
1475 wprintf(_("Subject Required (Force users to specify a message subject)"));
1477 /** start of anon options */
1480 wprintf(_("Anonymous messages"));
1483 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1484 if (((er_flags & QR_ANONONLY) == 0)
1485 && ((er_flags & QR_ANONOPT) == 0))
1486 wprintf("CHECKED ");
1488 wprintf(_("No anonymous messages"));
1490 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1491 if (er_flags & QR_ANONONLY)
1492 wprintf("CHECKED ");
1494 wprintf(_("All messages are anonymous"));
1496 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1497 if (er_flags & QR_ANONOPT)
1498 wprintf("CHECKED ");
1500 wprintf(_("Prompt user when entering messages"));
1503 /* end of anon options */
1506 wprintf(_("Room aide: "));
1508 serv_getln(buf, sizeof buf);
1509 if (buf[0] != '2') {
1510 wprintf("<em>%s</em>\n", &buf[4]);
1512 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1513 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1516 wprintf("</ul><CENTER>\n");
1517 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1518 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1520 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1530 /* Sharing the room with other Citadel nodes... */
1531 if (!strcmp(tab, "sharing")) {
1532 wprintf("<div class=\"tabcontent\">");
1534 shared_with = strdup("");
1535 not_shared_with = strdup("");
1537 /** Learn the current configuration */
1538 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1539 serv_getln(buf, sizeof buf);
1540 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1541 extract_token(node, buf, 0, '|', sizeof node);
1542 not_shared_with = realloc(not_shared_with,
1543 strlen(not_shared_with) + 32);
1544 strcat(not_shared_with, node);
1545 strcat(not_shared_with, "\n");
1549 serv_getln(buf, sizeof buf);
1550 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1551 extract_token(cmd, buf, 0, '|', sizeof cmd);
1552 extract_token(node, buf, 1, '|', sizeof node);
1553 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1554 if (!strcasecmp(cmd, "ignet_push_share")) {
1555 shared_with = realloc(shared_with,
1556 strlen(shared_with) + 32);
1557 strcat(shared_with, node);
1558 if (!IsEmptyStr(remote_room)) {
1559 strcat(shared_with, "|");
1560 strcat(shared_with, remote_room);
1562 strcat(shared_with, "\n");
1566 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1567 extract_token(buf, shared_with, i, '\n', sizeof buf);
1568 extract_token(node, buf, 0, '|', sizeof node);
1569 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1570 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1571 if (!strcasecmp(node, cmd)) {
1572 remove_token(not_shared_with, j, '\n');
1577 /* Display the stuff */
1578 wprintf("<CENTER><br />"
1579 "<table border=1 cellpadding=5><tr>"
1581 wprintf(_("Shared with"));
1582 wprintf("</I></B></td>"
1584 wprintf(_("Not shared with"));
1585 wprintf("</I></B></td></tr>\n"
1586 "<tr><td VALIGN=TOP>\n");
1588 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1589 wprintf(_("Remote node name"));
1590 wprintf("</td><td>");
1591 wprintf(_("Remote room name"));
1592 wprintf("</td><td>");
1593 wprintf(_("Actions"));
1594 wprintf("</td></tr>\n");
1596 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1597 extract_token(buf, shared_with, i, '\n', sizeof buf);
1598 extract_token(node, buf, 0, '|', sizeof node);
1599 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1600 if (!IsEmptyStr(node)) {
1601 wprintf("<form method=\"POST\" action=\"netedit\">");
1602 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1603 wprintf("<tr><td>%s</td>\n", node);
1606 if (!IsEmptyStr(remote_room)) {
1607 escputs(remote_room);
1613 wprintf("<input type=\"hidden\" NAME=\"line\" "
1614 "VALUE=\"ignet_push_share|");
1616 if (!IsEmptyStr(remote_room)) {
1618 urlescputs(remote_room);
1621 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1622 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1623 wprintf("<input type=\"submit\" "
1624 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1625 wprintf("</td></tr></form>\n");
1629 wprintf("</table>\n");
1630 wprintf("</td><td VALIGN=TOP>\n");
1631 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1632 wprintf(_("Remote node name"));
1633 wprintf("</td><td>");
1634 wprintf(_("Remote room name"));
1635 wprintf("</td><td>");
1636 wprintf(_("Actions"));
1637 wprintf("</td></tr>\n");
1639 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1640 extract_token(node, not_shared_with, i, '\n', sizeof node);
1641 if (!IsEmptyStr(node)) {
1642 wprintf("<form method=\"POST\" action=\"netedit\">");
1643 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1644 wprintf("<tr><td>");
1647 "<input type=\"INPUT\" "
1651 wprintf("<input type=\"hidden\" "
1653 "VALUE=\"ignet_push_share|");
1656 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1657 "VALUE=\"sharing\">\n");
1658 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1659 "VALUE=\"add\">\n");
1660 wprintf("<input type=\"submit\" "
1661 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1662 wprintf("</td></tr></form>\n");
1666 wprintf("</table>\n");
1667 wprintf("</td></tr>"
1668 "</table></CENTER><br />\n"
1669 "<I><B>%s</B><ul><li>", _("Notes:"));
1670 wprintf(_("When sharing a room, "
1671 "it must be shared from both ends. Adding a node to "
1672 "the 'shared' list sends messages out, but in order to"
1673 " receive messages, the other nodes must be configured"
1674 " to send messages out to your system as well. "
1675 "<li>If the remote room name is blank, it is assumed "
1676 "that the room name is identical on the remote node."
1677 "<li>If the remote room name is different, the remote "
1678 "node must also configure the name of the room here."
1685 /* Mailing list management */
1686 if (!strcmp(tab, "listserv")) {
1687 room_states RoomFlags;
1688 wprintf("<div class=\"tabcontent\">");
1690 wprintf("<br /><center>"
1691 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1692 "<tr><td VALIGN=TOP>");
1694 wprintf(_("<i>The contents of this room are being "
1695 "mailed <b>as individual messages</b> "
1696 "to the following list recipients:"
1697 "</i><br /><br />\n"));
1700 serv_getln(buf, sizeof buf);
1701 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1702 extract_token(cmd, buf, 0, '|', sizeof cmd);
1703 if (!strcasecmp(cmd, "listrecp")) {
1704 extract_token(recp, buf, 1, '|', sizeof recp);
1707 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1710 wprintf(_("(remove)"));
1711 wprintf("</A><br />");
1714 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1715 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1716 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1717 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1718 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1719 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1720 wprintf("</form>\n");
1722 wprintf("</td><td VALIGN=TOP>\n");
1724 wprintf(_("<i>The contents of this room are being "
1725 "mailed <b>in digest form</b> "
1726 "to the following list recipients:"
1727 "</i><br /><br />\n"));
1730 serv_getln(buf, sizeof buf);
1731 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1732 extract_token(cmd, buf, 0, '|', sizeof cmd);
1733 if (!strcasecmp(cmd, "digestrecp")) {
1734 extract_token(recp, buf, 1, '|', sizeof recp);
1737 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1741 wprintf(_("(remove)"));
1742 wprintf("</A><br />");
1745 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1746 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1747 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1748 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1749 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1750 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1751 wprintf("</form>\n");
1753 wprintf("</td></tr></table>\n");
1755 /** Pop open an address book -- begin **/
1756 wprintf("<div align=right>"
1757 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1759 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1764 _("Add recipients from Contacts or other address books"),
1765 _("Add recipients from Contacts or other address books")
1767 /* Pop open an address book -- end **/
1769 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1771 get_roomflags (&RoomFlags);
1773 /* Self Service subscription? */
1774 wprintf("<table><tr><td>\n");
1775 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1776 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1777 " <tr><td colspan=\"2\">\n",
1778 (is_selflist(&RoomFlags))?"checked":"");
1779 wprintf(_("The URL for subscribe/unsubscribe is: "));
1780 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1781 (is_https ? "https" : "http"),
1783 /* Public posting? */
1784 wprintf("<tr><td>");
1785 wprintf(_("Allow non-subscribers to mail to this room."));
1786 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1787 (is_publiclist(&RoomFlags))?"checked":"");
1789 /* Moderated List? */
1790 wprintf("<tr><td>");
1791 wprintf(_("Room post publication needs Aide permission."));
1792 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1793 (is_moderatedlist(&RoomFlags))?"checked":"");
1796 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1797 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1798 wprintf("</table></form>");
1801 wprintf("</CENTER>\n");
1806 /* Configuration of The Dreaded Auto-Purger */
1807 if (!strcmp(tab, "expire")) {
1808 wprintf("<div class=\"tabcontent\">");
1810 serv_puts("GPEX room");
1811 serv_getln(buf, sizeof buf);
1812 if (!strncmp(buf, "550", 3)) {
1813 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1814 _("Higher access is required to access this function.")
1817 else if (buf[0] != '2') {
1818 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1821 roompolicy = extract_int(&buf[4], 0);
1822 roomvalue = extract_int(&buf[4], 1);
1824 serv_puts("GPEX floor");
1825 serv_getln(buf, sizeof buf);
1826 if (buf[0] == '2') {
1827 floorpolicy = extract_int(&buf[4], 0);
1828 floorvalue = extract_int(&buf[4], 1);
1831 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1832 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1833 wprintf("<table border=0 cellspacing=5>\n");
1834 wprintf("<tr><td>");
1835 wprintf(_("Message expire policy for this room"));
1837 escputs(ChrPtr(WC->wc_roomname));
1838 wprintf(")</td><td>");
1839 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1840 ((roompolicy == 0) ? "CHECKED" : "") );
1841 wprintf(_("Use the default policy for this floor"));
1842 wprintf("<br />\n");
1843 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1844 ((roompolicy == 1) ? "CHECKED" : "") );
1845 wprintf(_("Never automatically expire messages"));
1846 wprintf("<br />\n");
1847 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1848 ((roompolicy == 2) ? "CHECKED" : "") );
1849 wprintf(_("Expire by message count"));
1850 wprintf("<br />\n");
1851 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1852 ((roompolicy == 3) ? "CHECKED" : "") );
1853 wprintf(_("Expire by message age"));
1855 wprintf(_("Number of messages or days: "));
1856 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1857 wprintf("</td></tr>\n");
1859 if (WC->axlevel >= 6) {
1860 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1861 wprintf("<tr><td>");
1862 wprintf(_("Message expire policy for this floor"));
1864 escputs(floorlist[WC->wc_floor]);
1865 wprintf(")</td><td>");
1866 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1867 ((floorpolicy == 0) ? "CHECKED" : "") );
1868 wprintf(_("Use the system default"));
1869 wprintf("<br />\n");
1870 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1871 ((floorpolicy == 1) ? "CHECKED" : "") );
1872 wprintf(_("Never automatically expire messages"));
1873 wprintf("<br />\n");
1874 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1875 ((floorpolicy == 2) ? "CHECKED" : "") );
1876 wprintf(_("Expire by message count"));
1877 wprintf("<br />\n");
1878 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1879 ((floorpolicy == 3) ? "CHECKED" : "") );
1880 wprintf(_("Expire by message age"));
1882 wprintf(_("Number of messages or days: "));
1883 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1887 wprintf("<CENTER>\n");
1888 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1889 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1891 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1892 wprintf("</CENTER></td><tr>\n");
1894 wprintf("</table>\n"
1895 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1903 /* Access controls */
1904 if (!strcmp(tab, "access")) {
1905 wprintf("<div class=\"tabcontent\">");
1910 /* Fetch messages from remote locations */
1911 if (!strcmp(tab, "feeds")) {
1912 wprintf("<div class=\"tabcontent\">");
1915 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1916 wprintf("</i><br />\n");
1918 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1919 "<tr class=\"even\"><th>");
1920 wprintf(_("Remote host"));
1921 wprintf("</th><th>");
1922 wprintf(_("User name"));
1923 wprintf("</th><th>");
1924 wprintf(_("Password"));
1925 wprintf("</th><th>");
1926 wprintf(_("Keep messages on server?"));
1927 wprintf("</th><th>");
1928 wprintf(_("Interval"));
1929 wprintf("</th><th> </th></tr>");
1932 serv_getln(buf, sizeof buf);
1934 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1935 extract_token(cmd, buf, 0, '|', sizeof cmd);
1936 if (!strcasecmp(cmd, "pop3client")) {
1937 safestrncpy(recp, &buf[11], sizeof recp);
1940 wprintf("<tr class=\"%s\">",
1941 (bg ? "even" : "odd")
1945 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1950 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1954 wprintf("<td>*****</td>"); /* Don't show the password */
1956 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1958 wprintf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
1960 wprintf("<td class=\"button_link\">");
1961 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1964 wprintf(_("(remove)"));
1965 wprintf("</a></td>");
1971 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1973 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1974 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1975 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1977 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1980 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1983 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1986 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1989 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
1992 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1993 wprintf("</td></tr>");
1994 wprintf("</form></table>\n");
1999 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
2000 wprintf("</i><br />\n");
2002 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
2003 "<tr class=\"even\"><th>");
2004 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2005 wprintf(_("Feed URL"));
2006 wprintf("</th><th>");
2007 wprintf("</th></tr>");
2010 serv_getln(buf, sizeof buf);
2012 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2013 extract_token(cmd, buf, 0, '|', sizeof cmd);
2014 if (!strcasecmp(cmd, "rssclient")) {
2015 safestrncpy(recp, &buf[10], sizeof recp);
2018 wprintf("<tr class=\"%s\">",
2019 (bg ? "even" : "odd")
2023 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2027 wprintf("<td class=\"button_link\">");
2028 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=rssclient|");
2031 wprintf(_("(remove)"));
2032 wprintf("</a></td>");
2038 wprintf("<form method=\"POST\" action=\"netedit\">\n"
2040 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2041 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2042 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2044 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2045 "maxlength=\"256\" name=\"line_pop3host\">\n");
2048 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2049 wprintf("</td></tr>");
2050 wprintf("</form></table>\n");
2056 /* end content of whatever tab is open now */
2057 wprintf("</div>\n");
2059 address_book_popup();
2065 * Toggle self-service list subscription
2067 void toggle_self_service(void) {
2068 room_states RoomFlags;
2070 get_roomflags (&RoomFlags);
2072 if (yesbstr("QR2_SelfList"))
2073 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2075 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2077 if (yesbstr("QR2_SMTP_PUBLIC"))
2078 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2080 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2082 if (yesbstr("QR2_Moderated"))
2083 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2085 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2086 if (yesbstr("QR2_SubsOnly"))
2087 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2089 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2091 set_roomflags (&RoomFlags);
2099 * save new parameters for a room
2106 StrBuf *er_password;
2108 StrBuf *er_roomaide;
2111 int er_listingorder;
2117 if (!havebstr("ok_button")) {
2118 strcpy(WC->ImportantMessage,
2119 _("Cancelled. Changes were not saved."));
2125 StrBuf_ServGetln(Buf);
2126 if (GetServerStatus(Buf, NULL) != 2) {
2127 StrBufCutLeft(Buf, 4);
2128 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2133 StrBufCutLeft(Buf, 4);
2134 StrBufExtract_token(er_name, Buf, 0, '|');
2135 StrBufExtract_token(er_password, Buf, 1, '|');
2136 StrBufExtract_token(er_dirname, Buf, 2, '|');
2137 er_flags = StrBufExtract_int(Buf, 3, '|');
2138 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2139 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2140 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2142 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2143 if (StrLength(er_roomaide) == 0) {
2145 StrBuf_ServGetln(Buf);
2146 if (GetServerStatus(Buf, NULL) != 2) {
2147 FlushStrBuf(er_roomaide);
2149 StrBufCutLeft(Buf, 4);
2150 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2153 Ptr = sbstr("er_name");
2154 if (StrLength(Ptr) > 0) {
2155 FlushStrBuf(er_name);
2156 StrBufAppendBuf(er_name, Ptr, 0);
2159 Ptr = sbstr("er_password");
2160 if (StrLength(Ptr) > 0) {
2161 FlushStrBuf(er_password);
2162 StrBufAppendBuf(er_password, Ptr, 0);
2166 Ptr = sbstr("er_dirname");
2167 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2168 FlushStrBuf(er_dirname);
2169 StrBufAppendBuf(er_dirname, Ptr, 0);
2173 Ptr = sbstr("type");
2174 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2176 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2177 er_flags |= (QR_PRIVATE);
2179 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2180 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2182 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2183 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2185 if (!strcmp(ChrPtr(Ptr), "personal")) {
2186 er_flags |= QR_MAILBOX;
2188 er_flags &= ~QR_MAILBOX;
2191 if (yesbstr("prefonly")) {
2192 er_flags |= QR_PREFONLY;
2194 er_flags &= ~QR_PREFONLY;
2197 if (yesbstr("readonly")) {
2198 er_flags |= QR_READONLY;
2200 er_flags &= ~QR_READONLY;
2204 if (yesbstr("collabdel")) {
2205 er_flags2 |= QR2_COLLABDEL;
2207 er_flags2 &= ~QR2_COLLABDEL;
2210 if (yesbstr("permanent")) {
2211 er_flags |= QR_PERMANENT;
2213 er_flags &= ~QR_PERMANENT;
2216 if (yesbstr("subjectreq")) {
2217 er_flags2 |= QR2_SUBJECTREQ;
2219 er_flags2 &= ~QR2_SUBJECTREQ;
2222 if (yesbstr("network")) {
2223 er_flags |= QR_NETWORK;
2225 er_flags &= ~QR_NETWORK;
2228 if (yesbstr("directory")) {
2229 er_flags |= QR_DIRECTORY;
2231 er_flags &= ~QR_DIRECTORY;
2234 if (yesbstr("ulallowed")) {
2235 er_flags |= QR_UPLOAD;
2237 er_flags &= ~QR_UPLOAD;
2240 if (yesbstr("dlallowed")) {
2241 er_flags |= QR_DOWNLOAD;
2243 er_flags &= ~QR_DOWNLOAD;
2246 if (yesbstr("visdir")) {
2247 er_flags |= QR_VISDIR;
2249 er_flags &= ~QR_VISDIR;
2252 Ptr = sbstr("anon");
2254 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2255 if (!strcmp(ChrPtr(Ptr), "anononly"))
2256 er_flags |= QR_ANONONLY;
2257 if (!strcmp(ChrPtr(Ptr), "anon2"))
2258 er_flags |= QR_ANONOPT;
2260 bump = yesbstr("bump");
2262 er_floor = ibstr("er_floor");
2264 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2266 ChrPtr(er_password),
2275 StrBuf_ServGetln(Buf);
2276 if (GetServerStatus(Buf, NULL) != 2) {
2277 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2280 FreeStrBuf(&er_name);
2281 FreeStrBuf(&er_password);
2282 FreeStrBuf(&er_dirname);
2283 FreeStrBuf(&er_roomaide);
2288 if (StrLength(er_roomaide) > 0) {
2289 serv_printf("SETA %s", ChrPtr(er_roomaide));
2290 StrBuf_ServGetln(Buf);
2291 if (GetServerStatus(Buf, NULL) != 2) {
2292 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2293 display_main_menu();
2295 FreeStrBuf(&er_name);
2296 FreeStrBuf(&er_password);
2297 FreeStrBuf(&er_dirname);
2298 FreeStrBuf(&er_roomaide);
2303 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2306 FreeStrBuf(&er_name);
2307 FreeStrBuf(&er_password);
2308 FreeStrBuf(&er_dirname);
2309 FreeStrBuf(&er_roomaide);
2315 * Display form for Invite, Kick, and show Who Knows a room
2317 void do_invt_kick(void) {
2318 char buf[SIZ], room[SIZ], username[SIZ];
2321 serv_getln(buf, sizeof buf);
2323 if (buf[0] != '2') {
2327 extract_token(room, &buf[4], 0, '|', sizeof room);
2329 strcpy(username, bstr("username"));
2331 if (havebstr("kick_button")) {
2332 sprintf(buf, "KICK %s", username);
2334 serv_getln(buf, sizeof buf);
2336 if (buf[0] != '2') {
2337 strcpy(WC->ImportantMessage, &buf[4]);
2339 sprintf(WC->ImportantMessage,
2340 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2345 if (havebstr("invite_button")) {
2346 sprintf(buf, "INVT %s", username);
2348 serv_getln(buf, sizeof buf);
2350 if (buf[0] != '2') {
2351 strcpy(WC->ImportantMessage, &buf[4]);
2353 sprintf(WC->ImportantMessage,
2354 _("<B><I>User %s invited to room %s.</I></B>\n"),
2365 * Display form for Invite, Kick, and show Who Knows a room
2367 void display_whok(void)
2369 char buf[SIZ], room[SIZ], username[SIZ];
2372 serv_getln(buf, sizeof buf);
2374 if (buf[0] != '2') {
2378 extract_token(room, &buf[4], 0, '|', sizeof room);
2381 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2382 wprintf(_("The users listed below have access to this room. "
2383 "To remove a user from the access list, select the user "
2384 "name from the list and click 'Kick'."));
2385 wprintf("<br /><br />");
2387 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2388 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2389 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2390 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2392 serv_getln(buf, sizeof buf);
2393 if (buf[0] == '1') {
2394 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2395 extract_token(username, buf, 0, '|', sizeof username);
2396 wprintf("<OPTION>");
2401 wprintf("</select><br />\n");
2403 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2404 wprintf("</form></CENTER>\n");
2406 wprintf("</td><td>");
2407 wprintf(_("To grant another user access to this room, enter the "
2408 "user name in the box below and click 'Invite'."));
2409 wprintf("<br /><br />");
2411 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2412 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2413 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2414 wprintf(_("Invite:"));
2416 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2417 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2418 "<input type=\"submit\" value=\"%s\">"
2419 "</form></CENTER>\n", _("Invite"));
2420 /* Pop open an address book -- begin **/
2422 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2424 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2427 _("Users"), _("Users")
2429 /* Pop open an address book -- end **/
2431 wprintf("</td></tr></table>\n");
2432 address_book_popup();
2439 * display the form for entering a new room
2441 void display_entroom(void)
2446 serv_puts("CRE8 0");
2447 serv_getln(buf, sizeof buf);
2449 if (buf[0] != '2') {
2450 strcpy(WC->ImportantMessage, &buf[4]);
2451 display_main_menu();
2455 output_headers(1, 1, 1, 0, 0, 0);
2457 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2458 do_template("beginbox", NULL);
2460 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2461 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2463 wprintf("<table class=\"altern\"> ");
2465 wprintf("<tr class=\"even\"><td>");
2466 wprintf(_("Name of room: "));
2467 wprintf("</td><td>");
2468 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2469 wprintf("</td></tr>");
2471 wprintf("<tr class=\"odd\"><td>");
2472 wprintf(_("Resides on floor: "));
2473 wprintf("</td><td>");
2475 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2476 for (i = 0; i < 128; ++i)
2477 if (!IsEmptyStr(floorlist[i])) {
2478 wprintf("<option ");
2479 wprintf("value=\"%d\">", i);
2480 escputs(floorlist[i]);
2481 wprintf("</option>\n");
2483 wprintf("</select>\n");
2484 wprintf("</td></tr>");
2487 * Our clever little snippet of JavaScript automatically selects
2488 * a public room if the view is set to Bulletin Board or wiki, and
2489 * it selects a mailbox room otherwise. The user can override this,
2490 * of course. We also disable the floor selector for mailboxes.
2492 wprintf("<tr class=\"even\"><td>");
2493 wprintf(_("Default view for room: "));
2494 wprintf("</td><td>");
2495 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2496 " if ( (this.form.er_view.value == 0) "
2497 " || (this.form.er_view.value == 6) ) { "
2498 " this.form.type[0].checked=true; "
2499 " this.form.er_floor.disabled = false; "
2502 " this.form.type[4].checked=true; "
2503 " this.form.er_floor.disabled = true; "
2506 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2507 if (is_view_allowed_as_default(i)) {
2508 wprintf("<option %s value=\"%d\">",
2509 ((i == 0) ? "selected" : ""), i );
2510 escputs(viewdefs[i]);
2511 wprintf("</option>\n");
2514 wprintf("</select>\n");
2515 wprintf("</td></tr>");
2517 wprintf("<tr class=\"even\"><td>");
2518 wprintf(_("Type of room:"));
2519 wprintf("</td><td>");
2520 wprintf("<ul class=\"adminlist\">\n");
2522 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2523 wprintf("CHECKED OnChange=\""
2524 " if (this.form.type[0].checked == true) { "
2525 " this.form.er_floor.disabled = false; "
2528 wprintf(_("Public (automatically appears to everyone)"));
2531 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2532 " if (this.form.type[1].checked == true) { "
2533 " this.form.er_floor.disabled = false; "
2536 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2539 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2540 " if (this.form.type[2].checked == true) { "
2541 " this.form.er_floor.disabled = false; "
2544 wprintf(_("Private - require password: "));
2545 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2548 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2549 " if (this.form.type[3].checked == true) { "
2550 " this.form.er_floor.disabled = false; "
2553 wprintf(_("Private - invitation only"));
2556 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2558 " if (this.form.type[4].checked == true) { "
2559 " this.form.er_floor.disabled = true; "
2562 wprintf(_("Personal (mailbox for you only)"));
2565 wprintf("\n</ul>\n");
2566 wprintf("</td></tr></table>\n");
2568 wprintf("<div class=\"buttons\">\n");
2569 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2571 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2572 wprintf("</div>\n");
2573 wprintf("</form>\n<hr />");
2574 serv_printf("MESG roomaccess");
2575 serv_getln(buf, sizeof buf);
2576 if (buf[0] == '1') {
2580 do_template("endbox", NULL);
2589 * support function for entroom() -- sets the default view
2591 void er_set_default_view(int newview) {
2604 serv_getln(buf, sizeof buf);
2605 if (buf[0] != '2') return;
2607 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2608 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2609 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2610 rm_bits1 = extract_int(&buf[4], 3);
2611 rm_floor = extract_int(&buf[4], 4);
2612 rm_listorder = extract_int(&buf[4], 5);
2613 rm_bits2 = extract_int(&buf[4], 7);
2615 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2616 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2617 rm_listorder, newview, rm_bits2
2619 serv_getln(buf, sizeof buf);
2630 const StrBuf *er_name;
2631 const StrBuf *er_type;
2632 const StrBuf *er_password;
2637 if (!havebstr("ok_button")) {
2638 strcpy(WC->ImportantMessage,
2639 _("Cancelled. No new room was created."));
2640 display_main_menu();
2643 er_name = sbstr("er_name");
2644 er_type = sbstr("type");
2645 er_password = sbstr("er_password");
2646 er_floor = ibstr("er_floor");
2647 er_view = ibstr("er_view");
2650 if (!strcmp(ChrPtr(er_type), "hidden"))
2652 else if (!strcmp(ChrPtr(er_type), "passworded"))
2654 else if (!strcmp(ChrPtr(er_type), "invonly"))
2656 else if (!strcmp(ChrPtr(er_type), "personal"))
2659 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2662 ChrPtr(er_password),
2667 serv_getln(buf, sizeof buf);
2668 if (buf[0] != '2') {
2669 strcpy(WC->ImportantMessage, &buf[4]);
2670 display_main_menu();
2673 /** TODO: Room created, now udate the left hand icon bar for this user */
2674 burn_folder_cache(0); /* burn the old folder cache */
2678 do_change_view(er_view); /* Now go there */
2683 * \brief display the screen to enter a private room
2685 void display_private(char *rname, int req_pass)
2687 WCTemplputParams SubTP;
2689 output_headers(1, 1, 1, 0, 0, 0);
2691 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2692 memset(&SubTP, 0, sizeof(WCTemplputParams));
2693 SubTP.ContextType = CTX_STRBUF;
2694 SubTP.Context = Buf;
2695 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2700 wprintf(_("If you know the name of a hidden (guess-name) or "
2701 "passworded room, you can enter that room by typing "
2702 "its name below. Once you gain access to a private "
2703 "room, it will appear in your regular room listings "
2704 "so you don't have to keep returning here."));
2707 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2708 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2710 wprintf("<table class=\"altern\"> "
2711 "<tr class=\"even\"><td>");
2712 wprintf(_("Enter room name:"));
2714 "<input type=\"text\" name=\"gr_name\" "
2715 "value=\"%s\" maxlength=\"128\">\n", rname);
2718 wprintf("</td></tr><tr class=\"odd\"><td>");
2719 wprintf(_("Enter room password:"));
2720 wprintf("</td><td>");
2721 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2723 wprintf("</td></tr></table>\n");
2725 wprintf("<div class=\"buttons\">\n");
2726 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2728 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2732 wprintf("</div></form>\n");
2734 do_template("endbox", NULL);
2740 * \brief goto a private room
2742 void goto_private(void)
2747 if (!havebstr("ok_button")) {
2748 display_main_menu();
2751 strcpy(hold_rm, ChrPtr(WC->wc_roomname));
2752 serv_printf("GOTO %s|%s",
2755 serv_getln(buf, sizeof buf);
2757 if (buf[0] == '2') {
2758 smart_goto(sbstr("gr_name"));
2761 if (!strncmp(buf, "540", 3)) {
2762 display_private(bstr("gr_name"), 1);
2765 output_headers(1, 1, 1, 0, 0, 0);
2766 wprintf("%s\n", &buf[4]);
2773 * \brief display the screen to zap a room
2775 void display_zap(void)
2777 output_headers(1, 1, 2, 0, 0, 0);
2779 wprintf("<div id=\"banner\">\n");
2781 wprintf(_("Zap (forget/unsubscribe) the current room"));
2783 wprintf("</div>\n");
2785 wprintf("<div id=\"content\" class=\"service\">\n");
2787 wprintf(_("If you select this option, <em>%s</em> will "
2788 "disappear from your room list. Is this what you wish "
2789 "to do?<br />\n"), ChrPtr(WC->wc_roomname));
2791 wprintf("<form method=\"POST\" action=\"zap\">\n");
2792 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2793 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2795 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2796 wprintf("</form>\n");
2807 StrBuf *final_destination;
2810 * If the forget-room routine fails for any reason, we fall back
2811 * to the current room; otherwise, we go to the Lobby
2813 final_destination = NewStrBufDup(WC->wc_roomname);
2815 if (havebstr("ok_button")) {
2816 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
2817 serv_getln(buf, sizeof buf);
2818 if (buf[0] == '2') {
2820 serv_getln(buf, sizeof buf);
2821 if (buf[0] == '2') {
2822 FlushStrBuf(final_destination);
2823 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2827 smart_goto(final_destination);
2828 FreeStrBuf(&final_destination);
2834 * \brief Delete the current room
2836 void delete_room(void)
2841 serv_puts("KILL 1");
2842 serv_getln(buf, sizeof buf);
2843 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2844 if (buf[0] != '2') {
2845 strcpy(WC->ImportantMessage, &buf[4]);
2846 display_main_menu();
2851 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2860 * \brief Perform changes to a room's network configuration
2862 void netedit(void) {
2871 /*/ TODO: do line dynamic! */
2872 if (havebstr("line_pop3host")) {
2873 strcpy(line, bstr("prefix"));
2874 strcat(line, bstr("line_pop3host"));
2876 strcat(line, bstr("line_pop3user"));
2878 strcat(line, bstr("line_pop3pass"));
2880 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2882 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2883 strcat(line, bstr("suffix"));
2885 else if (havebstr("line")) {
2886 strcpy(line, bstr("prefix"));
2887 strcat(line, bstr("line"));
2888 strcat(line, bstr("suffix"));
2903 serv_getln(buf, sizeof buf);
2904 if (buf[0] != '1') {
2910 /** This loop works for add *or* remove. Spiffy, eh? */
2911 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2912 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2913 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2914 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2915 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2916 if ( (strcasecmp(cmpa0, cmpb0))
2917 || (strcasecmp(cmpa1, cmpb1)) ) {
2918 fprintf(fp, "%s\n", buf);
2924 serv_getln(buf, sizeof buf);
2925 if (buf[0] != '4') {
2931 while (fgets(buf, sizeof buf, fp) != NULL) {
2932 buf[strlen(buf)-1] = 0;
2936 if (havebstr("add_button")) {
2937 num_addrs = num_tokens(bstr("line"), ',');
2938 if (num_addrs < 2) {
2939 /* just adding one node or address */
2943 /* adding multiple addresses separated by commas */
2944 for (i=0; i<num_addrs; ++i) {
2945 strcpy(line, bstr("prefix"));
2946 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2949 strcat(line, bstr("suffix"));
2963 * \brief Convert a room name to a folder-ish-looking name.
2964 * \param folder the folderish name
2965 * \param room the room name
2966 * \param floor the floor name
2967 * \param is_mailbox is it a mailbox?
2969 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2974 * For mailboxes, just do it straight...
2977 sprintf(folder, "My folders|%s", room);
2981 * Otherwise, prefix the floor name as a "public folders" moniker
2984 if (floor > MAX_FLOORS) {
2986 sprintf(folder, "%%%%%%|%s", room);
2989 sprintf(folder, "%s|%s", floorlist[floor], room);
2994 * Replace "\" characters with "|" for pseudo-folder-delimiting
2996 len = strlen (folder);
2997 for (i=0; i<len; ++i) {
2998 if (folder[i] == '\\') folder[i] = '|';
3006 * \brief Back end for change_view()
3007 * \param newview set newview???
3009 void do_change_view(int newview) {
3012 serv_printf("VIEW %d", newview);
3013 serv_getln(buf, sizeof buf);
3014 WC->wc_view = newview;
3015 smart_goto(WC->wc_roomname);
3021 * \brief Change the view for this room
3023 void change_view(void) {
3026 view = lbstr("view");
3027 do_change_view(view);
3032 * \brief One big expanded tree list view --- like a folder list
3033 * \param fold the folder to view
3034 * \param max_folders how many folders???
3035 * \param num_floors hom many floors???
3037 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
3041 int has_subfolders = 0;
3044 parents = malloc(max_folders * sizeof(int));
3046 /** BEGIN TREE MENU */
3047 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
3049 /** include NanoTree */
3050 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
3052 /** initialize NanoTree */
3053 wprintf("<script type=\"text/javascript\"> \n"
3054 " showRootNode = false; \n"
3055 " sortNodes = false; \n"
3056 " dragable = false; \n"
3058 " function standardClick(treeNode) { \n"
3061 " var closedGif = 'static/folder_closed.gif'; \n"
3062 " var openGif = 'static/folder_open.gif'; \n"
3064 " rootNode = new TreeNode(1, 'root node - hide'); \n"
3068 for (i=0; i<max_folders; ++i) {
3071 if ((i+1) < max_folders) {
3073 len = strlen(fold[i].name);
3074 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
3075 && (fold[i+1].name[len] == '|') ) {
3080 levels = num_tokens(fold[i].name, '|');
3081 parents[levels] = i;
3083 wprintf("var node%d = new TreeNode(%d, '", i, i);
3085 if (fold[i].selectable) {
3086 wprintf("<a href=\"dotgoto?room=");
3087 urlescputs(fold[i].room);
3092 wprintf("<span class=\"roomlist_floor\">");
3094 else if (fold[i].hasnewmsgs) {
3095 wprintf("<span class=\"roomlist_new\">");
3098 wprintf("<span class=\"roomlist_old\">");
3100 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3105 if (has_subfolders) {
3106 wprintf("new Array(closedGif, openGif)");
3108 else if (fold[i].view == VIEW_ADDRESSBOOK) {
3109 wprintf("'static/viewcontacts_16x.gif'");
3111 else if (fold[i].view == VIEW_CALENDAR) {
3112 wprintf("'static/calarea_16x.gif'");
3114 else if (fold[i].view == VIEW_CALBRIEF) {
3115 wprintf("'static/calarea_16x.gif'");
3117 else if (fold[i].view == VIEW_TASKS) {
3118 wprintf("'static/taskmanag_16x.gif'");
3120 else if (fold[i].view == VIEW_NOTES) {
3121 wprintf("'static/storenotes_16x.gif'");
3123 else if (fold[i].view == VIEW_MAILBOX) {
3124 wprintf("'static/privatemess_16x.gif'");
3127 wprintf("'static/chatrooms_16x.gif'");
3130 urlescputs(fold[i].name);
3134 wprintf("rootNode.addChild(node%d);\n", i);
3137 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3141 wprintf("container = document.getElementById('roomlist_div'); \n"
3147 /** END TREE MENU */
3151 * \brief Boxes and rooms and lists ... oh my!
3152 * \param fold the folder to view
3153 * \param max_folders how many folders???
3154 * \param num_floors hom many floors???
3156 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3158 char floor_name[256];
3159 char old_floor_name[256];
3160 int levels, oldlevels;
3163 static int columns = 3;
3164 int boxes_per_column = 0;
3165 int current_column = 0;
3168 strcpy(floor_name, "");
3169 strcpy(old_floor_name, "");
3172 while (nf % columns != 0) ++nf;
3173 boxes_per_column = (nf / columns);
3174 if (boxes_per_column < 1) boxes_per_column = 1;
3176 /** Outer table (for columnization) */
3177 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3178 "<tr><td valign=top>");
3182 for (i=0; i<max_folders; ++i) {
3184 levels = num_tokens(fold[i].name, '|');
3185 extract_token(floor_name, fold[i].name, 0,
3186 '|', sizeof floor_name);
3188 if ( (strcasecmp(floor_name, old_floor_name))
3189 && (!IsEmptyStr(old_floor_name)) ) {
3191 do_template("endbox", NULL);
3195 if ((num_boxes % boxes_per_column) == 0) {
3197 if (current_column < columns) {
3198 wprintf("</td><td valign=top>\n");
3202 strcpy(old_floor_name, floor_name);
3206 WCTemplputParams SubTP;
3208 Buf = NewStrBufPlain(floor_name, -1);
3209 memset(&SubTP, 0, sizeof(WCTemplputParams));
3210 SubTP.ContextType = CTX_STRBUF;
3211 SubTP.Context = Buf;
3212 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
3221 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3222 if (fold[i].selectable) {
3223 wprintf("<a href=\"dotgoto?room=");
3224 urlescputs(fold[i].room);
3230 if (fold[i].hasnewmsgs) {
3231 wprintf("<span class=\"roomlist_new\">");
3234 wprintf("<span class=\"roomlist_old\">");
3236 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3239 if (fold[i].selectable) {
3245 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3246 wprintf(" (INBOX)");
3248 wprintf("<br />\n");
3251 /** End the final inner box */
3252 do_template("endbox", NULL);
3254 wprintf("</td></tr></table>\n");
3258 * \brief print a floor div???
3259 * \param which_floordiv name of the floordiv???
3261 void set_floordiv_expanded(void) {
3262 wcsession *WCC = WC;
3265 FloorDiv = NewStrBuf();
3266 StrBufAppendBuf(FloorDiv, WCC->UrlFragment2, 0);
3267 set_preference("floordiv_expanded", FloorDiv, 1);
3268 WCC->floordiv_expanded = FloorDiv;
3272 * \brief view the iconbar
3273 * \param fold the folder to view
3274 * \param max_folders how many folders???
3275 * \param num_floors hom many floors???
3277 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3279 char floor_name[256];
3280 char old_floor_name[256];
3281 char floordivtitle[256];
3282 char floordiv_id[32];
3283 int levels, oldlevels;
3285 int num_drop_targets = 0;
3288 strcpy(floor_name, "");
3289 strcpy(old_floor_name, "");
3293 for (i=0; i<max_folders; ++i) {
3295 levels = num_tokens(fold[i].name, '|');
3296 extract_token(floor_name, fold[i].name, 0,
3297 '|', sizeof floor_name);
3299 if ( (strcasecmp(floor_name, old_floor_name))
3300 && (!IsEmptyStr(old_floor_name)) ) {
3301 /** End inner box */
3303 wprintf("</div>\n"); /** floordiv */
3305 strcpy(old_floor_name, floor_name);
3309 stresc(floordivtitle, 256, floor_name, 0, 0);
3310 sprintf(floordiv_id, "floordiv%d", i);
3311 wprintf("<span class=\"ib_roomlist_floor\" "
3312 "onClick=\"expand_floor('%s')\">"
3313 "%s</span><br>\n", floordiv_id, floordivtitle);
3314 wprintf("<div id=\"%s\" style=\"display:%s\">",
3316 (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
3323 wprintf("<div id=\"roomdiv%d\">", i);
3325 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3327 /** choose the icon */
3328 if (fold[i].view == VIEW_ADDRESSBOOK) {
3329 icon = "viewcontacts_16x.gif" ;
3331 else if (fold[i].view == VIEW_CALENDAR) {
3332 icon = "calarea_16x.gif" ;
3334 else if (fold[i].view == VIEW_CALBRIEF) {
3335 icon = "calarea_16x.gif" ;
3337 else if (fold[i].view == VIEW_TASKS) {
3338 icon = "taskmanag_16x.gif" ;
3340 else if (fold[i].view == VIEW_NOTES) {
3341 icon = "storenotes_16x.gif" ;
3343 else if (fold[i].view == VIEW_MAILBOX) {
3344 icon = "privatemess_16x.gif" ;
3347 icon = "chatrooms_16x.gif" ;
3350 if (fold[i].selectable) {
3351 wprintf("<a href=\"dotgoto?room=");
3352 urlescputs(fold[i].room);
3354 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3359 if (fold[i].hasnewmsgs) {
3360 wprintf("<span class=\"ib_roomlist_new\">");
3363 wprintf("<span class=\"ib_roomlist_old\">");
3365 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3367 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3368 wprintf(" (INBOX)");
3371 if (fold[i].selectable) {
3378 wprintf("</div>\n"); /** roomdiv */
3381 wprintf("</div>\n"); /** floordiv */
3384 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3385 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3387 num_drop_targets = 0;
3389 for (i=0; i<max_folders; ++i) {
3390 levels = num_tokens(fold[i].name, '|');
3392 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3393 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3394 jsescputs(fold[i].room);
3400 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3401 if ((ChrPtr(WC->floordiv_expanded)[0] != '\0')&&
3402 (ChrPtr(WC->floordiv_expanded)[1] != '\0')){
3403 wprintf("which_div_expanded = '%s';\n", ChrPtr(WC->floordiv_expanded));
3407 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3413 * \brief Burn the cached folder list.
3414 * \param age How old the cahce needs to be before we burn it.
3417 void burn_folder_cache(time_t age)
3419 /** If our cached folder list is very old, burn it. */
3420 if (WC->cache_fold != NULL) {
3421 if ((time(NULL) - WC->cache_timestamp) > age) {
3422 free(WC->cache_fold);
3423 WC->cache_fold = NULL;
3432 * \brief Show the room list.
3433 * (only should get called by
3434 * knrooms() because that's where output_headers() is called from)
3435 * \param viewpref the view preferences???
3438 void list_all_rooms_by_floor(const char *viewpref) {
3441 struct folder *fold = NULL;
3443 int max_folders = 0;
3444 int alloc_folders = 0;
3448 int ShowEmptyFloors;
3451 int num_floors = 1; /** add an extra one for private folders */
3454 /** If our cached folder list is very old, burn it. */
3455 burn_folder_cache(300);
3457 /** Can we do the iconbar roomlist from cache? */
3458 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3459 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3463 /** Grab the floor table so we know how to build the list... */
3466 /** Start with the mailboxes */
3469 fold = malloc(sizeof(struct folder));
3470 memset(fold, 0, sizeof(struct folder));
3471 strcpy(fold[0].name, "My folders");
3472 fold[0].is_mailbox = 1;
3474 /** Then add floors */
3476 serv_getln(buf, sizeof buf);
3477 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3478 if (max_folders >= alloc_folders) {
3479 alloc_folders = max_folders + 100;
3480 fold = realloc(fold,
3481 alloc_folders * sizeof(struct folder));
3483 memset(&fold[max_folders], 0, sizeof(struct folder));
3484 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3485 extract_token(buf3, buf, 0, '|', SIZ);
3486 fold[max_folders].floor = atol (buf3);
3491 for (i=0; i<num_floors; i++)
3492 if (IDMax < fold[i].floor)
3493 IDMax = fold[i].floor;
3494 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3495 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3496 for (i=0; i<num_floors; i++)
3497 floor_mapping[fold[i].floor]=i;
3499 /** refresh the messages index for this room */
3500 /* TODO serv_puts("GOTO ");
3501 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")); */
3502 /** Now add rooms */
3504 serv_getln(buf, sizeof buf);
3505 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3506 if (max_folders >= alloc_folders) {
3507 alloc_folders = max_folders + 100;
3508 fold = realloc(fold,
3509 alloc_folders * sizeof(struct folder));
3511 memset(&fold[max_folders], 0, sizeof(struct folder));
3512 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3513 ra_flags = extract_int(buf, 5);
3514 flags = extract_int(buf, 1);
3515 fold[max_folders].floor = extract_int(buf, 2);
3516 fold[max_folders].hasnewmsgs =
3517 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3518 if (flags & QR_MAILBOX) {
3519 fold[max_folders].is_mailbox = 1;
3521 fold[max_folders].view = extract_int(buf, 6);
3522 room_to_folder(fold[max_folders].name,
3523 fold[max_folders].room,
3524 fold[max_folders].floor,
3525 fold[max_folders].is_mailbox);
3526 fold[max_folders].selectable = 1;
3527 /* Increase the room count for the associtaed floor */
3528 if (fold[max_folders].is_mailbox) {
3529 fold[0].num_rooms++;
3532 i = floor_mapping[fold[max_folders].floor];
3533 fold[i].num_rooms++;
3539 * Remove any floors that don't have rooms
3541 get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
3542 if (ShowEmptyFloors)
3544 for (i=0; i<num_floors; i++)
3546 if (fold[i].num_rooms == 0) {
3547 for (j=i; j<max_folders; j++) {
3548 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3557 /** Bubble-sort the folder list */
3558 for (i=0; i<max_folders; ++i) {
3559 for (j=0; j<(max_folders-1)-i; ++j) {
3560 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3561 swap = strcasecmp(fold[j].name, fold[j+1].name);
3564 if ( (fold[j+1].is_mailbox)
3565 && (!fold[j].is_mailbox)) {
3573 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3574 memcpy(&fold[j], &fold[j+1],
3575 sizeof(struct folder));
3576 memcpy(&fold[j+1], &ftmp,
3577 sizeof(struct folder));
3583 if (!strcasecmp(viewpref, "folders")) {
3584 do_folder_view(fold, max_folders, num_floors);
3586 else if (!strcasecmp(viewpref, "hackish_view")) {
3587 for (i=0; i<max_folders; ++i) {
3588 escputs(fold[i].name);
3589 wprintf("<br />\n");
3592 else if (!strcasecmp(viewpref, "iconbar")) {
3593 do_iconbar_view(fold, max_folders, num_floors);
3596 do_rooms_view(fold, max_folders, num_floors);
3599 /* Don't free the folder list ... cache it for future use! */
3600 if (WC->cache_fold != NULL) {
3601 free(WC->cache_fold);
3603 WC->cache_fold = fold;
3604 WC->cache_max_folders = max_folders;
3605 WC->cache_num_floors = num_floors;
3606 WC->cache_timestamp = time(NULL);
3607 free(floor_mapping);
3612 * \brief Do either a known rooms list or a folders list, depending on the
3617 StrBuf *ListView = NULL;
3619 output_headers(1, 1, 2, 0, 0, 0);
3621 /** Determine whether the user is trying to change views */
3622 if (havebstr("view")) {
3623 ListView = NewStrBufPlain(bstr("view"), -1);
3624 set_preference("roomlistview", ListView, 1);
3626 /** Sanitize the input so its safe */
3627 if(!get_preference("roomlistview", &ListView) ||
3628 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3629 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3631 if (ListView == NULL) {
3632 ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1);
3633 set_preference("roomlistview", ListView, 0);
3636 StrBufPrintf(ListView, "rooms");
3642 wprintf("<div id=\"banner\">\n");
3643 wprintf("<div class=\"room_banner\">");
3645 if (!strcasecmp(ChrPtr(ListView), "rooms")) {
3646 wprintf(_("Room list"));
3648 else if (!strcasecmp(ChrPtr(ListView), "folders")) {
3649 wprintf(_("Folder list"));
3651 else if (!strcasecmp(ChrPtr(ListView), "table")) {
3652 wprintf(_("Room list"));
3654 wprintf("</h1></div>\n");
3656 /** offer the ability to switch views */
3657 wprintf("<ul class=\"room_actions\">\n");
3658 wprintf("<li class=\"start_page\">");
3659 offer_start_page(NULL, &NoCtx);
3661 wprintf("<li><form name=\"roomlistomatic\">\n"
3662 "<select name=\"newview\" size=\"1\" "
3663 "OnChange=\"location.href=roomlistomatic.newview.options"
3664 "[selectedIndex].value\">\n");
3666 wprintf("<option %s value=\"knrooms&view=rooms\">"
3669 ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" )
3672 wprintf("<option %s value=\"knrooms&view=folders\">"
3673 "View as folder list"
3675 ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" )
3678 wprintf("</select>");
3679 wprintf("</form></li>");
3680 wprintf("</ul></div>\n");
3682 wprintf("<div id=\"content\" class=\"service\">\n");
3684 /** Display the room list in the user's preferred format */
3685 list_all_rooms_by_floor(ChrPtr(ListView));
3692 * \brief Set the message expire policy for this room and/or floor
3694 void set_room_policy(void) {
3697 if (!havebstr("ok_button")) {
3698 strcpy(WC->ImportantMessage,
3699 _("Cancelled. Changes were not saved."));
3704 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3705 serv_getln(buf, sizeof buf);
3706 strcpy(WC->ImportantMessage, &buf[4]);
3708 if (WC->axlevel >= 6) {
3709 strcat(WC->ImportantMessage, "<br />\n");
3710 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3711 serv_getln(buf, sizeof buf);
3712 strcat(WC->ImportantMessage, &buf[4]);
3719 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3721 StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
3724 void _gotonext(void) { slrp_highest(); gotonext(); }
3725 void dotskip(void) {smart_goto(sbstr("room"));}
3726 void _display_private(void) { display_private("", 0); }
3727 void dotgoto(void) {
3728 if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3731 smart_goto(sbstr("room"));
3734 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3736 wprintf("<div id=\"banner\">\n");
3737 embed_room_banner(NULL, navbar_default);
3738 wprintf("</div>\n");
3742 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3744 wcsession *WCC = WC;
3747 (!IsEmptyStr(WCC->ugname)))
3748 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3752 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3754 wcsession *WCC = WC;
3756 return ((WCC!=NULL) &&
3757 (!IsEmptyStr(WCC->ugname)) &&
3758 (strcasecmp(WCC->ugname, ChrPtr(WCC->wc_roomname)) == 0));
3761 int ConditionalRoomHas_QR_PERMANENT(StrBuf *Target, WCTemplputParams *TP)
3763 wcsession *WCC = WC;
3765 return ((WCC!=NULL) &&
3766 ((WCC->room_flags & QR_PERMANENT) != 0));
3769 int ConditionalRoomHas_QR_INUSE(StrBuf *Target, WCTemplputParams *TP)
3771 wcsession *WCC = WC;
3773 return ((WCC!=NULL) &&
3774 ((WCC->room_flags & QR_INUSE) != 0));
3777 int ConditionalRoomHas_QR_PRIVATE(StrBuf *Target, WCTemplputParams *TP)
3779 wcsession *WCC = WC;
3781 return ((WCC!=NULL) &&
3782 ((WCC->room_flags & QR_PRIVATE) != 0));
3785 int ConditionalRoomHas_QR_PASSWORDED(StrBuf *Target, WCTemplputParams *TP)
3787 wcsession *WCC = WC;
3789 return ((WCC!=NULL) &&
3790 ((WCC->room_flags & QR_PASSWORDED) != 0));
3793 int ConditionalRoomHas_QR_GUESSNAME(StrBuf *Target, WCTemplputParams *TP)
3795 wcsession *WCC = WC;
3797 return ((WCC!=NULL) &&
3798 ((WCC->room_flags & QR_GUESSNAME) != 0));
3801 int ConditionalRoomHas_QR_DIRECTORY(StrBuf *Target, WCTemplputParams *TP)
3803 wcsession *WCC = WC;
3805 return ((WCC!=NULL) &&
3806 ((WCC->room_flags & QR_DIRECTORY) != 0));
3809 int ConditionalRoomHas_QR_UPLOAD(StrBuf *Target, WCTemplputParams *TP)
3811 wcsession *WCC = WC;
3813 return ((WCC!=NULL) &&
3814 ((WCC->room_flags & QR_UPLOAD) != 0));
3817 int ConditionalRoomHas_QR_DOWNLOAD(StrBuf *Target, WCTemplputParams *TP)
3819 wcsession *WCC = WC;
3821 return ((WCC!=NULL) &&
3822 ((WCC->room_flags & QR_DOWNLOAD) != 0));
3825 int ConditionalRoomHas_QR_VISDIR(StrBuf *Target, WCTemplputParams *TP)
3827 wcsession *WCC = WC;
3829 return ((WCC!=NULL) &&
3830 ((WCC->room_flags & QR_VISDIR) != 0));
3833 int ConditionalRoomHas_QR_ANONONLY(StrBuf *Target, WCTemplputParams *TP)
3835 wcsession *WCC = WC;
3837 return ((WCC!=NULL) &&
3838 ((WCC->room_flags & QR_ANONONLY) != 0));
3841 int ConditionalRoomHas_QR_ANONOPT(StrBuf *Target, WCTemplputParams *TP)
3843 wcsession *WCC = WC;
3845 return ((WCC!=NULL) &&
3846 ((WCC->room_flags & QR_ANONOPT) != 0));
3849 int ConditionalRoomHas_QR_NETWORK(StrBuf *Target, WCTemplputParams *TP)
3851 wcsession *WCC = WC;
3853 return ((WCC!=NULL) &&
3854 ((WCC->room_flags & QR_NETWORK) != 0));
3857 int ConditionalRoomHas_QR_PREFONLY(StrBuf *Target, WCTemplputParams *TP)
3859 wcsession *WCC = WC;
3861 return ((WCC!=NULL) &&
3862 ((WCC->room_flags & QR_PREFONLY) != 0));
3865 int ConditionalRoomHas_QR_READONLY(StrBuf *Target, WCTemplputParams *TP)
3867 wcsession *WCC = WC;
3869 return ((WCC!=NULL) &&
3870 ((WCC->room_flags & QR_READONLY) != 0));
3873 int ConditionalRoomHas_QR_MAILBOX(StrBuf *Target, WCTemplputParams *TP)
3875 wcsession *WCC = WC;
3877 return ((WCC!=NULL) &&
3878 ((WCC->room_flags & QR_MAILBOX) != 0));
3882 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3884 wcsession *WCC = WC;
3886 return ( (WCC!= NULL) &&
3887 ((WCC->axlevel >= 6) ||
3888 (WCC->is_room_aide) ||
3889 (WCC->is_mailbox) ));
3896 RegisterPreference(HKEY("roomlistview"),
3897 _("Room list view"),
3900 RegisterPreference(HKEY("emptyfloors"), _("Show empty floors"), PRF_YESNO, NULL);
3902 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, 0);
3904 WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
3905 WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, NEED_URL);
3906 WebcitAddUrlHandler(HKEY("skip"), gotonext, NEED_URL);
3907 WebcitAddUrlHandler(HKEY("ungoto"), ungoto, NEED_URL);
3908 WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, NEED_URL);
3909 WebcitAddUrlHandler(HKEY("dotskip"), dotskip, NEED_URL);
3910 WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
3911 WebcitAddUrlHandler(HKEY("goto_private"), goto_private, NEED_URL);
3912 WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
3913 WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
3914 WebcitAddUrlHandler(HKEY("zap"), zap, 0);
3915 WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
3916 WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
3917 WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
3918 WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
3919 WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
3920 WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
3921 WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
3922 WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
3923 WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
3924 WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
3925 WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);
3926 WebcitAddUrlHandler(HKEY("toggle_self_service"), toggle_self_service, 0);
3927 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, 0);
3929 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PERMANENT"), 0, ConditionalRoomHas_QR_PERMANENT, CTX_NONE);
3930 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_INUSE"), 0, ConditionalRoomHas_QR_INUSE, CTX_NONE);
3931 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PRIVATE"), 0, ConditionalRoomHas_QR_PRIVATE, CTX_NONE);
3932 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PASSWORDED"), 0, ConditionalRoomHas_QR_PASSWORDED, CTX_NONE);
3933 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_GUESSNAME"), 0, ConditionalRoomHas_QR_GUESSNAME, CTX_NONE);
3934 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DIRECTORY"), 0, ConditionalRoomHas_QR_DIRECTORY, CTX_NONE);
3935 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_UPLOAD"), 0, ConditionalRoomHas_QR_UPLOAD, CTX_NONE);
3936 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DOWNLOAD"), 0, ConditionalRoomHas_QR_DOWNLOAD, CTX_NONE);
3937 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_VISIDIR"), 0, ConditionalRoomHas_QR_VISDIR, CTX_NONE);
3938 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONONLY"), 0, ConditionalRoomHas_QR_ANONONLY, CTX_NONE);
3939 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONOPT"), 0, ConditionalRoomHas_QR_ANONOPT, CTX_NONE);
3940 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_NETWORK"), 0, ConditionalRoomHas_QR_NETWORK, CTX_NONE);
3941 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PREFONLY"), 0, ConditionalRoomHas_QR_PREFONLY, CTX_NONE);
3942 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_READONLY"), 0, ConditionalRoomHas_QR_READONLY, CTX_NONE);
3943 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_MAILBOX"), 0, ConditionalRoomHas_QR_MAILBOX, CTX_NONE);
3945 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3946 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3948 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, 0);