3 * Lots of different room-related operations.
10 char floorlist[MAX_FLOORS][SIZ]; /* list of our floor names */
12 char *viewdefs[9]; /* the different kinds of available views */
14 /* See GetFloorListHash and GetRoomListHash for info on these.
15 * Basically we pull LFLR/LKRA etc. and set up a room HashList with these keys.
18 #define FLOOR_PARAM_LEN 3
19 const ConstStr FLOOR_PARAM_NAMES[] = {{HKEY("ID")},
23 #define ROOM_PARAM_LEN 8
24 const ConstStr ROOM_PARAM_NAMES[] = {{HKEY("NAME")},
31 {HKEY("LASTCHANGE")}};
34 void display_whok(void);
37 * Initialize the viewdefs with localized strings
39 void initialize_viewdefs(void) {
40 viewdefs[0] = _("Bulletin Board");
41 viewdefs[1] = _("Mail Folder");
42 viewdefs[2] = _("Address Book");
43 viewdefs[3] = _("Calendar");
44 viewdefs[4] = _("Task List");
45 viewdefs[5] = _("Notes List");
46 viewdefs[6] = _("Wiki");
47 viewdefs[7] = _("Calendar List");
48 viewdefs[8] = _("Journal");
52 * Determine which views are allowed as the default for creating a new room.
54 int is_view_allowed_as_default(int which_view)
57 case VIEW_BBS: return(1);
58 case VIEW_MAILBOX: return(1);
59 case VIEW_ADDRESSBOOK: return(1);
60 case VIEW_CALENDAR: return(1);
61 case VIEW_TASKS: return(1);
62 case VIEW_NOTES: return(1);
65 case VIEW_WIKI: return(1);
66 #else /* TECH_PREVIEW */
67 case VIEW_WIKI: return(0); /* because it isn't finished yet */
68 #endif /* TECH_PREVIEW */
70 case VIEW_CALBRIEF: return(0);
71 case VIEW_JOURNAL: return(0);
72 default: return(0); /* should never get here */
78 * load the list of floors
80 void load_floorlist(StrBuf *Buf)
85 for (a = 0; a < MAX_FLOORS; ++a)
89 StrBuf_ServGetln(Buf);
90 if (GetServerStatus(Buf, NULL) != 1) {
91 strcpy(floorlist[0], "Main Floor");
94 while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
95 if ( (StrLength(Buf)==3) &&
96 !strcmp(ChrPtr(Buf), "000")) {
100 extract_token(floorlist[StrBufExtract_int(Buf, 0, '|')], ChrPtr(Buf), 1, '|', sizeof floorlist[0]);
108 * display rooms in tree structure
110 void room_tree_list(struct roomlisting *rp)
119 room_tree_list(rp->lnext);
121 strcpy(rmname, rp->rlname);
124 wprintf("<a href=\"dotgoto?room=");
128 escputs1(rmname, 1, 1);
129 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
131 else if (f & QR_DIRECTORY)
133 else if (f & QR_NETWORK)
137 wprintf("</a><tt> </tt>\n");
139 room_tree_list(rp->rnext);
145 * Room ordering stuff (compare first by floor, then by order)
147 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
149 if ((r1 == NULL) && (r2 == NULL))
155 if (r1->rlfloor < r2->rlfloor)
157 if (r1->rlfloor > r2->rlfloor)
159 if (r1->rlorder < r2->rlorder)
161 if (r1->rlorder > r2->rlorder)
168 * Common code for all room listings
170 void listrms(char *variety)
175 struct roomlisting *rl = NULL;
176 struct roomlisting *rp;
177 struct roomlisting *rs;
179 /* Ask the server for a room list */
181 serv_getln(buf, sizeof buf);
187 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
189 rp = malloc(sizeof(struct roomlisting));
190 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
191 rp->rlflags = extract_int(buf, 1);
192 rp->rlfloor = extract_int(buf, 2);
193 rp->rlorder = extract_int(buf, 3);
202 if (rordercmp(rp, rs) < 0) {
203 if (rs->lnext == NULL) {
210 if (rs->rnext == NULL) {
223 * If no rooms were listed, print an nbsp to make the cell
224 * borders show up anyway.
226 if (num_rooms == 0) wprintf(" ");
231 * list all forgotten rooms
233 void zapped_list(void)
235 WCTemplputParams SubTP;
238 output_headers(1, 1, 1, 0, 0, 0);
239 memset(&SubTP, 0, sizeof(WCTemplputParams));
240 Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
241 SubTP.Filter.ContextType = CTX_STRBUF;
243 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
249 wprintf("<br /><br />\n");
250 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
251 do_template("endbox", NULL);
257 * read this room's info file (set v to 1 for verbose mode)
259 void readinfo(StrBuf *Target, WCTemplputParams *TP)
264 int fullinfo_len = 0;
267 serv_getln(buf, sizeof buf);
270 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
271 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
272 strcpy(&fullinfo[fullinfo_len], buf);
273 fullinfo_len += strlen(buf);
277 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
278 strcpy(&briefinfo[50], "...");
280 wprintf("<div class=\"infos\" "
281 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
285 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
286 wprintf("<img class=\"close_infos\" "
287 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
288 "src=\"static/closewindow.gif\" alt=\"%s\" width=\"16\" height=\"16\">",
303 * Display room banner icon.
304 * The server doesn't actually need the room name, but we supply it in
305 * order to keep the browser from using a cached icon from another room.
307 void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP)
311 serv_puts("OIMG _roompic_");
312 serv_getln(buf, sizeof buf);
314 wprintf("<img height=\"64px\" src=\"image?name=_roompic_&room=");
315 urlescputs(ChrPtr(WC->wc_roomname));
318 serv_getln(buf, sizeof buf);
320 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
321 wprintf("<img class=\"roompic\" alt=\"\" src=\""
322 "static/viewcontacts_48x.gif"
326 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
327 wprintf("<img class=\"roompic\" alt=\"\" src=\""
328 "static/calarea_48x.gif"
329 "\" width=\"48\" height=\"48\">"
332 else if (WC->wc_view == VIEW_TASKS) {
333 wprintf("<img class=\"roompic\" alt=\"\" src=\""
334 "static/taskmanag_48x.gif"
335 "\" width=\"48\" height=\"48\">"
338 else if (WC->wc_view == VIEW_NOTES) {
339 wprintf("<img class=\"roompic\" alt=\"\" src=\""
340 "static/storenotes_48x.gif"
341 "\" width=\"48\" height=\"48\">"
344 else if (WC->wc_view == VIEW_MAILBOX) {
345 wprintf("<img class=\"roompic\" alt=\"\" src=\""
346 "static/privatemess_48x.gif"
347 "\" width=\"48\" height=\"48\">"
351 wprintf("<img class=\"roompic\" alt=\"\" src=\""
352 "static/chatrooms_48x.gif"
353 "\" width=\"48\" height=\"48\">"
362 * Display the current view and offer an option to change it
364 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
368 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
369 wprintf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
370 wprintf("<label for=\"view_name\">");
371 wprintf(_("View as:"));
373 "<select name=\"newview\" size=\"1\" "
374 "id=\"view_name\" class=\"selectbox\" "
375 "OnChange=\"location.href=viewomatic.newview.options"
376 "[selectedIndex].value\">\n");
378 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
380 * Only offer the views that make sense, given the default
381 * view for the room. For example, don't offer a Calendar
382 * view in a non-Calendar room.
386 || (i == WC->wc_default_view) /* default */
387 || ( (i == 0) && (WC->wc_default_view == 1) ) /* mail or bulletin */
388 || ( (i == 1) && (WC->wc_default_view == 0) ) /* mail or bulletin */
389 /* || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
392 wprintf("<option %s value=\"changeview?view=%d\">",
393 ((i == WC->wc_view) ? "selected" : ""),
395 escputs(viewdefs[i]);
396 wprintf("</option>\n");
399 wprintf("</select></div></form>\n");
404 * Display a search box
406 void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP)
408 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
409 wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
410 wprintf("<label for=\"srchquery\">");
411 wprintf(_("Search: "));
412 wprintf("</label><input ");
413 wprintf("%s", WC->serv_info->serv_fulltext_enabled ? "" : "disabled ");
414 wprintf("type=\"text\" name=\"query\" id=\"srchquery\" size=\"15\" maxlength=\"128\" class=\"inputbox\">\n"
416 wprintf("</div></form>\n");
421 * Embed the room banner
423 * got The information returned from a GOTO server command
424 * navbar_style Determines which navigation buttons to display
428 void embed_room_banner(char *got, int navbar_style) {
432 char with_files[256];
436 * We need to have the information returned by a GOTO server command.
437 * If it isn't supplied, we fake it by issuing our own GOTO.
440 memset(buf, '0', 20);
442 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
443 serv_getln(buf, sizeof buf);
447 /* The browser needs some information for its own use */
448 wprintf("<script type=\"text/javascript\"> \n"
449 " room_is_trash = %d; \n"
455 * If the user happens to select the "make this my start page" link,
456 * we want it to remember the URL as a "/dotskip" one instead of
457 * a "skip" or "gotonext" or something like that.
459 if (WCC->Hdr->this_page == NULL) {
460 WCC->Hdr->this_page = NewStrBuf();
462 StrBufPrintf(WCC->Hdr->this_page,
464 ChrPtr(WC->wc_roomname)
467 /* Check for new mail. */
468 WC->new_mail = extract_int(&got[4], 9);
469 WC->wc_view = extract_int(&got[4], 11);
471 /* Is this a directory room and does it contain files and how many? */
472 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
475 serv_getln(buf2, sizeof buf2);
476 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
478 snprintf (with_files, sizeof with_files,
479 "; <a href=\"do_template?template=files\"> %d %s </a>",
481 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
484 strcpy (with_files, "");
486 svprintf(HKEY("NUMMSGS"), WCS_STRING,
487 _("%d new of %d messages%s"),
488 extract_int(&got[4], 1),
489 extract_int(&got[4], 2),
492 svcallback("ROOMPIC", embed_room_graphic);
493 svcallback("ROOMINFO", readinfo);
494 svcallback("VIEWOMATIC", embed_view_o_matic);
495 svcallback("SEARCHOMATIC", embed_search_o_matic);
496 svcallback("START", offer_start_page);
498 do_template("roombanner", NULL);
499 /* roombanner contains this for mobile */
500 if (navbar_style != navbar_none && !WC->is_mobile) {
502 wprintf("<div id=\"navbar\"><ul>");
504 if (navbar_style == navbar_default) wprintf(
505 "<li class=\"ungoto\">"
506 "<a href=\"ungoto\">"
507 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
508 "<span class=\"navbar_link\">%s</span></A>"
509 "</li>\n", _("Ungoto")
512 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
514 "<li class=\"newmess\">"
515 "<a href=\"readnew\">"
516 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
517 "<span class=\"navbar_link\">%s</span></A>"
518 "</li>\n", _("Read new messages")
522 if (navbar_style == navbar_default) {
523 switch(WC->wc_view) {
524 case VIEW_ADDRESSBOOK:
526 "<li class=\"viewcontacts\">"
527 "<a href=\"readfwd\">"
528 "<img src=\"static/viewcontacts_24x.gif\" "
529 "alt=\"\" width=\"24\" height=\"24\">"
530 "<span class=\"navbar_link\">"
532 "</span></a></li>\n", _("View contacts")
537 "<li class=\"staskday\">"
538 "<a href=\"readfwd?calview=day\">"
539 "<img src=\"static/taskday2_24x.gif\" "
540 "alt=\"\" width=\"24\" height=\"24\">"
541 "<span class=\"navbar_link\">"
543 "</span></a></li>\n", _("Day view")
546 "<li class=\"monthview\">"
547 "<a href=\"readfwd?calview=month\">"
548 "<img src=\"static/monthview2_24x.gif\" "
549 "alt=\"\" width=\"24\" height=\"24\">"
550 "<span class=\"navbar_link\">"
552 "</span></a></li>\n", _("Month view")
557 "<li class=\"monthview\">"
558 "<a href=\"readfwd?calview=month\">"
559 "<img src=\"static/monthview2_24x.gif\" "
560 "alt=\"\" width=\"24\" height=\"24\">"
561 "<span class=\"navbar_link\">"
563 "</span></a></li>\n", _("Calendar list")
568 "<li class=\"taskmanag\">"
569 "<a href=\"readfwd\">"
570 "<img src=\"static/taskmanag_24x.gif\" "
571 "alt=\"\" width=\"24\" height=\"24\">"
572 "<span class=\"navbar_link\">"
574 "</span></a></li>\n", _("View tasks")
579 "<li class=\"viewnotes\">"
580 "<a href=\"readfwd\">"
581 "<img src=\"static/viewnotes_24x.gif\" "
582 "alt=\"\" width=\"24\" height=\"24\">"
583 "<span class=\"navbar_link\">"
585 "</span></a></li>\n", _("View notes")
590 "<li class=\"readallmess\">"
591 "<a id=\"m_refresh\" href=\"readfwd\">"
592 "<img src=\"static/readallmess3_24x.gif\" "
593 "alt=\"\" width=\"24\" height=\"24\">"
594 "<span class=\"navbar_link\">"
596 "</span></a></li>\n", _("Refresh message list")
601 "<li class=\"readallmess\">"
602 "<a href=\"readfwd\">"
603 "<img src=\"static/readallmess3_24x.gif\" "
604 "alt=\"\" width=\"24\" height=\"24\">"
605 "<span class=\"navbar_link\">"
607 "</span></a></li>\n", _("Wiki home")
612 "<li class=\"readallmess\">"
613 "<a href=\"readfwd\">"
614 "<img src=\"static/readallmess3_24x.gif\" "
615 "alt=\"\" width=\"24\" height=\"24\">"
616 "<span class=\"navbar_link\">"
618 "</span></a></li>\n", _("Read all messages")
624 if (navbar_style == navbar_default) {
625 switch(WC->wc_view) {
626 case VIEW_ADDRESSBOOK:
628 "<li class=\"addnewcontact\">"
629 "<a href=\"display_enter\">"
630 "<img src=\"static/addnewcontact_24x.gif\" "
631 "alt=\"\" width=\"24\" height=\"24\">"
632 "<span class=\"navbar_link\">"
634 "</span></a></li>\n", _("Add new contact")
639 wprintf("<li class=\"addevent\"><a href=\"display_enter");
640 if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
641 if (havebstr("month")) wprintf("?month=%s", bstr("month"));
642 if (havebstr("day" )) wprintf("?day=%s", bstr("day"));
644 "<img src=\"static/addevent_24x.gif\" "
645 "alt=\"\" width=\"24\" height=\"24\">"
646 "<span class=\"navbar_link\">"
648 "</span></a></li>\n", _("Add new event")
653 "<li class=\"newmess\">"
654 "<a href=\"display_enter\">"
655 "<img src=\"static/newmess3_24x.gif\" "
656 "alt=\"\" width=\"24\" height=\"24\">"
657 "<span class=\"navbar_link\">"
659 "</span></a></li>\n", _("Add new task")
664 "<li class=\"enternewnote\">"
665 "<a href=\"add_new_note\">"
666 "<img src=\"static/enternewnote_24x.gif\" "
667 "alt=\"\" width=\"24\" height=\"24\">"
668 "<span class=\"navbar_link\">"
670 "</span></a></li>\n", _("Add new note")
674 safestrncpy(buf, bstr("page"), sizeof buf);
677 "<li class=\"newmess\">"
678 "<a href=\"display_enter?wikipage=%s\">"
679 "<img src=\"static/newmess3_24x.gif\" "
680 "alt=\"\" width=\"24\" height=\"24\">"
681 "<span class=\"navbar_link\">"
683 "</span></a></li>\n", buf, _("Edit this page")
688 "<li class=\"newmess\">"
689 "<a href=\"display_enter\">"
690 "<img src=\"static/newmess3_24x.gif\" "
691 "alt=\"\" width=\"24\" height=\"24\">"
692 "<span class=\"navbar_link\">"
694 "</span></a></li>\n", _("Write mail")
697 "<li class=\"newmess\">"
698 "<a href=\"javascript:deleteAllSelectedMessages();\">"
699 "<img src=\"static/delete.gif\" "
700 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
702 "</span></a></li>\n", _("Delete")
707 "<li class=\"newmess\">"
708 "<a href=\"display_enter\">"
709 "<img src=\"static/newmess3_24x.gif\" "
710 "alt=\"\" width=\"24\" height=\"24\">"
711 "<span class=\"navbar_link\">"
713 "</span></a></li>\n", _("Enter a message")
719 if (navbar_style == navbar_default) wprintf(
720 "<li class=\"skipthisroom\">"
723 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
724 "width=\"24\" height=\"24\">"
725 "<span class=\"navbar_link\">%s</span></a>"
727 _("Leave all messages marked as unread, go to next room with unread messages"),
731 if (navbar_style == navbar_default) wprintf(
732 "<li class=\"markngo\">"
733 "<a href=\"gotonext\" "
735 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
736 "width=\"24\" height=\"24\">"
737 "<span class=\"navbar_link\">%s</span></a>"
739 _("Mark all messages as read, go to next room with unread messages"),
743 wprintf("</ul></div>\n");
750 * back end routine to take the session to a new room
752 long gotoroom(const StrBuf *gname)
755 static long ls = (-1L);
758 /* store ungoto information */
759 strcpy(WC->ugname, ChrPtr(WC->wc_roomname));
763 /* move to the new room */
764 serv_printf("GOTO %s", ChrPtr(gname));
765 StrBuf_ServGetln(Buf);
766 if (GetServerStatus(Buf, &err) != 2) {
767 serv_puts("GOTO _BASEROOM_");
768 StrBuf_ServGetln(Buf);
770 * well, we know that this is the fallback case,
771 * but we're interested that the first command
772 * didn't work out in first place.
774 if (GetServerStatus(Buf, NULL) != 2) {
780 if (WC->wc_roomname == NULL)
781 WC->wc_roomname = NewStrBuf();
783 FlushStrBuf(WC->wc_roomname);
785 StrBufExtract_token(WC->wc_roomname, Buf, 0, '|');
786 StrBufCutLeft(WC->wc_roomname, 4);
787 WC->room_flags = StrBufExtract_int(Buf, 4, '|');
788 /* highest_msg_read = extract_int(&buf[4],6);
789 maxmsgnum = extract_int(&buf[4],5);
791 WC->is_mailbox = StrBufExtract_int(Buf, 7, '|');
792 ls = StrBufExtract_long(Buf, 6, '|');
793 WC->wc_floor = StrBufExtract_int(Buf, 10, '|');
794 WC->wc_view = StrBufExtract_int(Buf, 11, '|');
795 WC->wc_default_view = StrBufExtract_int(Buf, 12, '|');
796 WC->wc_is_trash = StrBufExtract_int(Buf, 13, '|');
797 WC->room_flags2 = StrBufExtract_int(Buf, 14, '|');
800 WC->is_room_aide = WC->is_aide;
802 WC->is_room_aide = (char) StrBufExtract_int(Buf, 8, '|');
804 remove_march(WC->wc_roomname);
805 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
816 void smart_goto(const StrBuf *next_room) {
824 * mark all messages in current room as having been read
826 void slrp_highest(void)
830 serv_puts("SLRP HIGHEST");
831 serv_getln(buf, sizeof buf);
835 typedef struct __room_states {
850 * Set/clear/read the "self-service list subscribe" flag for a room
852 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
853 * returns the new value.
856 int self_service(int newval) {
857 int current_value = 0;
863 int flags, floor, order, view, flags2;
866 serv_getln(buf, sizeof buf);
867 if (buf[0] != '2') return(0);
869 extract_token(name, &buf[4], 0, '|', sizeof name);
870 extract_token(password, &buf[4], 1, '|', sizeof password);
871 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
872 flags = extract_int(&buf[4], 3);
873 floor = extract_int(&buf[4], 4);
874 order = extract_int(&buf[4], 5);
875 view = extract_int(&buf[4], 6);
876 flags2 = extract_int(&buf[4], 7);
878 if (flags2 & QR2_SELFLIST) {
886 flags2 = flags2 | QR2_SELFLIST;
888 else if (newval == 0) {
889 flags2 = flags2 & ~QR2_SELFLIST;
892 return(current_value);
895 if (newval != current_value) {
896 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
897 name, password, dirname, flags,
898 floor, order, view, flags2);
899 serv_getln(buf, sizeof buf);
906 int is_selflist(room_states *RoomFlags)
908 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
911 int is_publiclist(room_states *RoomFlags)
913 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
916 int is_moderatedlist(room_states *RoomFlags)
918 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
922 * Set/clear/read the "self-service list subscribe" flag for a room
924 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
925 * returns the new value.
928 int get_roomflags(room_states *RoomOps)
933 serv_getln(buf, sizeof buf);
934 if (buf[0] != '2') return(0);
936 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
937 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
938 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
939 RoomOps->flags = extract_int(&buf[4], 3);
940 RoomOps->floor = extract_int(&buf[4], 4);
941 RoomOps->order = extract_int(&buf[4], 5);
942 RoomOps->view = extract_int(&buf[4], 6);
943 RoomOps->flags2 = extract_int(&buf[4], 7);
947 int set_roomflags(room_states *RoomOps)
951 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
960 serv_getln(buf, sizeof buf);
970 * display the form for editing a room
972 void display_editroom(void)
978 char remote_room[128];
981 char er_password[10];
983 char er_roomaide[26];
990 char *not_shared_with;
1000 if (IsEmptyStr(tab)) tab = "admin";
1003 load_floorlist(Buf);
1005 output_headers(1, 1, 1, 0, 0, 0);
1007 wprintf("<div class=\"fix_scrollbar_bug\">");
1009 wprintf("<br />\n");
1011 /* print the tabbed dialog */
1012 wprintf("<div align=\"center\">");
1013 wprintf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1014 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1017 wprintf("<td class=\"");
1018 if (!strcmp(tab, "admin")) {
1019 wprintf(" tab_cell_label\">");
1020 wprintf(_("Administration"));
1023 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1024 wprintf(_("Administration"));
1028 wprintf("<td> </td>\n");
1030 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1032 wprintf("<td class=\"");
1033 if (!strcmp(tab, "config")) {
1034 wprintf(" tab_cell_label\">");
1035 wprintf(_("Configuration"));
1038 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1039 wprintf(_("Configuration"));
1043 wprintf("<td> </td>\n");
1045 wprintf("<td class=\"");
1046 if (!strcmp(tab, "expire")) {
1047 wprintf(" tab_cell_label\">");
1048 wprintf(_("Message expire policy"));
1051 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1052 wprintf(_("Message expire policy"));
1056 wprintf("<td> </td>\n");
1058 wprintf("<td class=\"");
1059 if (!strcmp(tab, "access")) {
1060 wprintf(" tab_cell_label\">");
1061 wprintf(_("Access controls"));
1064 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1065 wprintf(_("Access controls"));
1069 wprintf("<td> </td>\n");
1071 wprintf("<td class=\"");
1072 if (!strcmp(tab, "sharing")) {
1073 wprintf(" tab_cell_label\">");
1074 wprintf(_("Sharing"));
1077 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1078 wprintf(_("Sharing"));
1082 wprintf("<td> </td>\n");
1084 wprintf("<td class=\"");
1085 if (!strcmp(tab, "listserv")) {
1086 wprintf(" tab_cell_label\">");
1087 wprintf(_("Mailing list service"));
1090 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1091 wprintf(_("Mailing list service"));
1095 wprintf("<td> </td>\n");
1099 wprintf("<td class=\"");
1100 if (!strcmp(tab, "feeds")) {
1101 wprintf(" tab_cell_label\">");
1102 wprintf(_("Remote retrieval"));
1105 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1106 wprintf(_("Remote retrieval"));
1110 wprintf("<td> </td>\n");
1112 wprintf("</tr></table>\n");
1113 wprintf("</div>\n");
1114 /* end tabbed dialog */
1116 wprintf("<script type=\"text/javascript\">"
1117 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1121 /* begin content of whatever tab is open now */
1123 if (!strcmp(tab, "admin")) {
1124 wprintf("<div class=\"tabcontent\">");
1126 "<li><a href=\"delete_room\" "
1127 "onClick=\"return confirm('");
1128 wprintf(_("Are you sure you want to delete this room?"));
1129 wprintf("');\">\n");
1130 wprintf(_("Delete this room"));
1132 "<li><a href=\"display_editroompic?which_room=");
1133 urlescputs(ChrPtr(WC->wc_roomname));
1135 wprintf(_("Set or change the icon for this room's banner"));
1137 "<li><a href=\"display_editinfo\">\n");
1138 wprintf(_("Edit this room's Info file"));
1144 if (!strcmp(tab, "config")) {
1145 wprintf("<div class=\"tabcontent\">");
1147 serv_getln(buf, sizeof buf);
1149 if (!strncmp(buf, "550", 3)) {
1150 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1151 _("Higher access is required to access this function.")
1154 else if (buf[0] != '2') {
1155 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1158 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1159 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1160 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1161 er_flags = extract_int(&buf[4], 3);
1162 er_floor = extract_int(&buf[4], 4);
1163 er_flags2 = extract_int(&buf[4], 7);
1165 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1166 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1168 wprintf("<ul><li>");
1169 wprintf(_("Name of room: "));
1170 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1176 wprintf(_("Resides on floor: "));
1177 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1178 if (er_flags & QR_MAILBOX)
1179 wprintf("disabled >\n");
1180 for (i = 0; i < 128; ++i)
1181 if (!IsEmptyStr(floorlist[i])) {
1182 wprintf("<OPTION ");
1184 wprintf("SELECTED ");
1185 wprintf("VALUE=\"%d\">", i);
1186 escputs(floorlist[i]);
1187 wprintf("</OPTION>\n");
1189 wprintf("</select>\n");
1192 wprintf(_("Type of room:"));
1195 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1196 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1197 wprintf("CHECKED ");
1198 wprintf("OnChange=\""
1199 " if (this.form.type[0].checked == true) { "
1200 " this.form.er_floor.disabled = false; "
1203 wprintf(_("Public (automatically appears to everyone)"));
1206 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1207 if ((er_flags & QR_PRIVATE) &&
1208 (er_flags & QR_GUESSNAME))
1209 wprintf("CHECKED ");
1210 wprintf(" OnChange=\""
1211 " if (this.form.type[1].checked == true) { "
1212 " this.form.er_floor.disabled = false; "
1215 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1217 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1218 if ((er_flags & QR_PRIVATE) &&
1219 (er_flags & QR_PASSWORDED))
1220 wprintf("CHECKED ");
1221 wprintf(" OnChange=\""
1222 " if (this.form.type[2].checked == true) { "
1223 " this.form.er_floor.disabled = false; "
1226 wprintf(_("Private - require password: "));
1227 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1230 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1231 if ((er_flags & QR_PRIVATE)
1232 && ((er_flags & QR_GUESSNAME) == 0)
1233 && ((er_flags & QR_PASSWORDED) == 0))
1234 wprintf("CHECKED ");
1235 wprintf(" OnChange=\""
1236 " if (this.form.type[3].checked == true) { "
1237 " this.form.er_floor.disabled = false; "
1240 wprintf(_("Private - invitation only"));
1242 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1243 if (er_flags & QR_MAILBOX)
1244 wprintf("CHECKED ");
1245 wprintf (" OnChange=\""
1246 " if (this.form.type[4].checked == true) { "
1247 " this.form.er_floor.disabled = true; "
1250 wprintf(_("Personal (mailbox for you only)"));
1252 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1254 wprintf(_("If private, cause current users to forget room"));
1256 wprintf("\n</ul>\n");
1258 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1259 if (er_flags & QR_PREFONLY)
1260 wprintf("CHECKED ");
1262 wprintf(_("Preferred users only"));
1264 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1265 if (er_flags & QR_READONLY)
1266 wprintf("CHECKED ");
1268 wprintf(_("Read-only room"));
1270 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1271 if (er_flags2 & QR2_COLLABDEL)
1272 wprintf("CHECKED ");
1274 wprintf(_("All users allowed to post may also delete messages"));
1276 /** directory stuff */
1277 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1278 if (er_flags & QR_DIRECTORY)
1279 wprintf("CHECKED ");
1281 wprintf(_("File directory room"));
1283 wprintf("\n<ul><li>");
1284 wprintf(_("Directory name: "));
1285 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1288 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1289 if (er_flags & QR_UPLOAD)
1290 wprintf("CHECKED ");
1292 wprintf(_("Uploading allowed"));
1294 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1295 if (er_flags & QR_DOWNLOAD)
1296 wprintf("CHECKED ");
1298 wprintf(_("Downloading allowed"));
1300 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1301 if (er_flags & QR_VISDIR)
1302 wprintf("CHECKED ");
1304 wprintf(_("Visible directory"));
1307 /** end of directory stuff */
1309 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1310 if (er_flags & QR_NETWORK)
1311 wprintf("CHECKED ");
1313 wprintf(_("Network shared room"));
1315 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1316 if (er_flags & QR_PERMANENT)
1317 wprintf("CHECKED ");
1319 wprintf(_("Permanent (does not auto-purge)"));
1321 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1322 if (er_flags2 & QR2_SUBJECTREQ)
1323 wprintf("CHECKED ");
1325 wprintf(_("Subject Required (Force users to specify a message subject)"));
1327 /** start of anon options */
1330 wprintf(_("Anonymous messages"));
1333 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1334 if (((er_flags & QR_ANONONLY) == 0)
1335 && ((er_flags & QR_ANONOPT) == 0))
1336 wprintf("CHECKED ");
1338 wprintf(_("No anonymous messages"));
1340 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1341 if (er_flags & QR_ANONONLY)
1342 wprintf("CHECKED ");
1344 wprintf(_("All messages are anonymous"));
1346 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1347 if (er_flags & QR_ANONOPT)
1348 wprintf("CHECKED ");
1350 wprintf(_("Prompt user when entering messages"));
1353 /* end of anon options */
1356 wprintf(_("Room aide: "));
1358 serv_getln(buf, sizeof buf);
1359 if (buf[0] != '2') {
1360 wprintf("<em>%s</em>\n", &buf[4]);
1362 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1363 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1366 wprintf("</ul><CENTER>\n");
1367 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1368 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1370 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1380 /* Sharing the room with other Citadel nodes... */
1381 if (!strcmp(tab, "sharing")) {
1382 wprintf("<div class=\"tabcontent\">");
1384 shared_with = strdup("");
1385 not_shared_with = strdup("");
1387 /** Learn the current configuration */
1388 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1389 serv_getln(buf, sizeof buf);
1390 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1391 extract_token(node, buf, 0, '|', sizeof node);
1392 not_shared_with = realloc(not_shared_with,
1393 strlen(not_shared_with) + 32);
1394 strcat(not_shared_with, node);
1395 strcat(not_shared_with, "\n");
1399 serv_getln(buf, sizeof buf);
1400 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1401 extract_token(cmd, buf, 0, '|', sizeof cmd);
1402 extract_token(node, buf, 1, '|', sizeof node);
1403 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1404 if (!strcasecmp(cmd, "ignet_push_share")) {
1405 shared_with = realloc(shared_with,
1406 strlen(shared_with) + 32);
1407 strcat(shared_with, node);
1408 if (!IsEmptyStr(remote_room)) {
1409 strcat(shared_with, "|");
1410 strcat(shared_with, remote_room);
1412 strcat(shared_with, "\n");
1416 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1417 extract_token(buf, shared_with, i, '\n', sizeof buf);
1418 extract_token(node, buf, 0, '|', sizeof node);
1419 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1420 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1421 if (!strcasecmp(node, cmd)) {
1422 remove_token(not_shared_with, j, '\n');
1427 /* Display the stuff */
1428 wprintf("<CENTER><br />"
1429 "<table border=1 cellpadding=5><tr>"
1431 wprintf(_("Shared with"));
1432 wprintf("</I></B></td>"
1434 wprintf(_("Not shared with"));
1435 wprintf("</I></B></td></tr>\n"
1436 "<tr><td VALIGN=TOP>\n");
1438 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1439 wprintf(_("Remote node name"));
1440 wprintf("</td><td>");
1441 wprintf(_("Remote room name"));
1442 wprintf("</td><td>");
1443 wprintf(_("Actions"));
1444 wprintf("</td></tr>\n");
1446 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1447 extract_token(buf, shared_with, i, '\n', sizeof buf);
1448 extract_token(node, buf, 0, '|', sizeof node);
1449 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1450 if (!IsEmptyStr(node)) {
1451 wprintf("<form method=\"POST\" action=\"netedit\">");
1452 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1453 wprintf("<tr><td>%s</td>\n", node);
1456 if (!IsEmptyStr(remote_room)) {
1457 escputs(remote_room);
1463 wprintf("<input type=\"hidden\" NAME=\"line\" "
1464 "VALUE=\"ignet_push_share|");
1466 if (!IsEmptyStr(remote_room)) {
1468 urlescputs(remote_room);
1471 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1472 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1473 wprintf("<input type=\"submit\" "
1474 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1475 wprintf("</td></tr></form>\n");
1479 wprintf("</table>\n");
1480 wprintf("</td><td VALIGN=TOP>\n");
1481 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1482 wprintf(_("Remote node name"));
1483 wprintf("</td><td>");
1484 wprintf(_("Remote room name"));
1485 wprintf("</td><td>");
1486 wprintf(_("Actions"));
1487 wprintf("</td></tr>\n");
1489 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1490 extract_token(node, not_shared_with, i, '\n', sizeof node);
1491 if (!IsEmptyStr(node)) {
1492 wprintf("<form method=\"POST\" action=\"netedit\">");
1493 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1494 wprintf("<tr><td>");
1497 "<input type=\"INPUT\" "
1501 wprintf("<input type=\"hidden\" "
1503 "VALUE=\"ignet_push_share|");
1506 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1507 "VALUE=\"sharing\">\n");
1508 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1509 "VALUE=\"add\">\n");
1510 wprintf("<input type=\"submit\" "
1511 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1512 wprintf("</td></tr></form>\n");
1516 wprintf("</table>\n");
1517 wprintf("</td></tr>"
1518 "</table></CENTER><br />\n"
1519 "<I><B>%s</B><ul><li>", _("Notes:"));
1520 wprintf(_("When sharing a room, "
1521 "it must be shared from both ends. Adding a node to "
1522 "the 'shared' list sends messages out, but in order to"
1523 " receive messages, the other nodes must be configured"
1524 " to send messages out to your system as well. "
1525 "<li>If the remote room name is blank, it is assumed "
1526 "that the room name is identical on the remote node."
1527 "<li>If the remote room name is different, the remote "
1528 "node must also configure the name of the room here."
1535 /* Mailing list management */
1536 if (!strcmp(tab, "listserv")) {
1537 room_states RoomFlags;
1538 wprintf("<div class=\"tabcontent\">");
1540 wprintf("<br /><center>"
1541 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1542 "<tr><td VALIGN=TOP>");
1544 wprintf(_("<i>The contents of this room are being "
1545 "mailed <b>as individual messages</b> "
1546 "to the following list recipients:"
1547 "</i><br /><br />\n"));
1550 serv_getln(buf, sizeof buf);
1551 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1552 extract_token(cmd, buf, 0, '|', sizeof cmd);
1553 if (!strcasecmp(cmd, "listrecp")) {
1554 extract_token(recp, buf, 1, '|', sizeof recp);
1557 wprintf(" <a href=\"netedit?cmd=remove&tab=listserv&line=listrecp|");
1560 wprintf(_("(remove)"));
1561 wprintf("</A><br />");
1564 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1565 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1566 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1567 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1568 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1569 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1570 wprintf("</form>\n");
1572 wprintf("</td><td VALIGN=TOP>\n");
1574 wprintf(_("<i>The contents of this room are being "
1575 "mailed <b>in digest form</b> "
1576 "to the following list recipients:"
1577 "</i><br /><br />\n"));
1580 serv_getln(buf, sizeof buf);
1581 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1582 extract_token(cmd, buf, 0, '|', sizeof cmd);
1583 if (!strcasecmp(cmd, "digestrecp")) {
1584 extract_token(recp, buf, 1, '|', sizeof recp);
1587 wprintf(" <a href=\"netedit?cmd=remove&tab=listserv&line="
1591 wprintf(_("(remove)"));
1592 wprintf("</A><br />");
1595 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1596 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1597 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1598 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1599 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1600 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1601 wprintf("</form>\n");
1603 wprintf("</td></tr></table>\n");
1605 /** Pop open an address book -- begin **/
1606 wprintf("<div align=right>"
1607 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1609 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1614 _("Add recipients from Contacts or other address books"),
1615 _("Add recipients from Contacts or other address books")
1617 /* Pop open an address book -- end **/
1619 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1621 get_roomflags (&RoomFlags);
1623 /* Self Service subscription? */
1624 wprintf("<table><tr><td>\n");
1625 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1626 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1627 " <tr><td colspan=\"2\">\n",
1628 (is_selflist(&RoomFlags))?"checked":"");
1629 wprintf(_("The URL for subscribe/unsubscribe is: "));
1630 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1631 (is_https ? "https" : "http"),
1632 ChrPtr(WC->Hdr->HR.http_host));
1633 /* Public posting? */
1634 wprintf("<tr><td>");
1635 wprintf(_("Allow non-subscribers to mail to this room."));
1636 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1637 (is_publiclist(&RoomFlags))?"checked":"");
1639 /* Moderated List? */
1640 wprintf("<tr><td>");
1641 wprintf(_("Room post publication needs Aide permission."));
1642 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1643 (is_moderatedlist(&RoomFlags))?"checked":"");
1646 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1647 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1648 wprintf("</table></form>");
1651 wprintf("</CENTER>\n");
1656 /* Configuration of The Dreaded Auto-Purger */
1657 if (!strcmp(tab, "expire")) {
1658 wprintf("<div class=\"tabcontent\">");
1660 serv_puts("GPEX room");
1661 serv_getln(buf, sizeof buf);
1662 if (!strncmp(buf, "550", 3)) {
1663 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1664 _("Higher access is required to access this function.")
1667 else if (buf[0] != '2') {
1668 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1671 roompolicy = extract_int(&buf[4], 0);
1672 roomvalue = extract_int(&buf[4], 1);
1674 serv_puts("GPEX floor");
1675 serv_getln(buf, sizeof buf);
1676 if (buf[0] == '2') {
1677 floorpolicy = extract_int(&buf[4], 0);
1678 floorvalue = extract_int(&buf[4], 1);
1681 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1682 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1683 wprintf("<table border=0 cellspacing=5>\n");
1684 wprintf("<tr><td>");
1685 wprintf(_("Message expire policy for this room"));
1687 escputs(ChrPtr(WC->wc_roomname));
1688 wprintf(")</td><td>");
1689 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1690 ((roompolicy == 0) ? "CHECKED" : "") );
1691 wprintf(_("Use the default policy for this floor"));
1692 wprintf("<br />\n");
1693 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1694 ((roompolicy == 1) ? "CHECKED" : "") );
1695 wprintf(_("Never automatically expire messages"));
1696 wprintf("<br />\n");
1697 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1698 ((roompolicy == 2) ? "CHECKED" : "") );
1699 wprintf(_("Expire by message count"));
1700 wprintf("<br />\n");
1701 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1702 ((roompolicy == 3) ? "CHECKED" : "") );
1703 wprintf(_("Expire by message age"));
1705 wprintf(_("Number of messages or days: "));
1706 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1707 wprintf("</td></tr>\n");
1709 if (WC->axlevel >= 6) {
1710 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1711 wprintf("<tr><td>");
1712 wprintf(_("Message expire policy for this floor"));
1714 escputs(floorlist[WC->wc_floor]);
1715 wprintf(")</td><td>");
1716 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1717 ((floorpolicy == 0) ? "CHECKED" : "") );
1718 wprintf(_("Use the system default"));
1719 wprintf("<br />\n");
1720 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1721 ((floorpolicy == 1) ? "CHECKED" : "") );
1722 wprintf(_("Never automatically expire messages"));
1723 wprintf("<br />\n");
1724 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1725 ((floorpolicy == 2) ? "CHECKED" : "") );
1726 wprintf(_("Expire by message count"));
1727 wprintf("<br />\n");
1728 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1729 ((floorpolicy == 3) ? "CHECKED" : "") );
1730 wprintf(_("Expire by message age"));
1732 wprintf(_("Number of messages or days: "));
1733 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1737 wprintf("<CENTER>\n");
1738 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1739 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1741 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1742 wprintf("</CENTER></td><tr>\n");
1744 wprintf("</table>\n"
1745 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1753 /* Access controls */
1754 if (!strcmp(tab, "access")) {
1755 wprintf("<div class=\"tabcontent\">");
1760 /* Fetch messages from remote locations */
1761 if (!strcmp(tab, "feeds")) {
1762 wprintf("<div class=\"tabcontent\">");
1765 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1766 wprintf("</i><br />\n");
1768 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1769 "<tr class=\"even\"><th>");
1770 wprintf(_("Remote host"));
1771 wprintf("</th><th>");
1772 wprintf(_("User name"));
1773 wprintf("</th><th>");
1774 wprintf(_("Password"));
1775 wprintf("</th><th>");
1776 wprintf(_("Keep messages on server?"));
1777 wprintf("</th><th>");
1778 wprintf(_("Interval"));
1779 wprintf("</th><th> </th></tr>");
1782 serv_getln(buf, sizeof buf);
1784 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1785 extract_token(cmd, buf, 0, '|', sizeof cmd);
1786 if (!strcasecmp(cmd, "pop3client")) {
1787 safestrncpy(recp, &buf[11], sizeof recp);
1790 wprintf("<tr class=\"%s\">",
1791 (bg ? "even" : "odd")
1795 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1800 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1804 wprintf("<td>*****</td>"); /* Don't show the password */
1806 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1808 wprintf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
1810 wprintf("<td class=\"button_link\">");
1811 wprintf(" <a href=\"netedit?cmd=remove&tab=feeds&line=pop3client|");
1814 wprintf(_("(remove)"));
1815 wprintf("</a></td>");
1821 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1823 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1824 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1825 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1827 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1830 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1833 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1836 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1839 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
1842 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1843 wprintf("</td></tr>");
1844 wprintf("</form></table>\n");
1849 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1850 wprintf("</i><br />\n");
1852 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1853 "<tr class=\"even\"><th>");
1854 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1855 wprintf(_("Feed URL"));
1856 wprintf("</th><th>");
1857 wprintf("</th></tr>");
1860 serv_getln(buf, sizeof buf);
1862 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1863 extract_token(cmd, buf, 0, '|', sizeof cmd);
1864 if (!strcasecmp(cmd, "rssclient")) {
1865 safestrncpy(recp, &buf[10], sizeof recp);
1868 wprintf("<tr class=\"%s\">",
1869 (bg ? "even" : "odd")
1873 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1877 wprintf("<td class=\"button_link\">");
1878 wprintf(" <a href=\"netedit?cmd=remove&tab=feeds&line=rssclient|");
1881 wprintf(_("(remove)"));
1882 wprintf("</a></td>");
1888 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1890 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1891 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
1892 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1894 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
1895 "maxlength=\"256\" name=\"line_pop3host\">\n");
1898 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
1899 wprintf("</td></tr>");
1900 wprintf("</form></table>\n");
1906 /* end content of whatever tab is open now */
1907 wprintf("</div>\n");
1909 address_book_popup();
1915 * Toggle self-service list subscription
1917 void toggle_self_service(void) {
1918 room_states RoomFlags;
1920 get_roomflags (&RoomFlags);
1922 if (yesbstr("QR2_SelfList"))
1923 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
1925 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
1927 if (yesbstr("QR2_SMTP_PUBLIC"))
1928 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
1930 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
1932 if (yesbstr("QR2_Moderated"))
1933 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
1935 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
1936 if (yesbstr("QR2_SubsOnly"))
1937 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
1939 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
1941 set_roomflags (&RoomFlags);
1949 * save new parameters for a room
1956 StrBuf *er_password;
1958 StrBuf *er_roomaide;
1961 int er_listingorder;
1967 if (!havebstr("ok_button")) {
1968 strcpy(WC->ImportantMessage,
1969 _("Cancelled. Changes were not saved."));
1975 StrBuf_ServGetln(Buf);
1976 if (GetServerStatus(Buf, NULL) != 2) {
1977 StrBufCutLeft(Buf, 4);
1978 strcpy(WC->ImportantMessage, ChrPtr(Buf));
1984 er_name = NewStrBuf();
1985 er_password = NewStrBuf();
1986 er_dirname = NewStrBuf();
1987 er_roomaide = NewStrBuf();
1989 StrBufCutLeft(Buf, 4);
1990 StrBufExtract_token(er_name, Buf, 0, '|');
1991 StrBufExtract_token(er_password, Buf, 1, '|');
1992 StrBufExtract_token(er_dirname, Buf, 2, '|');
1993 er_flags = StrBufExtract_int(Buf, 3, '|');
1994 er_listingorder = StrBufExtract_int(Buf, 5, '|');
1995 er_defaultview = StrBufExtract_int(Buf, 6, '|');
1996 er_flags2 = StrBufExtract_int(Buf, 7, '|');
1998 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
1999 if (StrLength(er_roomaide) == 0) {
2001 StrBuf_ServGetln(Buf);
2002 if (GetServerStatus(Buf, NULL) != 2) {
2003 FlushStrBuf(er_roomaide);
2005 StrBufCutLeft(Buf, 4);
2006 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2009 Ptr = sbstr("er_name");
2010 if (StrLength(Ptr) > 0) {
2011 FlushStrBuf(er_name);
2012 StrBufAppendBuf(er_name, Ptr, 0);
2015 Ptr = sbstr("er_password");
2016 if (StrLength(Ptr) > 0) {
2017 FlushStrBuf(er_password);
2018 StrBufAppendBuf(er_password, Ptr, 0);
2022 Ptr = sbstr("er_dirname");
2023 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2024 FlushStrBuf(er_dirname);
2025 StrBufAppendBuf(er_dirname, Ptr, 0);
2029 Ptr = sbstr("type");
2030 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2032 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2033 er_flags |= (QR_PRIVATE);
2035 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2036 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2038 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2039 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2041 if (!strcmp(ChrPtr(Ptr), "personal")) {
2042 er_flags |= QR_MAILBOX;
2044 er_flags &= ~QR_MAILBOX;
2047 if (yesbstr("prefonly")) {
2048 er_flags |= QR_PREFONLY;
2050 er_flags &= ~QR_PREFONLY;
2053 if (yesbstr("readonly")) {
2054 er_flags |= QR_READONLY;
2056 er_flags &= ~QR_READONLY;
2060 if (yesbstr("collabdel")) {
2061 er_flags2 |= QR2_COLLABDEL;
2063 er_flags2 &= ~QR2_COLLABDEL;
2066 if (yesbstr("permanent")) {
2067 er_flags |= QR_PERMANENT;
2069 er_flags &= ~QR_PERMANENT;
2072 if (yesbstr("subjectreq")) {
2073 er_flags2 |= QR2_SUBJECTREQ;
2075 er_flags2 &= ~QR2_SUBJECTREQ;
2078 if (yesbstr("network")) {
2079 er_flags |= QR_NETWORK;
2081 er_flags &= ~QR_NETWORK;
2084 if (yesbstr("directory")) {
2085 er_flags |= QR_DIRECTORY;
2087 er_flags &= ~QR_DIRECTORY;
2090 if (yesbstr("ulallowed")) {
2091 er_flags |= QR_UPLOAD;
2093 er_flags &= ~QR_UPLOAD;
2096 if (yesbstr("dlallowed")) {
2097 er_flags |= QR_DOWNLOAD;
2099 er_flags &= ~QR_DOWNLOAD;
2102 if (yesbstr("visdir")) {
2103 er_flags |= QR_VISDIR;
2105 er_flags &= ~QR_VISDIR;
2108 Ptr = sbstr("anon");
2110 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2111 if (!strcmp(ChrPtr(Ptr), "anononly"))
2112 er_flags |= QR_ANONONLY;
2113 if (!strcmp(ChrPtr(Ptr), "anon2"))
2114 er_flags |= QR_ANONOPT;
2116 bump = yesbstr("bump");
2118 er_floor = ibstr("er_floor");
2120 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2122 ChrPtr(er_password),
2131 StrBuf_ServGetln(Buf);
2132 if (GetServerStatus(Buf, NULL) != 2) {
2133 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2136 FreeStrBuf(&er_name);
2137 FreeStrBuf(&er_password);
2138 FreeStrBuf(&er_dirname);
2139 FreeStrBuf(&er_roomaide);
2144 if (StrLength(er_roomaide) > 0) {
2145 serv_printf("SETA %s", ChrPtr(er_roomaide));
2146 StrBuf_ServGetln(Buf);
2147 if (GetServerStatus(Buf, NULL) != 2) {
2148 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2149 display_main_menu();
2151 FreeStrBuf(&er_name);
2152 FreeStrBuf(&er_password);
2153 FreeStrBuf(&er_dirname);
2154 FreeStrBuf(&er_roomaide);
2159 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2162 FreeStrBuf(&er_name);
2163 FreeStrBuf(&er_password);
2164 FreeStrBuf(&er_dirname);
2165 FreeStrBuf(&er_roomaide);
2171 * Display form for Invite, Kick, and show Who Knows a room
2173 void do_invt_kick(void) {
2174 char buf[SIZ], room[SIZ], username[SIZ];
2177 serv_getln(buf, sizeof buf);
2179 if (buf[0] != '2') {
2183 extract_token(room, &buf[4], 0, '|', sizeof room);
2185 strcpy(username, bstr("username"));
2187 if (havebstr("kick_button")) {
2188 sprintf(buf, "KICK %s", username);
2190 serv_getln(buf, sizeof buf);
2192 if (buf[0] != '2') {
2193 strcpy(WC->ImportantMessage, &buf[4]);
2195 sprintf(WC->ImportantMessage,
2196 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2201 if (havebstr("invite_button")) {
2202 sprintf(buf, "INVT %s", username);
2204 serv_getln(buf, sizeof buf);
2206 if (buf[0] != '2') {
2207 strcpy(WC->ImportantMessage, &buf[4]);
2209 sprintf(WC->ImportantMessage,
2210 _("<B><I>User %s invited to room %s.</I></B>\n"),
2221 * Display form for Invite, Kick, and show Who Knows a room
2223 void display_whok(void)
2225 char buf[SIZ], room[SIZ], username[SIZ];
2228 serv_getln(buf, sizeof buf);
2230 if (buf[0] != '2') {
2234 extract_token(room, &buf[4], 0, '|', sizeof room);
2237 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2238 wprintf(_("The users listed below have access to this room. "
2239 "To remove a user from the access list, select the user "
2240 "name from the list and click 'Kick'."));
2241 wprintf("<br /><br />");
2243 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2244 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2245 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2246 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2248 serv_getln(buf, sizeof buf);
2249 if (buf[0] == '1') {
2250 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2251 extract_token(username, buf, 0, '|', sizeof username);
2252 wprintf("<OPTION>");
2257 wprintf("</select><br />\n");
2259 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2260 wprintf("</form></CENTER>\n");
2262 wprintf("</td><td>");
2263 wprintf(_("To grant another user access to this room, enter the "
2264 "user name in the box below and click 'Invite'."));
2265 wprintf("<br /><br />");
2267 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2268 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2269 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2270 wprintf(_("Invite:"));
2272 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2273 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2274 "<input type=\"submit\" value=\"%s\">"
2275 "</form></CENTER>\n", _("Invite"));
2276 /* Pop open an address book -- begin **/
2278 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2280 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2283 _("Users"), _("Users")
2285 /* Pop open an address book -- end **/
2287 wprintf("</td></tr></table>\n");
2288 address_book_popup();
2295 * display the form for entering a new room
2297 void display_entroom(void)
2304 serv_puts("CRE8 0");
2305 serv_getln(buf, sizeof buf);
2307 if (buf[0] != '2') {
2308 strcpy(WC->ImportantMessage, &buf[4]);
2309 display_main_menu();
2314 output_headers(1, 1, 1, 0, 0, 0);
2316 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2317 do_template("beginbox", NULL);
2319 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2320 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2322 wprintf("<table class=\"altern\"> ");
2324 wprintf("<tr class=\"even\"><td>");
2325 wprintf(_("Name of room: "));
2326 wprintf("</td><td>");
2327 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2328 wprintf("</td></tr>");
2330 wprintf("<tr class=\"odd\"><td>");
2331 wprintf(_("Resides on floor: "));
2332 wprintf("</td><td>");
2333 load_floorlist(Buf);
2334 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2335 for (i = 0; i < 128; ++i)
2336 if (!IsEmptyStr(floorlist[i])) {
2337 wprintf("<option ");
2338 wprintf("value=\"%d\">", i);
2339 escputs(floorlist[i]);
2340 wprintf("</option>\n");
2342 wprintf("</select>\n");
2343 wprintf("</td></tr>");
2346 * Our clever little snippet of JavaScript automatically selects
2347 * a public room if the view is set to Bulletin Board or wiki, and
2348 * it selects a mailbox room otherwise. The user can override this,
2349 * of course. We also disable the floor selector for mailboxes.
2351 wprintf("<tr class=\"even\"><td>");
2352 wprintf(_("Default view for room: "));
2353 wprintf("</td><td>");
2354 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2355 " if ( (this.form.er_view.value == 0) "
2356 " || (this.form.er_view.value == 6) ) { "
2357 " this.form.type[0].checked=true; "
2358 " this.form.er_floor.disabled = false; "
2361 " this.form.type[4].checked=true; "
2362 " this.form.er_floor.disabled = true; "
2365 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2366 if (is_view_allowed_as_default(i)) {
2367 wprintf("<option %s value=\"%d\">",
2368 ((i == 0) ? "selected" : ""), i );
2369 escputs(viewdefs[i]);
2370 wprintf("</option>\n");
2373 wprintf("</select>\n");
2374 wprintf("</td></tr>");
2376 wprintf("<tr class=\"even\"><td>");
2377 wprintf(_("Type of room:"));
2378 wprintf("</td><td>");
2379 wprintf("<ul class=\"adminlist\">\n");
2381 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2382 wprintf("CHECKED OnChange=\""
2383 " if (this.form.type[0].checked == true) { "
2384 " this.form.er_floor.disabled = false; "
2387 wprintf(_("Public (automatically appears to everyone)"));
2390 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2391 " if (this.form.type[1].checked == true) { "
2392 " this.form.er_floor.disabled = false; "
2395 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2398 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2399 " if (this.form.type[2].checked == true) { "
2400 " this.form.er_floor.disabled = false; "
2403 wprintf(_("Private - require password: "));
2404 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2407 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2408 " if (this.form.type[3].checked == true) { "
2409 " this.form.er_floor.disabled = false; "
2412 wprintf(_("Private - invitation only"));
2415 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2417 " if (this.form.type[4].checked == true) { "
2418 " this.form.er_floor.disabled = true; "
2421 wprintf(_("Personal (mailbox for you only)"));
2424 wprintf("\n</ul>\n");
2425 wprintf("</td></tr></table>\n");
2427 wprintf("<div class=\"buttons\">\n");
2428 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2430 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2431 wprintf("</div>\n");
2432 wprintf("</form>\n<hr />");
2433 serv_printf("MESG roomaccess");
2434 serv_getln(buf, sizeof buf);
2435 if (buf[0] == '1') {
2439 do_template("endbox", NULL);
2449 * support function for entroom() -- sets the default view
2451 void er_set_default_view(int newview) {
2464 serv_getln(buf, sizeof buf);
2465 if (buf[0] != '2') return;
2467 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2468 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2469 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2470 rm_bits1 = extract_int(&buf[4], 3);
2471 rm_floor = extract_int(&buf[4], 4);
2472 rm_listorder = extract_int(&buf[4], 5);
2473 rm_bits2 = extract_int(&buf[4], 7);
2475 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2476 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2477 rm_listorder, newview, rm_bits2
2479 serv_getln(buf, sizeof buf);
2490 const StrBuf *er_name;
2491 const StrBuf *er_type;
2492 const StrBuf *er_password;
2497 if (!havebstr("ok_button")) {
2498 strcpy(WC->ImportantMessage,
2499 _("Cancelled. No new room was created."));
2500 display_main_menu();
2503 er_name = sbstr("er_name");
2504 er_type = sbstr("type");
2505 er_password = sbstr("er_password");
2506 er_floor = ibstr("er_floor");
2507 er_view = ibstr("er_view");
2510 if (!strcmp(ChrPtr(er_type), "hidden"))
2512 else if (!strcmp(ChrPtr(er_type), "passworded"))
2514 else if (!strcmp(ChrPtr(er_type), "invonly"))
2516 else if (!strcmp(ChrPtr(er_type), "personal"))
2519 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2522 ChrPtr(er_password),
2527 serv_getln(buf, sizeof buf);
2528 if (buf[0] != '2') {
2529 strcpy(WC->ImportantMessage, &buf[4]);
2530 display_main_menu();
2533 /** TODO: Room created, now udate the left hand icon bar for this user */
2534 burn_folder_cache(0); /* burn the old folder cache */
2538 do_change_view(er_view); /* Now go there */
2543 * \brief display the screen to enter a private room
2545 void display_private(char *rname, int req_pass)
2547 WCTemplputParams SubTP;
2549 output_headers(1, 1, 1, 0, 0, 0);
2551 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2552 memset(&SubTP, 0, sizeof(WCTemplputParams));
2553 SubTP.Filter.ContextType = CTX_STRBUF;
2554 SubTP.Context = Buf;
2555 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2560 wprintf(_("If you know the name of a hidden (guess-name) or "
2561 "passworded room, you can enter that room by typing "
2562 "its name below. Once you gain access to a private "
2563 "room, it will appear in your regular room listings "
2564 "so you don't have to keep returning here."));
2567 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2568 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2570 wprintf("<table class=\"altern\"> "
2571 "<tr class=\"even\"><td>");
2572 wprintf(_("Enter room name:"));
2574 "<input type=\"text\" name=\"gr_name\" "
2575 "value=\"%s\" maxlength=\"128\">\n", rname);
2578 wprintf("</td></tr><tr class=\"odd\"><td>");
2579 wprintf(_("Enter room password:"));
2580 wprintf("</td><td>");
2581 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2583 wprintf("</td></tr></table>\n");
2585 wprintf("<div class=\"buttons\">\n");
2586 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2588 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2592 wprintf("</div></form>\n");
2594 do_template("endbox", NULL);
2600 * \brief goto a private room
2602 void goto_private(void)
2607 if (!havebstr("ok_button")) {
2608 display_main_menu();
2611 strcpy(hold_rm, ChrPtr(WC->wc_roomname));
2612 serv_printf("GOTO %s|%s",
2615 serv_getln(buf, sizeof buf);
2617 if (buf[0] == '2') {
2618 smart_goto(sbstr("gr_name"));
2621 if (!strncmp(buf, "540", 3)) {
2622 display_private(bstr("gr_name"), 1);
2625 output_headers(1, 1, 1, 0, 0, 0);
2626 wprintf("%s\n", &buf[4]);
2633 * \brief display the screen to zap a room
2635 void display_zap(void)
2637 output_headers(1, 1, 2, 0, 0, 0);
2639 wprintf("<div id=\"banner\">\n");
2641 wprintf(_("Zap (forget/unsubscribe) the current room"));
2643 wprintf("</div>\n");
2645 wprintf("<div id=\"content\" class=\"service\">\n");
2647 wprintf(_("If you select this option, <em>%s</em> will "
2648 "disappear from your room list. Is this what you wish "
2649 "to do?<br />\n"), ChrPtr(WC->wc_roomname));
2651 wprintf("<form method=\"POST\" action=\"zap\">\n");
2652 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2653 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2655 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2656 wprintf("</form>\n");
2667 StrBuf *final_destination;
2670 * If the forget-room routine fails for any reason, we fall back
2671 * to the current room; otherwise, we go to the Lobby
2673 final_destination = NewStrBufDup(WC->wc_roomname);
2675 if (havebstr("ok_button")) {
2676 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
2677 serv_getln(buf, sizeof buf);
2678 if (buf[0] == '2') {
2680 serv_getln(buf, sizeof buf);
2681 if (buf[0] == '2') {
2682 FlushStrBuf(final_destination);
2683 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2687 smart_goto(final_destination);
2688 FreeStrBuf(&final_destination);
2694 * \brief Delete the current room
2696 void delete_room(void)
2701 serv_puts("KILL 1");
2702 serv_getln(buf, sizeof buf);
2703 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2704 if (buf[0] != '2') {
2705 strcpy(WC->ImportantMessage, &buf[4]);
2706 display_main_menu();
2711 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2720 * \brief Perform changes to a room's network configuration
2722 void netedit(void) {
2731 /*/ TODO: do line dynamic! */
2732 if (havebstr("line_pop3host")) {
2733 strcpy(line, bstr("prefix"));
2734 strcat(line, bstr("line_pop3host"));
2736 strcat(line, bstr("line_pop3user"));
2738 strcat(line, bstr("line_pop3pass"));
2740 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2742 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2743 strcat(line, bstr("suffix"));
2745 else if (havebstr("line")) {
2746 strcpy(line, bstr("prefix"));
2747 strcat(line, bstr("line"));
2748 strcat(line, bstr("suffix"));
2763 serv_getln(buf, sizeof buf);
2764 if (buf[0] != '1') {
2770 /** This loop works for add *or* remove. Spiffy, eh? */
2771 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2772 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2773 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2774 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2775 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2776 if ( (strcasecmp(cmpa0, cmpb0))
2777 || (strcasecmp(cmpa1, cmpb1)) ) {
2778 fprintf(fp, "%s\n", buf);
2784 serv_getln(buf, sizeof buf);
2785 if (buf[0] != '4') {
2791 while (fgets(buf, sizeof buf, fp) != NULL) {
2792 buf[strlen(buf)-1] = 0;
2796 if (havebstr("add_button")) {
2797 num_addrs = num_tokens(bstr("line"), ',');
2798 if (num_addrs < 2) {
2799 /* just adding one node or address */
2803 /* adding multiple addresses separated by commas */
2804 for (i=0; i<num_addrs; ++i) {
2805 strcpy(line, bstr("prefix"));
2806 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2809 strcat(line, bstr("suffix"));
2823 * \brief Convert a room name to a folder-ish-looking name.
2824 * \param folder the folderish name
2825 * \param room the room name
2826 * \param floor the floor name
2827 * \param is_mailbox is it a mailbox?
2829 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2834 * For mailboxes, just do it straight...
2837 sprintf(folder, "My folders|%s", room);
2841 * Otherwise, prefix the floor name as a "public folders" moniker
2844 if (floor > MAX_FLOORS) {
2846 sprintf(folder, "%%%%%%|%s", room);
2849 sprintf(folder, "%s|%s", floorlist[floor], room);
2854 * Replace "\" characters with "|" for pseudo-folder-delimiting
2856 len = strlen (folder);
2857 for (i=0; i<len; ++i) {
2858 if (folder[i] == '\\') folder[i] = '|';
2866 * \brief Back end for change_view()
2867 * \param newview set newview???
2869 void do_change_view(int newview) {
2872 serv_printf("VIEW %d", newview);
2873 serv_getln(buf, sizeof buf);
2874 WC->wc_view = newview;
2875 smart_goto(WC->wc_roomname);
2881 * \brief Change the view for this room
2883 void change_view(void) {
2886 view = lbstr("view");
2887 do_change_view(view);
2892 * \brief One big expanded tree list view --- like a folder list
2893 * \param fold the folder to view
2894 * \param max_folders how many folders???
2895 * \param num_floors hom many floors???
2897 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2901 int has_subfolders = 0;
2904 parents = malloc(max_folders * sizeof(int));
2906 /** BEGIN TREE MENU */
2907 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2909 /** include NanoTree */
2910 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2912 /** initialize NanoTree */
2913 wprintf("<script type=\"text/javascript\"> \n"
2914 " showRootNode = false; \n"
2915 " sortNodes = false; \n"
2916 " dragable = false; \n"
2918 " function standardClick(treeNode) { \n"
2921 " var closedGif = 'static/folder_closed.gif'; \n"
2922 " var openGif = 'static/folder_open.gif'; \n"
2924 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2928 for (i=0; i<max_folders; ++i) {
2931 if ((i+1) < max_folders) {
2933 len = strlen(fold[i].name);
2934 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2935 && (fold[i+1].name[len] == '|') ) {
2940 levels = num_tokens(fold[i].name, '|');
2941 parents[levels] = i;
2943 wprintf("var node%d = new TreeNode(%d, '", i, i);
2945 if (fold[i].selectable) {
2946 wprintf("<a href=\"dotgoto?room=");
2947 urlescputs(fold[i].room);
2952 wprintf("<span class=\"roomlist_floor\">");
2954 else if (fold[i].hasnewmsgs) {
2955 wprintf("<span class=\"roomlist_new\">");
2958 wprintf("<span class=\"roomlist_old\">");
2960 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2965 if (has_subfolders) {
2966 wprintf("new Array(closedGif, openGif)");
2968 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2969 wprintf("'static/viewcontacts_16x.gif'");
2971 else if (fold[i].view == VIEW_CALENDAR) {
2972 wprintf("'static/calarea_16x.gif'");
2974 else if (fold[i].view == VIEW_CALBRIEF) {
2975 wprintf("'static/calarea_16x.gif'");
2977 else if (fold[i].view == VIEW_TASKS) {
2978 wprintf("'static/taskmanag_16x.gif'");
2980 else if (fold[i].view == VIEW_NOTES) {
2981 wprintf("'static/storenotes_16x.gif'");
2983 else if (fold[i].view == VIEW_MAILBOX) {
2984 wprintf("'static/privatemess_16x.gif'");
2987 wprintf("'static/chatrooms_16x.gif'");
2990 urlescputs(fold[i].name);
2994 wprintf("rootNode.addChild(node%d);\n", i);
2997 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3001 wprintf("container = document.getElementById('roomlist_div'); \n"
3007 /** END TREE MENU */
3011 * \brief Boxes and rooms and lists ... oh my!
3012 * \param fold the folder to view
3013 * \param max_folders how many folders???
3014 * \param num_floors hom many floors???
3016 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3018 char floor_name[256];
3019 char old_floor_name[256];
3020 int levels, oldlevels;
3023 static int columns = 3;
3024 int boxes_per_column = 0;
3025 int current_column = 0;
3028 strcpy(floor_name, "");
3029 strcpy(old_floor_name, "");
3032 while (nf % columns != 0) ++nf;
3033 boxes_per_column = (nf / columns);
3034 if (boxes_per_column < 1) boxes_per_column = 1;
3036 /** Outer table (for columnization) */
3037 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3038 "<tr><td valign=top>");
3042 for (i=0; i<max_folders; ++i) {
3044 levels = num_tokens(fold[i].name, '|');
3045 extract_token(floor_name, fold[i].name, 0,
3046 '|', sizeof floor_name);
3048 if ( (strcasecmp(floor_name, old_floor_name))
3049 && (!IsEmptyStr(old_floor_name)) ) {
3051 do_template("endbox", NULL);
3055 if ((num_boxes % boxes_per_column) == 0) {
3057 if (current_column < columns) {
3058 wprintf("</td><td valign=top>\n");
3062 strcpy(old_floor_name, floor_name);
3066 WCTemplputParams SubTP;
3068 Buf = NewStrBufPlain(floor_name, -1);
3069 memset(&SubTP, 0, sizeof(WCTemplputParams));
3070 SubTP.Filter.ContextType = CTX_STRBUF;
3071 SubTP.Context = Buf;
3072 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
3081 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3082 if (fold[i].selectable) {
3083 wprintf("<a href=\"dotgoto?room=");
3084 urlescputs(fold[i].room);
3090 if (fold[i].hasnewmsgs) {
3091 wprintf("<span class=\"roomlist_new\">");
3094 wprintf("<span class=\"roomlist_old\">");
3096 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3099 if (fold[i].selectable) {
3105 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3106 wprintf(" (INBOX)");
3108 wprintf("<br />\n");
3111 /** End the final inner box */
3112 do_template("endbox", NULL);
3114 wprintf("</td></tr></table>\n");
3118 * \brief print a floor div???
3119 * \param which_floordiv name of the floordiv???
3121 void set_floordiv_expanded(void) {
3122 wcsession *WCC = WC;
3125 FloorDiv = NewStrBuf();
3126 StrBufExtract_token(FloorDiv, WCC->Hdr->HR.ReqLine, 0, '/');
3127 set_preference("floordiv_expanded", FloorDiv, 1);
3128 WCC->floordiv_expanded = FloorDiv;
3132 * \brief view the iconbar
3133 * \param fold the folder to view
3134 * \param max_folders how many folders???
3135 * \param num_floors hom many floors???
3137 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3139 char floor_name[256];
3140 char old_floor_name[256];
3141 char floordivtitle[256];
3142 char floordiv_id[32];
3143 int levels, oldlevels;
3147 strcpy(floor_name, "");
3148 strcpy(old_floor_name, "");
3152 for (i=0; i<max_folders; ++i) {
3154 levels = num_tokens(fold[i].name, '|');
3155 extract_token(floor_name, fold[i].name, 0,
3156 '|', sizeof floor_name);
3158 if ( (strcasecmp(floor_name, old_floor_name))
3159 && (!IsEmptyStr(old_floor_name)) ) {
3160 /** End inner box */
3162 wprintf("</div>\n"); /** floordiv */
3164 strcpy(old_floor_name, floor_name);
3168 stresc(floordivtitle, 256, floor_name, 0, 0);
3169 sprintf(floordiv_id, "floordiv%d", i);
3170 wprintf("<span class=\"ib_roomlist_floor\" "
3171 "onClick=\"expand_floor('%s')\">"
3172 "%s</span><br>\n", floordiv_id, floordivtitle);
3173 wprintf("<div id=\"%s\" style=\"display:%s\">",
3175 (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
3182 wprintf("<div id=\"roomdiv%d\">", i);
3184 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3186 /** choose the icon */
3187 if (fold[i].view == VIEW_ADDRESSBOOK) {
3188 icon = "viewcontacts_16x.gif" ;
3190 else if (fold[i].view == VIEW_CALENDAR) {
3191 icon = "calarea_16x.gif" ;
3193 else if (fold[i].view == VIEW_CALBRIEF) {
3194 icon = "calarea_16x.gif" ;
3196 else if (fold[i].view == VIEW_TASKS) {
3197 icon = "taskmanag_16x.gif" ;
3199 else if (fold[i].view == VIEW_NOTES) {
3200 icon = "storenotes_16x.gif" ;
3202 else if (fold[i].view == VIEW_MAILBOX) {
3203 icon = "privatemess_16x.gif" ;
3206 icon = "chatrooms_16x.gif" ;
3209 if (fold[i].selectable) {
3210 wprintf("<a href=\"dotgoto?room=");
3211 urlescputs(fold[i].room);
3213 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3218 if (fold[i].hasnewmsgs) {
3219 wprintf("<span class=\"ib_roomlist_new\">");
3222 wprintf("<span class=\"ib_roomlist_old\">");
3224 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3226 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3227 wprintf(" (INBOX)");
3230 if (fold[i].selectable) {
3237 wprintf("</div>\n"); /** roomdiv */
3240 wprintf("</div>\n"); /** floordiv */
3248 * \brief Burn the cached folder list.
3249 * \param age How old the cahce needs to be before we burn it.
3252 void burn_folder_cache(time_t age)
3254 /** If our cached folder list is very old, burn it. */
3255 if (WC->cache_fold != NULL) {
3256 if ((time(NULL) - WC->cache_timestamp) > age) {
3257 free(WC->cache_fold);
3258 WC->cache_fold = NULL;
3267 * \brief Show the room list.
3268 * (only should get called by
3269 * knrooms() because that's where output_headers() is called from)
3270 * \param viewpref the view preferences???
3273 void list_all_rooms_by_floor(const char *viewpref) {
3277 struct folder *fold = NULL;
3279 int max_folders = 0;
3280 int alloc_folders = 0;
3284 int ShowEmptyFloors;
3287 int num_floors = 1; /** add an extra one for private folders */
3290 /** If our cached folder list is very old, burn it. */
3291 burn_folder_cache(300);
3293 /** Can we do the iconbar roomlist from cache? */
3294 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3295 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3300 /** Grab the floor table so we know how to build the list... */
3301 load_floorlist(Buf);
3303 /** Start with the mailboxes */
3306 fold = malloc(sizeof(struct folder));
3307 memset(fold, 0, sizeof(struct folder));
3308 strcpy(fold[0].name, "My folders");
3309 fold[0].is_mailbox = 1;
3311 /** Then add floors */
3313 serv_getln(buf, sizeof buf);
3314 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3315 if (max_folders >= alloc_folders) {
3316 alloc_folders = max_folders + 100;
3317 fold = realloc(fold,
3318 alloc_folders * sizeof(struct folder));
3320 memset(&fold[max_folders], 0, sizeof(struct folder));
3321 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3322 extract_token(buf3, buf, 0, '|', SIZ);
3323 fold[max_folders].floor = atol (buf3);
3328 for (i=0; i<num_floors; i++)
3329 if (IDMax < fold[i].floor)
3330 IDMax = fold[i].floor;
3331 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3332 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3333 for (i=0; i<num_floors; i++)
3334 floor_mapping[fold[i].floor]=i;
3336 /** refresh the messages index for this room */
3337 /* TODO serv_puts("GOTO ");
3338 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")); */
3339 /** Now add rooms */
3341 serv_getln(buf, sizeof buf);
3342 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3343 if (max_folders >= alloc_folders) {
3344 alloc_folders = max_folders + 100;
3345 fold = realloc(fold,
3346 alloc_folders * sizeof(struct folder));
3348 memset(&fold[max_folders], 0, sizeof(struct folder));
3349 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3350 ra_flags = extract_int(buf, 5);
3351 flags = extract_int(buf, 1);
3352 fold[max_folders].floor = extract_int(buf, 2);
3353 fold[max_folders].hasnewmsgs =
3354 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3355 if (flags & QR_MAILBOX) {
3356 fold[max_folders].is_mailbox = 1;
3358 fold[max_folders].view = extract_int(buf, 6);
3359 room_to_folder(fold[max_folders].name,
3360 fold[max_folders].room,
3361 fold[max_folders].floor,
3362 fold[max_folders].is_mailbox);
3363 fold[max_folders].selectable = 1;
3364 /* Increase the room count for the associtaed floor */
3365 if (fold[max_folders].is_mailbox) {
3366 fold[0].num_rooms++;
3369 i = floor_mapping[fold[max_folders].floor];
3370 fold[i].num_rooms++;
3376 * Remove any floors that don't have rooms
3378 get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
3379 if (ShowEmptyFloors)
3381 for (i=0; i<num_floors; i++)
3383 if (fold[i].num_rooms == 0) {
3384 for (j=i; j<max_folders; j++) {
3385 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3394 /** Bubble-sort the folder list */
3395 for (i=0; i<max_folders; ++i) {
3396 for (j=0; j<(max_folders-1)-i; ++j) {
3397 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3398 swap = strcasecmp(fold[j].name, fold[j+1].name);
3401 if ( (fold[j+1].is_mailbox)
3402 && (!fold[j].is_mailbox)) {
3410 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3411 memcpy(&fold[j], &fold[j+1],
3412 sizeof(struct folder));
3413 memcpy(&fold[j+1], &ftmp,
3414 sizeof(struct folder));
3420 if (!strcasecmp(viewpref, "folders")) {
3421 do_folder_view(fold, max_folders, num_floors);
3423 else if (!strcasecmp(viewpref, "hackish_view")) {
3424 for (i=0; i<max_folders; ++i) {
3425 escputs(fold[i].name);
3426 wprintf("<br />\n");
3429 else if (!strcasecmp(viewpref, "iconbar")) {
3430 do_iconbar_view(fold, max_folders, num_floors);
3433 do_rooms_view(fold, max_folders, num_floors);
3436 /* Don't free the folder list ... cache it for future use! */
3437 if (WC->cache_fold != NULL) {
3438 free(WC->cache_fold);
3440 WC->cache_fold = fold;
3441 WC->cache_max_folders = max_folders;
3442 WC->cache_num_floors = num_floors;
3443 WC->cache_timestamp = time(NULL);
3444 free(floor_mapping);
3449 * \brief Do either a known rooms list or a folders list, depending on the
3454 StrBuf *ListView = NULL;
3456 output_headers(1, 1, 2, 0, 0, 0);
3458 /** Determine whether the user is trying to change views */
3459 if (havebstr("view")) {
3460 ListView = NewStrBufPlain(bstr("view"), -1);
3461 set_preference("roomlistview", ListView, 1);
3463 /** Sanitize the input so its safe */
3464 if(!get_preference("roomlistview", &ListView) ||
3465 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3466 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3468 if (ListView == NULL) {
3469 ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1);
3470 set_preference("roomlistview", ListView, 0);
3473 StrBufPrintf(ListView, "rooms");
3479 wprintf("<div id=\"banner\">\n");
3480 wprintf("<div class=\"room_banner\" id=\"room_banner\">");
3482 if (!strcasecmp(ChrPtr(ListView), "rooms")) {
3483 wprintf(_("Room list"));
3485 else if (!strcasecmp(ChrPtr(ListView), "folders")) {
3486 wprintf(_("Folder list"));
3488 else if (!strcasecmp(ChrPtr(ListView), "table")) {
3489 wprintf(_("Room list"));
3491 wprintf("</h1></div>\n");
3493 /** offer the ability to switch views */
3494 wprintf("<div id=\"actiondiv\">");
3495 wprintf("<ul class=\"room_actions\">\n");
3496 wprintf("<li class=\"start_page\">");
3497 offer_start_page(NULL, &NoCtx);
3499 wprintf("<li><form name=\"roomlistomatic\">\n"
3500 "<select name=\"newview\" size=\"1\" "
3501 "OnChange=\"location.href=roomlistomatic.newview.options"
3502 "[selectedIndex].value\">\n");
3504 wprintf("<option %s value=\"knrooms?view=rooms\">"
3507 ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" )
3510 wprintf("<option %s value=\"knrooms?view=folders\">"
3511 "View as folder list"
3513 ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" )
3516 wprintf("</select>");
3517 wprintf("</form></li>");
3518 wprintf("</ul></div></div>\n");
3520 wprintf("<div id=\"content\" class=\"service\">\n");
3522 /** Display the room list in the user's preferred format */
3523 list_all_rooms_by_floor(ChrPtr(ListView));
3530 * \brief Set the message expire policy for this room and/or floor
3532 void set_room_policy(void) {
3535 if (!havebstr("ok_button")) {
3536 strcpy(WC->ImportantMessage,
3537 _("Cancelled. Changes were not saved."));
3542 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3543 serv_getln(buf, sizeof buf);
3544 strcpy(WC->ImportantMessage, &buf[4]);
3546 if (WC->axlevel >= 6) {
3547 strcat(WC->ImportantMessage, "<br />\n");
3548 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3549 serv_getln(buf, sizeof buf);
3550 strcat(WC->ImportantMessage, &buf[4]);
3556 HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP) {
3557 /* todo: check context */
3563 floors = NewHash(1, NULL);
3565 serv_puts("LFLR"); /* get floors */
3566 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err); /* '100', we hope */
3567 if (GetServerStatus(Buf, NULL) == 1)
3568 while(StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err), strcmp(ChrPtr(Buf), "000")) {
3570 const StrBuf *floorNum = NULL;
3571 floor = NewHash(1, NULL);
3572 for(a=0; a<FLOOR_PARAM_LEN; a++) {
3574 StrBufExtract_token(Buf2, Buf, a, '|');
3576 floorNum = Buf2; /* hmm, should we copy Buf2 first? */
3579 Put(floor, CKEY(FLOOR_PARAM_NAMES[a]), Buf2, HFreeStrBuf);
3581 Put(floors, SKEY(floorNum), floor, HDeleteHash);
3587 void tmplput_FLOOR_Value(StrBuf *TemplBuffer, WCTemplputParams *TP)
3590 HashList *floor = (HashList *)(TP->Context);
3592 GetHash(floor, TKEY(0), &value);
3593 val = (StrBuf *)value;
3594 StrECMAEscAppend(TemplBuffer, val, 0);
3596 HashList *GetRoomListHashLKRA(StrBuf *Target, WCTemplputParams *TP)
3599 return GetRoomListHash(Target, TP);
3601 HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP)
3603 /* TODO: Check context */
3610 rooms = NewHash(1, NULL);
3611 StrBufTCP_read_line(buf, &WC->serv_sock, 0, &Err);
3612 if (GetServerStatus(buf, NULL) == 1)
3613 while(StrBufTCP_read_line(buf, &WC->serv_sock, 0, &Err), strcmp(ChrPtr(buf), "000")) {
3615 StrBuf *rmName = NULL;
3616 room = NewHash(1, NULL);
3617 for(i=0; i<ROOM_PARAM_LEN; i++) {
3619 StrBufExtract_token(buf2, buf, i, '|');
3623 Put(room, CKEY(ROOM_PARAM_NAMES[i]), buf2, HFreeStrBuf);
3625 Put(rooms, SKEY(rmName), room, HDeleteHash);
3627 SortByHashKey(rooms, 1);
3628 /*SortByPayload(rooms, SortRoomsByListOrder); */
3632 /** Unused function that orders rooms by the listorder flag */
3633 int SortRoomsByListOrder(const void *room1, const void *room2)
3637 HashList *r1 = (HashList *)GetSearchPayload(room1);
3638 HashList *r2 = (HashList *)GetSearchPayload(room2);
3639 StrBuf *listOrderBuf1;
3640 StrBuf *listOrderBuf2;
3642 GetHash(r1, CKEY(ROOM_PARAM_NAMES[3]), (void *)&listOrderBuf1);
3643 GetHash(r2, CKEY(ROOM_PARAM_NAMES[3]), (void *)&listOrderBuf2);
3644 l1 = atoi(ChrPtr(listOrderBuf1));
3645 l2 = atoi(ChrPtr(listOrderBuf2));
3646 if (l1 < l2) return -1;
3647 else if (l1 > l2) return +1;
3650 void tmplput_ROOM_Value(StrBuf *TemplBuffer, WCTemplputParams *TP)
3654 HashList *room = (HashList *)(TP->Context);
3656 GetHash(room, TKEY(0), &value);
3657 val = (StrBuf *)value;
3658 StrECMAEscAppend(TemplBuffer, val, 0);
3660 void jsonRoomFlr(void)
3662 /* Send as our own (application/json) content type */
3663 hprintf("HTTP/1.1 200 OK\r\n");
3664 hprintf("Content-type: application/json; charset=utf-8\r\n");
3665 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
3666 hprintf("Connection: close\r\n");
3667 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
3669 DoTemplate(HKEY("json_roomflr"),NULL,&NoCtx);
3673 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3675 StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
3679 void _display_private(void) {
3680 display_private("", 0);
3683 void dotgoto(void) {
3684 if (!havebstr("room")) {
3688 if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3691 smart_goto(sbstr("room"));
3694 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3696 wprintf("<div id=\"banner\">\n");
3697 embed_room_banner(NULL, navbar_default);
3698 wprintf("</div>\n");
3702 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3704 wcsession *WCC = WC;
3707 (!IsEmptyStr(WCC->ugname)))
3708 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3712 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3714 wcsession *WCC = WC;
3716 return ((WCC!=NULL) &&
3717 (!IsEmptyStr(WCC->ugname)) &&
3718 (strcasecmp(WCC->ugname, ChrPtr(WCC->wc_roomname)) == 0));
3721 int ConditionalRoomHas_QR_PERMANENT(StrBuf *Target, WCTemplputParams *TP)
3723 wcsession *WCC = WC;
3725 return ((WCC!=NULL) &&
3726 ((WCC->room_flags & QR_PERMANENT) != 0));
3729 int ConditionalRoomHas_QR_INUSE(StrBuf *Target, WCTemplputParams *TP)
3731 wcsession *WCC = WC;
3733 return ((WCC!=NULL) &&
3734 ((WCC->room_flags & QR_INUSE) != 0));
3737 int ConditionalRoomHas_QR_PRIVATE(StrBuf *Target, WCTemplputParams *TP)
3739 wcsession *WCC = WC;
3741 return ((WCC!=NULL) &&
3742 ((WCC->room_flags & QR_PRIVATE) != 0));
3745 int ConditionalRoomHas_QR_PASSWORDED(StrBuf *Target, WCTemplputParams *TP)
3747 wcsession *WCC = WC;
3749 return ((WCC!=NULL) &&
3750 ((WCC->room_flags & QR_PASSWORDED) != 0));
3753 int ConditionalRoomHas_QR_GUESSNAME(StrBuf *Target, WCTemplputParams *TP)
3755 wcsession *WCC = WC;
3757 return ((WCC!=NULL) &&
3758 ((WCC->room_flags & QR_GUESSNAME) != 0));
3761 int ConditionalRoomHas_QR_DIRECTORY(StrBuf *Target, WCTemplputParams *TP)
3763 wcsession *WCC = WC;
3765 return ((WCC!=NULL) &&
3766 ((WCC->room_flags & QR_DIRECTORY) != 0));
3769 int ConditionalRoomHas_QR_UPLOAD(StrBuf *Target, WCTemplputParams *TP)
3771 wcsession *WCC = WC;
3773 return ((WCC!=NULL) &&
3774 ((WCC->room_flags & QR_UPLOAD) != 0));
3777 int ConditionalRoomHas_QR_DOWNLOAD(StrBuf *Target, WCTemplputParams *TP)
3779 wcsession *WCC = WC;
3781 return ((WCC!=NULL) &&
3782 ((WCC->room_flags & QR_DOWNLOAD) != 0));
3785 int ConditionalRoomHas_QR_VISDIR(StrBuf *Target, WCTemplputParams *TP)
3787 wcsession *WCC = WC;
3789 return ((WCC!=NULL) &&
3790 ((WCC->room_flags & QR_VISDIR) != 0));
3793 int ConditionalRoomHas_QR_ANONONLY(StrBuf *Target, WCTemplputParams *TP)
3795 wcsession *WCC = WC;
3797 return ((WCC!=NULL) &&
3798 ((WCC->room_flags & QR_ANONONLY) != 0));
3801 int ConditionalRoomHas_QR_ANONOPT(StrBuf *Target, WCTemplputParams *TP)
3803 wcsession *WCC = WC;
3805 return ((WCC!=NULL) &&
3806 ((WCC->room_flags & QR_ANONOPT) != 0));
3809 int ConditionalRoomHas_QR_NETWORK(StrBuf *Target, WCTemplputParams *TP)
3811 wcsession *WCC = WC;
3813 return ((WCC!=NULL) &&
3814 ((WCC->room_flags & QR_NETWORK) != 0));
3817 int ConditionalRoomHas_QR_PREFONLY(StrBuf *Target, WCTemplputParams *TP)
3819 wcsession *WCC = WC;
3821 return ((WCC!=NULL) &&
3822 ((WCC->room_flags & QR_PREFONLY) != 0));
3825 int ConditionalRoomHas_QR_READONLY(StrBuf *Target, WCTemplputParams *TP)
3827 wcsession *WCC = WC;
3829 return ((WCC!=NULL) &&
3830 ((WCC->room_flags & QR_READONLY) != 0));
3833 int ConditionalRoomHas_QR_MAILBOX(StrBuf *Target, WCTemplputParams *TP)
3835 wcsession *WCC = WC;
3837 return ((WCC!=NULL) &&
3838 ((WCC->room_flags & QR_MAILBOX) != 0));
3842 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3844 wcsession *WCC = WC;
3846 return ( (WCC!= NULL) &&
3847 ((WCC->axlevel >= 6) ||
3848 (WCC->is_room_aide) ||
3849 (WCC->is_mailbox) ));
3852 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3854 wcsession *WCC = WC;
3856 if ((WCC == NULL) ||
3857 (TP->Tokens->nParameters < 3) ||
3858 (TP->Tokens->Params[2]->Type != TYPE_STR)||
3859 (TP->Tokens->Params[2]->len < 7))
3862 switch(WCC->wc_view) {
3864 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_BBS"));
3866 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_MAILBOX"));
3867 case VIEW_ADDRESSBOOK:
3868 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_ADDRESSBOOK"));
3870 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_TASKS"));
3872 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_NOTES"));
3874 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_WIKI"));
3876 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_JOURNAL"));
3878 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_CALENDAR"));
3880 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_CALBRIEF"));
3890 RegisterPreference("roomlistview",
3891 _("Room list view"),
3894 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3896 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, 0);
3898 WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
3899 WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, NEED_URL);
3900 WebcitAddUrlHandler(HKEY("dotskip"), dotskip, NEED_URL);
3901 WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
3902 WebcitAddUrlHandler(HKEY("goto_private"), goto_private, NEED_URL);
3903 WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
3904 WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
3905 WebcitAddUrlHandler(HKEY("zap"), zap, 0);
3906 WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
3907 WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
3908 WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
3909 WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
3910 WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
3911 WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
3912 WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
3913 WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
3914 WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
3915 WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
3916 WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);
3917 WebcitAddUrlHandler(HKEY("toggle_self_service"), toggle_self_service, 0);
3918 WebcitAddUrlHandler(HKEY("json_roomflr"), jsonRoomFlr, 0);
3919 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, 0);
3921 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3922 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PERMANENT"), 0, ConditionalRoomHas_QR_PERMANENT, CTX_NONE);
3923 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_INUSE"), 0, ConditionalRoomHas_QR_INUSE, CTX_NONE);
3924 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PRIVATE"), 0, ConditionalRoomHas_QR_PRIVATE, CTX_NONE);
3925 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PASSWORDED"), 0, ConditionalRoomHas_QR_PASSWORDED, CTX_NONE);
3926 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_GUESSNAME"), 0, ConditionalRoomHas_QR_GUESSNAME, CTX_NONE);
3927 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DIRECTORY"), 0, ConditionalRoomHas_QR_DIRECTORY, CTX_NONE);
3928 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_UPLOAD"), 0, ConditionalRoomHas_QR_UPLOAD, CTX_NONE);
3929 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DOWNLOAD"), 0, ConditionalRoomHas_QR_DOWNLOAD, CTX_NONE);
3930 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_VISIDIR"), 0, ConditionalRoomHas_QR_VISDIR, CTX_NONE);
3931 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONONLY"), 0, ConditionalRoomHas_QR_ANONONLY, CTX_NONE);
3932 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONOPT"), 0, ConditionalRoomHas_QR_ANONOPT, CTX_NONE);
3933 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_NETWORK"), 0, ConditionalRoomHas_QR_NETWORK, CTX_NONE);
3934 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PREFONLY"), 0, ConditionalRoomHas_QR_PREFONLY, CTX_NONE);
3935 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_READONLY"), 0, ConditionalRoomHas_QR_READONLY, CTX_NONE);
3936 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_MAILBOX"), 0, ConditionalRoomHas_QR_MAILBOX, CTX_NONE);
3938 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3939 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3941 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, 0);
3942 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, DeleteHash, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3943 RegisterNamespace("FLOOR:INFO", 1, 2, tmplput_FLOOR_Value, CTX_FLOORS);
3944 RegisterIterator("LKRA", 0, NULL, GetRoomListHashLKRA, NULL, DeleteHash, CTX_ROOMS, CTX_NONE, IT_NOFLAG);
3945 RegisterNamespace("ROOM:INFO", 1, 2, tmplput_ROOM_Value, CTX_ROOMS);
3951 SessionDestroyModule_ROOMOPS
3954 if (sess->cache_fold != NULL) {
3955 free(sess->cache_fold);
3958 free_march_list(sess);