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]);
106 * Free a session's march list
108 void free_march_list(wcsession *wcf)
112 while (wcf->march != NULL) {
113 mptr = wcf->march->next;
123 * remove a room from the march list
125 void remove_march(const StrBuf *aaa)
127 struct march *mptr, *mptr2;
129 if (WC->march == NULL)
132 if (!strcasecmp(WC->march->march_name, ChrPtr(aaa))) {
133 mptr = WC->march->next;
139 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
140 if (!strcasecmp(mptr->march_name, ChrPtr(aaa))) {
141 mptr2->next = mptr->next;
154 * display rooms in tree structure
156 void room_tree_list(struct roomlisting *rp)
165 room_tree_list(rp->lnext);
167 strcpy(rmname, rp->rlname);
170 wprintf("<a href=\"dotgoto?room=");
174 escputs1(rmname, 1, 1);
175 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
177 else if (f & QR_DIRECTORY)
179 else if (f & QR_NETWORK)
183 wprintf("</a><tt> </tt>\n");
185 room_tree_list(rp->rnext);
191 * Room ordering stuff (compare first by floor, then by order)
193 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
195 if ((r1 == NULL) && (r2 == NULL))
201 if (r1->rlfloor < r2->rlfloor)
203 if (r1->rlfloor > r2->rlfloor)
205 if (r1->rlorder < r2->rlorder)
207 if (r1->rlorder > r2->rlorder)
214 * Common code for all room listings
216 void listrms(char *variety)
221 struct roomlisting *rl = NULL;
222 struct roomlisting *rp;
223 struct roomlisting *rs;
225 /* Ask the server for a room list */
227 serv_getln(buf, sizeof buf);
233 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
235 rp = malloc(sizeof(struct roomlisting));
236 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
237 rp->rlflags = extract_int(buf, 1);
238 rp->rlfloor = extract_int(buf, 2);
239 rp->rlorder = extract_int(buf, 3);
248 if (rordercmp(rp, rs) < 0) {
249 if (rs->lnext == NULL) {
256 if (rs->rnext == NULL) {
269 * If no rooms were listed, print an nbsp to make the cell
270 * borders show up anyway.
272 if (num_rooms == 0) wprintf(" ");
277 * list all forgotten rooms
279 void zapped_list(void)
281 WCTemplputParams SubTP;
284 output_headers(1, 1, 1, 0, 0, 0);
285 memset(&SubTP, 0, sizeof(WCTemplputParams));
286 Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
287 SubTP.Filter.ContextType = CTX_STRBUF;
289 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
295 wprintf("<br /><br />\n");
296 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
297 do_template("endbox", NULL);
303 * read this room's info file (set v to 1 for verbose mode)
305 void readinfo(StrBuf *Target, WCTemplputParams *TP)
310 int fullinfo_len = 0;
313 serv_getln(buf, sizeof buf);
316 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
317 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
318 strcpy(&fullinfo[fullinfo_len], buf);
319 fullinfo_len += strlen(buf);
323 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
324 strcpy(&briefinfo[50], "...");
326 wprintf("<div class=\"infos\" "
327 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
331 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
332 wprintf("<img class=\"close_infos\" "
333 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
334 "src=\"static/closewindow.gif\" alt=\"%s\" width=\"16\" height=\"16\">",
349 * Display room banner icon.
350 * The server doesn't actually need the room name, but we supply it in
351 * order to keep the browser from using a cached icon from another room.
353 void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP)
357 serv_puts("OIMG _roompic_");
358 serv_getln(buf, sizeof buf);
360 wprintf("<img height=\"64px\" src=\"image?name=_roompic_&room=");
361 urlescputs(ChrPtr(WC->wc_roomname));
364 serv_getln(buf, sizeof buf);
366 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
367 wprintf("<img class=\"roompic\" alt=\"\" src=\""
368 "static/viewcontacts_48x.gif"
372 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
373 wprintf("<img class=\"roompic\" alt=\"\" src=\""
374 "static/calarea_48x.gif"
375 "\" width=\"48\" height=\"48\">"
378 else if (WC->wc_view == VIEW_TASKS) {
379 wprintf("<img class=\"roompic\" alt=\"\" src=\""
380 "static/taskmanag_48x.gif"
381 "\" width=\"48\" height=\"48\">"
384 else if (WC->wc_view == VIEW_NOTES) {
385 wprintf("<img class=\"roompic\" alt=\"\" src=\""
386 "static/storenotes_48x.gif"
387 "\" width=\"48\" height=\"48\">"
390 else if (WC->wc_view == VIEW_MAILBOX) {
391 wprintf("<img class=\"roompic\" alt=\"\" src=\""
392 "static/privatemess_48x.gif"
393 "\" width=\"48\" height=\"48\">"
397 wprintf("<img class=\"roompic\" alt=\"\" src=\""
398 "static/chatrooms_48x.gif"
399 "\" width=\"48\" height=\"48\">"
408 * Display the current view and offer an option to change it
410 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
414 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
415 wprintf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
416 wprintf("<label for=\"view_name\">");
417 wprintf(_("View as:"));
419 "<select name=\"newview\" size=\"1\" "
420 "id=\"view_name\" class=\"selectbox\" "
421 "OnChange=\"location.href=viewomatic.newview.options"
422 "[selectedIndex].value\">\n");
424 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
426 * Only offer the views that make sense, given the default
427 * view for the room. For example, don't offer a Calendar
428 * view in a non-Calendar room.
432 || (i == WC->wc_default_view) /* default */
433 || ( (i == 0) && (WC->wc_default_view == 1) ) /* mail or bulletin */
434 || ( (i == 1) && (WC->wc_default_view == 0) ) /* mail or bulletin */
435 /* || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
438 wprintf("<option %s value=\"changeview?view=%d\">",
439 ((i == WC->wc_view) ? "selected" : ""),
441 escputs(viewdefs[i]);
442 wprintf("</option>\n");
445 wprintf("</select></div></form>\n");
450 * Display a search box
452 void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP)
454 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
455 wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
456 wprintf("<label for=\"srchquery\">");
457 wprintf(_("Search: "));
458 wprintf("</label><input ");
459 wprintf("%s", WC->serv_info->serv_fulltext_enabled ? "" : "disabled ");
460 wprintf("type=\"text\" name=\"query\" id=\"srchquery\" size=\"15\" maxlength=\"128\" class=\"inputbox\">\n"
462 wprintf("</div></form>\n");
467 * Embed the room banner
469 * got The information returned from a GOTO server command
470 * navbar_style Determines which navigation buttons to display
474 void embed_room_banner(char *got, int navbar_style) {
478 char with_files[256];
482 * We need to have the information returned by a GOTO server command.
483 * If it isn't supplied, we fake it by issuing our own GOTO.
486 memset(buf, '0', 20);
488 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
489 serv_getln(buf, sizeof buf);
493 /* The browser needs some information for its own use */
494 wprintf("<script type=\"text/javascript\"> \n"
495 " room_is_trash = %d; \n"
501 * If the user happens to select the "make this my start page" link,
502 * we want it to remember the URL as a "/dotskip" one instead of
503 * a "skip" or "gotonext" or something like that.
505 if (WCC->Hdr->this_page == NULL) {
506 WCC->Hdr->this_page = NewStrBuf();
508 StrBufPrintf(WCC->Hdr->this_page,
510 ChrPtr(WC->wc_roomname)
513 /* Check for new mail. */
514 WC->new_mail = extract_int(&got[4], 9);
515 WC->wc_view = extract_int(&got[4], 11);
517 /* Is this a directory room and does it contain files and how many? */
518 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
521 serv_getln(buf2, sizeof buf2);
522 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
524 snprintf (with_files, sizeof with_files,
525 "; <a href=\"do_template?template=files\"> %d %s </a>",
527 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
530 strcpy (with_files, "");
532 svprintf(HKEY("NUMMSGS"), WCS_STRING,
533 _("%d new of %d messages%s"),
534 extract_int(&got[4], 1),
535 extract_int(&got[4], 2),
538 svcallback("ROOMPIC", embed_room_graphic);
539 svcallback("ROOMINFO", readinfo);
540 svcallback("VIEWOMATIC", embed_view_o_matic);
541 svcallback("SEARCHOMATIC", embed_search_o_matic);
542 svcallback("START", offer_start_page);
544 do_template("roombanner", NULL);
545 /* roombanner contains this for mobile */
546 if (navbar_style != navbar_none && !WC->is_mobile) {
548 wprintf("<div id=\"navbar\"><ul>");
550 if (navbar_style == navbar_default) wprintf(
551 "<li class=\"ungoto\">"
552 "<a href=\"ungoto\">"
553 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
554 "<span class=\"navbar_link\">%s</span></A>"
555 "</li>\n", _("Ungoto")
558 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
560 "<li class=\"newmess\">"
561 "<a href=\"readnew\">"
562 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
563 "<span class=\"navbar_link\">%s</span></A>"
564 "</li>\n", _("Read new messages")
568 if (navbar_style == navbar_default) {
569 switch(WC->wc_view) {
570 case VIEW_ADDRESSBOOK:
572 "<li class=\"viewcontacts\">"
573 "<a href=\"readfwd\">"
574 "<img src=\"static/viewcontacts_24x.gif\" "
575 "alt=\"\" width=\"24\" height=\"24\">"
576 "<span class=\"navbar_link\">"
578 "</span></a></li>\n", _("View contacts")
583 "<li class=\"staskday\">"
584 "<a href=\"readfwd?calview=day\">"
585 "<img src=\"static/taskday2_24x.gif\" "
586 "alt=\"\" width=\"24\" height=\"24\">"
587 "<span class=\"navbar_link\">"
589 "</span></a></li>\n", _("Day view")
592 "<li class=\"monthview\">"
593 "<a href=\"readfwd?calview=month\">"
594 "<img src=\"static/monthview2_24x.gif\" "
595 "alt=\"\" width=\"24\" height=\"24\">"
596 "<span class=\"navbar_link\">"
598 "</span></a></li>\n", _("Month view")
603 "<li class=\"monthview\">"
604 "<a href=\"readfwd?calview=month\">"
605 "<img src=\"static/monthview2_24x.gif\" "
606 "alt=\"\" width=\"24\" height=\"24\">"
607 "<span class=\"navbar_link\">"
609 "</span></a></li>\n", _("Calendar list")
614 "<li class=\"taskmanag\">"
615 "<a href=\"readfwd\">"
616 "<img src=\"static/taskmanag_24x.gif\" "
617 "alt=\"\" width=\"24\" height=\"24\">"
618 "<span class=\"navbar_link\">"
620 "</span></a></li>\n", _("View tasks")
625 "<li class=\"viewnotes\">"
626 "<a href=\"readfwd\">"
627 "<img src=\"static/viewnotes_24x.gif\" "
628 "alt=\"\" width=\"24\" height=\"24\">"
629 "<span class=\"navbar_link\">"
631 "</span></a></li>\n", _("View notes")
636 "<li class=\"readallmess\">"
637 "<a id=\"m_refresh\" href=\"readfwd\">"
638 "<img src=\"static/readallmess3_24x.gif\" "
639 "alt=\"\" width=\"24\" height=\"24\">"
640 "<span class=\"navbar_link\">"
642 "</span></a></li>\n", _("Refresh message list")
647 "<li class=\"readallmess\">"
648 "<a href=\"readfwd\">"
649 "<img src=\"static/readallmess3_24x.gif\" "
650 "alt=\"\" width=\"24\" height=\"24\">"
651 "<span class=\"navbar_link\">"
653 "</span></a></li>\n", _("Wiki home")
658 "<li class=\"readallmess\">"
659 "<a href=\"readfwd\">"
660 "<img src=\"static/readallmess3_24x.gif\" "
661 "alt=\"\" width=\"24\" height=\"24\">"
662 "<span class=\"navbar_link\">"
664 "</span></a></li>\n", _("Read all messages")
670 if (navbar_style == navbar_default) {
671 switch(WC->wc_view) {
672 case VIEW_ADDRESSBOOK:
674 "<li class=\"addnewcontact\">"
675 "<a href=\"display_enter\">"
676 "<img src=\"static/addnewcontact_24x.gif\" "
677 "alt=\"\" width=\"24\" height=\"24\">"
678 "<span class=\"navbar_link\">"
680 "</span></a></li>\n", _("Add new contact")
685 wprintf("<li class=\"addevent\"><a href=\"display_enter");
686 if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
687 if (havebstr("month")) wprintf("?month=%s", bstr("month"));
688 if (havebstr("day" )) wprintf("?day=%s", bstr("day"));
690 "<img src=\"static/addevent_24x.gif\" "
691 "alt=\"\" width=\"24\" height=\"24\">"
692 "<span class=\"navbar_link\">"
694 "</span></a></li>\n", _("Add new event")
699 "<li class=\"newmess\">"
700 "<a href=\"display_enter\">"
701 "<img src=\"static/newmess3_24x.gif\" "
702 "alt=\"\" width=\"24\" height=\"24\">"
703 "<span class=\"navbar_link\">"
705 "</span></a></li>\n", _("Add new task")
710 "<li class=\"enternewnote\">"
711 "<a href=\"add_new_note\">"
712 "<img src=\"static/enternewnote_24x.gif\" "
713 "alt=\"\" width=\"24\" height=\"24\">"
714 "<span class=\"navbar_link\">"
716 "</span></a></li>\n", _("Add new note")
720 safestrncpy(buf, bstr("page"), sizeof buf);
723 "<li class=\"newmess\">"
724 "<a href=\"display_enter?wikipage=%s\">"
725 "<img src=\"static/newmess3_24x.gif\" "
726 "alt=\"\" width=\"24\" height=\"24\">"
727 "<span class=\"navbar_link\">"
729 "</span></a></li>\n", buf, _("Edit this page")
734 "<li class=\"newmess\">"
735 "<a href=\"display_enter\">"
736 "<img src=\"static/newmess3_24x.gif\" "
737 "alt=\"\" width=\"24\" height=\"24\">"
738 "<span class=\"navbar_link\">"
740 "</span></a></li>\n", _("Write mail")
743 "<li class=\"newmess\">"
744 "<a href=\"javascript:deleteAllSelectedMessages();\">"
745 "<img src=\"static/delete.gif\" "
746 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
748 "</span></a></li>\n", _("Delete")
753 "<li class=\"newmess\">"
754 "<a href=\"display_enter\">"
755 "<img src=\"static/newmess3_24x.gif\" "
756 "alt=\"\" width=\"24\" height=\"24\">"
757 "<span class=\"navbar_link\">"
759 "</span></a></li>\n", _("Enter a message")
765 if (navbar_style == navbar_default) wprintf(
766 "<li class=\"skipthisroom\">"
769 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
770 "width=\"24\" height=\"24\">"
771 "<span class=\"navbar_link\">%s</span></a>"
773 _("Leave all messages marked as unread, go to next room with unread messages"),
777 if (navbar_style == navbar_default) wprintf(
778 "<li class=\"markngo\">"
779 "<a href=\"gotonext\" "
781 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
782 "width=\"24\" height=\"24\">"
783 "<span class=\"navbar_link\">%s</span></a>"
785 _("Mark all messages as read, go to next room with unread messages"),
789 wprintf("</ul></div>\n");
796 * back end routine to take the session to a new room
798 long gotoroom(const StrBuf *gname)
801 static long ls = (-1L);
804 /* store ungoto information */
805 strcpy(WC->ugname, ChrPtr(WC->wc_roomname));
808 /** move to the new room */
809 serv_printf("GOTO %s", ChrPtr(gname));
810 StrBuf_ServGetln(Buf);
811 if (GetServerStatus(Buf, &err) != 2) {
812 serv_puts("GOTO _BASEROOM_");
813 StrBuf_ServGetln(Buf);
815 * well, we know that this is the fallback case,
816 * but we're interested that the first command
817 * didn't work out in first place.
819 if (GetServerStatus(Buf, NULL) != 2) {
825 if (WC->wc_roomname == NULL)
826 WC->wc_roomname = NewStrBuf();
828 FlushStrBuf(WC->wc_roomname);
830 StrBufExtract_token(WC->wc_roomname, Buf, 0, '|');
831 StrBufCutLeft(WC->wc_roomname, 4);
832 WC->room_flags = StrBufExtract_int(Buf, 4, '|');
833 /* highest_msg_read = extract_int(&buf[4],6);
834 maxmsgnum = extract_int(&buf[4],5);
836 WC->is_mailbox = StrBufExtract_int(Buf, 7, '|');
837 ls = StrBufExtract_long(Buf, 6, '|');
838 WC->wc_floor = StrBufExtract_int(Buf, 10, '|');
839 WC->wc_view = StrBufExtract_int(Buf, 11, '|');
840 WC->wc_default_view = StrBufExtract_int(Buf, 12, '|');
841 WC->wc_is_trash = StrBufExtract_int(Buf, 13, '|');
842 WC->room_flags2 = StrBufExtract_int(Buf, 14, '|');
845 WC->is_room_aide = WC->is_aide;
847 WC->is_room_aide = (char) StrBufExtract_int(Buf, 8, '|');
849 remove_march(WC->wc_roomname);
850 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
859 * \brief Locate the room on the march list which we most want to go to.
861 * is measured given a "weight" of preference based on various factors.
862 * \param desired_floor the room number on the citadel server
863 * \return the roomname
865 char *pop_march(int desired_floor)
867 static char TheRoom[128];
869 int TheOrder = 32767;
872 struct march *mptr = NULL;
874 strcpy(TheRoom, "_BASEROOM_");
875 if (WC->march == NULL)
878 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
880 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
881 weight = weight + 10000;
882 if (mptr->march_floor == desired_floor)
883 weight = weight + 5000;
885 weight = weight + ((128 - (mptr->march_floor)) * 128);
886 weight = weight + (128 - (mptr->march_order));
888 if (weight > TheWeight) {
890 strcpy(TheRoom, mptr->march_name);
891 TheFloor = mptr->march_floor;
892 TheOrder = mptr->march_order;
901 * Goto next room having unread messages.
903 * We want to skip over rooms that the user has already been to, and take the
904 * user back to the lobby when done. The room we end up in is placed in
905 * newroom - which is set to 0 (the lobby) initially.
906 * We start the search in the current room rather than the beginning to prevent
907 * two or more concurrent users from dragging each other back to the same room.
912 struct march *mptr = NULL;
913 struct march *mptr2 = NULL;
919 * First check to see if the march-mode list is already allocated.
920 * If it is, pop the first room off the list and go there.
923 if (WC->march == NULL) {
925 serv_getln(buf, sizeof buf);
927 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
928 if (IsEmptyStr(buf)) {
931 if (ELoop % 100 == 0)
936 extract_token(room_name, buf, 0, '|', sizeof room_name);
937 if (strcasecmp(room_name, ChrPtr(WC->wc_roomname))) {
938 mptr = (struct march *) malloc(sizeof(struct march));
940 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
941 mptr->march_floor = extract_int(buf, 2);
942 mptr->march_order = extract_int(buf, 3);
943 if (WC->march == NULL)
952 * add _BASEROOM_ to the end of the march list, so the user will end up
953 * in the system base room (usually the Lobby>) at the end of the loop
955 mptr = (struct march *) malloc(sizeof(struct march));
957 mptr->march_order = 0;
958 mptr->march_floor = 0;
959 strcpy(mptr->march_name, "_BASEROOM_");
960 if (WC->march == NULL) {
964 while (mptr2->next != NULL)
969 * ...and remove the room we're currently in, so a <G>oto doesn't make us
970 * walk around in circles
972 remove_march(WC->wc_roomname);
974 if (WC->march != NULL) {
975 next_room = NewStrBufPlain(pop_march(-1), -1);/*TODO: migrate march to strbuf */
977 next_room = NewStrBufPlain(HKEY("_BASEROOM_"));
981 smart_goto(next_room);
982 FreeStrBuf(&next_room);
989 void smart_goto(const StrBuf *next_room) {
997 * mark all messages in current room as having been read
999 void slrp_highest(void)
1003 serv_puts("SLRP HIGHEST");
1004 serv_getln(buf, sizeof buf);
1009 * un-goto the previous room
1015 if (!strcmp(WC->ugname, "")) {
1016 smart_goto(WC->wc_roomname);
1019 serv_printf("GOTO %s", WC->ugname);
1021 StrBuf_ServGetln(Buf);
1022 if (GetServerStatus(Buf, NULL) != 2) {
1023 smart_goto(WC->wc_roomname);
1027 if (WC->uglsn >= 0L) {
1028 serv_printf("SLRP %ld", WC->uglsn);
1029 StrBuf_ServGetln(Buf);
1032 StrBufAppendBufPlain(Buf, WC->ugname, -1, 0);
1033 strcpy(WC->ugname, "");
1038 typedef struct __room_states {
1053 * Set/clear/read the "self-service list subscribe" flag for a room
1055 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1056 * returns the new value.
1059 int self_service(int newval) {
1060 int current_value = 0;
1066 int flags, floor, order, view, flags2;
1069 serv_getln(buf, sizeof buf);
1070 if (buf[0] != '2') return(0);
1072 extract_token(name, &buf[4], 0, '|', sizeof name);
1073 extract_token(password, &buf[4], 1, '|', sizeof password);
1074 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1075 flags = extract_int(&buf[4], 3);
1076 floor = extract_int(&buf[4], 4);
1077 order = extract_int(&buf[4], 5);
1078 view = extract_int(&buf[4], 6);
1079 flags2 = extract_int(&buf[4], 7);
1081 if (flags2 & QR2_SELFLIST) {
1089 flags2 = flags2 | QR2_SELFLIST;
1091 else if (newval == 0) {
1092 flags2 = flags2 & ~QR2_SELFLIST;
1095 return(current_value);
1098 if (newval != current_value) {
1099 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1100 name, password, dirname, flags,
1101 floor, order, view, flags2);
1102 serv_getln(buf, sizeof buf);
1109 int is_selflist(room_states *RoomFlags)
1111 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1114 int is_publiclist(room_states *RoomFlags)
1116 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1119 int is_moderatedlist(room_states *RoomFlags)
1121 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1125 * Set/clear/read the "self-service list subscribe" flag for a room
1127 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1128 * returns the new value.
1131 int get_roomflags(room_states *RoomOps)
1136 serv_getln(buf, sizeof buf);
1137 if (buf[0] != '2') return(0);
1139 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1140 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1141 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1142 RoomOps->flags = extract_int(&buf[4], 3);
1143 RoomOps->floor = extract_int(&buf[4], 4);
1144 RoomOps->order = extract_int(&buf[4], 5);
1145 RoomOps->view = extract_int(&buf[4], 6);
1146 RoomOps->flags2 = extract_int(&buf[4], 7);
1150 int set_roomflags(room_states *RoomOps)
1154 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1163 serv_getln(buf, sizeof buf);
1173 * display the form for editing a room
1175 void display_editroom(void)
1181 char remote_room[128];
1184 char er_password[10];
1185 char er_dirname[15];
1186 char er_roomaide[26];
1193 char *not_shared_with;
1196 int floorpolicy = 0;
1198 char pop3_host[128];
1203 if (IsEmptyStr(tab)) tab = "admin";
1206 load_floorlist(Buf);
1208 output_headers(1, 1, 1, 0, 0, 0);
1210 wprintf("<div class=\"fix_scrollbar_bug\">");
1212 wprintf("<br />\n");
1214 /* print the tabbed dialog */
1215 wprintf("<div align=\"center\">");
1216 wprintf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1217 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1220 wprintf("<td class=\"");
1221 if (!strcmp(tab, "admin")) {
1222 wprintf(" tab_cell_label\">");
1223 wprintf(_("Administration"));
1226 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1227 wprintf(_("Administration"));
1231 wprintf("<td> </td>\n");
1233 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1235 wprintf("<td class=\"");
1236 if (!strcmp(tab, "config")) {
1237 wprintf(" tab_cell_label\">");
1238 wprintf(_("Configuration"));
1241 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1242 wprintf(_("Configuration"));
1246 wprintf("<td> </td>\n");
1248 wprintf("<td class=\"");
1249 if (!strcmp(tab, "expire")) {
1250 wprintf(" tab_cell_label\">");
1251 wprintf(_("Message expire policy"));
1254 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1255 wprintf(_("Message expire policy"));
1259 wprintf("<td> </td>\n");
1261 wprintf("<td class=\"");
1262 if (!strcmp(tab, "access")) {
1263 wprintf(" tab_cell_label\">");
1264 wprintf(_("Access controls"));
1267 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1268 wprintf(_("Access controls"));
1272 wprintf("<td> </td>\n");
1274 wprintf("<td class=\"");
1275 if (!strcmp(tab, "sharing")) {
1276 wprintf(" tab_cell_label\">");
1277 wprintf(_("Sharing"));
1280 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1281 wprintf(_("Sharing"));
1285 wprintf("<td> </td>\n");
1287 wprintf("<td class=\"");
1288 if (!strcmp(tab, "listserv")) {
1289 wprintf(" tab_cell_label\">");
1290 wprintf(_("Mailing list service"));
1293 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1294 wprintf(_("Mailing list service"));
1298 wprintf("<td> </td>\n");
1302 wprintf("<td class=\"");
1303 if (!strcmp(tab, "feeds")) {
1304 wprintf(" tab_cell_label\">");
1305 wprintf(_("Remote retrieval"));
1308 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1309 wprintf(_("Remote retrieval"));
1313 wprintf("<td> </td>\n");
1315 wprintf("</tr></table>\n");
1316 wprintf("</div>\n");
1317 /* end tabbed dialog */
1319 wprintf("<script type=\"text/javascript\">"
1320 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1324 /* begin content of whatever tab is open now */
1326 if (!strcmp(tab, "admin")) {
1327 wprintf("<div class=\"tabcontent\">");
1329 "<li><a href=\"delete_room\" "
1330 "onClick=\"return confirm('");
1331 wprintf(_("Are you sure you want to delete this room?"));
1332 wprintf("');\">\n");
1333 wprintf(_("Delete this room"));
1335 "<li><a href=\"display_editroompic\">\n");
1336 wprintf(_("Set or change the icon for this room's banner"));
1338 "<li><a href=\"display_editinfo\">\n");
1339 wprintf(_("Edit this room's Info file"));
1345 if (!strcmp(tab, "config")) {
1346 wprintf("<div class=\"tabcontent\">");
1348 serv_getln(buf, sizeof buf);
1350 if (!strncmp(buf, "550", 3)) {
1351 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1352 _("Higher access is required to access this function.")
1355 else if (buf[0] != '2') {
1356 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1359 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1360 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1361 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1362 er_flags = extract_int(&buf[4], 3);
1363 er_floor = extract_int(&buf[4], 4);
1364 er_flags2 = extract_int(&buf[4], 7);
1366 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1367 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1369 wprintf("<ul><li>");
1370 wprintf(_("Name of room: "));
1371 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1377 wprintf(_("Resides on floor: "));
1378 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1379 if (er_flags & QR_MAILBOX)
1380 wprintf("disabled >\n");
1381 for (i = 0; i < 128; ++i)
1382 if (!IsEmptyStr(floorlist[i])) {
1383 wprintf("<OPTION ");
1385 wprintf("SELECTED ");
1386 wprintf("VALUE=\"%d\">", i);
1387 escputs(floorlist[i]);
1388 wprintf("</OPTION>\n");
1390 wprintf("</select>\n");
1393 wprintf(_("Type of room:"));
1396 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1397 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1398 wprintf("CHECKED ");
1399 wprintf("OnChange=\""
1400 " if (this.form.type[0].checked == true) { "
1401 " this.form.er_floor.disabled = false; "
1404 wprintf(_("Public (automatically appears to everyone)"));
1407 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1408 if ((er_flags & QR_PRIVATE) &&
1409 (er_flags & QR_GUESSNAME))
1410 wprintf("CHECKED ");
1411 wprintf(" OnChange=\""
1412 " if (this.form.type[1].checked == true) { "
1413 " this.form.er_floor.disabled = false; "
1416 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1418 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1419 if ((er_flags & QR_PRIVATE) &&
1420 (er_flags & QR_PASSWORDED))
1421 wprintf("CHECKED ");
1422 wprintf(" OnChange=\""
1423 " if (this.form.type[2].checked == true) { "
1424 " this.form.er_floor.disabled = false; "
1427 wprintf(_("Private - require password: "));
1428 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1431 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1432 if ((er_flags & QR_PRIVATE)
1433 && ((er_flags & QR_GUESSNAME) == 0)
1434 && ((er_flags & QR_PASSWORDED) == 0))
1435 wprintf("CHECKED ");
1436 wprintf(" OnChange=\""
1437 " if (this.form.type[3].checked == true) { "
1438 " this.form.er_floor.disabled = false; "
1441 wprintf(_("Private - invitation only"));
1443 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1444 if (er_flags & QR_MAILBOX)
1445 wprintf("CHECKED ");
1446 wprintf (" OnChange=\""
1447 " if (this.form.type[4].checked == true) { "
1448 " this.form.er_floor.disabled = true; "
1451 wprintf(_("Personal (mailbox for you only)"));
1453 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1455 wprintf(_("If private, cause current users to forget room"));
1457 wprintf("\n</ul>\n");
1459 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1460 if (er_flags & QR_PREFONLY)
1461 wprintf("CHECKED ");
1463 wprintf(_("Preferred users only"));
1465 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1466 if (er_flags & QR_READONLY)
1467 wprintf("CHECKED ");
1469 wprintf(_("Read-only room"));
1471 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1472 if (er_flags2 & QR2_COLLABDEL)
1473 wprintf("CHECKED ");
1475 wprintf(_("All users allowed to post may also delete messages"));
1477 /** directory stuff */
1478 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1479 if (er_flags & QR_DIRECTORY)
1480 wprintf("CHECKED ");
1482 wprintf(_("File directory room"));
1484 wprintf("\n<ul><li>");
1485 wprintf(_("Directory name: "));
1486 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1489 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1490 if (er_flags & QR_UPLOAD)
1491 wprintf("CHECKED ");
1493 wprintf(_("Uploading allowed"));
1495 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1496 if (er_flags & QR_DOWNLOAD)
1497 wprintf("CHECKED ");
1499 wprintf(_("Downloading allowed"));
1501 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1502 if (er_flags & QR_VISDIR)
1503 wprintf("CHECKED ");
1505 wprintf(_("Visible directory"));
1508 /** end of directory stuff */
1510 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1511 if (er_flags & QR_NETWORK)
1512 wprintf("CHECKED ");
1514 wprintf(_("Network shared room"));
1516 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1517 if (er_flags & QR_PERMANENT)
1518 wprintf("CHECKED ");
1520 wprintf(_("Permanent (does not auto-purge)"));
1522 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1523 if (er_flags2 & QR2_SUBJECTREQ)
1524 wprintf("CHECKED ");
1526 wprintf(_("Subject Required (Force users to specify a message subject)"));
1528 /** start of anon options */
1531 wprintf(_("Anonymous messages"));
1534 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1535 if (((er_flags & QR_ANONONLY) == 0)
1536 && ((er_flags & QR_ANONOPT) == 0))
1537 wprintf("CHECKED ");
1539 wprintf(_("No anonymous messages"));
1541 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1542 if (er_flags & QR_ANONONLY)
1543 wprintf("CHECKED ");
1545 wprintf(_("All messages are anonymous"));
1547 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1548 if (er_flags & QR_ANONOPT)
1549 wprintf("CHECKED ");
1551 wprintf(_("Prompt user when entering messages"));
1554 /* end of anon options */
1557 wprintf(_("Room aide: "));
1559 serv_getln(buf, sizeof buf);
1560 if (buf[0] != '2') {
1561 wprintf("<em>%s</em>\n", &buf[4]);
1563 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1564 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1567 wprintf("</ul><CENTER>\n");
1568 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1569 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1571 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1581 /* Sharing the room with other Citadel nodes... */
1582 if (!strcmp(tab, "sharing")) {
1583 wprintf("<div class=\"tabcontent\">");
1585 shared_with = strdup("");
1586 not_shared_with = strdup("");
1588 /** Learn the current configuration */
1589 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1590 serv_getln(buf, sizeof buf);
1591 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1592 extract_token(node, buf, 0, '|', sizeof node);
1593 not_shared_with = realloc(not_shared_with,
1594 strlen(not_shared_with) + 32);
1595 strcat(not_shared_with, node);
1596 strcat(not_shared_with, "\n");
1600 serv_getln(buf, sizeof buf);
1601 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1602 extract_token(cmd, buf, 0, '|', sizeof cmd);
1603 extract_token(node, buf, 1, '|', sizeof node);
1604 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1605 if (!strcasecmp(cmd, "ignet_push_share")) {
1606 shared_with = realloc(shared_with,
1607 strlen(shared_with) + 32);
1608 strcat(shared_with, node);
1609 if (!IsEmptyStr(remote_room)) {
1610 strcat(shared_with, "|");
1611 strcat(shared_with, remote_room);
1613 strcat(shared_with, "\n");
1617 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1618 extract_token(buf, shared_with, i, '\n', sizeof buf);
1619 extract_token(node, buf, 0, '|', sizeof node);
1620 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1621 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1622 if (!strcasecmp(node, cmd)) {
1623 remove_token(not_shared_with, j, '\n');
1628 /* Display the stuff */
1629 wprintf("<CENTER><br />"
1630 "<table border=1 cellpadding=5><tr>"
1632 wprintf(_("Shared with"));
1633 wprintf("</I></B></td>"
1635 wprintf(_("Not shared with"));
1636 wprintf("</I></B></td></tr>\n"
1637 "<tr><td VALIGN=TOP>\n");
1639 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1640 wprintf(_("Remote node name"));
1641 wprintf("</td><td>");
1642 wprintf(_("Remote room name"));
1643 wprintf("</td><td>");
1644 wprintf(_("Actions"));
1645 wprintf("</td></tr>\n");
1647 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1648 extract_token(buf, shared_with, i, '\n', sizeof buf);
1649 extract_token(node, buf, 0, '|', sizeof node);
1650 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1651 if (!IsEmptyStr(node)) {
1652 wprintf("<form method=\"POST\" action=\"netedit\">");
1653 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1654 wprintf("<tr><td>%s</td>\n", node);
1657 if (!IsEmptyStr(remote_room)) {
1658 escputs(remote_room);
1664 wprintf("<input type=\"hidden\" NAME=\"line\" "
1665 "VALUE=\"ignet_push_share|");
1667 if (!IsEmptyStr(remote_room)) {
1669 urlescputs(remote_room);
1672 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1673 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1674 wprintf("<input type=\"submit\" "
1675 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1676 wprintf("</td></tr></form>\n");
1680 wprintf("</table>\n");
1681 wprintf("</td><td VALIGN=TOP>\n");
1682 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1683 wprintf(_("Remote node name"));
1684 wprintf("</td><td>");
1685 wprintf(_("Remote room name"));
1686 wprintf("</td><td>");
1687 wprintf(_("Actions"));
1688 wprintf("</td></tr>\n");
1690 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1691 extract_token(node, not_shared_with, i, '\n', sizeof node);
1692 if (!IsEmptyStr(node)) {
1693 wprintf("<form method=\"POST\" action=\"netedit\">");
1694 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1695 wprintf("<tr><td>");
1698 "<input type=\"INPUT\" "
1702 wprintf("<input type=\"hidden\" "
1704 "VALUE=\"ignet_push_share|");
1707 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1708 "VALUE=\"sharing\">\n");
1709 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1710 "VALUE=\"add\">\n");
1711 wprintf("<input type=\"submit\" "
1712 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1713 wprintf("</td></tr></form>\n");
1717 wprintf("</table>\n");
1718 wprintf("</td></tr>"
1719 "</table></CENTER><br />\n"
1720 "<I><B>%s</B><ul><li>", _("Notes:"));
1721 wprintf(_("When sharing a room, "
1722 "it must be shared from both ends. Adding a node to "
1723 "the 'shared' list sends messages out, but in order to"
1724 " receive messages, the other nodes must be configured"
1725 " to send messages out to your system as well. "
1726 "<li>If the remote room name is blank, it is assumed "
1727 "that the room name is identical on the remote node."
1728 "<li>If the remote room name is different, the remote "
1729 "node must also configure the name of the room here."
1736 /* Mailing list management */
1737 if (!strcmp(tab, "listserv")) {
1738 room_states RoomFlags;
1739 wprintf("<div class=\"tabcontent\">");
1741 wprintf("<br /><center>"
1742 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1743 "<tr><td VALIGN=TOP>");
1745 wprintf(_("<i>The contents of this room are being "
1746 "mailed <b>as individual messages</b> "
1747 "to the following list recipients:"
1748 "</i><br /><br />\n"));
1751 serv_getln(buf, sizeof buf);
1752 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1753 extract_token(cmd, buf, 0, '|', sizeof cmd);
1754 if (!strcasecmp(cmd, "listrecp")) {
1755 extract_token(recp, buf, 1, '|', sizeof recp);
1758 wprintf(" <a href=\"netedit?cmd=remove&tab=listserv&line=listrecp|");
1761 wprintf(_("(remove)"));
1762 wprintf("</A><br />");
1765 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1766 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1767 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1768 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1769 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1770 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1771 wprintf("</form>\n");
1773 wprintf("</td><td VALIGN=TOP>\n");
1775 wprintf(_("<i>The contents of this room are being "
1776 "mailed <b>in digest form</b> "
1777 "to the following list recipients:"
1778 "</i><br /><br />\n"));
1781 serv_getln(buf, sizeof buf);
1782 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1783 extract_token(cmd, buf, 0, '|', sizeof cmd);
1784 if (!strcasecmp(cmd, "digestrecp")) {
1785 extract_token(recp, buf, 1, '|', sizeof recp);
1788 wprintf(" <a href=\"netedit?cmd=remove&tab=listserv&line="
1792 wprintf(_("(remove)"));
1793 wprintf("</A><br />");
1796 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1797 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1798 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1799 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1800 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1801 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1802 wprintf("</form>\n");
1804 wprintf("</td></tr></table>\n");
1806 /** Pop open an address book -- begin **/
1807 wprintf("<div align=right>"
1808 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1810 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1815 _("Add recipients from Contacts or other address books"),
1816 _("Add recipients from Contacts or other address books")
1818 /* Pop open an address book -- end **/
1820 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1822 get_roomflags (&RoomFlags);
1824 /* Self Service subscription? */
1825 wprintf("<table><tr><td>\n");
1826 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1827 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1828 " <tr><td colspan=\"2\">\n",
1829 (is_selflist(&RoomFlags))?"checked":"");
1830 wprintf(_("The URL for subscribe/unsubscribe is: "));
1831 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1832 (is_https ? "https" : "http"),
1833 ChrPtr(WC->Hdr->HR.http_host));
1834 /* Public posting? */
1835 wprintf("<tr><td>");
1836 wprintf(_("Allow non-subscribers to mail to this room."));
1837 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1838 (is_publiclist(&RoomFlags))?"checked":"");
1840 /* Moderated List? */
1841 wprintf("<tr><td>");
1842 wprintf(_("Room post publication needs Aide permission."));
1843 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1844 (is_moderatedlist(&RoomFlags))?"checked":"");
1847 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1848 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1849 wprintf("</table></form>");
1852 wprintf("</CENTER>\n");
1857 /* Configuration of The Dreaded Auto-Purger */
1858 if (!strcmp(tab, "expire")) {
1859 wprintf("<div class=\"tabcontent\">");
1861 serv_puts("GPEX room");
1862 serv_getln(buf, sizeof buf);
1863 if (!strncmp(buf, "550", 3)) {
1864 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1865 _("Higher access is required to access this function.")
1868 else if (buf[0] != '2') {
1869 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1872 roompolicy = extract_int(&buf[4], 0);
1873 roomvalue = extract_int(&buf[4], 1);
1875 serv_puts("GPEX floor");
1876 serv_getln(buf, sizeof buf);
1877 if (buf[0] == '2') {
1878 floorpolicy = extract_int(&buf[4], 0);
1879 floorvalue = extract_int(&buf[4], 1);
1882 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1883 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1884 wprintf("<table border=0 cellspacing=5>\n");
1885 wprintf("<tr><td>");
1886 wprintf(_("Message expire policy for this room"));
1888 escputs(ChrPtr(WC->wc_roomname));
1889 wprintf(")</td><td>");
1890 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1891 ((roompolicy == 0) ? "CHECKED" : "") );
1892 wprintf(_("Use the default policy for this floor"));
1893 wprintf("<br />\n");
1894 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1895 ((roompolicy == 1) ? "CHECKED" : "") );
1896 wprintf(_("Never automatically expire messages"));
1897 wprintf("<br />\n");
1898 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1899 ((roompolicy == 2) ? "CHECKED" : "") );
1900 wprintf(_("Expire by message count"));
1901 wprintf("<br />\n");
1902 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1903 ((roompolicy == 3) ? "CHECKED" : "") );
1904 wprintf(_("Expire by message age"));
1906 wprintf(_("Number of messages or days: "));
1907 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1908 wprintf("</td></tr>\n");
1910 if (WC->axlevel >= 6) {
1911 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1912 wprintf("<tr><td>");
1913 wprintf(_("Message expire policy for this floor"));
1915 escputs(floorlist[WC->wc_floor]);
1916 wprintf(")</td><td>");
1917 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1918 ((floorpolicy == 0) ? "CHECKED" : "") );
1919 wprintf(_("Use the system default"));
1920 wprintf("<br />\n");
1921 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1922 ((floorpolicy == 1) ? "CHECKED" : "") );
1923 wprintf(_("Never automatically expire messages"));
1924 wprintf("<br />\n");
1925 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1926 ((floorpolicy == 2) ? "CHECKED" : "") );
1927 wprintf(_("Expire by message count"));
1928 wprintf("<br />\n");
1929 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1930 ((floorpolicy == 3) ? "CHECKED" : "") );
1931 wprintf(_("Expire by message age"));
1933 wprintf(_("Number of messages or days: "));
1934 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1938 wprintf("<CENTER>\n");
1939 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1940 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1942 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1943 wprintf("</CENTER></td><tr>\n");
1945 wprintf("</table>\n"
1946 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1954 /* Access controls */
1955 if (!strcmp(tab, "access")) {
1956 wprintf("<div class=\"tabcontent\">");
1961 /* Fetch messages from remote locations */
1962 if (!strcmp(tab, "feeds")) {
1963 wprintf("<div class=\"tabcontent\">");
1966 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1967 wprintf("</i><br />\n");
1969 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1970 "<tr class=\"even\"><th>");
1971 wprintf(_("Remote host"));
1972 wprintf("</th><th>");
1973 wprintf(_("User name"));
1974 wprintf("</th><th>");
1975 wprintf(_("Password"));
1976 wprintf("</th><th>");
1977 wprintf(_("Keep messages on server?"));
1978 wprintf("</th><th>");
1979 wprintf(_("Interval"));
1980 wprintf("</th><th> </th></tr>");
1983 serv_getln(buf, sizeof buf);
1985 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1986 extract_token(cmd, buf, 0, '|', sizeof cmd);
1987 if (!strcasecmp(cmd, "pop3client")) {
1988 safestrncpy(recp, &buf[11], sizeof recp);
1991 wprintf("<tr class=\"%s\">",
1992 (bg ? "even" : "odd")
1996 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2001 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2005 wprintf("<td>*****</td>"); /* Don't show the password */
2007 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2009 wprintf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2011 wprintf("<td class=\"button_link\">");
2012 wprintf(" <a href=\"netedit?cmd=remove&tab=feeds&line=pop3client|");
2015 wprintf(_("(remove)"));
2016 wprintf("</a></td>");
2022 wprintf("<form method=\"POST\" action=\"netedit\">\n"
2024 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2025 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2026 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2028 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2031 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2034 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2037 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2040 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2043 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2044 wprintf("</td></tr>");
2045 wprintf("</form></table>\n");
2050 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
2051 wprintf("</i><br />\n");
2053 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
2054 "<tr class=\"even\"><th>");
2055 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2056 wprintf(_("Feed URL"));
2057 wprintf("</th><th>");
2058 wprintf("</th></tr>");
2061 serv_getln(buf, sizeof buf);
2063 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2064 extract_token(cmd, buf, 0, '|', sizeof cmd);
2065 if (!strcasecmp(cmd, "rssclient")) {
2066 safestrncpy(recp, &buf[10], sizeof recp);
2069 wprintf("<tr class=\"%s\">",
2070 (bg ? "even" : "odd")
2074 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2078 wprintf("<td class=\"button_link\">");
2079 wprintf(" <a href=\"netedit?cmd=remove&tab=feeds&line=rssclient|");
2082 wprintf(_("(remove)"));
2083 wprintf("</a></td>");
2089 wprintf("<form method=\"POST\" action=\"netedit\">\n"
2091 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2092 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2093 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2095 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2096 "maxlength=\"256\" name=\"line_pop3host\">\n");
2099 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2100 wprintf("</td></tr>");
2101 wprintf("</form></table>\n");
2107 /* end content of whatever tab is open now */
2108 wprintf("</div>\n");
2110 address_book_popup();
2116 * Toggle self-service list subscription
2118 void toggle_self_service(void) {
2119 room_states RoomFlags;
2121 get_roomflags (&RoomFlags);
2123 if (yesbstr("QR2_SelfList"))
2124 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2126 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2128 if (yesbstr("QR2_SMTP_PUBLIC"))
2129 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2131 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2133 if (yesbstr("QR2_Moderated"))
2134 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2136 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2137 if (yesbstr("QR2_SubsOnly"))
2138 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2140 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2142 set_roomflags (&RoomFlags);
2150 * save new parameters for a room
2157 StrBuf *er_password;
2159 StrBuf *er_roomaide;
2162 int er_listingorder;
2168 if (!havebstr("ok_button")) {
2169 strcpy(WC->ImportantMessage,
2170 _("Cancelled. Changes were not saved."));
2176 StrBuf_ServGetln(Buf);
2177 if (GetServerStatus(Buf, NULL) != 2) {
2178 StrBufCutLeft(Buf, 4);
2179 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2185 er_name = NewStrBuf();
2186 er_password = NewStrBuf();
2187 er_dirname = NewStrBuf();
2188 er_roomaide = NewStrBuf();
2190 StrBufCutLeft(Buf, 4);
2191 StrBufExtract_token(er_name, Buf, 0, '|');
2192 StrBufExtract_token(er_password, Buf, 1, '|');
2193 StrBufExtract_token(er_dirname, Buf, 2, '|');
2194 er_flags = StrBufExtract_int(Buf, 3, '|');
2195 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2196 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2197 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2199 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2200 if (StrLength(er_roomaide) == 0) {
2202 StrBuf_ServGetln(Buf);
2203 if (GetServerStatus(Buf, NULL) != 2) {
2204 FlushStrBuf(er_roomaide);
2206 StrBufCutLeft(Buf, 4);
2207 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2210 Ptr = sbstr("er_name");
2211 if (StrLength(Ptr) > 0) {
2212 FlushStrBuf(er_name);
2213 StrBufAppendBuf(er_name, Ptr, 0);
2216 Ptr = sbstr("er_password");
2217 if (StrLength(Ptr) > 0) {
2218 FlushStrBuf(er_password);
2219 StrBufAppendBuf(er_password, Ptr, 0);
2223 Ptr = sbstr("er_dirname");
2224 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2225 FlushStrBuf(er_dirname);
2226 StrBufAppendBuf(er_dirname, Ptr, 0);
2230 Ptr = sbstr("type");
2231 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2233 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2234 er_flags |= (QR_PRIVATE);
2236 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2237 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2239 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2240 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2242 if (!strcmp(ChrPtr(Ptr), "personal")) {
2243 er_flags |= QR_MAILBOX;
2245 er_flags &= ~QR_MAILBOX;
2248 if (yesbstr("prefonly")) {
2249 er_flags |= QR_PREFONLY;
2251 er_flags &= ~QR_PREFONLY;
2254 if (yesbstr("readonly")) {
2255 er_flags |= QR_READONLY;
2257 er_flags &= ~QR_READONLY;
2261 if (yesbstr("collabdel")) {
2262 er_flags2 |= QR2_COLLABDEL;
2264 er_flags2 &= ~QR2_COLLABDEL;
2267 if (yesbstr("permanent")) {
2268 er_flags |= QR_PERMANENT;
2270 er_flags &= ~QR_PERMANENT;
2273 if (yesbstr("subjectreq")) {
2274 er_flags2 |= QR2_SUBJECTREQ;
2276 er_flags2 &= ~QR2_SUBJECTREQ;
2279 if (yesbstr("network")) {
2280 er_flags |= QR_NETWORK;
2282 er_flags &= ~QR_NETWORK;
2285 if (yesbstr("directory")) {
2286 er_flags |= QR_DIRECTORY;
2288 er_flags &= ~QR_DIRECTORY;
2291 if (yesbstr("ulallowed")) {
2292 er_flags |= QR_UPLOAD;
2294 er_flags &= ~QR_UPLOAD;
2297 if (yesbstr("dlallowed")) {
2298 er_flags |= QR_DOWNLOAD;
2300 er_flags &= ~QR_DOWNLOAD;
2303 if (yesbstr("visdir")) {
2304 er_flags |= QR_VISDIR;
2306 er_flags &= ~QR_VISDIR;
2309 Ptr = sbstr("anon");
2311 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2312 if (!strcmp(ChrPtr(Ptr), "anononly"))
2313 er_flags |= QR_ANONONLY;
2314 if (!strcmp(ChrPtr(Ptr), "anon2"))
2315 er_flags |= QR_ANONOPT;
2317 bump = yesbstr("bump");
2319 er_floor = ibstr("er_floor");
2321 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2323 ChrPtr(er_password),
2332 StrBuf_ServGetln(Buf);
2333 if (GetServerStatus(Buf, NULL) != 2) {
2334 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2337 FreeStrBuf(&er_name);
2338 FreeStrBuf(&er_password);
2339 FreeStrBuf(&er_dirname);
2340 FreeStrBuf(&er_roomaide);
2345 if (StrLength(er_roomaide) > 0) {
2346 serv_printf("SETA %s", ChrPtr(er_roomaide));
2347 StrBuf_ServGetln(Buf);
2348 if (GetServerStatus(Buf, NULL) != 2) {
2349 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2350 display_main_menu();
2352 FreeStrBuf(&er_name);
2353 FreeStrBuf(&er_password);
2354 FreeStrBuf(&er_dirname);
2355 FreeStrBuf(&er_roomaide);
2360 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2363 FreeStrBuf(&er_name);
2364 FreeStrBuf(&er_password);
2365 FreeStrBuf(&er_dirname);
2366 FreeStrBuf(&er_roomaide);
2372 * Display form for Invite, Kick, and show Who Knows a room
2374 void do_invt_kick(void) {
2375 char buf[SIZ], room[SIZ], username[SIZ];
2378 serv_getln(buf, sizeof buf);
2380 if (buf[0] != '2') {
2384 extract_token(room, &buf[4], 0, '|', sizeof room);
2386 strcpy(username, bstr("username"));
2388 if (havebstr("kick_button")) {
2389 sprintf(buf, "KICK %s", username);
2391 serv_getln(buf, sizeof buf);
2393 if (buf[0] != '2') {
2394 strcpy(WC->ImportantMessage, &buf[4]);
2396 sprintf(WC->ImportantMessage,
2397 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2402 if (havebstr("invite_button")) {
2403 sprintf(buf, "INVT %s", username);
2405 serv_getln(buf, sizeof buf);
2407 if (buf[0] != '2') {
2408 strcpy(WC->ImportantMessage, &buf[4]);
2410 sprintf(WC->ImportantMessage,
2411 _("<B><I>User %s invited to room %s.</I></B>\n"),
2422 * Display form for Invite, Kick, and show Who Knows a room
2424 void display_whok(void)
2426 char buf[SIZ], room[SIZ], username[SIZ];
2429 serv_getln(buf, sizeof buf);
2431 if (buf[0] != '2') {
2435 extract_token(room, &buf[4], 0, '|', sizeof room);
2438 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2439 wprintf(_("The users listed below have access to this room. "
2440 "To remove a user from the access list, select the user "
2441 "name from the list and click 'Kick'."));
2442 wprintf("<br /><br />");
2444 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2445 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2446 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2447 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2449 serv_getln(buf, sizeof buf);
2450 if (buf[0] == '1') {
2451 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2452 extract_token(username, buf, 0, '|', sizeof username);
2453 wprintf("<OPTION>");
2458 wprintf("</select><br />\n");
2460 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2461 wprintf("</form></CENTER>\n");
2463 wprintf("</td><td>");
2464 wprintf(_("To grant another user access to this room, enter the "
2465 "user name in the box below and click 'Invite'."));
2466 wprintf("<br /><br />");
2468 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2469 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2470 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2471 wprintf(_("Invite:"));
2473 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2474 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2475 "<input type=\"submit\" value=\"%s\">"
2476 "</form></CENTER>\n", _("Invite"));
2477 /* Pop open an address book -- begin **/
2479 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2481 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2484 _("Users"), _("Users")
2486 /* Pop open an address book -- end **/
2488 wprintf("</td></tr></table>\n");
2489 address_book_popup();
2496 * display the form for entering a new room
2498 void display_entroom(void)
2505 serv_puts("CRE8 0");
2506 serv_getln(buf, sizeof buf);
2508 if (buf[0] != '2') {
2509 strcpy(WC->ImportantMessage, &buf[4]);
2510 display_main_menu();
2515 output_headers(1, 1, 1, 0, 0, 0);
2517 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2518 do_template("beginbox", NULL);
2520 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2521 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2523 wprintf("<table class=\"altern\"> ");
2525 wprintf("<tr class=\"even\"><td>");
2526 wprintf(_("Name of room: "));
2527 wprintf("</td><td>");
2528 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2529 wprintf("</td></tr>");
2531 wprintf("<tr class=\"odd\"><td>");
2532 wprintf(_("Resides on floor: "));
2533 wprintf("</td><td>");
2534 load_floorlist(Buf);
2535 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2536 for (i = 0; i < 128; ++i)
2537 if (!IsEmptyStr(floorlist[i])) {
2538 wprintf("<option ");
2539 wprintf("value=\"%d\">", i);
2540 escputs(floorlist[i]);
2541 wprintf("</option>\n");
2543 wprintf("</select>\n");
2544 wprintf("</td></tr>");
2547 * Our clever little snippet of JavaScript automatically selects
2548 * a public room if the view is set to Bulletin Board or wiki, and
2549 * it selects a mailbox room otherwise. The user can override this,
2550 * of course. We also disable the floor selector for mailboxes.
2552 wprintf("<tr class=\"even\"><td>");
2553 wprintf(_("Default view for room: "));
2554 wprintf("</td><td>");
2555 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2556 " if ( (this.form.er_view.value == 0) "
2557 " || (this.form.er_view.value == 6) ) { "
2558 " this.form.type[0].checked=true; "
2559 " this.form.er_floor.disabled = false; "
2562 " this.form.type[4].checked=true; "
2563 " this.form.er_floor.disabled = true; "
2566 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2567 if (is_view_allowed_as_default(i)) {
2568 wprintf("<option %s value=\"%d\">",
2569 ((i == 0) ? "selected" : ""), i );
2570 escputs(viewdefs[i]);
2571 wprintf("</option>\n");
2574 wprintf("</select>\n");
2575 wprintf("</td></tr>");
2577 wprintf("<tr class=\"even\"><td>");
2578 wprintf(_("Type of room:"));
2579 wprintf("</td><td>");
2580 wprintf("<ul class=\"adminlist\">\n");
2582 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2583 wprintf("CHECKED OnChange=\""
2584 " if (this.form.type[0].checked == true) { "
2585 " this.form.er_floor.disabled = false; "
2588 wprintf(_("Public (automatically appears to everyone)"));
2591 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2592 " if (this.form.type[1].checked == true) { "
2593 " this.form.er_floor.disabled = false; "
2596 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2599 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2600 " if (this.form.type[2].checked == true) { "
2601 " this.form.er_floor.disabled = false; "
2604 wprintf(_("Private - require password: "));
2605 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2608 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2609 " if (this.form.type[3].checked == true) { "
2610 " this.form.er_floor.disabled = false; "
2613 wprintf(_("Private - invitation only"));
2616 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2618 " if (this.form.type[4].checked == true) { "
2619 " this.form.er_floor.disabled = true; "
2622 wprintf(_("Personal (mailbox for you only)"));
2625 wprintf("\n</ul>\n");
2626 wprintf("</td></tr></table>\n");
2628 wprintf("<div class=\"buttons\">\n");
2629 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2631 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2632 wprintf("</div>\n");
2633 wprintf("</form>\n<hr />");
2634 serv_printf("MESG roomaccess");
2635 serv_getln(buf, sizeof buf);
2636 if (buf[0] == '1') {
2640 do_template("endbox", NULL);
2650 * support function for entroom() -- sets the default view
2652 void er_set_default_view(int newview) {
2665 serv_getln(buf, sizeof buf);
2666 if (buf[0] != '2') return;
2668 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2669 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2670 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2671 rm_bits1 = extract_int(&buf[4], 3);
2672 rm_floor = extract_int(&buf[4], 4);
2673 rm_listorder = extract_int(&buf[4], 5);
2674 rm_bits2 = extract_int(&buf[4], 7);
2676 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2677 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2678 rm_listorder, newview, rm_bits2
2680 serv_getln(buf, sizeof buf);
2691 const StrBuf *er_name;
2692 const StrBuf *er_type;
2693 const StrBuf *er_password;
2698 if (!havebstr("ok_button")) {
2699 strcpy(WC->ImportantMessage,
2700 _("Cancelled. No new room was created."));
2701 display_main_menu();
2704 er_name = sbstr("er_name");
2705 er_type = sbstr("type");
2706 er_password = sbstr("er_password");
2707 er_floor = ibstr("er_floor");
2708 er_view = ibstr("er_view");
2711 if (!strcmp(ChrPtr(er_type), "hidden"))
2713 else if (!strcmp(ChrPtr(er_type), "passworded"))
2715 else if (!strcmp(ChrPtr(er_type), "invonly"))
2717 else if (!strcmp(ChrPtr(er_type), "personal"))
2720 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2723 ChrPtr(er_password),
2728 serv_getln(buf, sizeof buf);
2729 if (buf[0] != '2') {
2730 strcpy(WC->ImportantMessage, &buf[4]);
2731 display_main_menu();
2734 /** TODO: Room created, now udate the left hand icon bar for this user */
2735 burn_folder_cache(0); /* burn the old folder cache */
2739 do_change_view(er_view); /* Now go there */
2744 * \brief display the screen to enter a private room
2746 void display_private(char *rname, int req_pass)
2748 WCTemplputParams SubTP;
2750 output_headers(1, 1, 1, 0, 0, 0);
2752 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2753 memset(&SubTP, 0, sizeof(WCTemplputParams));
2754 SubTP.Filter.ContextType = CTX_STRBUF;
2755 SubTP.Context = Buf;
2756 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2761 wprintf(_("If you know the name of a hidden (guess-name) or "
2762 "passworded room, you can enter that room by typing "
2763 "its name below. Once you gain access to a private "
2764 "room, it will appear in your regular room listings "
2765 "so you don't have to keep returning here."));
2768 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2769 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2771 wprintf("<table class=\"altern\"> "
2772 "<tr class=\"even\"><td>");
2773 wprintf(_("Enter room name:"));
2775 "<input type=\"text\" name=\"gr_name\" "
2776 "value=\"%s\" maxlength=\"128\">\n", rname);
2779 wprintf("</td></tr><tr class=\"odd\"><td>");
2780 wprintf(_("Enter room password:"));
2781 wprintf("</td><td>");
2782 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2784 wprintf("</td></tr></table>\n");
2786 wprintf("<div class=\"buttons\">\n");
2787 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2789 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2793 wprintf("</div></form>\n");
2795 do_template("endbox", NULL);
2801 * \brief goto a private room
2803 void goto_private(void)
2808 if (!havebstr("ok_button")) {
2809 display_main_menu();
2812 strcpy(hold_rm, ChrPtr(WC->wc_roomname));
2813 serv_printf("GOTO %s|%s",
2816 serv_getln(buf, sizeof buf);
2818 if (buf[0] == '2') {
2819 smart_goto(sbstr("gr_name"));
2822 if (!strncmp(buf, "540", 3)) {
2823 display_private(bstr("gr_name"), 1);
2826 output_headers(1, 1, 1, 0, 0, 0);
2827 wprintf("%s\n", &buf[4]);
2834 * \brief display the screen to zap a room
2836 void display_zap(void)
2838 output_headers(1, 1, 2, 0, 0, 0);
2840 wprintf("<div id=\"banner\">\n");
2842 wprintf(_("Zap (forget/unsubscribe) the current room"));
2844 wprintf("</div>\n");
2846 wprintf("<div id=\"content\" class=\"service\">\n");
2848 wprintf(_("If you select this option, <em>%s</em> will "
2849 "disappear from your room list. Is this what you wish "
2850 "to do?<br />\n"), ChrPtr(WC->wc_roomname));
2852 wprintf("<form method=\"POST\" action=\"zap\">\n");
2853 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2854 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2856 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2857 wprintf("</form>\n");
2868 StrBuf *final_destination;
2871 * If the forget-room routine fails for any reason, we fall back
2872 * to the current room; otherwise, we go to the Lobby
2874 final_destination = NewStrBufDup(WC->wc_roomname);
2876 if (havebstr("ok_button")) {
2877 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
2878 serv_getln(buf, sizeof buf);
2879 if (buf[0] == '2') {
2881 serv_getln(buf, sizeof buf);
2882 if (buf[0] == '2') {
2883 FlushStrBuf(final_destination);
2884 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2888 smart_goto(final_destination);
2889 FreeStrBuf(&final_destination);
2895 * \brief Delete the current room
2897 void delete_room(void)
2902 serv_puts("KILL 1");
2903 serv_getln(buf, sizeof buf);
2904 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2905 if (buf[0] != '2') {
2906 strcpy(WC->ImportantMessage, &buf[4]);
2907 display_main_menu();
2912 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2921 * \brief Perform changes to a room's network configuration
2923 void netedit(void) {
2932 /*/ TODO: do line dynamic! */
2933 if (havebstr("line_pop3host")) {
2934 strcpy(line, bstr("prefix"));
2935 strcat(line, bstr("line_pop3host"));
2937 strcat(line, bstr("line_pop3user"));
2939 strcat(line, bstr("line_pop3pass"));
2941 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2943 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2944 strcat(line, bstr("suffix"));
2946 else if (havebstr("line")) {
2947 strcpy(line, bstr("prefix"));
2948 strcat(line, bstr("line"));
2949 strcat(line, bstr("suffix"));
2964 serv_getln(buf, sizeof buf);
2965 if (buf[0] != '1') {
2971 /** This loop works for add *or* remove. Spiffy, eh? */
2972 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2973 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2974 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2975 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2976 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2977 if ( (strcasecmp(cmpa0, cmpb0))
2978 || (strcasecmp(cmpa1, cmpb1)) ) {
2979 fprintf(fp, "%s\n", buf);
2985 serv_getln(buf, sizeof buf);
2986 if (buf[0] != '4') {
2992 while (fgets(buf, sizeof buf, fp) != NULL) {
2993 buf[strlen(buf)-1] = 0;
2997 if (havebstr("add_button")) {
2998 num_addrs = num_tokens(bstr("line"), ',');
2999 if (num_addrs < 2) {
3000 /* just adding one node or address */
3004 /* adding multiple addresses separated by commas */
3005 for (i=0; i<num_addrs; ++i) {
3006 strcpy(line, bstr("prefix"));
3007 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3010 strcat(line, bstr("suffix"));
3024 * \brief Convert a room name to a folder-ish-looking name.
3025 * \param folder the folderish name
3026 * \param room the room name
3027 * \param floor the floor name
3028 * \param is_mailbox is it a mailbox?
3030 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3035 * For mailboxes, just do it straight...
3038 sprintf(folder, "My folders|%s", room);
3042 * Otherwise, prefix the floor name as a "public folders" moniker
3045 if (floor > MAX_FLOORS) {
3047 sprintf(folder, "%%%%%%|%s", room);
3050 sprintf(folder, "%s|%s", floorlist[floor], room);
3055 * Replace "\" characters with "|" for pseudo-folder-delimiting
3057 len = strlen (folder);
3058 for (i=0; i<len; ++i) {
3059 if (folder[i] == '\\') folder[i] = '|';
3067 * \brief Back end for change_view()
3068 * \param newview set newview???
3070 void do_change_view(int newview) {
3073 serv_printf("VIEW %d", newview);
3074 serv_getln(buf, sizeof buf);
3075 WC->wc_view = newview;
3076 smart_goto(WC->wc_roomname);
3082 * \brief Change the view for this room
3084 void change_view(void) {
3087 view = lbstr("view");
3088 do_change_view(view);
3093 * \brief One big expanded tree list view --- like a folder list
3094 * \param fold the folder to view
3095 * \param max_folders how many folders???
3096 * \param num_floors hom many floors???
3098 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
3102 int has_subfolders = 0;
3105 parents = malloc(max_folders * sizeof(int));
3107 /** BEGIN TREE MENU */
3108 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
3110 /** include NanoTree */
3111 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
3113 /** initialize NanoTree */
3114 wprintf("<script type=\"text/javascript\"> \n"
3115 " showRootNode = false; \n"
3116 " sortNodes = false; \n"
3117 " dragable = false; \n"
3119 " function standardClick(treeNode) { \n"
3122 " var closedGif = 'static/folder_closed.gif'; \n"
3123 " var openGif = 'static/folder_open.gif'; \n"
3125 " rootNode = new TreeNode(1, 'root node - hide'); \n"
3129 for (i=0; i<max_folders; ++i) {
3132 if ((i+1) < max_folders) {
3134 len = strlen(fold[i].name);
3135 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
3136 && (fold[i+1].name[len] == '|') ) {
3141 levels = num_tokens(fold[i].name, '|');
3142 parents[levels] = i;
3144 wprintf("var node%d = new TreeNode(%d, '", i, i);
3146 if (fold[i].selectable) {
3147 wprintf("<a href=\"dotgoto?room=");
3148 urlescputs(fold[i].room);
3153 wprintf("<span class=\"roomlist_floor\">");
3155 else if (fold[i].hasnewmsgs) {
3156 wprintf("<span class=\"roomlist_new\">");
3159 wprintf("<span class=\"roomlist_old\">");
3161 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3166 if (has_subfolders) {
3167 wprintf("new Array(closedGif, openGif)");
3169 else if (fold[i].view == VIEW_ADDRESSBOOK) {
3170 wprintf("'static/viewcontacts_16x.gif'");
3172 else if (fold[i].view == VIEW_CALENDAR) {
3173 wprintf("'static/calarea_16x.gif'");
3175 else if (fold[i].view == VIEW_CALBRIEF) {
3176 wprintf("'static/calarea_16x.gif'");
3178 else if (fold[i].view == VIEW_TASKS) {
3179 wprintf("'static/taskmanag_16x.gif'");
3181 else if (fold[i].view == VIEW_NOTES) {
3182 wprintf("'static/storenotes_16x.gif'");
3184 else if (fold[i].view == VIEW_MAILBOX) {
3185 wprintf("'static/privatemess_16x.gif'");
3188 wprintf("'static/chatrooms_16x.gif'");
3191 urlescputs(fold[i].name);
3195 wprintf("rootNode.addChild(node%d);\n", i);
3198 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3202 wprintf("container = document.getElementById('roomlist_div'); \n"
3208 /** END TREE MENU */
3212 * \brief Boxes and rooms and lists ... oh my!
3213 * \param fold the folder to view
3214 * \param max_folders how many folders???
3215 * \param num_floors hom many floors???
3217 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3219 char floor_name[256];
3220 char old_floor_name[256];
3221 int levels, oldlevels;
3224 static int columns = 3;
3225 int boxes_per_column = 0;
3226 int current_column = 0;
3229 strcpy(floor_name, "");
3230 strcpy(old_floor_name, "");
3233 while (nf % columns != 0) ++nf;
3234 boxes_per_column = (nf / columns);
3235 if (boxes_per_column < 1) boxes_per_column = 1;
3237 /** Outer table (for columnization) */
3238 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3239 "<tr><td valign=top>");
3243 for (i=0; i<max_folders; ++i) {
3245 levels = num_tokens(fold[i].name, '|');
3246 extract_token(floor_name, fold[i].name, 0,
3247 '|', sizeof floor_name);
3249 if ( (strcasecmp(floor_name, old_floor_name))
3250 && (!IsEmptyStr(old_floor_name)) ) {
3252 do_template("endbox", NULL);
3256 if ((num_boxes % boxes_per_column) == 0) {
3258 if (current_column < columns) {
3259 wprintf("</td><td valign=top>\n");
3263 strcpy(old_floor_name, floor_name);
3267 WCTemplputParams SubTP;
3269 Buf = NewStrBufPlain(floor_name, -1);
3270 memset(&SubTP, 0, sizeof(WCTemplputParams));
3271 SubTP.Filter.ContextType = CTX_STRBUF;
3272 SubTP.Context = Buf;
3273 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
3282 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3283 if (fold[i].selectable) {
3284 wprintf("<a href=\"dotgoto?room=");
3285 urlescputs(fold[i].room);
3291 if (fold[i].hasnewmsgs) {
3292 wprintf("<span class=\"roomlist_new\">");
3295 wprintf("<span class=\"roomlist_old\">");
3297 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3300 if (fold[i].selectable) {
3306 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3307 wprintf(" (INBOX)");
3309 wprintf("<br />\n");
3312 /** End the final inner box */
3313 do_template("endbox", NULL);
3315 wprintf("</td></tr></table>\n");
3319 * \brief print a floor div???
3320 * \param which_floordiv name of the floordiv???
3322 void set_floordiv_expanded(void) {
3323 wcsession *WCC = WC;
3326 FloorDiv = NewStrBuf();
3327 StrBufExtract_token(FloorDiv, WCC->Hdr->HR.ReqLine, 0, '/');
3328 set_preference("floordiv_expanded", FloorDiv, 1);
3329 WCC->floordiv_expanded = FloorDiv;
3333 * \brief view the iconbar
3334 * \param fold the folder to view
3335 * \param max_folders how many folders???
3336 * \param num_floors hom many floors???
3338 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3340 char floor_name[256];
3341 char old_floor_name[256];
3342 char floordivtitle[256];
3343 char floordiv_id[32];
3344 int levels, oldlevels;
3348 strcpy(floor_name, "");
3349 strcpy(old_floor_name, "");
3353 for (i=0; i<max_folders; ++i) {
3355 levels = num_tokens(fold[i].name, '|');
3356 extract_token(floor_name, fold[i].name, 0,
3357 '|', sizeof floor_name);
3359 if ( (strcasecmp(floor_name, old_floor_name))
3360 && (!IsEmptyStr(old_floor_name)) ) {
3361 /** End inner box */
3363 wprintf("</div>\n"); /** floordiv */
3365 strcpy(old_floor_name, floor_name);
3369 stresc(floordivtitle, 256, floor_name, 0, 0);
3370 sprintf(floordiv_id, "floordiv%d", i);
3371 wprintf("<span class=\"ib_roomlist_floor\" "
3372 "onClick=\"expand_floor('%s')\">"
3373 "%s</span><br>\n", floordiv_id, floordivtitle);
3374 wprintf("<div id=\"%s\" style=\"display:%s\">",
3376 (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
3383 wprintf("<div id=\"roomdiv%d\">", i);
3385 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3387 /** choose the icon */
3388 if (fold[i].view == VIEW_ADDRESSBOOK) {
3389 icon = "viewcontacts_16x.gif" ;
3391 else if (fold[i].view == VIEW_CALENDAR) {
3392 icon = "calarea_16x.gif" ;
3394 else if (fold[i].view == VIEW_CALBRIEF) {
3395 icon = "calarea_16x.gif" ;
3397 else if (fold[i].view == VIEW_TASKS) {
3398 icon = "taskmanag_16x.gif" ;
3400 else if (fold[i].view == VIEW_NOTES) {
3401 icon = "storenotes_16x.gif" ;
3403 else if (fold[i].view == VIEW_MAILBOX) {
3404 icon = "privatemess_16x.gif" ;
3407 icon = "chatrooms_16x.gif" ;
3410 if (fold[i].selectable) {
3411 wprintf("<a href=\"dotgoto?room=");
3412 urlescputs(fold[i].room);
3414 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3419 if (fold[i].hasnewmsgs) {
3420 wprintf("<span class=\"ib_roomlist_new\">");
3423 wprintf("<span class=\"ib_roomlist_old\">");
3425 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3427 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3428 wprintf(" (INBOX)");
3431 if (fold[i].selectable) {
3438 wprintf("</div>\n"); /** roomdiv */
3441 wprintf("</div>\n"); /** floordiv */
3449 * \brief Burn the cached folder list.
3450 * \param age How old the cahce needs to be before we burn it.
3453 void burn_folder_cache(time_t age)
3455 /** If our cached folder list is very old, burn it. */
3456 if (WC->cache_fold != NULL) {
3457 if ((time(NULL) - WC->cache_timestamp) > age) {
3458 free(WC->cache_fold);
3459 WC->cache_fold = NULL;
3468 * \brief Show the room list.
3469 * (only should get called by
3470 * knrooms() because that's where output_headers() is called from)
3471 * \param viewpref the view preferences???
3474 void list_all_rooms_by_floor(const char *viewpref) {
3478 struct folder *fold = NULL;
3480 int max_folders = 0;
3481 int alloc_folders = 0;
3485 int ShowEmptyFloors;
3488 int num_floors = 1; /** add an extra one for private folders */
3491 /** If our cached folder list is very old, burn it. */
3492 burn_folder_cache(300);
3494 /** Can we do the iconbar roomlist from cache? */
3495 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3496 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3501 /** Grab the floor table so we know how to build the list... */
3502 load_floorlist(Buf);
3504 /** Start with the mailboxes */
3507 fold = malloc(sizeof(struct folder));
3508 memset(fold, 0, sizeof(struct folder));
3509 strcpy(fold[0].name, "My folders");
3510 fold[0].is_mailbox = 1;
3512 /** Then add floors */
3514 serv_getln(buf, sizeof buf);
3515 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3516 if (max_folders >= alloc_folders) {
3517 alloc_folders = max_folders + 100;
3518 fold = realloc(fold,
3519 alloc_folders * sizeof(struct folder));
3521 memset(&fold[max_folders], 0, sizeof(struct folder));
3522 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3523 extract_token(buf3, buf, 0, '|', SIZ);
3524 fold[max_folders].floor = atol (buf3);
3529 for (i=0; i<num_floors; i++)
3530 if (IDMax < fold[i].floor)
3531 IDMax = fold[i].floor;
3532 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3533 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3534 for (i=0; i<num_floors; i++)
3535 floor_mapping[fold[i].floor]=i;
3537 /** refresh the messages index for this room */
3538 /* TODO serv_puts("GOTO ");
3539 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")); */
3540 /** Now add rooms */
3542 serv_getln(buf, sizeof buf);
3543 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3544 if (max_folders >= alloc_folders) {
3545 alloc_folders = max_folders + 100;
3546 fold = realloc(fold,
3547 alloc_folders * sizeof(struct folder));
3549 memset(&fold[max_folders], 0, sizeof(struct folder));
3550 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3551 ra_flags = extract_int(buf, 5);
3552 flags = extract_int(buf, 1);
3553 fold[max_folders].floor = extract_int(buf, 2);
3554 fold[max_folders].hasnewmsgs =
3555 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3556 if (flags & QR_MAILBOX) {
3557 fold[max_folders].is_mailbox = 1;
3559 fold[max_folders].view = extract_int(buf, 6);
3560 room_to_folder(fold[max_folders].name,
3561 fold[max_folders].room,
3562 fold[max_folders].floor,
3563 fold[max_folders].is_mailbox);
3564 fold[max_folders].selectable = 1;
3565 /* Increase the room count for the associtaed floor */
3566 if (fold[max_folders].is_mailbox) {
3567 fold[0].num_rooms++;
3570 i = floor_mapping[fold[max_folders].floor];
3571 fold[i].num_rooms++;
3577 * Remove any floors that don't have rooms
3579 get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
3580 if (ShowEmptyFloors)
3582 for (i=0; i<num_floors; i++)
3584 if (fold[i].num_rooms == 0) {
3585 for (j=i; j<max_folders; j++) {
3586 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3595 /** Bubble-sort the folder list */
3596 for (i=0; i<max_folders; ++i) {
3597 for (j=0; j<(max_folders-1)-i; ++j) {
3598 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3599 swap = strcasecmp(fold[j].name, fold[j+1].name);
3602 if ( (fold[j+1].is_mailbox)
3603 && (!fold[j].is_mailbox)) {
3611 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3612 memcpy(&fold[j], &fold[j+1],
3613 sizeof(struct folder));
3614 memcpy(&fold[j+1], &ftmp,
3615 sizeof(struct folder));
3621 if (!strcasecmp(viewpref, "folders")) {
3622 do_folder_view(fold, max_folders, num_floors);
3624 else if (!strcasecmp(viewpref, "hackish_view")) {
3625 for (i=0; i<max_folders; ++i) {
3626 escputs(fold[i].name);
3627 wprintf("<br />\n");
3630 else if (!strcasecmp(viewpref, "iconbar")) {
3631 do_iconbar_view(fold, max_folders, num_floors);
3634 do_rooms_view(fold, max_folders, num_floors);
3637 /* Don't free the folder list ... cache it for future use! */
3638 if (WC->cache_fold != NULL) {
3639 free(WC->cache_fold);
3641 WC->cache_fold = fold;
3642 WC->cache_max_folders = max_folders;
3643 WC->cache_num_floors = num_floors;
3644 WC->cache_timestamp = time(NULL);
3645 free(floor_mapping);
3650 * \brief Do either a known rooms list or a folders list, depending on the
3655 StrBuf *ListView = NULL;
3657 output_headers(1, 1, 2, 0, 0, 0);
3659 /** Determine whether the user is trying to change views */
3660 if (havebstr("view")) {
3661 ListView = NewStrBufPlain(bstr("view"), -1);
3662 set_preference("roomlistview", ListView, 1);
3664 /** Sanitize the input so its safe */
3665 if(!get_preference("roomlistview", &ListView) ||
3666 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3667 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3669 if (ListView == NULL) {
3670 ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1);
3671 set_preference("roomlistview", ListView, 0);
3674 StrBufPrintf(ListView, "rooms");
3680 wprintf("<div id=\"banner\">\n");
3681 wprintf("<div class=\"room_banner\" id=\"room_banner\">");
3683 if (!strcasecmp(ChrPtr(ListView), "rooms")) {
3684 wprintf(_("Room list"));
3686 else if (!strcasecmp(ChrPtr(ListView), "folders")) {
3687 wprintf(_("Folder list"));
3689 else if (!strcasecmp(ChrPtr(ListView), "table")) {
3690 wprintf(_("Room list"));
3692 wprintf("</h1></div>\n");
3694 /** offer the ability to switch views */
3695 wprintf("<div id=\"actiondiv\">");
3696 wprintf("<ul class=\"room_actions\">\n");
3697 wprintf("<li class=\"start_page\">");
3698 offer_start_page(NULL, &NoCtx);
3700 wprintf("<li><form name=\"roomlistomatic\">\n"
3701 "<select name=\"newview\" size=\"1\" "
3702 "OnChange=\"location.href=roomlistomatic.newview.options"
3703 "[selectedIndex].value\">\n");
3705 wprintf("<option %s value=\"knrooms?view=rooms\">"
3708 ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" )
3711 wprintf("<option %s value=\"knrooms?view=folders\">"
3712 "View as folder list"
3714 ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" )
3717 wprintf("</select>");
3718 wprintf("</form></li>");
3719 wprintf("</ul></div></div>\n");
3721 wprintf("<div id=\"content\" class=\"service\">\n");
3723 /** Display the room list in the user's preferred format */
3724 list_all_rooms_by_floor(ChrPtr(ListView));
3731 * \brief Set the message expire policy for this room and/or floor
3733 void set_room_policy(void) {
3736 if (!havebstr("ok_button")) {
3737 strcpy(WC->ImportantMessage,
3738 _("Cancelled. Changes were not saved."));
3743 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3744 serv_getln(buf, sizeof buf);
3745 strcpy(WC->ImportantMessage, &buf[4]);
3747 if (WC->axlevel >= 6) {
3748 strcat(WC->ImportantMessage, "<br />\n");
3749 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3750 serv_getln(buf, sizeof buf);
3751 strcat(WC->ImportantMessage, &buf[4]);
3757 HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP) {
3758 /* todo: check context */
3764 floors = NewHash(1, NULL);
3766 serv_puts("LFLR"); /* get floors */
3767 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err); /* '100', we hope */
3768 if (GetServerStatus(Buf, NULL) == 1)
3769 while(StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err), strcmp(ChrPtr(Buf), "000")) {
3771 const StrBuf *floorNum = NULL;
3772 floor = NewHash(1, NULL);
3773 for(a=0; a<FLOOR_PARAM_LEN; a++) {
3775 StrBufExtract_token(Buf2, Buf, a, '|');
3777 floorNum = Buf2; /* hmm, should we copy Buf2 first? */
3780 Put(floor, CKEY(FLOOR_PARAM_NAMES[a]), Buf2, HFreeStrBuf);
3782 Put(floors, SKEY(floorNum), floor, HDeleteHash);
3788 void tmplput_FLOOR_Value(StrBuf *TemplBuffer, WCTemplputParams *TP)
3791 HashList *floor = (HashList *)(TP->Context);
3793 GetHash(floor, TKEY(0), &value);
3794 val = (StrBuf *)value;
3795 StrECMAEscAppend(TemplBuffer, val, 0);
3797 HashList *GetRoomListHashLKRA(StrBuf *Target, WCTemplputParams *TP)
3800 return GetRoomListHash(Target, TP);
3802 HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP)
3804 /* TODO: Check context */
3811 rooms = NewHash(1, NULL);
3812 StrBufTCP_read_line(buf, &WC->serv_sock, 0, &Err);
3813 if (GetServerStatus(buf, NULL) == 1)
3814 while(StrBufTCP_read_line(buf, &WC->serv_sock, 0, &Err), strcmp(ChrPtr(buf), "000")) {
3816 StrBuf *rmName = NULL;
3817 room = NewHash(1, NULL);
3818 for(i=0; i<ROOM_PARAM_LEN; i++) {
3820 StrBufExtract_token(buf2, buf, i, '|');
3824 Put(room, CKEY(ROOM_PARAM_NAMES[i]), buf2, HFreeStrBuf);
3826 Put(rooms, SKEY(rmName), room, HDeleteHash);
3828 SortByHashKey(rooms, 1);
3829 /*SortByPayload(rooms, SortRoomsByListOrder); */
3833 /** Unused function that orders rooms by the listorder flag */
3834 int SortRoomsByListOrder(const void *room1, const void *room2)
3838 HashList *r1 = (HashList *)GetSearchPayload(room1);
3839 HashList *r2 = (HashList *)GetSearchPayload(room2);
3840 StrBuf *listOrderBuf1;
3841 StrBuf *listOrderBuf2;
3843 GetHash(r1, CKEY(ROOM_PARAM_NAMES[3]), (void *)&listOrderBuf1);
3844 GetHash(r2, CKEY(ROOM_PARAM_NAMES[3]), (void *)&listOrderBuf2);
3845 l1 = atoi(ChrPtr(listOrderBuf1));
3846 l2 = atoi(ChrPtr(listOrderBuf2));
3847 if (l1 < l2) return -1;
3848 else if (l1 > l2) return +1;
3851 void tmplput_ROOM_Value(StrBuf *TemplBuffer, WCTemplputParams *TP)
3855 HashList *room = (HashList *)(TP->Context);
3857 GetHash(room, TKEY(0), &value);
3858 val = (StrBuf *)value;
3859 StrECMAEscAppend(TemplBuffer, val, 0);
3861 void jsonRoomFlr(void)
3863 /* Send as our own (application/json) content type */
3864 hprintf("HTTP/1.1 200 OK\r\n");
3865 hprintf("Content-type: application/json; charset=utf-8\r\n");
3866 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
3867 hprintf("Connection: close\r\n");
3868 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
3870 DoTemplate(HKEY("json_roomflr"),NULL,&NoCtx);
3874 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3876 StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
3879 void _gotonext(void) {
3884 void dotskip(void) {
3885 smart_goto(sbstr("room"));
3888 void _display_private(void) {
3889 display_private("", 0);
3892 void dotgoto(void) {
3893 if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3896 smart_goto(sbstr("room"));
3899 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3901 wprintf("<div id=\"banner\">\n");
3902 embed_room_banner(NULL, navbar_default);
3903 wprintf("</div>\n");
3907 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3909 wcsession *WCC = WC;
3912 (!IsEmptyStr(WCC->ugname)))
3913 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3917 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3919 wcsession *WCC = WC;
3921 return ((WCC!=NULL) &&
3922 (!IsEmptyStr(WCC->ugname)) &&
3923 (strcasecmp(WCC->ugname, ChrPtr(WCC->wc_roomname)) == 0));
3926 int ConditionalRoomHas_QR_PERMANENT(StrBuf *Target, WCTemplputParams *TP)
3928 wcsession *WCC = WC;
3930 return ((WCC!=NULL) &&
3931 ((WCC->room_flags & QR_PERMANENT) != 0));
3934 int ConditionalRoomHas_QR_INUSE(StrBuf *Target, WCTemplputParams *TP)
3936 wcsession *WCC = WC;
3938 return ((WCC!=NULL) &&
3939 ((WCC->room_flags & QR_INUSE) != 0));
3942 int ConditionalRoomHas_QR_PRIVATE(StrBuf *Target, WCTemplputParams *TP)
3944 wcsession *WCC = WC;
3946 return ((WCC!=NULL) &&
3947 ((WCC->room_flags & QR_PRIVATE) != 0));
3950 int ConditionalRoomHas_QR_PASSWORDED(StrBuf *Target, WCTemplputParams *TP)
3952 wcsession *WCC = WC;
3954 return ((WCC!=NULL) &&
3955 ((WCC->room_flags & QR_PASSWORDED) != 0));
3958 int ConditionalRoomHas_QR_GUESSNAME(StrBuf *Target, WCTemplputParams *TP)
3960 wcsession *WCC = WC;
3962 return ((WCC!=NULL) &&
3963 ((WCC->room_flags & QR_GUESSNAME) != 0));
3966 int ConditionalRoomHas_QR_DIRECTORY(StrBuf *Target, WCTemplputParams *TP)
3968 wcsession *WCC = WC;
3970 return ((WCC!=NULL) &&
3971 ((WCC->room_flags & QR_DIRECTORY) != 0));
3974 int ConditionalRoomHas_QR_UPLOAD(StrBuf *Target, WCTemplputParams *TP)
3976 wcsession *WCC = WC;
3978 return ((WCC!=NULL) &&
3979 ((WCC->room_flags & QR_UPLOAD) != 0));
3982 int ConditionalRoomHas_QR_DOWNLOAD(StrBuf *Target, WCTemplputParams *TP)
3984 wcsession *WCC = WC;
3986 return ((WCC!=NULL) &&
3987 ((WCC->room_flags & QR_DOWNLOAD) != 0));
3990 int ConditionalRoomHas_QR_VISDIR(StrBuf *Target, WCTemplputParams *TP)
3992 wcsession *WCC = WC;
3994 return ((WCC!=NULL) &&
3995 ((WCC->room_flags & QR_VISDIR) != 0));
3998 int ConditionalRoomHas_QR_ANONONLY(StrBuf *Target, WCTemplputParams *TP)
4000 wcsession *WCC = WC;
4002 return ((WCC!=NULL) &&
4003 ((WCC->room_flags & QR_ANONONLY) != 0));
4006 int ConditionalRoomHas_QR_ANONOPT(StrBuf *Target, WCTemplputParams *TP)
4008 wcsession *WCC = WC;
4010 return ((WCC!=NULL) &&
4011 ((WCC->room_flags & QR_ANONOPT) != 0));
4014 int ConditionalRoomHas_QR_NETWORK(StrBuf *Target, WCTemplputParams *TP)
4016 wcsession *WCC = WC;
4018 return ((WCC!=NULL) &&
4019 ((WCC->room_flags & QR_NETWORK) != 0));
4022 int ConditionalRoomHas_QR_PREFONLY(StrBuf *Target, WCTemplputParams *TP)
4024 wcsession *WCC = WC;
4026 return ((WCC!=NULL) &&
4027 ((WCC->room_flags & QR_PREFONLY) != 0));
4030 int ConditionalRoomHas_QR_READONLY(StrBuf *Target, WCTemplputParams *TP)
4032 wcsession *WCC = WC;
4034 return ((WCC!=NULL) &&
4035 ((WCC->room_flags & QR_READONLY) != 0));
4038 int ConditionalRoomHas_QR_MAILBOX(StrBuf *Target, WCTemplputParams *TP)
4040 wcsession *WCC = WC;
4042 return ((WCC!=NULL) &&
4043 ((WCC->room_flags & QR_MAILBOX) != 0));
4047 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
4049 wcsession *WCC = WC;
4051 return ( (WCC!= NULL) &&
4052 ((WCC->axlevel >= 6) ||
4053 (WCC->is_room_aide) ||
4054 (WCC->is_mailbox) ));
4057 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
4059 wcsession *WCC = WC;
4061 if ((WCC == NULL) ||
4062 (TP->Tokens->nParameters < 3) ||
4063 (TP->Tokens->Params[2]->Type != TYPE_STR)||
4064 (TP->Tokens->Params[2]->len < 7))
4067 switch(WCC->wc_view) {
4069 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_BBS"));
4071 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_MAILBOX"));
4072 case VIEW_ADDRESSBOOK:
4073 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_ADDRESSBOOK"));
4075 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_TASKS"));
4077 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_NOTES"));
4079 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_WIKI"));
4081 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_JOURNAL"));
4083 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_CALENDAR"));
4085 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_CALBRIEF"));
4095 RegisterPreference("roomlistview",
4096 _("Room list view"),
4099 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
4101 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, 0);
4103 WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
4104 WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, NEED_URL);
4105 WebcitAddUrlHandler(HKEY("skip"), gotonext, NEED_URL);
4106 WebcitAddUrlHandler(HKEY("ungoto"), ungoto, NEED_URL);
4107 WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, NEED_URL);
4108 WebcitAddUrlHandler(HKEY("dotskip"), dotskip, NEED_URL);
4109 WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
4110 WebcitAddUrlHandler(HKEY("goto_private"), goto_private, NEED_URL);
4111 WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
4112 WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
4113 WebcitAddUrlHandler(HKEY("zap"), zap, 0);
4114 WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
4115 WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
4116 WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
4117 WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
4118 WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
4119 WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
4120 WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
4121 WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
4122 WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
4123 WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
4124 WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);
4125 WebcitAddUrlHandler(HKEY("toggle_self_service"), toggle_self_service, 0);
4126 WebcitAddUrlHandler(HKEY("json_roomflr"), jsonRoomFlr, 0);
4127 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, 0);
4129 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
4130 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PERMANENT"), 0, ConditionalRoomHas_QR_PERMANENT, CTX_NONE);
4131 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_INUSE"), 0, ConditionalRoomHas_QR_INUSE, CTX_NONE);
4132 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PRIVATE"), 0, ConditionalRoomHas_QR_PRIVATE, CTX_NONE);
4133 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PASSWORDED"), 0, ConditionalRoomHas_QR_PASSWORDED, CTX_NONE);
4134 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_GUESSNAME"), 0, ConditionalRoomHas_QR_GUESSNAME, CTX_NONE);
4135 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DIRECTORY"), 0, ConditionalRoomHas_QR_DIRECTORY, CTX_NONE);
4136 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_UPLOAD"), 0, ConditionalRoomHas_QR_UPLOAD, CTX_NONE);
4137 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DOWNLOAD"), 0, ConditionalRoomHas_QR_DOWNLOAD, CTX_NONE);
4138 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_VISIDIR"), 0, ConditionalRoomHas_QR_VISDIR, CTX_NONE);
4139 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONONLY"), 0, ConditionalRoomHas_QR_ANONONLY, CTX_NONE);
4140 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONOPT"), 0, ConditionalRoomHas_QR_ANONOPT, CTX_NONE);
4141 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_NETWORK"), 0, ConditionalRoomHas_QR_NETWORK, CTX_NONE);
4142 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PREFONLY"), 0, ConditionalRoomHas_QR_PREFONLY, CTX_NONE);
4143 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_READONLY"), 0, ConditionalRoomHas_QR_READONLY, CTX_NONE);
4144 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_MAILBOX"), 0, ConditionalRoomHas_QR_MAILBOX, CTX_NONE);
4146 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
4147 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
4149 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, 0);
4150 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, DeleteHash, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
4151 RegisterNamespace("FLOOR:INFO", 1, 2, tmplput_FLOOR_Value, CTX_FLOORS);
4152 RegisterIterator("LKRA", 0, NULL, GetRoomListHashLKRA, NULL, DeleteHash, CTX_ROOMS, CTX_NONE, IT_NOFLAG);
4153 RegisterNamespace("ROOM:INFO", 1, 2, tmplput_ROOM_Value, CTX_ROOMS);
4159 SessionDestroyModule_ROOMOPS
4162 if (sess->cache_fold != NULL) {
4163 free(sess->cache_fold);
4166 free_march_list(sess);