3 * Lots of different room-related operations.
11 char floorlist[MAX_FLOORS][SIZ]; /* list of our floor names */
13 char *viewdefs[9]; /* the different kinds of available views */
15 /* See GetFloorListHash and GetRoomListHash for info on these.
16 * Basically we pull LFLR/LKRA etc. and set up a room HashList with these keys.
19 void display_whok(void);
22 * Initialize the viewdefs with localized strings
24 void initialize_viewdefs(void) {
25 viewdefs[0] = _("Bulletin Board");
26 viewdefs[1] = _("Mail Folder");
27 viewdefs[2] = _("Address Book");
28 viewdefs[3] = _("Calendar");
29 viewdefs[4] = _("Task List");
30 viewdefs[5] = _("Notes List");
31 viewdefs[6] = _("Wiki");
32 viewdefs[7] = _("Calendar List");
33 viewdefs[8] = _("Journal");
37 * Determine which views are allowed as the default for creating a new room.
39 int is_view_allowed_as_default(int which_view)
42 case VIEW_BBS: return(1);
43 case VIEW_MAILBOX: return(1);
44 case VIEW_ADDRESSBOOK: return(1);
45 case VIEW_CALENDAR: return(1);
46 case VIEW_TASKS: return(1);
47 case VIEW_NOTES: return(1);
50 case VIEW_WIKI: return(1);
51 #else /* TECH_PREVIEW */
52 case VIEW_WIKI: return(0); /* because it isn't finished yet */
53 #endif /* TECH_PREVIEW */
55 case VIEW_CALBRIEF: return(0);
56 case VIEW_JOURNAL: return(0);
57 default: return(0); /* should never get here */
63 * load the list of floors
65 void load_floorlist(StrBuf *Buf)
70 for (a = 0; a < MAX_FLOORS; ++a)
74 StrBuf_ServGetln(Buf);
75 if (GetServerStatus(Buf, NULL) != 1) {
76 strcpy(floorlist[0], "Main Floor");
79 while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
80 if ( (StrLength(Buf)==3) &&
81 !strcmp(ChrPtr(Buf), "000")) {
85 extract_token(floorlist[StrBufExtract_int(Buf, 0, '|')], ChrPtr(Buf), 1, '|', sizeof floorlist[0]);
93 * display rooms in tree structure
95 void room_tree_list(struct roomlisting *rp)
104 room_tree_list(rp->lnext);
106 strcpy(rmname, rp->rlname);
109 wprintf("<a href=\"dotgoto?room=");
113 escputs1(rmname, 1, 1);
114 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
116 else if (f & QR_DIRECTORY)
118 else if (f & QR_NETWORK)
122 wprintf("</a><tt> </tt>\n");
124 room_tree_list(rp->rnext);
130 * Room ordering stuff (compare first by floor, then by order)
132 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
134 if ((r1 == NULL) && (r2 == NULL))
140 if (r1->rlfloor < r2->rlfloor)
142 if (r1->rlfloor > r2->rlfloor)
144 if (r1->rlorder < r2->rlorder)
146 if (r1->rlorder > r2->rlorder)
153 * Common code for all room listings
155 void listrms(char *variety)
160 struct roomlisting *rl = NULL;
161 struct roomlisting *rp;
162 struct roomlisting *rs;
164 /* Ask the server for a room list */
166 serv_getln(buf, sizeof buf);
172 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
174 rp = malloc(sizeof(struct roomlisting));
175 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
176 rp->rlflags = extract_int(buf, 1);
177 rp->rlfloor = extract_int(buf, 2);
178 rp->rlorder = extract_int(buf, 3);
187 if (rordercmp(rp, rs) < 0) {
188 if (rs->lnext == NULL) {
195 if (rs->rnext == NULL) {
208 * If no rooms were listed, print an nbsp to make the cell
209 * borders show up anyway.
211 if (num_rooms == 0) wprintf(" ");
216 * list all forgotten rooms
218 void zapped_list(void)
220 WCTemplputParams SubTP;
223 output_headers(1, 1, 1, 0, 0, 0);
224 memset(&SubTP, 0, sizeof(WCTemplputParams));
225 Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
226 SubTP.Filter.ContextType = CTX_STRBUF;
228 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
234 wprintf("<br /><br />\n");
235 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
236 do_template("endbox", NULL);
242 * read this room's info file (set v to 1 for verbose mode)
244 void readinfo(StrBuf *Target, WCTemplputParams *TP)
249 int fullinfo_len = 0;
252 serv_getln(buf, sizeof buf);
255 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
256 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
257 strcpy(&fullinfo[fullinfo_len], buf);
258 fullinfo_len += strlen(buf);
262 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
263 strcpy(&briefinfo[50], "...");
265 wprintf("<div class=\"infos\" "
266 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
270 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
271 wprintf("<img class=\"close_infos\" "
272 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
273 "src=\"static/closewindow.gif\" alt=\"%s\" width=\"16\" height=\"16\">",
288 * Display room banner icon.
289 * The server doesn't actually need the room name, but we supply it in
290 * order to keep the browser from using a cached icon from another room.
292 void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP)
296 serv_puts("OIMG _roompic_");
297 serv_getln(buf, sizeof buf);
299 wprintf("<img height=\"64px\" src=\"image?name=_roompic_&room=");
300 urlescputs(ChrPtr(WC->wc_roomname));
303 serv_getln(buf, sizeof buf);
305 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
306 wprintf("<img class=\"roompic\" alt=\"\" src=\""
307 "static/viewcontacts_48x.gif"
311 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
312 wprintf("<img class=\"roompic\" alt=\"\" src=\""
313 "static/calarea_48x.gif"
314 "\" width=\"48\" height=\"48\">"
317 else if (WC->wc_view == VIEW_TASKS) {
318 wprintf("<img class=\"roompic\" alt=\"\" src=\""
319 "static/taskmanag_48x.gif"
320 "\" width=\"48\" height=\"48\">"
323 else if (WC->wc_view == VIEW_NOTES) {
324 wprintf("<img class=\"roompic\" alt=\"\" src=\""
325 "static/storenotes_48x.gif"
326 "\" width=\"48\" height=\"48\">"
329 else if (WC->wc_view == VIEW_MAILBOX) {
330 wprintf("<img class=\"roompic\" alt=\"\" src=\""
331 "static/privatemess_48x.gif"
332 "\" width=\"48\" height=\"48\">"
336 wprintf("<img class=\"roompic\" alt=\"\" src=\""
337 "static/chatrooms_48x.gif"
338 "\" width=\"48\" height=\"48\">"
347 * Display the current view and offer an option to change it
349 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
353 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
354 wprintf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
355 wprintf("<label for=\"view_name\">");
356 wprintf(_("View as:"));
358 "<select name=\"newview\" size=\"1\" "
359 "id=\"view_name\" class=\"selectbox\" "
360 "OnChange=\"location.href=viewomatic.newview.options"
361 "[selectedIndex].value\">\n");
363 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
365 * Only offer the views that make sense, given the default
366 * view for the room. For example, don't offer a Calendar
367 * view in a non-Calendar room.
371 || (i == WC->wc_default_view) /* default */
372 || ( (i == 0) && (WC->wc_default_view == 1) ) /* mail or bulletin */
373 || ( (i == 1) && (WC->wc_default_view == 0) ) /* mail or bulletin */
374 /* || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
377 wprintf("<option %s value=\"changeview?view=%d\">",
378 ((i == WC->wc_view) ? "selected" : ""),
380 escputs(viewdefs[i]);
381 wprintf("</option>\n");
384 wprintf("</select></div></form>\n");
389 * Display a search box
391 void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP)
393 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
394 wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
395 wprintf("<label for=\"srchquery\">");
396 wprintf(_("Search: "));
397 wprintf("</label><input ");
398 wprintf("%s", WC->serv_info->serv_fulltext_enabled ? "" : "disabled ");
399 wprintf("type=\"text\" name=\"query\" id=\"srchquery\" size=\"15\" maxlength=\"128\" class=\"inputbox\">\n"
401 wprintf("</div></form>\n");
406 * Embed the room banner
408 * got The information returned from a GOTO server command
409 * navbar_style Determines which navigation buttons to display
413 void embed_room_banner(char *got, int navbar_style) {
417 char with_files[256];
421 * We need to have the information returned by a GOTO server command.
422 * If it isn't supplied, we fake it by issuing our own GOTO.
425 memset(buf, '0', 20);
427 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
428 serv_getln(buf, sizeof buf);
432 /* The browser needs some information for its own use */
433 wprintf("<script type=\"text/javascript\"> \n"
434 " room_is_trash = %d; \n"
440 * If the user happens to select the "make this my start page" link,
441 * we want it to remember the URL as a "/dotskip" one instead of
442 * a "skip" or "gotonext" or something like that.
444 if (WCC->Hdr->this_page == NULL) {
445 WCC->Hdr->this_page = NewStrBuf();
447 StrBufPrintf(WCC->Hdr->this_page,
449 ChrPtr(WC->wc_roomname)
452 /* Check for new mail. */
453 WC->new_mail = extract_int(&got[4], 9);
454 WC->wc_view = extract_int(&got[4], 11);
456 /* Is this a directory room and does it contain files and how many? */
457 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
460 serv_getln(buf2, sizeof buf2);
461 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
463 snprintf (with_files, sizeof with_files,
464 "; <a href=\"do_template?template=files\"> %d %s </a>",
466 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
469 strcpy (with_files, "");
471 svprintf(HKEY("NUMMSGS"), WCS_STRING,
472 _("%d new of %d messages%s"),
473 extract_int(&got[4], 1),
474 extract_int(&got[4], 2),
477 svcallback("ROOMPIC", embed_room_graphic);
478 svcallback("ROOMINFO", readinfo);
479 svcallback("VIEWOMATIC", embed_view_o_matic);
480 svcallback("SEARCHOMATIC", embed_search_o_matic);
481 svcallback("START", offer_start_page);
483 do_template("roombanner", NULL);
484 /* roombanner contains this for mobile */
485 if (navbar_style != navbar_none && !WC->is_mobile) {
487 wprintf("<div id=\"navbar\"><ul>");
489 if (navbar_style == navbar_default) wprintf(
490 "<li class=\"ungoto\">"
491 "<a href=\"ungoto\">"
492 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
493 "<span class=\"navbar_link\">%s</span></A>"
494 "</li>\n", _("Ungoto")
497 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
499 "<li class=\"newmess\">"
500 "<a href=\"readnew\">"
501 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
502 "<span class=\"navbar_link\">%s</span></A>"
503 "</li>\n", _("Read new messages")
507 if (navbar_style == navbar_default) {
508 switch(WC->wc_view) {
509 case VIEW_ADDRESSBOOK:
511 "<li class=\"viewcontacts\">"
512 "<a href=\"readfwd\">"
513 "<img src=\"static/viewcontacts_24x.gif\" "
514 "alt=\"\" width=\"24\" height=\"24\">"
515 "<span class=\"navbar_link\">"
517 "</span></a></li>\n", _("View contacts")
522 "<li class=\"staskday\">"
523 "<a href=\"readfwd?calview=day\">"
524 "<img src=\"static/taskday2_24x.gif\" "
525 "alt=\"\" width=\"24\" height=\"24\">"
526 "<span class=\"navbar_link\">"
528 "</span></a></li>\n", _("Day view")
531 "<li class=\"monthview\">"
532 "<a href=\"readfwd?calview=month\">"
533 "<img src=\"static/monthview2_24x.gif\" "
534 "alt=\"\" width=\"24\" height=\"24\">"
535 "<span class=\"navbar_link\">"
537 "</span></a></li>\n", _("Month view")
542 "<li class=\"monthview\">"
543 "<a href=\"readfwd?calview=month\">"
544 "<img src=\"static/monthview2_24x.gif\" "
545 "alt=\"\" width=\"24\" height=\"24\">"
546 "<span class=\"navbar_link\">"
548 "</span></a></li>\n", _("Calendar list")
553 "<li class=\"taskmanag\">"
554 "<a href=\"readfwd\">"
555 "<img src=\"static/taskmanag_24x.gif\" "
556 "alt=\"\" width=\"24\" height=\"24\">"
557 "<span class=\"navbar_link\">"
559 "</span></a></li>\n", _("View tasks")
564 "<li class=\"viewnotes\">"
565 "<a href=\"readfwd\">"
566 "<img src=\"static/viewnotes_24x.gif\" "
567 "alt=\"\" width=\"24\" height=\"24\">"
568 "<span class=\"navbar_link\">"
570 "</span></a></li>\n", _("View notes")
575 "<li class=\"readallmess\">"
576 "<a id=\"m_refresh\" href=\"readfwd\">"
577 "<img src=\"static/readallmess3_24x.gif\" "
578 "alt=\"\" width=\"24\" height=\"24\">"
579 "<span class=\"navbar_link\">"
581 "</span></a></li>\n", _("Refresh message list")
586 "<li class=\"readallmess\">"
587 "<a href=\"readfwd\">"
588 "<img src=\"static/readallmess3_24x.gif\" "
589 "alt=\"\" width=\"24\" height=\"24\">"
590 "<span class=\"navbar_link\">"
592 "</span></a></li>\n", _("Wiki home")
597 "<li class=\"readallmess\">"
598 "<a href=\"readfwd\">"
599 "<img src=\"static/readallmess3_24x.gif\" "
600 "alt=\"\" width=\"24\" height=\"24\">"
601 "<span class=\"navbar_link\">"
603 "</span></a></li>\n", _("Read all messages")
609 if (navbar_style == navbar_default) {
610 switch(WC->wc_view) {
611 case VIEW_ADDRESSBOOK:
613 "<li class=\"addnewcontact\">"
614 "<a href=\"display_enter\">"
615 "<img src=\"static/addnewcontact_24x.gif\" "
616 "alt=\"\" width=\"24\" height=\"24\">"
617 "<span class=\"navbar_link\">"
619 "</span></a></li>\n", _("Add new contact")
624 wprintf("<li class=\"addevent\"><a href=\"display_enter");
625 if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
626 if (havebstr("month")) wprintf("?month=%s", bstr("month"));
627 if (havebstr("day" )) wprintf("?day=%s", bstr("day"));
629 "<img src=\"static/addevent_24x.gif\" "
630 "alt=\"\" width=\"24\" height=\"24\">"
631 "<span class=\"navbar_link\">"
633 "</span></a></li>\n", _("Add new event")
638 "<li class=\"newmess\">"
639 "<a href=\"display_enter\">"
640 "<img src=\"static/newmess3_24x.gif\" "
641 "alt=\"\" width=\"24\" height=\"24\">"
642 "<span class=\"navbar_link\">"
644 "</span></a></li>\n", _("Add new task")
649 "<li class=\"enternewnote\">"
650 "<a href=\"add_new_note\">"
651 "<img src=\"static/enternewnote_24x.gif\" "
652 "alt=\"\" width=\"24\" height=\"24\">"
653 "<span class=\"navbar_link\">"
655 "</span></a></li>\n", _("Add new note")
659 safestrncpy(buf, bstr("page"), sizeof buf);
662 "<li class=\"newmess\">"
663 "<a href=\"display_enter?wikipage=%s\">"
664 "<img src=\"static/newmess3_24x.gif\" "
665 "alt=\"\" width=\"24\" height=\"24\">"
666 "<span class=\"navbar_link\">"
668 "</span></a></li>\n", buf, _("Edit this page")
673 "<li class=\"newmess\">"
674 "<a href=\"display_enter\">"
675 "<img src=\"static/newmess3_24x.gif\" "
676 "alt=\"\" width=\"24\" height=\"24\">"
677 "<span class=\"navbar_link\">"
679 "</span></a></li>\n", _("Write mail")
682 "<li class=\"newmess\">"
683 "<a href=\"javascript:deleteAllSelectedMessages();\">"
684 "<img src=\"static/delete.gif\" "
685 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
687 "</span></a></li>\n", _("Delete")
692 "<li class=\"newmess\">"
693 "<a href=\"display_enter\">"
694 "<img src=\"static/newmess3_24x.gif\" "
695 "alt=\"\" width=\"24\" height=\"24\">"
696 "<span class=\"navbar_link\">"
698 "</span></a></li>\n", _("Enter a message")
704 if (navbar_style == navbar_default) wprintf(
705 "<li class=\"skipthisroom\">"
708 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
709 "width=\"24\" height=\"24\">"
710 "<span class=\"navbar_link\">%s</span></a>"
712 _("Leave all messages marked as unread, go to next room with unread messages"),
716 if (navbar_style == navbar_default) wprintf(
717 "<li class=\"markngo\">"
718 "<a href=\"gotonext\" "
720 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
721 "width=\"24\" height=\"24\">"
722 "<span class=\"navbar_link\">%s</span></a>"
724 _("Mark all messages as read, go to next room with unread messages"),
728 wprintf("</ul></div>\n");
735 * back end routine to take the session to a new room
737 long gotoroom(const StrBuf *gname)
740 static long ls = (-1L);
743 /* store ungoto information */
744 strcpy(WC->ugname, ChrPtr(WC->wc_roomname));
748 /* move to the new room */
749 serv_printf("GOTO %s", ChrPtr(gname));
750 StrBuf_ServGetln(Buf);
751 if (GetServerStatus(Buf, &err) != 2) {
752 serv_puts("GOTO _BASEROOM_");
753 StrBuf_ServGetln(Buf);
755 * well, we know that this is the fallback case,
756 * but we're interested that the first command
757 * didn't work out in first place.
759 if (GetServerStatus(Buf, NULL) != 2) {
765 if (WC->wc_roomname == NULL)
766 WC->wc_roomname = NewStrBuf();
768 FlushStrBuf(WC->wc_roomname);
770 StrBufExtract_token(WC->wc_roomname, Buf, 0, '|');
771 StrBufCutLeft(WC->wc_roomname, 4);
772 WC->room_flags = StrBufExtract_int(Buf, 4, '|');
773 /* highest_msg_read = extract_int(&buf[4],6);
774 maxmsgnum = extract_int(&buf[4],5);
776 WC->is_mailbox = StrBufExtract_int(Buf, 7, '|');
777 ls = StrBufExtract_long(Buf, 6, '|');
778 WC->wc_floor = StrBufExtract_int(Buf, 10, '|');
779 WC->wc_view = StrBufExtract_int(Buf, 11, '|');
780 WC->wc_default_view = StrBufExtract_int(Buf, 12, '|');
781 WC->wc_is_trash = StrBufExtract_int(Buf, 13, '|');
782 WC->room_flags2 = StrBufExtract_int(Buf, 14, '|');
785 WC->is_room_aide = WC->is_aide;
787 WC->is_room_aide = (char) StrBufExtract_int(Buf, 8, '|');
789 remove_march(WC->wc_roomname);
790 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
801 void smart_goto(const StrBuf *next_room) {
809 * mark all messages in current room as having been read
811 void slrp_highest(void)
815 serv_puts("SLRP HIGHEST");
816 serv_getln(buf, sizeof buf);
820 typedef struct __room_states {
835 * Set/clear/read the "self-service list subscribe" flag for a room
837 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
838 * returns the new value.
841 int self_service(int newval) {
842 int current_value = 0;
848 int flags, floor, order, view, flags2;
851 serv_getln(buf, sizeof buf);
852 if (buf[0] != '2') return(0);
854 extract_token(name, &buf[4], 0, '|', sizeof name);
855 extract_token(password, &buf[4], 1, '|', sizeof password);
856 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
857 flags = extract_int(&buf[4], 3);
858 floor = extract_int(&buf[4], 4);
859 order = extract_int(&buf[4], 5);
860 view = extract_int(&buf[4], 6);
861 flags2 = extract_int(&buf[4], 7);
863 if (flags2 & QR2_SELFLIST) {
871 flags2 = flags2 | QR2_SELFLIST;
873 else if (newval == 0) {
874 flags2 = flags2 & ~QR2_SELFLIST;
877 return(current_value);
880 if (newval != current_value) {
881 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
882 name, password, dirname, flags,
883 floor, order, view, flags2);
884 serv_getln(buf, sizeof buf);
891 int is_selflist(room_states *RoomFlags)
893 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
896 int is_publiclist(room_states *RoomFlags)
898 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
901 int is_moderatedlist(room_states *RoomFlags)
903 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
907 * Set/clear/read the "self-service list subscribe" flag for a room
909 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
910 * returns the new value.
913 int get_roomflags(room_states *RoomOps)
918 serv_getln(buf, sizeof buf);
919 if (buf[0] != '2') return(0);
921 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
922 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
923 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
924 RoomOps->flags = extract_int(&buf[4], 3);
925 RoomOps->floor = extract_int(&buf[4], 4);
926 RoomOps->order = extract_int(&buf[4], 5);
927 RoomOps->view = extract_int(&buf[4], 6);
928 RoomOps->flags2 = extract_int(&buf[4], 7);
932 int set_roomflags(room_states *RoomOps)
936 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
945 serv_getln(buf, sizeof buf);
955 * display the form for editing a room
957 void display_editroom(void)
963 char remote_room[128];
966 char er_password[10];
968 char er_roomaide[26];
975 char *not_shared_with;
985 if (IsEmptyStr(tab)) tab = "admin";
990 output_headers(1, 1, 1, 0, 0, 0);
992 wprintf("<div class=\"fix_scrollbar_bug\">");
996 /* print the tabbed dialog */
997 wprintf("<div align=\"center\">");
998 wprintf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
999 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1002 wprintf("<td class=\"");
1003 if (!strcmp(tab, "admin")) {
1004 wprintf(" tab_cell_label\">");
1005 wprintf(_("Administration"));
1008 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1009 wprintf(_("Administration"));
1013 wprintf("<td> </td>\n");
1015 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1017 wprintf("<td class=\"");
1018 if (!strcmp(tab, "config")) {
1019 wprintf(" tab_cell_label\">");
1020 wprintf(_("Configuration"));
1023 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1024 wprintf(_("Configuration"));
1028 wprintf("<td> </td>\n");
1030 wprintf("<td class=\"");
1031 if (!strcmp(tab, "expire")) {
1032 wprintf(" tab_cell_label\">");
1033 wprintf(_("Message expire policy"));
1036 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1037 wprintf(_("Message expire policy"));
1041 wprintf("<td> </td>\n");
1043 wprintf("<td class=\"");
1044 if (!strcmp(tab, "access")) {
1045 wprintf(" tab_cell_label\">");
1046 wprintf(_("Access controls"));
1049 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1050 wprintf(_("Access controls"));
1054 wprintf("<td> </td>\n");
1056 wprintf("<td class=\"");
1057 if (!strcmp(tab, "sharing")) {
1058 wprintf(" tab_cell_label\">");
1059 wprintf(_("Sharing"));
1062 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1063 wprintf(_("Sharing"));
1067 wprintf("<td> </td>\n");
1069 wprintf("<td class=\"");
1070 if (!strcmp(tab, "listserv")) {
1071 wprintf(" tab_cell_label\">");
1072 wprintf(_("Mailing list service"));
1075 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1076 wprintf(_("Mailing list service"));
1080 wprintf("<td> </td>\n");
1084 wprintf("<td class=\"");
1085 if (!strcmp(tab, "feeds")) {
1086 wprintf(" tab_cell_label\">");
1087 wprintf(_("Remote retrieval"));
1090 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1091 wprintf(_("Remote retrieval"));
1095 wprintf("<td> </td>\n");
1097 wprintf("</tr></table>\n");
1098 wprintf("</div>\n");
1099 /* end tabbed dialog */
1101 wprintf("<script type=\"text/javascript\">"
1102 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1106 /* begin content of whatever tab is open now */
1108 if (!strcmp(tab, "admin")) {
1109 wprintf("<div class=\"tabcontent\">");
1111 "<li><a href=\"delete_room\" "
1112 "onClick=\"return confirm('");
1113 wprintf(_("Are you sure you want to delete this room?"));
1114 wprintf("');\">\n");
1115 wprintf(_("Delete this room"));
1117 "<li><a href=\"display_editroompic?which_room=");
1118 urlescputs(ChrPtr(WC->wc_roomname));
1120 wprintf(_("Set or change the icon for this room's banner"));
1122 "<li><a href=\"display_editinfo\">\n");
1123 wprintf(_("Edit this room's Info file"));
1129 if (!strcmp(tab, "config")) {
1130 wprintf("<div class=\"tabcontent\">");
1132 serv_getln(buf, sizeof buf);
1134 if (!strncmp(buf, "550", 3)) {
1135 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1136 _("Higher access is required to access this function.")
1139 else if (buf[0] != '2') {
1140 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1143 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1144 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1145 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1146 er_flags = extract_int(&buf[4], 3);
1147 er_floor = extract_int(&buf[4], 4);
1148 er_flags2 = extract_int(&buf[4], 7);
1150 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1151 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1153 wprintf("<ul><li>");
1154 wprintf(_("Name of room: "));
1155 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1161 wprintf(_("Resides on floor: "));
1162 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1163 if (er_flags & QR_MAILBOX)
1164 wprintf("disabled >\n");
1165 for (i = 0; i < 128; ++i)
1166 if (!IsEmptyStr(floorlist[i])) {
1167 wprintf("<OPTION ");
1169 wprintf("SELECTED ");
1170 wprintf("VALUE=\"%d\">", i);
1171 escputs(floorlist[i]);
1172 wprintf("</OPTION>\n");
1174 wprintf("</select>\n");
1177 wprintf(_("Type of room:"));
1180 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1181 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1182 wprintf("CHECKED ");
1183 wprintf("OnChange=\""
1184 " if (this.form.type[0].checked == true) { "
1185 " this.form.er_floor.disabled = false; "
1188 wprintf(_("Public (automatically appears to everyone)"));
1191 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1192 if ((er_flags & QR_PRIVATE) &&
1193 (er_flags & QR_GUESSNAME))
1194 wprintf("CHECKED ");
1195 wprintf(" OnChange=\""
1196 " if (this.form.type[1].checked == true) { "
1197 " this.form.er_floor.disabled = false; "
1200 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1202 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1203 if ((er_flags & QR_PRIVATE) &&
1204 (er_flags & QR_PASSWORDED))
1205 wprintf("CHECKED ");
1206 wprintf(" OnChange=\""
1207 " if (this.form.type[2].checked == true) { "
1208 " this.form.er_floor.disabled = false; "
1211 wprintf(_("Private - require password: "));
1212 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1215 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1216 if ((er_flags & QR_PRIVATE)
1217 && ((er_flags & QR_GUESSNAME) == 0)
1218 && ((er_flags & QR_PASSWORDED) == 0))
1219 wprintf("CHECKED ");
1220 wprintf(" OnChange=\""
1221 " if (this.form.type[3].checked == true) { "
1222 " this.form.er_floor.disabled = false; "
1225 wprintf(_("Private - invitation only"));
1227 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1228 if (er_flags & QR_MAILBOX)
1229 wprintf("CHECKED ");
1230 wprintf (" OnChange=\""
1231 " if (this.form.type[4].checked == true) { "
1232 " this.form.er_floor.disabled = true; "
1235 wprintf(_("Personal (mailbox for you only)"));
1237 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1239 wprintf(_("If private, cause current users to forget room"));
1241 wprintf("\n</ul>\n");
1243 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1244 if (er_flags & QR_PREFONLY)
1245 wprintf("CHECKED ");
1247 wprintf(_("Preferred users only"));
1249 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1250 if (er_flags & QR_READONLY)
1251 wprintf("CHECKED ");
1253 wprintf(_("Read-only room"));
1255 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1256 if (er_flags2 & QR2_COLLABDEL)
1257 wprintf("CHECKED ");
1259 wprintf(_("All users allowed to post may also delete messages"));
1261 /** directory stuff */
1262 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1263 if (er_flags & QR_DIRECTORY)
1264 wprintf("CHECKED ");
1266 wprintf(_("File directory room"));
1268 wprintf("\n<ul><li>");
1269 wprintf(_("Directory name: "));
1270 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1273 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1274 if (er_flags & QR_UPLOAD)
1275 wprintf("CHECKED ");
1277 wprintf(_("Uploading allowed"));
1279 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1280 if (er_flags & QR_DOWNLOAD)
1281 wprintf("CHECKED ");
1283 wprintf(_("Downloading allowed"));
1285 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1286 if (er_flags & QR_VISDIR)
1287 wprintf("CHECKED ");
1289 wprintf(_("Visible directory"));
1292 /** end of directory stuff */
1294 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1295 if (er_flags & QR_NETWORK)
1296 wprintf("CHECKED ");
1298 wprintf(_("Network shared room"));
1300 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1301 if (er_flags & QR_PERMANENT)
1302 wprintf("CHECKED ");
1304 wprintf(_("Permanent (does not auto-purge)"));
1306 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1307 if (er_flags2 & QR2_SUBJECTREQ)
1308 wprintf("CHECKED ");
1310 wprintf(_("Subject Required (Force users to specify a message subject)"));
1312 /** start of anon options */
1315 wprintf(_("Anonymous messages"));
1318 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1319 if (((er_flags & QR_ANONONLY) == 0)
1320 && ((er_flags & QR_ANONOPT) == 0))
1321 wprintf("CHECKED ");
1323 wprintf(_("No anonymous messages"));
1325 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1326 if (er_flags & QR_ANONONLY)
1327 wprintf("CHECKED ");
1329 wprintf(_("All messages are anonymous"));
1331 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1332 if (er_flags & QR_ANONOPT)
1333 wprintf("CHECKED ");
1335 wprintf(_("Prompt user when entering messages"));
1338 /* end of anon options */
1341 wprintf(_("Room aide: "));
1343 serv_getln(buf, sizeof buf);
1344 if (buf[0] != '2') {
1345 wprintf("<em>%s</em>\n", &buf[4]);
1347 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1348 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1351 wprintf("</ul><CENTER>\n");
1352 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1353 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1355 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1365 /* Sharing the room with other Citadel nodes... */
1366 if (!strcmp(tab, "sharing")) {
1367 wprintf("<div class=\"tabcontent\">");
1369 shared_with = strdup("");
1370 not_shared_with = strdup("");
1372 /** Learn the current configuration */
1373 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1374 serv_getln(buf, sizeof buf);
1375 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1376 extract_token(node, buf, 0, '|', sizeof node);
1377 not_shared_with = realloc(not_shared_with,
1378 strlen(not_shared_with) + 32);
1379 strcat(not_shared_with, node);
1380 strcat(not_shared_with, "\n");
1384 serv_getln(buf, sizeof buf);
1385 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1386 extract_token(cmd, buf, 0, '|', sizeof cmd);
1387 extract_token(node, buf, 1, '|', sizeof node);
1388 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1389 if (!strcasecmp(cmd, "ignet_push_share")) {
1390 shared_with = realloc(shared_with,
1391 strlen(shared_with) + 32);
1392 strcat(shared_with, node);
1393 if (!IsEmptyStr(remote_room)) {
1394 strcat(shared_with, "|");
1395 strcat(shared_with, remote_room);
1397 strcat(shared_with, "\n");
1401 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1402 extract_token(buf, shared_with, i, '\n', sizeof buf);
1403 extract_token(node, buf, 0, '|', sizeof node);
1404 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1405 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1406 if (!strcasecmp(node, cmd)) {
1407 remove_token(not_shared_with, j, '\n');
1412 /* Display the stuff */
1413 wprintf("<CENTER><br />"
1414 "<table border=1 cellpadding=5><tr>"
1416 wprintf(_("Shared with"));
1417 wprintf("</I></B></td>"
1419 wprintf(_("Not shared with"));
1420 wprintf("</I></B></td></tr>\n"
1421 "<tr><td VALIGN=TOP>\n");
1423 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1424 wprintf(_("Remote node name"));
1425 wprintf("</td><td>");
1426 wprintf(_("Remote room name"));
1427 wprintf("</td><td>");
1428 wprintf(_("Actions"));
1429 wprintf("</td></tr>\n");
1431 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1432 extract_token(buf, shared_with, i, '\n', sizeof buf);
1433 extract_token(node, buf, 0, '|', sizeof node);
1434 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1435 if (!IsEmptyStr(node)) {
1436 wprintf("<form method=\"POST\" action=\"netedit\">");
1437 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1438 wprintf("<tr><td>%s</td>\n", node);
1441 if (!IsEmptyStr(remote_room)) {
1442 escputs(remote_room);
1448 wprintf("<input type=\"hidden\" NAME=\"line\" "
1449 "VALUE=\"ignet_push_share|");
1451 if (!IsEmptyStr(remote_room)) {
1453 urlescputs(remote_room);
1456 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1457 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1458 wprintf("<input type=\"submit\" "
1459 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1460 wprintf("</td></tr></form>\n");
1464 wprintf("</table>\n");
1465 wprintf("</td><td VALIGN=TOP>\n");
1466 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1467 wprintf(_("Remote node name"));
1468 wprintf("</td><td>");
1469 wprintf(_("Remote room name"));
1470 wprintf("</td><td>");
1471 wprintf(_("Actions"));
1472 wprintf("</td></tr>\n");
1474 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1475 extract_token(node, not_shared_with, i, '\n', sizeof node);
1476 if (!IsEmptyStr(node)) {
1477 wprintf("<form method=\"POST\" action=\"netedit\">");
1478 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1479 wprintf("<tr><td>");
1482 "<input type=\"INPUT\" "
1486 wprintf("<input type=\"hidden\" "
1488 "VALUE=\"ignet_push_share|");
1491 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1492 "VALUE=\"sharing\">\n");
1493 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1494 "VALUE=\"add\">\n");
1495 wprintf("<input type=\"submit\" "
1496 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1497 wprintf("</td></tr></form>\n");
1501 wprintf("</table>\n");
1502 wprintf("</td></tr>"
1503 "</table></CENTER><br />\n"
1504 "<I><B>%s</B><ul><li>", _("Notes:"));
1505 wprintf(_("When sharing a room, "
1506 "it must be shared from both ends. Adding a node to "
1507 "the 'shared' list sends messages out, but in order to"
1508 " receive messages, the other nodes must be configured"
1509 " to send messages out to your system as well. "
1510 "<li>If the remote room name is blank, it is assumed "
1511 "that the room name is identical on the remote node."
1512 "<li>If the remote room name is different, the remote "
1513 "node must also configure the name of the room here."
1520 /* Mailing list management */
1521 if (!strcmp(tab, "listserv")) {
1522 room_states RoomFlags;
1523 wprintf("<div class=\"tabcontent\">");
1525 wprintf("<br /><center>"
1526 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1527 "<tr><td VALIGN=TOP>");
1529 wprintf(_("<i>The contents of this room are being "
1530 "mailed <b>as individual messages</b> "
1531 "to the following list recipients:"
1532 "</i><br /><br />\n"));
1535 serv_getln(buf, sizeof buf);
1536 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1537 extract_token(cmd, buf, 0, '|', sizeof cmd);
1538 if (!strcasecmp(cmd, "listrecp")) {
1539 extract_token(recp, buf, 1, '|', sizeof recp);
1542 wprintf(" <a href=\"netedit?cmd=remove&tab=listserv&line=listrecp|");
1545 wprintf(_("(remove)"));
1546 wprintf("</A><br />");
1549 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1550 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1551 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1552 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1553 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1554 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1555 wprintf("</form>\n");
1557 wprintf("</td><td VALIGN=TOP>\n");
1559 wprintf(_("<i>The contents of this room are being "
1560 "mailed <b>in digest form</b> "
1561 "to the following list recipients:"
1562 "</i><br /><br />\n"));
1565 serv_getln(buf, sizeof buf);
1566 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1567 extract_token(cmd, buf, 0, '|', sizeof cmd);
1568 if (!strcasecmp(cmd, "digestrecp")) {
1569 extract_token(recp, buf, 1, '|', sizeof recp);
1572 wprintf(" <a href=\"netedit?cmd=remove&tab=listserv&line="
1576 wprintf(_("(remove)"));
1577 wprintf("</A><br />");
1580 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1581 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1582 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1583 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1584 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1585 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1586 wprintf("</form>\n");
1588 wprintf("</td></tr></table>\n");
1590 /** Pop open an address book -- begin **/
1591 wprintf("<div align=right>"
1592 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1594 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1599 _("Add recipients from Contacts or other address books"),
1600 _("Add recipients from Contacts or other address books")
1602 /* Pop open an address book -- end **/
1604 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1606 get_roomflags (&RoomFlags);
1608 /* Self Service subscription? */
1609 wprintf("<table><tr><td>\n");
1610 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1611 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1612 " <tr><td colspan=\"2\">\n",
1613 (is_selflist(&RoomFlags))?"checked":"");
1614 wprintf(_("The URL for subscribe/unsubscribe is: "));
1615 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1616 (is_https ? "https" : "http"),
1617 ChrPtr(WC->Hdr->HR.http_host));
1618 /* Public posting? */
1619 wprintf("<tr><td>");
1620 wprintf(_("Allow non-subscribers to mail to this room."));
1621 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1622 (is_publiclist(&RoomFlags))?"checked":"");
1624 /* Moderated List? */
1625 wprintf("<tr><td>");
1626 wprintf(_("Room post publication needs Aide permission."));
1627 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1628 (is_moderatedlist(&RoomFlags))?"checked":"");
1631 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1632 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1633 wprintf("</table></form>");
1636 wprintf("</CENTER>\n");
1641 /* Configuration of The Dreaded Auto-Purger */
1642 if (!strcmp(tab, "expire")) {
1643 wprintf("<div class=\"tabcontent\">");
1645 serv_puts("GPEX room");
1646 serv_getln(buf, sizeof buf);
1647 if (!strncmp(buf, "550", 3)) {
1648 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1649 _("Higher access is required to access this function.")
1652 else if (buf[0] != '2') {
1653 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1656 roompolicy = extract_int(&buf[4], 0);
1657 roomvalue = extract_int(&buf[4], 1);
1659 serv_puts("GPEX floor");
1660 serv_getln(buf, sizeof buf);
1661 if (buf[0] == '2') {
1662 floorpolicy = extract_int(&buf[4], 0);
1663 floorvalue = extract_int(&buf[4], 1);
1666 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1667 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1668 wprintf("<table border=0 cellspacing=5>\n");
1669 wprintf("<tr><td>");
1670 wprintf(_("Message expire policy for this room"));
1672 escputs(ChrPtr(WC->wc_roomname));
1673 wprintf(")</td><td>");
1674 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1675 ((roompolicy == 0) ? "CHECKED" : "") );
1676 wprintf(_("Use the default policy for this floor"));
1677 wprintf("<br />\n");
1678 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1679 ((roompolicy == 1) ? "CHECKED" : "") );
1680 wprintf(_("Never automatically expire messages"));
1681 wprintf("<br />\n");
1682 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1683 ((roompolicy == 2) ? "CHECKED" : "") );
1684 wprintf(_("Expire by message count"));
1685 wprintf("<br />\n");
1686 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1687 ((roompolicy == 3) ? "CHECKED" : "") );
1688 wprintf(_("Expire by message age"));
1690 wprintf(_("Number of messages or days: "));
1691 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1692 wprintf("</td></tr>\n");
1694 if (WC->axlevel >= 6) {
1695 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1696 wprintf("<tr><td>");
1697 wprintf(_("Message expire policy for this floor"));
1699 escputs(floorlist[WC->wc_floor]);
1700 wprintf(")</td><td>");
1701 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1702 ((floorpolicy == 0) ? "CHECKED" : "") );
1703 wprintf(_("Use the system default"));
1704 wprintf("<br />\n");
1705 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1706 ((floorpolicy == 1) ? "CHECKED" : "") );
1707 wprintf(_("Never automatically expire messages"));
1708 wprintf("<br />\n");
1709 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1710 ((floorpolicy == 2) ? "CHECKED" : "") );
1711 wprintf(_("Expire by message count"));
1712 wprintf("<br />\n");
1713 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1714 ((floorpolicy == 3) ? "CHECKED" : "") );
1715 wprintf(_("Expire by message age"));
1717 wprintf(_("Number of messages or days: "));
1718 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1722 wprintf("<CENTER>\n");
1723 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1724 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1726 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1727 wprintf("</CENTER></td><tr>\n");
1729 wprintf("</table>\n"
1730 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1738 /* Access controls */
1739 if (!strcmp(tab, "access")) {
1740 wprintf("<div class=\"tabcontent\">");
1745 /* Fetch messages from remote locations */
1746 if (!strcmp(tab, "feeds")) {
1747 wprintf("<div class=\"tabcontent\">");
1750 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1751 wprintf("</i><br />\n");
1753 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1754 "<tr class=\"even\"><th>");
1755 wprintf(_("Remote host"));
1756 wprintf("</th><th>");
1757 wprintf(_("User name"));
1758 wprintf("</th><th>");
1759 wprintf(_("Password"));
1760 wprintf("</th><th>");
1761 wprintf(_("Keep messages on server?"));
1762 wprintf("</th><th>");
1763 wprintf(_("Interval"));
1764 wprintf("</th><th> </th></tr>");
1767 serv_getln(buf, sizeof buf);
1769 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1770 extract_token(cmd, buf, 0, '|', sizeof cmd);
1771 if (!strcasecmp(cmd, "pop3client")) {
1772 safestrncpy(recp, &buf[11], sizeof recp);
1775 wprintf("<tr class=\"%s\">",
1776 (bg ? "even" : "odd")
1780 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1785 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1789 wprintf("<td>*****</td>"); /* Don't show the password */
1791 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1793 wprintf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
1795 wprintf("<td class=\"button_link\">");
1796 wprintf(" <a href=\"netedit?cmd=remove&tab=feeds&line=pop3client|");
1799 wprintf(_("(remove)"));
1800 wprintf("</a></td>");
1806 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1808 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1809 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1810 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1812 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1815 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1818 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1821 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1824 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
1827 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1828 wprintf("</td></tr>");
1829 wprintf("</form></table>\n");
1834 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1835 wprintf("</i><br />\n");
1837 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1838 "<tr class=\"even\"><th>");
1839 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1840 wprintf(_("Feed URL"));
1841 wprintf("</th><th>");
1842 wprintf("</th></tr>");
1845 serv_getln(buf, sizeof buf);
1847 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1848 extract_token(cmd, buf, 0, '|', sizeof cmd);
1849 if (!strcasecmp(cmd, "rssclient")) {
1850 safestrncpy(recp, &buf[10], sizeof recp);
1853 wprintf("<tr class=\"%s\">",
1854 (bg ? "even" : "odd")
1858 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1862 wprintf("<td class=\"button_link\">");
1863 wprintf(" <a href=\"netedit?cmd=remove&tab=feeds&line=rssclient|");
1866 wprintf(_("(remove)"));
1867 wprintf("</a></td>");
1873 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1875 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1876 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
1877 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1879 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
1880 "maxlength=\"256\" name=\"line_pop3host\">\n");
1883 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
1884 wprintf("</td></tr>");
1885 wprintf("</form></table>\n");
1891 /* end content of whatever tab is open now */
1892 wprintf("</div>\n");
1894 address_book_popup();
1900 * Toggle self-service list subscription
1902 void toggle_self_service(void) {
1903 room_states RoomFlags;
1905 get_roomflags (&RoomFlags);
1907 if (yesbstr("QR2_SelfList"))
1908 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
1910 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
1912 if (yesbstr("QR2_SMTP_PUBLIC"))
1913 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
1915 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
1917 if (yesbstr("QR2_Moderated"))
1918 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
1920 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
1921 if (yesbstr("QR2_SubsOnly"))
1922 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
1924 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
1926 set_roomflags (&RoomFlags);
1934 * save new parameters for a room
1941 StrBuf *er_password;
1943 StrBuf *er_roomaide;
1946 int er_listingorder;
1952 if (!havebstr("ok_button")) {
1953 strcpy(WC->ImportantMessage,
1954 _("Cancelled. Changes were not saved."));
1960 StrBuf_ServGetln(Buf);
1961 if (GetServerStatus(Buf, NULL) != 2) {
1962 StrBufCutLeft(Buf, 4);
1963 strcpy(WC->ImportantMessage, ChrPtr(Buf));
1969 er_name = NewStrBuf();
1970 er_password = NewStrBuf();
1971 er_dirname = NewStrBuf();
1972 er_roomaide = NewStrBuf();
1974 StrBufCutLeft(Buf, 4);
1975 StrBufExtract_token(er_name, Buf, 0, '|');
1976 StrBufExtract_token(er_password, Buf, 1, '|');
1977 StrBufExtract_token(er_dirname, Buf, 2, '|');
1978 er_flags = StrBufExtract_int(Buf, 3, '|');
1979 er_listingorder = StrBufExtract_int(Buf, 5, '|');
1980 er_defaultview = StrBufExtract_int(Buf, 6, '|');
1981 er_flags2 = StrBufExtract_int(Buf, 7, '|');
1983 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
1984 if (StrLength(er_roomaide) == 0) {
1986 StrBuf_ServGetln(Buf);
1987 if (GetServerStatus(Buf, NULL) != 2) {
1988 FlushStrBuf(er_roomaide);
1990 StrBufCutLeft(Buf, 4);
1991 StrBufExtract_token(er_roomaide, Buf, 0, '|');
1994 Ptr = sbstr("er_name");
1995 if (StrLength(Ptr) > 0) {
1996 FlushStrBuf(er_name);
1997 StrBufAppendBuf(er_name, Ptr, 0);
2000 Ptr = sbstr("er_password");
2001 if (StrLength(Ptr) > 0) {
2002 FlushStrBuf(er_password);
2003 StrBufAppendBuf(er_password, Ptr, 0);
2007 Ptr = sbstr("er_dirname");
2008 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2009 FlushStrBuf(er_dirname);
2010 StrBufAppendBuf(er_dirname, Ptr, 0);
2014 Ptr = sbstr("type");
2015 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2017 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2018 er_flags |= (QR_PRIVATE);
2020 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2021 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2023 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2024 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2026 if (!strcmp(ChrPtr(Ptr), "personal")) {
2027 er_flags |= QR_MAILBOX;
2029 er_flags &= ~QR_MAILBOX;
2032 if (yesbstr("prefonly")) {
2033 er_flags |= QR_PREFONLY;
2035 er_flags &= ~QR_PREFONLY;
2038 if (yesbstr("readonly")) {
2039 er_flags |= QR_READONLY;
2041 er_flags &= ~QR_READONLY;
2045 if (yesbstr("collabdel")) {
2046 er_flags2 |= QR2_COLLABDEL;
2048 er_flags2 &= ~QR2_COLLABDEL;
2051 if (yesbstr("permanent")) {
2052 er_flags |= QR_PERMANENT;
2054 er_flags &= ~QR_PERMANENT;
2057 if (yesbstr("subjectreq")) {
2058 er_flags2 |= QR2_SUBJECTREQ;
2060 er_flags2 &= ~QR2_SUBJECTREQ;
2063 if (yesbstr("network")) {
2064 er_flags |= QR_NETWORK;
2066 er_flags &= ~QR_NETWORK;
2069 if (yesbstr("directory")) {
2070 er_flags |= QR_DIRECTORY;
2072 er_flags &= ~QR_DIRECTORY;
2075 if (yesbstr("ulallowed")) {
2076 er_flags |= QR_UPLOAD;
2078 er_flags &= ~QR_UPLOAD;
2081 if (yesbstr("dlallowed")) {
2082 er_flags |= QR_DOWNLOAD;
2084 er_flags &= ~QR_DOWNLOAD;
2087 if (yesbstr("visdir")) {
2088 er_flags |= QR_VISDIR;
2090 er_flags &= ~QR_VISDIR;
2093 Ptr = sbstr("anon");
2095 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2096 if (!strcmp(ChrPtr(Ptr), "anononly"))
2097 er_flags |= QR_ANONONLY;
2098 if (!strcmp(ChrPtr(Ptr), "anon2"))
2099 er_flags |= QR_ANONOPT;
2101 bump = yesbstr("bump");
2103 er_floor = ibstr("er_floor");
2105 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2107 ChrPtr(er_password),
2116 StrBuf_ServGetln(Buf);
2117 if (GetServerStatus(Buf, NULL) != 2) {
2118 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2121 FreeStrBuf(&er_name);
2122 FreeStrBuf(&er_password);
2123 FreeStrBuf(&er_dirname);
2124 FreeStrBuf(&er_roomaide);
2129 if (StrLength(er_roomaide) > 0) {
2130 serv_printf("SETA %s", ChrPtr(er_roomaide));
2131 StrBuf_ServGetln(Buf);
2132 if (GetServerStatus(Buf, NULL) != 2) {
2133 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2134 display_main_menu();
2136 FreeStrBuf(&er_name);
2137 FreeStrBuf(&er_password);
2138 FreeStrBuf(&er_dirname);
2139 FreeStrBuf(&er_roomaide);
2144 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2147 FreeStrBuf(&er_name);
2148 FreeStrBuf(&er_password);
2149 FreeStrBuf(&er_dirname);
2150 FreeStrBuf(&er_roomaide);
2156 * Display form for Invite, Kick, and show Who Knows a room
2158 void do_invt_kick(void) {
2159 char buf[SIZ], room[SIZ], username[SIZ];
2162 serv_getln(buf, sizeof buf);
2164 if (buf[0] != '2') {
2168 extract_token(room, &buf[4], 0, '|', sizeof room);
2170 strcpy(username, bstr("username"));
2172 if (havebstr("kick_button")) {
2173 sprintf(buf, "KICK %s", username);
2175 serv_getln(buf, sizeof buf);
2177 if (buf[0] != '2') {
2178 strcpy(WC->ImportantMessage, &buf[4]);
2180 sprintf(WC->ImportantMessage,
2181 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2186 if (havebstr("invite_button")) {
2187 sprintf(buf, "INVT %s", username);
2189 serv_getln(buf, sizeof buf);
2191 if (buf[0] != '2') {
2192 strcpy(WC->ImportantMessage, &buf[4]);
2194 sprintf(WC->ImportantMessage,
2195 _("<B><I>User %s invited to room %s.</I></B>\n"),
2206 * Display form for Invite, Kick, and show Who Knows a room
2208 void display_whok(void)
2210 char buf[SIZ], room[SIZ], username[SIZ];
2213 serv_getln(buf, sizeof buf);
2215 if (buf[0] != '2') {
2219 extract_token(room, &buf[4], 0, '|', sizeof room);
2222 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2223 wprintf(_("The users listed below have access to this room. "
2224 "To remove a user from the access list, select the user "
2225 "name from the list and click 'Kick'."));
2226 wprintf("<br /><br />");
2228 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2229 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2230 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2231 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2233 serv_getln(buf, sizeof buf);
2234 if (buf[0] == '1') {
2235 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2236 extract_token(username, buf, 0, '|', sizeof username);
2237 wprintf("<OPTION>");
2242 wprintf("</select><br />\n");
2244 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2245 wprintf("</form></CENTER>\n");
2247 wprintf("</td><td>");
2248 wprintf(_("To grant another user access to this room, enter the "
2249 "user name in the box below and click 'Invite'."));
2250 wprintf("<br /><br />");
2252 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2253 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2254 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2255 wprintf(_("Invite:"));
2257 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2258 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2259 "<input type=\"submit\" value=\"%s\">"
2260 "</form></CENTER>\n", _("Invite"));
2261 /* Pop open an address book -- begin **/
2263 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2265 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2268 _("Users"), _("Users")
2270 /* Pop open an address book -- end **/
2272 wprintf("</td></tr></table>\n");
2273 address_book_popup();
2280 * display the form for entering a new room
2282 void display_entroom(void)
2289 serv_puts("CRE8 0");
2290 serv_getln(buf, sizeof buf);
2292 if (buf[0] != '2') {
2293 strcpy(WC->ImportantMessage, &buf[4]);
2294 display_main_menu();
2299 output_headers(1, 1, 1, 0, 0, 0);
2301 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2302 do_template("beginbox", NULL);
2304 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2305 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2307 wprintf("<table class=\"altern\"> ");
2309 wprintf("<tr class=\"even\"><td>");
2310 wprintf(_("Name of room: "));
2311 wprintf("</td><td>");
2312 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2313 wprintf("</td></tr>");
2315 wprintf("<tr class=\"odd\"><td>");
2316 wprintf(_("Resides on floor: "));
2317 wprintf("</td><td>");
2318 load_floorlist(Buf);
2319 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2320 for (i = 0; i < 128; ++i)
2321 if (!IsEmptyStr(floorlist[i])) {
2322 wprintf("<option ");
2323 wprintf("value=\"%d\">", i);
2324 escputs(floorlist[i]);
2325 wprintf("</option>\n");
2327 wprintf("</select>\n");
2328 wprintf("</td></tr>");
2331 * Our clever little snippet of JavaScript automatically selects
2332 * a public room if the view is set to Bulletin Board or wiki, and
2333 * it selects a mailbox room otherwise. The user can override this,
2334 * of course. We also disable the floor selector for mailboxes.
2336 wprintf("<tr class=\"even\"><td>");
2337 wprintf(_("Default view for room: "));
2338 wprintf("</td><td>");
2339 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2340 " if ( (this.form.er_view.value == 0) "
2341 " || (this.form.er_view.value == 6) ) { "
2342 " this.form.type[0].checked=true; "
2343 " this.form.er_floor.disabled = false; "
2346 " this.form.type[4].checked=true; "
2347 " this.form.er_floor.disabled = true; "
2350 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2351 if (is_view_allowed_as_default(i)) {
2352 wprintf("<option %s value=\"%d\">",
2353 ((i == 0) ? "selected" : ""), i );
2354 escputs(viewdefs[i]);
2355 wprintf("</option>\n");
2358 wprintf("</select>\n");
2359 wprintf("</td></tr>");
2361 wprintf("<tr class=\"even\"><td>");
2362 wprintf(_("Type of room:"));
2363 wprintf("</td><td>");
2364 wprintf("<ul class=\"adminlist\">\n");
2366 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2367 wprintf("CHECKED OnChange=\""
2368 " if (this.form.type[0].checked == true) { "
2369 " this.form.er_floor.disabled = false; "
2372 wprintf(_("Public (automatically appears to everyone)"));
2375 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2376 " if (this.form.type[1].checked == true) { "
2377 " this.form.er_floor.disabled = false; "
2380 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2383 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2384 " if (this.form.type[2].checked == true) { "
2385 " this.form.er_floor.disabled = false; "
2388 wprintf(_("Private - require password: "));
2389 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2392 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2393 " if (this.form.type[3].checked == true) { "
2394 " this.form.er_floor.disabled = false; "
2397 wprintf(_("Private - invitation only"));
2400 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2402 " if (this.form.type[4].checked == true) { "
2403 " this.form.er_floor.disabled = true; "
2406 wprintf(_("Personal (mailbox for you only)"));
2409 wprintf("\n</ul>\n");
2410 wprintf("</td></tr></table>\n");
2412 wprintf("<div class=\"buttons\">\n");
2413 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2415 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2416 wprintf("</div>\n");
2417 wprintf("</form>\n<hr />");
2418 serv_printf("MESG roomaccess");
2419 serv_getln(buf, sizeof buf);
2420 if (buf[0] == '1') {
2424 do_template("endbox", NULL);
2434 * support function for entroom() -- sets the default view
2436 void er_set_default_view(int newview) {
2449 serv_getln(buf, sizeof buf);
2450 if (buf[0] != '2') return;
2452 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2453 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2454 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2455 rm_bits1 = extract_int(&buf[4], 3);
2456 rm_floor = extract_int(&buf[4], 4);
2457 rm_listorder = extract_int(&buf[4], 5);
2458 rm_bits2 = extract_int(&buf[4], 7);
2460 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2461 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2462 rm_listorder, newview, rm_bits2
2464 serv_getln(buf, sizeof buf);
2475 const StrBuf *er_name;
2476 const StrBuf *er_type;
2477 const StrBuf *er_password;
2482 if (!havebstr("ok_button")) {
2483 strcpy(WC->ImportantMessage,
2484 _("Cancelled. No new room was created."));
2485 display_main_menu();
2488 er_name = sbstr("er_name");
2489 er_type = sbstr("type");
2490 er_password = sbstr("er_password");
2491 er_floor = ibstr("er_floor");
2492 er_view = ibstr("er_view");
2495 if (!strcmp(ChrPtr(er_type), "hidden"))
2497 else if (!strcmp(ChrPtr(er_type), "passworded"))
2499 else if (!strcmp(ChrPtr(er_type), "invonly"))
2501 else if (!strcmp(ChrPtr(er_type), "personal"))
2504 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2507 ChrPtr(er_password),
2512 serv_getln(buf, sizeof buf);
2513 if (buf[0] != '2') {
2514 strcpy(WC->ImportantMessage, &buf[4]);
2515 display_main_menu();
2518 /** TODO: Room created, now udate the left hand icon bar for this user */
2519 burn_folder_cache(0); /* burn the old folder cache */
2523 do_change_view(er_view); /* Now go there */
2528 * \brief display the screen to enter a private room
2530 void display_private(char *rname, int req_pass)
2532 WCTemplputParams SubTP;
2534 output_headers(1, 1, 1, 0, 0, 0);
2536 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2537 memset(&SubTP, 0, sizeof(WCTemplputParams));
2538 SubTP.Filter.ContextType = CTX_STRBUF;
2539 SubTP.Context = Buf;
2540 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2545 wprintf(_("If you know the name of a hidden (guess-name) or "
2546 "passworded room, you can enter that room by typing "
2547 "its name below. Once you gain access to a private "
2548 "room, it will appear in your regular room listings "
2549 "so you don't have to keep returning here."));
2552 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2553 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2555 wprintf("<table class=\"altern\"> "
2556 "<tr class=\"even\"><td>");
2557 wprintf(_("Enter room name:"));
2559 "<input type=\"text\" name=\"gr_name\" "
2560 "value=\"%s\" maxlength=\"128\">\n", rname);
2563 wprintf("</td></tr><tr class=\"odd\"><td>");
2564 wprintf(_("Enter room password:"));
2565 wprintf("</td><td>");
2566 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2568 wprintf("</td></tr></table>\n");
2570 wprintf("<div class=\"buttons\">\n");
2571 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2573 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2577 wprintf("</div></form>\n");
2579 do_template("endbox", NULL);
2585 * \brief goto a private room
2587 void goto_private(void)
2592 if (!havebstr("ok_button")) {
2593 display_main_menu();
2596 strcpy(hold_rm, ChrPtr(WC->wc_roomname));
2597 serv_printf("GOTO %s|%s",
2600 serv_getln(buf, sizeof buf);
2602 if (buf[0] == '2') {
2603 smart_goto(sbstr("gr_name"));
2606 if (!strncmp(buf, "540", 3)) {
2607 display_private(bstr("gr_name"), 1);
2610 output_headers(1, 1, 1, 0, 0, 0);
2611 wprintf("%s\n", &buf[4]);
2618 * \brief display the screen to zap a room
2620 void display_zap(void)
2622 output_headers(1, 1, 2, 0, 0, 0);
2624 wprintf("<div id=\"banner\">\n");
2626 wprintf(_("Zap (forget/unsubscribe) the current room"));
2628 wprintf("</div>\n");
2630 wprintf("<div id=\"content\" class=\"service\">\n");
2632 wprintf(_("If you select this option, <em>%s</em> will "
2633 "disappear from your room list. Is this what you wish "
2634 "to do?<br />\n"), ChrPtr(WC->wc_roomname));
2636 wprintf("<form method=\"POST\" action=\"zap\">\n");
2637 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2638 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2640 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2641 wprintf("</form>\n");
2652 StrBuf *final_destination;
2655 * If the forget-room routine fails for any reason, we fall back
2656 * to the current room; otherwise, we go to the Lobby
2658 final_destination = NewStrBufDup(WC->wc_roomname);
2660 if (havebstr("ok_button")) {
2661 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
2662 serv_getln(buf, sizeof buf);
2663 if (buf[0] == '2') {
2665 serv_getln(buf, sizeof buf);
2666 if (buf[0] == '2') {
2667 FlushStrBuf(final_destination);
2668 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2672 smart_goto(final_destination);
2673 FreeStrBuf(&final_destination);
2679 * \brief Delete the current room
2681 void delete_room(void)
2686 serv_puts("KILL 1");
2687 serv_getln(buf, sizeof buf);
2688 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2689 if (buf[0] != '2') {
2690 strcpy(WC->ImportantMessage, &buf[4]);
2691 display_main_menu();
2696 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2705 * \brief Perform changes to a room's network configuration
2707 void netedit(void) {
2716 /*/ TODO: do line dynamic! */
2717 if (havebstr("line_pop3host")) {
2718 strcpy(line, bstr("prefix"));
2719 strcat(line, bstr("line_pop3host"));
2721 strcat(line, bstr("line_pop3user"));
2723 strcat(line, bstr("line_pop3pass"));
2725 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2727 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2728 strcat(line, bstr("suffix"));
2730 else if (havebstr("line")) {
2731 strcpy(line, bstr("prefix"));
2732 strcat(line, bstr("line"));
2733 strcat(line, bstr("suffix"));
2748 serv_getln(buf, sizeof buf);
2749 if (buf[0] != '1') {
2755 /** This loop works for add *or* remove. Spiffy, eh? */
2756 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2757 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2758 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2759 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2760 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2761 if ( (strcasecmp(cmpa0, cmpb0))
2762 || (strcasecmp(cmpa1, cmpb1)) ) {
2763 fprintf(fp, "%s\n", buf);
2769 serv_getln(buf, sizeof buf);
2770 if (buf[0] != '4') {
2776 while (fgets(buf, sizeof buf, fp) != NULL) {
2777 buf[strlen(buf)-1] = 0;
2781 if (havebstr("add_button")) {
2782 num_addrs = num_tokens(bstr("line"), ',');
2783 if (num_addrs < 2) {
2784 /* just adding one node or address */
2788 /* adding multiple addresses separated by commas */
2789 for (i=0; i<num_addrs; ++i) {
2790 strcpy(line, bstr("prefix"));
2791 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2794 strcat(line, bstr("suffix"));
2808 * \brief Convert a room name to a folder-ish-looking name.
2809 * \param folder the folderish name
2810 * \param room the room name
2811 * \param floor the floor name
2812 * \param is_mailbox is it a mailbox?
2814 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2819 * For mailboxes, just do it straight...
2822 sprintf(folder, "My folders|%s", room);
2826 * Otherwise, prefix the floor name as a "public folders" moniker
2829 if (floor > MAX_FLOORS) {
2831 sprintf(folder, "%%%%%%|%s", room);
2834 sprintf(folder, "%s|%s", floorlist[floor], room);
2839 * Replace "\" characters with "|" for pseudo-folder-delimiting
2841 len = strlen (folder);
2842 for (i=0; i<len; ++i) {
2843 if (folder[i] == '\\') folder[i] = '|';
2851 * \brief Back end for change_view()
2852 * \param newview set newview???
2854 void do_change_view(int newview) {
2857 serv_printf("VIEW %d", newview);
2858 serv_getln(buf, sizeof buf);
2859 WC->wc_view = newview;
2860 smart_goto(WC->wc_roomname);
2866 * \brief Change the view for this room
2868 void change_view(void) {
2871 view = lbstr("view");
2872 do_change_view(view);
2877 * \brief One big expanded tree list view --- like a folder list
2878 * \param fold the folder to view
2879 * \param max_folders how many folders???
2880 * \param num_floors hom many floors???
2882 void do_folder_view(struct __ofolder *fold, int max_folders, int num_floors) {
2886 int has_subfolders = 0;
2889 parents = malloc(max_folders * sizeof(int));
2891 /** BEGIN TREE MENU */
2892 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2894 /** include NanoTree */
2895 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2897 /** initialize NanoTree */
2898 wprintf("<script type=\"text/javascript\"> \n"
2899 " showRootNode = false; \n"
2900 " sortNodes = false; \n"
2901 " dragable = false; \n"
2903 " function standardClick(treeNode) { \n"
2906 " var closedGif = 'static/folder_closed.gif'; \n"
2907 " var openGif = 'static/folder_open.gif'; \n"
2909 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2913 for (i=0; i<max_folders; ++i) {
2916 if ((i+1) < max_folders) {
2918 len = strlen(fold[i].name);
2919 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2920 && (fold[i+1].name[len] == '|') ) {
2925 levels = num_tokens(fold[i].name, '|');
2926 parents[levels] = i;
2928 wprintf("var node%d = new TreeNode(%d, '", i, i);
2930 if (fold[i].selectable) {
2931 wprintf("<a href=\"dotgoto?room=");
2932 urlescputs(fold[i].room);
2937 wprintf("<span class=\"roomlist_floor\">");
2939 else if (fold[i].hasnewmsgs) {
2940 wprintf("<span class=\"roomlist_new\">");
2943 wprintf("<span class=\"roomlist_old\">");
2945 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2950 if (has_subfolders) {
2951 wprintf("new Array(closedGif, openGif)");
2953 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2954 wprintf("'static/viewcontacts_16x.gif'");
2956 else if (fold[i].view == VIEW_CALENDAR) {
2957 wprintf("'static/calarea_16x.gif'");
2959 else if (fold[i].view == VIEW_CALBRIEF) {
2960 wprintf("'static/calarea_16x.gif'");
2962 else if (fold[i].view == VIEW_TASKS) {
2963 wprintf("'static/taskmanag_16x.gif'");
2965 else if (fold[i].view == VIEW_NOTES) {
2966 wprintf("'static/storenotes_16x.gif'");
2968 else if (fold[i].view == VIEW_MAILBOX) {
2969 wprintf("'static/privatemess_16x.gif'");
2972 wprintf("'static/chatrooms_16x.gif'");
2975 urlescputs(fold[i].name);
2979 wprintf("rootNode.addChild(node%d);\n", i);
2982 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2986 wprintf("container = document.getElementById('roomlist_div'); \n"
2992 /** END TREE MENU */
2996 * \brief Boxes and rooms and lists ... oh my!
2997 * \param fold the folder to view
2998 * \param max_folders how many folders???
2999 * \param num_floors hom many floors???
3001 void do_rooms_view(struct __ofolder *fold, int max_folders, int num_floors) {
3003 char floor_name[256];
3004 char old_floor_name[256];
3005 int levels, oldlevels;
3008 static int columns = 3;
3009 int boxes_per_column = 0;
3010 int current_column = 0;
3013 strcpy(floor_name, "");
3014 strcpy(old_floor_name, "");
3017 while (nf % columns != 0) ++nf;
3018 boxes_per_column = (nf / columns);
3019 if (boxes_per_column < 1) boxes_per_column = 1;
3021 /** Outer table (for columnization) */
3022 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3023 "<tr><td valign=top>");
3027 for (i=0; i<max_folders; ++i) {
3029 levels = num_tokens(fold[i].name, '|');
3030 extract_token(floor_name, fold[i].name, 0,
3031 '|', sizeof floor_name);
3033 if ( (strcasecmp(floor_name, old_floor_name))
3034 && (!IsEmptyStr(old_floor_name)) ) {
3036 do_template("endbox", NULL);
3040 if ((num_boxes % boxes_per_column) == 0) {
3042 if (current_column < columns) {
3043 wprintf("</td><td valign=top>\n");
3047 strcpy(old_floor_name, floor_name);
3051 WCTemplputParams SubTP;
3053 Buf = NewStrBufPlain(floor_name, -1);
3054 memset(&SubTP, 0, sizeof(WCTemplputParams));
3055 SubTP.Filter.ContextType = CTX_STRBUF;
3056 SubTP.Context = Buf;
3057 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
3066 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3067 if (fold[i].selectable) {
3068 wprintf("<a href=\"dotgoto?room=");
3069 urlescputs(fold[i].room);
3075 if (fold[i].hasnewmsgs) {
3076 wprintf("<span class=\"roomlist_new\">");
3079 wprintf("<span class=\"roomlist_old\">");
3081 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3084 if (fold[i].selectable) {
3090 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3091 wprintf(" (INBOX)");
3093 wprintf("<br />\n");
3096 /** End the final inner box */
3097 do_template("endbox", NULL);
3099 wprintf("</td></tr></table>\n");
3103 * \brief print a floor div???
3104 * \param which_floordiv name of the floordiv???
3106 void set_floordiv_expanded(void) {
3107 wcsession *WCC = WC;
3110 FloorDiv = NewStrBuf();
3111 StrBufExtract_token(FloorDiv, WCC->Hdr->HR.ReqLine, 0, '/');
3112 set_preference("floordiv_expanded", FloorDiv, 1);
3113 WCC->floordiv_expanded = FloorDiv;
3117 * \brief view the iconbar
3118 * \param fold the folder to view
3119 * \param max_folders how many folders???
3120 * \param num_floors hom many floors???
3122 void do_iconbar_view(struct __ofolder *fold, int max_folders, int num_floors) {
3124 char floor_name[256];
3125 char old_floor_name[256];
3126 char floordivtitle[256];
3127 char floordiv_id[32];
3128 int levels, oldlevels;
3132 strcpy(floor_name, "");
3133 strcpy(old_floor_name, "");
3137 for (i=0; i<max_folders; ++i) {
3139 levels = num_tokens(fold[i].name, '|');
3140 extract_token(floor_name, fold[i].name, 0,
3141 '|', sizeof floor_name);
3143 if ( (strcasecmp(floor_name, old_floor_name))
3144 && (!IsEmptyStr(old_floor_name)) ) {
3145 /** End inner box */
3147 wprintf("</div>\n"); /** floordiv */
3149 strcpy(old_floor_name, floor_name);
3153 stresc(floordivtitle, 256, floor_name, 0, 0);
3154 sprintf(floordiv_id, "floordiv%d", i);
3155 wprintf("<span class=\"ib_roomlist_floor\" "
3156 "onClick=\"expand_floor('%s')\">"
3157 "%s</span><br>\n", floordiv_id, floordivtitle);
3158 wprintf("<div id=\"%s\" style=\"display:%s\">",
3160 (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
3167 wprintf("<div id=\"roomdiv%d\">", i);
3169 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3171 /** choose the icon */
3172 if (fold[i].view == VIEW_ADDRESSBOOK) {
3173 icon = "viewcontacts_16x.gif" ;
3175 else if (fold[i].view == VIEW_CALENDAR) {
3176 icon = "calarea_16x.gif" ;
3178 else if (fold[i].view == VIEW_CALBRIEF) {
3179 icon = "calarea_16x.gif" ;
3181 else if (fold[i].view == VIEW_TASKS) {
3182 icon = "taskmanag_16x.gif" ;
3184 else if (fold[i].view == VIEW_NOTES) {
3185 icon = "storenotes_16x.gif" ;
3187 else if (fold[i].view == VIEW_MAILBOX) {
3188 icon = "privatemess_16x.gif" ;
3191 icon = "chatrooms_16x.gif" ;
3194 if (fold[i].selectable) {
3195 wprintf("<a href=\"dotgoto?room=");
3196 urlescputs(fold[i].room);
3198 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3203 if (fold[i].hasnewmsgs) {
3204 wprintf("<span class=\"ib_roomlist_new\">");
3207 wprintf("<span class=\"ib_roomlist_old\">");
3209 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3211 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3212 wprintf(" (INBOX)");
3215 if (fold[i].selectable) {
3222 wprintf("</div>\n"); /** roomdiv */
3225 wprintf("</div>\n"); /** floordiv */
3233 * \brief Burn the cached folder list.
3234 * \param age How old the cahce needs to be before we burn it.
3237 void burn_folder_cache(time_t age)
3239 /** If our cached folder list is very old, burn it. */
3240 if (WC->cache_fold != NULL) {
3241 if ((time(NULL) - WC->cache_timestamp) > age) {
3242 free(WC->cache_fold);
3243 WC->cache_fold = NULL;
3252 * \brief Show the room list.
3253 * (only should get called by
3254 * knrooms() because that's where output_headers() is called from)
3255 * \param viewpref the view preferences???
3258 void list_all_rooms_by_floor(const char *viewpref) {
3262 struct __ofolder *fold = NULL;
3263 struct __ofolder ftmp;
3264 int max_folders = 0;
3265 int alloc_folders = 0;
3269 int ShowEmptyFloors;
3272 int num_floors = 1; /** add an extra one for private folders */
3275 /** If our cached folder list is very old, burn it. */
3276 burn_folder_cache(300);
3278 /** Can we do the iconbar roomlist from cache? */
3279 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3280 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3285 /** Grab the floor table so we know how to build the list... */
3286 load_floorlist(Buf);
3288 /** Start with the mailboxes */
3291 fold = malloc(sizeof(struct __ofolder));
3292 memset(fold, 0, sizeof(struct __ofolder));
3293 strcpy(fold[0].name, "My folders");
3294 fold[0].is_mailbox = 1;
3296 /** Then add floors */
3298 serv_getln(buf, sizeof buf);
3299 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3300 if (max_folders >= alloc_folders) {
3301 alloc_folders = max_folders + 100;
3302 fold = realloc(fold,
3303 alloc_folders * sizeof(struct __ofolder));
3305 memset(&fold[max_folders], 0, sizeof(struct __ofolder));
3306 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3307 extract_token(buf3, buf, 0, '|', SIZ);
3308 fold[max_folders].floor = atol (buf3);
3313 for (i=0; i<num_floors; i++)
3314 if (IDMax < fold[i].floor)
3315 IDMax = fold[i].floor;
3316 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3317 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3318 for (i=0; i<num_floors; i++)
3319 floor_mapping[fold[i].floor]=i;
3321 /** refresh the messages index for this room */
3322 /* TODO serv_puts("GOTO ");
3323 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")); */
3324 /** Now add rooms */
3326 serv_getln(buf, sizeof buf);
3327 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3328 if (max_folders >= alloc_folders) {
3329 alloc_folders = max_folders + 100;
3330 fold = realloc(fold,
3331 alloc_folders * sizeof(struct __ofolder));
3333 memset(&fold[max_folders], 0, sizeof(struct __ofolder));
3334 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3335 ra_flags = extract_int(buf, 5);
3336 flags = extract_int(buf, 1);
3337 fold[max_folders].floor = extract_int(buf, 2);
3338 fold[max_folders].hasnewmsgs =
3339 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3340 if (flags & QR_MAILBOX) {
3341 fold[max_folders].is_mailbox = 1;
3343 fold[max_folders].view = extract_int(buf, 6);
3344 room_to_folder(fold[max_folders].name,
3345 fold[max_folders].room,
3346 fold[max_folders].floor,
3347 fold[max_folders].is_mailbox);
3348 fold[max_folders].selectable = 1;
3349 /* Increase the room count for the associtaed floor */
3350 if (fold[max_folders].is_mailbox) {
3351 fold[0].num_rooms++;
3354 i = floor_mapping[fold[max_folders].floor];
3355 fold[i].num_rooms++;
3361 * Remove any floors that don't have rooms
3363 get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
3364 if (ShowEmptyFloors)
3366 for (i=0; i<num_floors; i++)
3368 if (fold[i].num_rooms == 0) {
3369 for (j=i; j<max_folders; j++) {
3370 memcpy(&fold[j], &fold[j+1], sizeof(struct __ofolder));
3379 /** Bubble-sort the folder list */
3380 for (i=0; i<max_folders; ++i) {
3381 for (j=0; j<(max_folders-1)-i; ++j) {
3382 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3383 swap = strcasecmp(fold[j].name, fold[j+1].name);
3386 if ( (fold[j+1].is_mailbox)
3387 && (!fold[j].is_mailbox)) {
3395 memcpy(&ftmp, &fold[j], sizeof(struct __ofolder));
3396 memcpy(&fold[j], &fold[j+1],
3397 sizeof(struct __ofolder));
3398 memcpy(&fold[j+1], &ftmp,
3399 sizeof(struct __ofolder));
3405 if (!strcasecmp(viewpref, "folders")) {
3406 do_folder_view(fold, max_folders, num_floors);
3408 else if (!strcasecmp(viewpref, "hackish_view")) {
3409 for (i=0; i<max_folders; ++i) {
3410 escputs(fold[i].name);
3411 wprintf("<br />\n");
3414 else if (!strcasecmp(viewpref, "iconbar")) {
3415 do_iconbar_view(fold, max_folders, num_floors);
3418 do_rooms_view(fold, max_folders, num_floors);
3421 /* Don't free the folder list ... cache it for future use! */
3422 if (WC->cache_fold != NULL) {
3423 free(WC->cache_fold);
3425 WC->cache_fold = fold;
3426 WC->cache_max_folders = max_folders;
3427 WC->cache_num_floors = num_floors;
3428 WC->cache_timestamp = time(NULL);
3429 free(floor_mapping);
3434 * \brief Do either a known rooms list or a folders list, depending on the
3439 StrBuf *ListView = NULL;
3441 output_headers(1, 1, 2, 0, 0, 0);
3443 /** Determine whether the user is trying to change views */
3444 if (havebstr("view")) {
3445 ListView = NewStrBufPlain(bstr("view"), -1);
3446 set_preference("roomlistview", ListView, 1);
3448 /** Sanitize the input so its safe */
3449 if(!get_preference("roomlistview", &ListView) ||
3450 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3451 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3453 if (ListView == NULL) {
3454 ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1);
3455 set_preference("roomlistview", ListView, 0);
3458 StrBufPrintf(ListView, "rooms");
3464 wprintf("<div id=\"banner\">\n");
3465 wprintf("<div class=\"room_banner\" id=\"room_banner\">");
3467 if (!strcasecmp(ChrPtr(ListView), "rooms")) {
3468 wprintf(_("Room list"));
3470 else if (!strcasecmp(ChrPtr(ListView), "folders")) {
3471 wprintf(_("Folder list"));
3473 else if (!strcasecmp(ChrPtr(ListView), "table")) {
3474 wprintf(_("Room list"));
3476 wprintf("</h1></div>\n");
3478 /** offer the ability to switch views */
3479 wprintf("<div id=\"actiondiv\">");
3480 wprintf("<ul class=\"room_actions\">\n");
3481 wprintf("<li class=\"start_page\">");
3482 offer_start_page(NULL, &NoCtx);
3484 wprintf("<li><form name=\"roomlistomatic\">\n"
3485 "<select name=\"newview\" size=\"1\" "
3486 "OnChange=\"location.href=roomlistomatic.newview.options"
3487 "[selectedIndex].value\">\n");
3489 wprintf("<option %s value=\"knrooms?view=rooms\">"
3492 ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" )
3495 wprintf("<option %s value=\"knrooms?view=folders\">"
3496 "View as folder list"
3498 ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" )
3501 wprintf("</select>");
3502 wprintf("</form></li>");
3503 wprintf("</ul></div></div>\n");
3505 wprintf("<div id=\"content\" class=\"service\">\n");
3507 /** Display the room list in the user's preferred format */
3508 list_all_rooms_by_floor(ChrPtr(ListView));
3515 * \brief Set the message expire policy for this room and/or floor
3517 void set_room_policy(void) {
3520 if (!havebstr("ok_button")) {
3521 strcpy(WC->ImportantMessage,
3522 _("Cancelled. Changes were not saved."));
3527 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3528 serv_getln(buf, sizeof buf);
3529 strcpy(WC->ImportantMessage, &buf[4]);
3531 if (WC->axlevel >= 6) {
3532 strcat(WC->ImportantMessage, "<br />\n");
3533 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3534 serv_getln(buf, sizeof buf);
3535 strcat(WC->ImportantMessage, &buf[4]);
3541 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3543 StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
3547 void _display_private(void) {
3548 display_private("", 0);
3551 void dotgoto(void) {
3552 if (!havebstr("room")) {
3556 if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3559 smart_goto(sbstr("room"));
3562 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3564 wprintf("<div id=\"banner\">\n");
3565 embed_room_banner(NULL, navbar_default);
3566 wprintf("</div>\n");
3570 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3572 wcsession *WCC = WC;
3575 (!IsEmptyStr(WCC->ugname)))
3576 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3580 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3582 wcsession *WCC = WC;
3584 return ((WCC!=NULL) &&
3585 (!IsEmptyStr(WCC->ugname)) &&
3586 (strcasecmp(WCC->ugname, ChrPtr(WCC->wc_roomname)) == 0));
3589 int ConditionalRoomHas_QR_PERMANENT(StrBuf *Target, WCTemplputParams *TP)
3591 wcsession *WCC = WC;
3593 return ((WCC!=NULL) &&
3594 ((WCC->room_flags & QR_PERMANENT) != 0));
3597 int ConditionalRoomHas_QR_INUSE(StrBuf *Target, WCTemplputParams *TP)
3599 wcsession *WCC = WC;
3601 return ((WCC!=NULL) &&
3602 ((WCC->room_flags & QR_INUSE) != 0));
3605 int ConditionalRoomHas_QR_PRIVATE(StrBuf *Target, WCTemplputParams *TP)
3607 wcsession *WCC = WC;
3609 return ((WCC!=NULL) &&
3610 ((WCC->room_flags & QR_PRIVATE) != 0));
3613 int ConditionalRoomHas_QR_PASSWORDED(StrBuf *Target, WCTemplputParams *TP)
3615 wcsession *WCC = WC;
3617 return ((WCC!=NULL) &&
3618 ((WCC->room_flags & QR_PASSWORDED) != 0));
3621 int ConditionalRoomHas_QR_GUESSNAME(StrBuf *Target, WCTemplputParams *TP)
3623 wcsession *WCC = WC;
3625 return ((WCC!=NULL) &&
3626 ((WCC->room_flags & QR_GUESSNAME) != 0));
3629 int ConditionalRoomHas_QR_DIRECTORY(StrBuf *Target, WCTemplputParams *TP)
3631 wcsession *WCC = WC;
3633 return ((WCC!=NULL) &&
3634 ((WCC->room_flags & QR_DIRECTORY) != 0));
3637 int ConditionalRoomHas_QR_UPLOAD(StrBuf *Target, WCTemplputParams *TP)
3639 wcsession *WCC = WC;
3641 return ((WCC!=NULL) &&
3642 ((WCC->room_flags & QR_UPLOAD) != 0));
3645 int ConditionalRoomHas_QR_DOWNLOAD(StrBuf *Target, WCTemplputParams *TP)
3647 wcsession *WCC = WC;
3649 return ((WCC!=NULL) &&
3650 ((WCC->room_flags & QR_DOWNLOAD) != 0));
3653 int ConditionalRoomHas_QR_VISDIR(StrBuf *Target, WCTemplputParams *TP)
3655 wcsession *WCC = WC;
3657 return ((WCC!=NULL) &&
3658 ((WCC->room_flags & QR_VISDIR) != 0));
3661 int ConditionalRoomHas_QR_ANONONLY(StrBuf *Target, WCTemplputParams *TP)
3663 wcsession *WCC = WC;
3665 return ((WCC!=NULL) &&
3666 ((WCC->room_flags & QR_ANONONLY) != 0));
3669 int ConditionalRoomHas_QR_ANONOPT(StrBuf *Target, WCTemplputParams *TP)
3671 wcsession *WCC = WC;
3673 return ((WCC!=NULL) &&
3674 ((WCC->room_flags & QR_ANONOPT) != 0));
3677 int ConditionalRoomHas_QR_NETWORK(StrBuf *Target, WCTemplputParams *TP)
3679 wcsession *WCC = WC;
3681 return ((WCC!=NULL) &&
3682 ((WCC->room_flags & QR_NETWORK) != 0));
3685 int ConditionalRoomHas_QR_PREFONLY(StrBuf *Target, WCTemplputParams *TP)
3687 wcsession *WCC = WC;
3689 return ((WCC!=NULL) &&
3690 ((WCC->room_flags & QR_PREFONLY) != 0));
3693 int ConditionalRoomHas_QR_READONLY(StrBuf *Target, WCTemplputParams *TP)
3695 wcsession *WCC = WC;
3697 return ((WCC!=NULL) &&
3698 ((WCC->room_flags & QR_READONLY) != 0));
3701 int ConditionalRoomHas_QR_MAILBOX(StrBuf *Target, WCTemplputParams *TP)
3703 wcsession *WCC = WC;
3705 return ((WCC!=NULL) &&
3706 ((WCC->room_flags & QR_MAILBOX) != 0));
3710 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3712 wcsession *WCC = WC;
3714 return ( (WCC!= NULL) &&
3715 ((WCC->axlevel >= 6) ||
3716 (WCC->is_room_aide) ||
3717 (WCC->is_mailbox) ));
3720 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3722 wcsession *WCC = WC;
3724 if ((WCC == NULL) ||
3725 (TP->Tokens->nParameters < 3) ||
3726 (TP->Tokens->Params[2]->Type != TYPE_STR)||
3727 (TP->Tokens->Params[2]->len < 7))
3730 switch(WCC->wc_view) {
3732 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_BBS"));
3734 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_MAILBOX"));
3735 case VIEW_ADDRESSBOOK:
3736 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_ADDRESSBOOK"));
3738 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_TASKS"));
3740 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_NOTES"));
3742 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_WIKI"));
3744 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_JOURNAL"));
3746 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_CALENDAR"));
3748 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_CALBRIEF"));
3758 RegisterPreference("roomlistview",
3759 _("Room list view"),
3762 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3764 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, 0);
3766 WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
3767 WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, NEED_URL);
3768 WebcitAddUrlHandler(HKEY("dotskip"), dotskip, NEED_URL);
3769 WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
3770 WebcitAddUrlHandler(HKEY("goto_private"), goto_private, NEED_URL);
3771 WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
3772 WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
3773 WebcitAddUrlHandler(HKEY("zap"), zap, 0);
3774 WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
3775 WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
3776 WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
3777 WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
3778 WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
3779 WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
3780 WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
3781 WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
3782 WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
3783 WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
3784 WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);
3785 WebcitAddUrlHandler(HKEY("toggle_self_service"), toggle_self_service, 0);
3786 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, 0);
3788 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3789 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PERMANENT"), 0, ConditionalRoomHas_QR_PERMANENT, CTX_NONE);
3790 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_INUSE"), 0, ConditionalRoomHas_QR_INUSE, CTX_NONE);
3791 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PRIVATE"), 0, ConditionalRoomHas_QR_PRIVATE, CTX_NONE);
3792 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PASSWORDED"), 0, ConditionalRoomHas_QR_PASSWORDED, CTX_NONE);
3793 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_GUESSNAME"), 0, ConditionalRoomHas_QR_GUESSNAME, CTX_NONE);
3794 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DIRECTORY"), 0, ConditionalRoomHas_QR_DIRECTORY, CTX_NONE);
3795 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_UPLOAD"), 0, ConditionalRoomHas_QR_UPLOAD, CTX_NONE);
3796 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DOWNLOAD"), 0, ConditionalRoomHas_QR_DOWNLOAD, CTX_NONE);
3797 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_VISIDIR"), 0, ConditionalRoomHas_QR_VISDIR, CTX_NONE);
3798 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONONLY"), 0, ConditionalRoomHas_QR_ANONONLY, CTX_NONE);
3799 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONOPT"), 0, ConditionalRoomHas_QR_ANONOPT, CTX_NONE);
3800 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_NETWORK"), 0, ConditionalRoomHas_QR_NETWORK, CTX_NONE);
3801 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PREFONLY"), 0, ConditionalRoomHas_QR_PREFONLY, CTX_NONE);
3802 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_READONLY"), 0, ConditionalRoomHas_QR_READONLY, CTX_NONE);
3803 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_MAILBOX"), 0, ConditionalRoomHas_QR_MAILBOX, CTX_NONE);
3805 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3806 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3808 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, 0);
3809 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3816 SessionDestroyModule_ROOMOPS
3819 if (sess->cache_fold != NULL) {
3820 free(sess->cache_fold);
3823 free_march_list(sess);
3824 DeleteHash(&sess->Floors);