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 void display_whok(void);
19 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP);
22 * Initialize the viewdefs with localized strings
24 void initialize_viewdefs(void) {
25 viewdefs[0] = _("Bulletin Board");
26 viewdefs[1] = _("Mail Folder");
27 viewdefs[2] = _("Address Book");
28 viewdefs[3] = _("Calendar");
29 viewdefs[4] = _("Task List");
30 viewdefs[5] = _("Notes List");
31 viewdefs[6] = _("Wiki");
32 viewdefs[7] = _("Calendar List");
33 viewdefs[8] = _("Journal");
37 * Determine which views are allowed as the default for creating a new room.
39 int is_view_allowed_as_default(int which_view)
42 case VIEW_BBS: return(1);
43 case VIEW_MAILBOX: return(1);
44 case VIEW_ADDRESSBOOK: return(1);
45 case VIEW_CALENDAR: return(1);
46 case VIEW_TASKS: return(1);
47 case VIEW_NOTES: return(1);
48 case VIEW_WIKI: return(1);
49 case VIEW_CALBRIEF: return(0);
50 case VIEW_JOURNAL: return(0);
51 default: return(0); /* should never get here */
57 * load the list of floors
59 void load_floorlist(StrBuf *Buf)
64 for (a = 0; a < MAX_FLOORS; ++a)
68 StrBuf_ServGetln(Buf);
69 if (GetServerStatus(Buf, NULL) != 1) {
70 strcpy(floorlist[0], "Main Floor");
73 while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
74 if ( (StrLength(Buf)==3) &&
75 !strcmp(ChrPtr(Buf), "000")) {
79 extract_token(floorlist[StrBufExtract_int(Buf, 0, '|')], ChrPtr(Buf), 1, '|', sizeof floorlist[0]);
87 * display rooms in tree structure
89 void room_tree_list(struct roomlisting *rp)
98 room_tree_list(rp->lnext);
100 strcpy(rmname, rp->rlname);
103 wc_printf("<a href=\"dotgoto?room=");
107 escputs1(rmname, 1, 1);
108 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
110 else if (f & QR_DIRECTORY)
112 else if (f & QR_NETWORK)
116 wc_printf("</a><tt> </tt>\n");
118 room_tree_list(rp->rnext);
124 * Room ordering stuff (compare first by floor, then by order)
126 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
128 if ((r1 == NULL) && (r2 == NULL))
134 if (r1->rlfloor < r2->rlfloor)
136 if (r1->rlfloor > r2->rlfloor)
138 if (r1->rlorder < r2->rlorder)
140 if (r1->rlorder > r2->rlorder)
147 * Common code for all room listings
149 void listrms(char *variety)
154 struct roomlisting *rl = NULL;
155 struct roomlisting *rp;
156 struct roomlisting *rs;
158 /* Ask the server for a room list */
160 serv_getln(buf, sizeof buf);
166 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
168 rp = malloc(sizeof(struct roomlisting));
169 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
170 rp->rlflags = extract_int(buf, 1);
171 rp->rlfloor = extract_int(buf, 2);
172 rp->rlorder = extract_int(buf, 3);
181 if (rordercmp(rp, rs) < 0) {
182 if (rs->lnext == NULL) {
189 if (rs->rnext == NULL) {
202 * If no rooms were listed, print an nbsp to make the cell
203 * borders show up anyway.
205 if (num_rooms == 0) wc_printf(" ");
210 * list all forgotten rooms
212 void zapped_list(void)
214 WCTemplputParams SubTP;
217 output_headers(1, 1, 1, 0, 0, 0);
218 memset(&SubTP, 0, sizeof(WCTemplputParams));
219 Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
220 SubTP.Filter.ContextType = CTX_STRBUF;
222 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
228 wc_printf("<br /><br />\n");
229 wc_printf(_("Click on any room to un-zap it and goto that room.\n"));
230 do_template("endbox", NULL);
236 * read this room's info file (set v to 1 for verbose mode)
238 void readinfo(StrBuf *Target, WCTemplputParams *TP)
243 int fullinfo_len = 0;
246 serv_getln(buf, sizeof buf);
249 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
250 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
251 strcpy(&fullinfo[fullinfo_len], buf);
252 fullinfo_len += strlen(buf);
256 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
257 strcpy(&briefinfo[50], "...");
259 wc_printf("<div class=\"infos\" "
260 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
264 wc_printf("</div><div id=\"room_infos\" style=\"display:none;\">");
265 wc_printf("<img class=\"close_infos\" "
266 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
267 "src=\"static/closewindow.gif\" alt=\"%s\" width=\"16\" height=\"16\">",
282 * Display room banner icon.
283 * The server doesn't actually need the room name, but we supply it in
284 * order to keep the browser from using a cached icon from another room.
286 void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP)
290 serv_puts("OIMG _roompic_");
291 serv_getln(buf, sizeof buf);
293 wc_printf("<img height=\"64px\" src=\"image?name=_roompic_&room=");
294 urlescputs(ChrPtr(WC->CurRoom.name));
297 serv_getln(buf, sizeof buf);
299 else if (WC->CurRoom.view == VIEW_ADDRESSBOOK) {
300 wc_printf("<img class=\"roompic\" alt=\"\" src=\""
301 "static/viewcontacts_48x.gif"
305 else if ( (WC->CurRoom.view == VIEW_CALENDAR) || (WC->CurRoom.view == VIEW_CALBRIEF) ) {
306 wc_printf("<img class=\"roompic\" alt=\"\" src=\""
307 "static/calarea_48x.gif"
308 "\" width=\"48\" height=\"48\">"
311 else if (WC->CurRoom.view == VIEW_TASKS) {
312 wc_printf("<img class=\"roompic\" alt=\"\" src=\""
313 "static/taskmanag_48x.gif"
314 "\" width=\"48\" height=\"48\">"
317 else if (WC->CurRoom.view == VIEW_NOTES) {
318 wc_printf("<img class=\"roompic\" alt=\"\" src=\""
319 "static/storenotes_48x.gif"
320 "\" width=\"48\" height=\"48\">"
323 else if (WC->CurRoom.view == VIEW_MAILBOX) {
324 wc_printf("<img class=\"roompic\" alt=\"\" src=\""
325 "static/privatemess_48x.gif"
326 "\" width=\"48\" height=\"48\">"
330 wc_printf("<img class=\"roompic\" alt=\"\" src=\""
331 "static/chatrooms_48x.gif"
332 "\" width=\"48\" height=\"48\">"
341 * Display the current view and offer an option to change it
343 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
347 wc_printf("<form name=\"viewomatic\" action=\"changeview\">\n");
348 wc_printf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
349 wc_printf("<label for=\"view_name\">");
350 wc_printf(_("View as:"));
351 wc_printf("</label> "
352 "<select name=\"newview\" size=\"1\" "
353 "id=\"view_name\" class=\"selectbox\" "
354 "OnChange=\"location.href=viewomatic.newview.options"
355 "[selectedIndex].value\">\n");
357 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
359 * Only offer the views that make sense, given the default
360 * view for the room. For example, don't offer a Calendar
361 * view in a non-Calendar room.
364 (i == WC->CurRoom.view)
365 || (i == WC->CurRoom.defview) /* default */
366 || ( (i == 0) && (WC->CurRoom.defview == 1) ) /* mail or bulletin */
367 || ( (i == 1) && (WC->CurRoom.defview == 0) ) /* mail or bulletin */
368 /* || ( (i == 7) && (WC->CurRoom.defview == 3) ) (calendar list temporarily disabled) */
371 wc_printf("<option %s value=\"changeview?view=%d\">",
372 ((i == WC->CurRoom.view) ? "selected" : ""),
374 escputs(viewdefs[i]);
375 wc_printf("</option>\n");
378 wc_printf("</select></div></form>\n");
383 * Display a search box
385 void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP)
387 wc_printf("<form name=\"searchomatic\" action=\"do_search\">\n");
388 wc_printf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
389 wc_printf("<label for=\"srchquery\">");
390 wc_printf(_("Search: "));
391 wc_printf("</label><input ");
392 wc_printf("%s", WC->serv_info->serv_fulltext_enabled ? "" : "disabled ");
393 wc_printf("type=\"text\" name=\"query\" id=\"srchquery\" size=\"15\" maxlength=\"128\" class=\"inputbox\">\n"
395 wc_printf("</div></form>\n");
400 * Embed the room banner
402 * got The information returned from a GOTO server command
403 * navbar_style Determines which navigation buttons to display
407 void embed_room_banner(char *got, int navbar_style) {
411 char with_files[256];
415 * We need to have the information returned by a GOTO server command.
416 * If it isn't supplied, we fake it by issuing our own GOTO.
419 memset(buf, '0', 20);
421 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
422 serv_getln(buf, sizeof buf);
426 /* The browser needs some information for its own use */
427 wc_printf("<script type=\"text/javascript\"> \n"
428 " room_is_trash = %d; \n"
430 ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
434 * If the user happens to select the "make this my start page" link,
435 * we want it to remember the URL as a "/dotskip" one instead of
436 * a "skip" or "gotonext" or something like that.
438 if (WCC->Hdr->this_page == NULL) {
439 WCC->Hdr->this_page = NewStrBuf();
441 StrBufPrintf(WCC->Hdr->this_page,
443 ChrPtr(WC->CurRoom.name)
446 /* Check for new mail. */
447 WC->new_mail = extract_int(&got[4], 9);
448 WC->CurRoom.view = extract_int(&got[4], 11);
450 /* Is this a directory room and does it contain files and how many? */
451 if ((WC->CurRoom.QRFlags & QR_DIRECTORY) && (WC->CurRoom.QRFlags & QR_VISDIR))
454 serv_getln(buf2, sizeof buf2);
455 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
457 snprintf (with_files, sizeof with_files,
458 "; <a href=\"do_template?template=files\"> %d %s </a>",
460 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
463 strcpy (with_files, "");
465 svprintf(HKEY("NUMMSGS"), WCS_STRING,
466 _("%d new of %d messages%s"),
467 extract_int(&got[4], 1),
468 extract_int(&got[4], 2),
471 svcallback("ROOMPIC", embed_room_graphic);
472 svcallback("ROOMINFO", readinfo);
473 svcallback("VIEWOMATIC", embed_view_o_matic);
474 svcallback("SEARCHOMATIC", embed_search_o_matic);
475 svcallback("START", offer_start_page);
477 do_template("roombanner", NULL);
478 /* roombanner contains this for mobile */
479 if (navbar_style != navbar_none && (WC->is_mobile < 1)) {
481 wc_printf("<div id=\"navbar\"><ul>");
483 if (navbar_style == navbar_default) wc_printf(
484 "<li class=\"ungoto\">"
485 "<a href=\"ungoto\">"
486 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
487 "<span class=\"navbar_link\">%s</span></A>"
488 "</li>\n", _("Ungoto")
491 if ( (navbar_style == navbar_default) && (WC->CurRoom.view == VIEW_BBS) ) {
493 "<li class=\"newmess\">"
494 "<a href=\"readnew\">"
495 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
496 "<span class=\"navbar_link\">%s</span></A>"
497 "</li>\n", _("Read new messages")
501 if (navbar_style == navbar_default) {
502 switch(WC->CurRoom.view) {
503 case VIEW_ADDRESSBOOK:
505 "<li class=\"viewcontacts\">"
506 "<a href=\"readfwd\">"
507 "<img src=\"static/viewcontacts_24x.gif\" "
508 "alt=\"\" width=\"24\" height=\"24\">"
509 "<span class=\"navbar_link\">"
511 "</span></a></li>\n", _("View contacts")
516 "<li class=\"staskday\">"
517 "<a href=\"readfwd?calview=day\">"
518 "<img src=\"static/taskday2_24x.gif\" "
519 "alt=\"\" width=\"24\" height=\"24\">"
520 "<span class=\"navbar_link\">"
522 "</span></a></li>\n", _("Day view")
525 "<li class=\"monthview\">"
526 "<a href=\"readfwd?calview=month\">"
527 "<img src=\"static/monthview2_24x.gif\" "
528 "alt=\"\" width=\"24\" height=\"24\">"
529 "<span class=\"navbar_link\">"
531 "</span></a></li>\n", _("Month view")
536 "<li class=\"monthview\">"
537 "<a href=\"readfwd?calview=month\">"
538 "<img src=\"static/monthview2_24x.gif\" "
539 "alt=\"\" width=\"24\" height=\"24\">"
540 "<span class=\"navbar_link\">"
542 "</span></a></li>\n", _("Calendar list")
547 "<li class=\"taskmanag\">"
548 "<a href=\"readfwd\">"
549 "<img src=\"static/taskmanag_24x.gif\" "
550 "alt=\"\" width=\"24\" height=\"24\">"
551 "<span class=\"navbar_link\">"
553 "</span></a></li>\n", _("View tasks")
558 "<li class=\"viewnotes\">"
559 "<a href=\"readfwd\">"
560 "<img src=\"static/viewnotes_24x.gif\" "
561 "alt=\"\" width=\"24\" height=\"24\">"
562 "<span class=\"navbar_link\">"
564 "</span></a></li>\n", _("View notes")
569 "<li class=\"readallmess\">"
570 "<a id=\"m_refresh\" href=\"readfwd\">"
571 "<img src=\"static/readallmess3_24x.gif\" "
572 "alt=\"\" width=\"24\" height=\"24\">"
573 "<span class=\"navbar_link\">"
575 "</span></a></li>\n", _("Refresh message list")
580 "<li class=\"readallmess\">"
581 "<a href=\"wiki?page=home\">"
582 "<img src=\"static/readallmess3_24x.gif\" "
583 "alt=\"\" width=\"24\" height=\"24\">"
584 "<span class=\"navbar_link\">"
586 "</span></a></li>\n", _("Wiki home")
591 "<li class=\"readallmess\">"
592 "<a href=\"readfwd\">"
593 "<img src=\"static/readallmess3_24x.gif\" "
594 "alt=\"\" width=\"24\" height=\"24\">"
595 "<span class=\"navbar_link\">"
597 "</span></a></li>\n", _("Read all messages")
603 if (navbar_style == navbar_default) {
604 switch(WC->CurRoom.view) {
605 case VIEW_ADDRESSBOOK:
607 "<li class=\"addnewcontact\">"
608 "<a href=\"display_enter\">"
609 "<img src=\"static/addnewcontact_24x.gif\" "
610 "alt=\"\" width=\"24\" height=\"24\">"
611 "<span class=\"navbar_link\">"
613 "</span></a></li>\n", _("Add new contact")
618 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
619 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
620 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
621 if (havebstr("day" )) wc_printf("?day=%s", bstr("day"));
623 "<img src=\"static/addevent_24x.gif\" "
624 "alt=\"\" width=\"24\" height=\"24\">"
625 "<span class=\"navbar_link\">"
627 "</span></a></li>\n", _("Add new event")
632 "<li class=\"newmess\">"
633 "<a href=\"display_enter\">"
634 "<img src=\"static/newmess3_24x.gif\" "
635 "alt=\"\" width=\"24\" height=\"24\">"
636 "<span class=\"navbar_link\">"
638 "</span></a></li>\n", _("Add new task")
643 "<li class=\"enternewnote\">"
644 "<a href=\"add_new_note\">"
645 "<img src=\"static/enternewnote_24x.gif\" "
646 "alt=\"\" width=\"24\" height=\"24\">"
647 "<span class=\"navbar_link\">"
649 "</span></a></li>\n", _("Add new note")
653 safestrncpy(buf, bstr("page"), sizeof buf);
654 if (IsEmptyStr(buf)) {
655 safestrncpy(buf, "home", sizeof buf);
659 "<li class=\"newmess\">"
660 "<a href=\"display_enter?page=%s\">"
661 "<img src=\"static/newmess3_24x.gif\" "
662 "alt=\"\" width=\"24\" height=\"24\">"
663 "<span class=\"navbar_link\">"
665 "</span></a></li>\n", buf, _("Edit this page")
668 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
669 /* already viewing history; display a link to the current page */
671 "<li class=\"newmess\">"
672 "<a href=\"wiki?page=%s\">"
673 "<img src=\"static/newmess3_24x.gif\" "
674 "alt=\"\" width=\"24\" height=\"24\">"
675 "<span class=\"navbar_link\">"
677 "</span></a></li>\n", buf, _("Current version")
681 /* display a link to the history */
683 "<li class=\"newmess\">"
684 "<a href=\"wiki_history?page=%s\">"
685 "<img src=\"static/newmess3_24x.gif\" "
686 "alt=\"\" width=\"24\" height=\"24\">"
687 "<span class=\"navbar_link\">"
689 "</span></a></li>\n", buf, _("History")
695 "<li class=\"newmess\">"
696 "<a href=\"display_enter\">"
697 "<img src=\"static/newmess3_24x.gif\" "
698 "alt=\"\" width=\"24\" height=\"24\">"
699 "<span class=\"navbar_link\">"
701 "</span></a></li>\n", _("Write mail")
704 "<li class=\"newmess\">"
705 "<a href=\"javascript:deleteAllSelectedMessages();\">"
706 "<img src=\"static/delete.gif\" "
707 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
709 "</span></a></li>\n", _("Delete")
714 "<li class=\"newmess\">"
715 "<a href=\"display_enter\">"
716 "<img src=\"static/newmess3_24x.gif\" "
717 "alt=\"\" width=\"24\" height=\"24\">"
718 "<span class=\"navbar_link\">"
720 "</span></a></li>\n", _("Enter a message")
726 if (navbar_style == navbar_default) wc_printf(
727 "<li class=\"skipthisroom\">"
730 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
731 "width=\"24\" height=\"24\">"
732 "<span class=\"navbar_link\">%s</span></a>"
734 _("Leave all messages marked as unread, go to next room with unread messages"),
738 if (navbar_style == navbar_default) wc_printf(
739 "<li class=\"markngo\">"
740 "<a href=\"gotonext\" "
742 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
743 "width=\"24\" height=\"24\">"
744 "<span class=\"navbar_link\">%s</span></a>"
746 _("Mark all messages as read, go to next room with unread messages"),
750 wc_printf("</ul></div>\n");
757 * back end routine to take the session to a new room
759 long gotoroom(const StrBuf *gname)
763 static long ls = (-1L);
766 /* store ungoto information */
767 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
771 /* move to the new room */
772 serv_printf("GOTO %s", ChrPtr(gname));
773 StrBuf_ServGetln(Buf);
774 if (GetServerStatus(Buf, &err) != 2) {
775 serv_puts("GOTO _BASEROOM_");
776 StrBuf_ServGetln(Buf);
778 * well, we know that this is the fallback case,
779 * but we're interested that the first command
780 * didn't work out in first place.
782 if (GetServerStatus(Buf, NULL) != 2) {
787 ParseGoto(&WCC->CurRoom, Buf);
789 remove_march(WCC->CurRoom.name);
790 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
798 void ParseGoto(folder *room, StrBuf *Line)
806 if (StrLength(Line) < 4) {
810 /* ignore the commandstate... */
811 Pos = ChrPtr(Line) + 4;
813 if (room->RoomNameParts != NULL)
816 for (i=0; i < room->nRoomNameParts; i++)
817 FreeStrBuf(&room->RoomNameParts[i]);
818 free(room->RoomNameParts);
819 room->RoomNameParts = NULL;
824 pBuf = NewStrBufPlain(NULL, StrLength(Line));
827 memset(room, 0, sizeof(folder));
830 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
832 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
833 if (room->nNewMessages > 0)
834 room->RAFlags |= UA_HASNEWMSGS;
836 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
838 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
840 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
842 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
843 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
845 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
847 flag = StrBufExtractNext_long(Line, &Pos, '|');
848 if (WCC->is_aide || flag) {
849 room->RAFlags |= UA_ADMINALLOWED;
852 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
854 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
856 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
858 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
860 flag = StrBufExtractNext_long(Line, &Pos, '|');
862 room->RAFlags |= UA_ISTRASH; // wc_is_trash
864 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
866 /* find out, whether we are in a sub-room */
867 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
868 if (room->nRoomNameParts > 1)
873 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
874 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
875 for (i=0; i < room->nRoomNameParts; i++)
877 room->RoomNameParts[i] = NewStrBuf();
878 StrBufExtract_NextToken(room->RoomNameParts[i],
879 room->name, &Pos, '\\');
883 /* Private mailboxes on the main floor get remapped to the personal folder */
884 if ((room->QRFlags & QR_MAILBOX) &&
885 (room->floorid == 0))
887 room->floorid = VIRTUAL_MY_FLOOR;
888 if ((room->nRoomNameParts == 1) &&
889 (StrLength(room->name) == 4) &&
890 (strcmp(ChrPtr(room->name), "Mail") == 0))
896 /* get a pointer to the floor we're on: */
897 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
898 room->Floor = (const Floor*) vFloor;
901 void LoadRoomAide(void)
906 if (WCC->CurRoom.RoomAideLoaded)
909 WCC->CurRoom.RoomAideLoaded = 1;
912 StrBuf_ServGetln(Buf);
913 if (GetServerStatus(Buf, NULL) != 2) {
914 FlushStrBuf(WCC->CurRoom.RoomAide);
915 AppendImportantMessage (ChrPtr(Buf) + 4,
920 Pos = ChrPtr(Buf) + 4;
922 FreeStrBuf(&WCC->CurRoom.RoomAide);
923 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
925 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
930 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
936 StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
940 void LoadRoomXA (void)
945 if (WCC->CurRoom.XALoaded)
948 WCC->CurRoom.XALoaded = 1;
951 StrBuf_ServGetln(Buf);
952 if (GetServerStatus(Buf, NULL) != 2) {
953 FlushStrBuf(WCC->CurRoom.XAPass);
954 FlushStrBuf(WCC->CurRoom.Directory);
956 AppendImportantMessage (ChrPtr(Buf) + 4,
961 Pos = ChrPtr(Buf) + 4;
963 FreeStrBuf(&WCC->CurRoom.XAPass);
964 FreeStrBuf(&WCC->CurRoom.Directory);
966 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
967 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
969 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
970 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
971 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
972 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
973 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
974 WCC->CurRoom.DefView = StrBufExtractNext_long(Buf, &Pos, '|');
975 /* QR2Flags, we already know them... */
981 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
987 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
989 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
995 StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
997 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
1003 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
1005 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1007 wcsession *WCC = WC;
1011 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.DefView);
1015 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
1017 wcsession *WCC = WC;
1025 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1026 return CheckThis == WCC->CurRoom.Order;
1029 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1031 wcsession *WCC = WC;
1039 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1040 return CheckThis == WCC->CurRoom.DefView;
1050 void smart_goto(const StrBuf *next_room) {
1051 gotoroom(next_room);
1052 readloop(readnew, eUseDefault);
1058 * mark all messages in current room as having been read
1060 void slrp_highest(void)
1064 serv_puts("SLRP HIGHEST");
1065 serv_getln(buf, sizeof buf);
1069 typedef struct __room_states {
1084 * Set/clear/read the "self-service list subscribe" flag for a room
1086 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1087 * returns the new value.
1090 int self_service(int newval) {
1091 int current_value = 0;
1097 int flags, floor, order, view, flags2;
1100 serv_getln(buf, sizeof buf);
1101 if (buf[0] != '2') return(0);
1103 extract_token(name, &buf[4], 0, '|', sizeof name);
1104 extract_token(password, &buf[4], 1, '|', sizeof password);
1105 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1106 flags = extract_int(&buf[4], 3);
1107 floor = extract_int(&buf[4], 4);
1108 order = extract_int(&buf[4], 5);
1109 view = extract_int(&buf[4], 6);
1110 flags2 = extract_int(&buf[4], 7);
1112 if (flags2 & QR2_SELFLIST) {
1120 flags2 = flags2 | QR2_SELFLIST;
1122 else if (newval == 0) {
1123 flags2 = flags2 & ~QR2_SELFLIST;
1126 return(current_value);
1129 if (newval != current_value) {
1130 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1131 name, password, dirname, flags,
1132 floor, order, view, flags2);
1133 serv_getln(buf, sizeof buf);
1140 int is_selflist(room_states *RoomFlags)
1142 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1145 int is_publiclist(room_states *RoomFlags)
1147 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1150 int is_moderatedlist(room_states *RoomFlags)
1152 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1156 * Set/clear/read the "self-service list subscribe" flag for a room
1158 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1159 * returns the new value.
1162 int get_roomflags(room_states *RoomOps)
1167 serv_getln(buf, sizeof buf);
1168 if (buf[0] != '2') return(0);
1170 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1171 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1172 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1173 RoomOps->flags = extract_int(&buf[4], 3);
1174 RoomOps->floor = extract_int(&buf[4], 4);
1175 RoomOps->order = extract_int(&buf[4], 5);
1176 RoomOps->view = extract_int(&buf[4], 6);
1177 RoomOps->flags2 = extract_int(&buf[4], 7);
1181 int set_roomflags(room_states *RoomOps)
1185 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1194 serv_getln(buf, sizeof buf);
1204 * display the form for editing a room
1206 void display_editroom(void)
1212 char remote_room[128];
1215 char er_password[10];
1216 char er_dirname[15];
1217 char er_roomaide[26];
1224 char *not_shared_with = NULL;
1227 int floorpolicy = 0;
1229 char pop3_host[128];
1234 if (IsEmptyStr(tab)) tab = "admin";
1237 load_floorlist(Buf);
1239 output_headers(1, 1, 1, 0, 0, 0);
1241 wc_printf("<div class=\"fix_scrollbar_bug\">");
1243 wc_printf("<br />\n");
1245 /* print the tabbed dialog */
1246 wc_printf("<div align=\"center\">");
1247 wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1248 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1251 wc_printf("<td class=\"");
1252 if (!strcmp(tab, "admin")) {
1253 wc_printf(" tab_cell_label\">");
1254 wc_printf(_("Administration"));
1257 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1258 wc_printf(_("Administration"));
1261 wc_printf("</td>\n");
1262 wc_printf("<td> </td>\n");
1264 if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1266 wc_printf("<td class=\"");
1267 if (!strcmp(tab, "config")) {
1268 wc_printf(" tab_cell_label\">");
1269 wc_printf(_("Configuration"));
1272 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1273 wc_printf(_("Configuration"));
1276 wc_printf("</td>\n");
1277 wc_printf("<td> </td>\n");
1279 wc_printf("<td class=\"");
1280 if (!strcmp(tab, "expire")) {
1281 wc_printf(" tab_cell_label\">");
1282 wc_printf(_("Message expire policy"));
1285 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1286 wc_printf(_("Message expire policy"));
1289 wc_printf("</td>\n");
1290 wc_printf("<td> </td>\n");
1292 wc_printf("<td class=\"");
1293 if (!strcmp(tab, "access")) {
1294 wc_printf(" tab_cell_label\">");
1295 wc_printf(_("Access controls"));
1298 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1299 wc_printf(_("Access controls"));
1302 wc_printf("</td>\n");
1303 wc_printf("<td> </td>\n");
1305 wc_printf("<td class=\"");
1306 if (!strcmp(tab, "sharing")) {
1307 wc_printf(" tab_cell_label\">");
1308 wc_printf(_("Sharing"));
1311 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1312 wc_printf(_("Sharing"));
1315 wc_printf("</td>\n");
1316 wc_printf("<td> </td>\n");
1318 wc_printf("<td class=\"");
1319 if (!strcmp(tab, "listserv")) {
1320 wc_printf(" tab_cell_label\">");
1321 wc_printf(_("Mailing list service"));
1324 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1325 wc_printf(_("Mailing list service"));
1328 wc_printf("</td>\n");
1329 wc_printf("<td> </td>\n");
1333 wc_printf("<td class=\"");
1334 if (!strcmp(tab, "feeds")) {
1335 wc_printf(" tab_cell_label\">");
1336 wc_printf(_("Remote retrieval"));
1339 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1340 wc_printf(_("Remote retrieval"));
1343 wc_printf("</td>\n");
1344 wc_printf("<td> </td>\n");
1346 wc_printf("</tr></table>\n");
1347 wc_printf("</div>\n");
1348 /* end tabbed dialog */
1350 wc_printf("<script type=\"text/javascript\">"
1351 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1355 /* begin content of whatever tab is open now */
1357 if (!strcmp(tab, "admin")) {
1358 wc_printf("<div class=\"tabcontent\">");
1360 "<li><a href=\"delete_room\" "
1361 "onClick=\"return confirm('");
1362 wc_printf(_("Are you sure you want to delete this room?"));
1363 wc_printf("');\">\n");
1364 wc_printf(_("Delete this room"));
1366 "<li><a href=\"display_editroompic?which_room=");
1367 urlescputs(ChrPtr(WC->CurRoom.name));
1369 wc_printf(_("Set or change the icon for this room's banner"));
1371 "<li><a href=\"display_editinfo\">\n");
1372 wc_printf(_("Edit this room's Info file"));
1375 wc_printf("</div>");
1378 if (!strcmp(tab, "config")) {
1379 wc_printf("<div class=\"tabcontent\">");
1381 serv_getln(buf, sizeof buf);
1383 if (!strncmp(buf, "550", 3)) {
1384 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1385 _("Higher access is required to access this function.")
1388 else if (buf[0] != '2') {
1389 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1392 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1393 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1394 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1395 er_flags = extract_int(&buf[4], 3);
1396 er_floor = extract_int(&buf[4], 4);
1397 er_flags2 = extract_int(&buf[4], 7);
1399 wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1400 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1402 wc_printf("<ul><li>");
1403 wc_printf(_("Name of room: "));
1404 wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1410 wc_printf(_("Resides on floor: "));
1411 wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1412 if (er_flags & QR_MAILBOX)
1413 wc_printf("disabled >\n");
1414 for (i = 0; i < 128; ++i)
1415 if (!IsEmptyStr(floorlist[i])) {
1416 wc_printf("<OPTION ");
1418 wc_printf("SELECTED ");
1419 wc_printf("VALUE=\"%d\">", i);
1420 escputs(floorlist[i]);
1421 wc_printf("</OPTION>\n");
1423 wc_printf("</select>\n");
1426 wc_printf(_("Type of room:"));
1427 wc_printf("<ul>\n");
1429 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1430 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1431 wc_printf("CHECKED ");
1432 wc_printf("OnChange=\""
1433 " if (this.form.type[0].checked == true) { "
1434 " this.form.er_floor.disabled = false; "
1437 wc_printf(_("Public (automatically appears to everyone)"));
1440 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1441 if ((er_flags & QR_PRIVATE) &&
1442 (er_flags & QR_GUESSNAME))
1443 wc_printf("CHECKED ");
1444 wc_printf(" OnChange=\""
1445 " if (this.form.type[1].checked == true) { "
1446 " this.form.er_floor.disabled = false; "
1449 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1451 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1452 if ((er_flags & QR_PRIVATE) &&
1453 (er_flags & QR_PASSWORDED))
1454 wc_printf("CHECKED ");
1455 wc_printf(" OnChange=\""
1456 " if (this.form.type[2].checked == true) { "
1457 " this.form.er_floor.disabled = false; "
1460 wc_printf(_("Private - require password: "));
1461 wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1464 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1465 if ((er_flags & QR_PRIVATE)
1466 && ((er_flags & QR_GUESSNAME) == 0)
1467 && ((er_flags & QR_PASSWORDED) == 0))
1468 wc_printf("CHECKED ");
1469 wc_printf(" OnChange=\""
1470 " if (this.form.type[3].checked == true) { "
1471 " this.form.er_floor.disabled = false; "
1474 wc_printf(_("Private - invitation only"));
1476 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1477 if (er_flags & QR_MAILBOX)
1478 wc_printf("CHECKED ");
1479 wc_printf (" OnChange=\""
1480 " if (this.form.type[4].checked == true) { "
1481 " this.form.er_floor.disabled = true; "
1484 wc_printf(_("Personal (mailbox for you only)"));
1486 wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1488 wc_printf(_("If private, cause current users to forget room"));
1490 wc_printf("\n</ul>\n");
1492 wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1493 if (er_flags & QR_PREFONLY)
1494 wc_printf("CHECKED ");
1496 wc_printf(_("Preferred users only"));
1498 wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1499 if (er_flags & QR_READONLY)
1500 wc_printf("CHECKED ");
1502 wc_printf(_("Read-only room"));
1504 wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1505 if (er_flags2 & QR2_COLLABDEL)
1506 wc_printf("CHECKED ");
1508 wc_printf(_("All users allowed to post may also delete messages"));
1510 /** directory stuff */
1511 wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1512 if (er_flags & QR_DIRECTORY)
1513 wc_printf("CHECKED ");
1515 wc_printf(_("File directory room"));
1517 wc_printf("\n<ul><li>");
1518 wc_printf(_("Directory name: "));
1519 wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1522 wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1523 if (er_flags & QR_UPLOAD)
1524 wc_printf("CHECKED ");
1526 wc_printf(_("Uploading allowed"));
1528 wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1529 if (er_flags & QR_DOWNLOAD)
1530 wc_printf("CHECKED ");
1532 wc_printf(_("Downloading allowed"));
1534 wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1535 if (er_flags & QR_VISDIR)
1536 wc_printf("CHECKED ");
1538 wc_printf(_("Visible directory"));
1539 wc_printf("</ul>\n");
1541 /** end of directory stuff */
1543 wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1544 if (er_flags & QR_NETWORK)
1545 wc_printf("CHECKED ");
1547 wc_printf(_("Network shared room"));
1549 wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1550 if (er_flags & QR_PERMANENT)
1551 wc_printf("CHECKED ");
1553 wc_printf(_("Permanent (does not auto-purge)"));
1555 wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1556 if (er_flags2 & QR2_SUBJECTREQ)
1557 wc_printf("CHECKED ");
1559 wc_printf(_("Subject Required (Force users to specify a message subject)"));
1561 /** start of anon options */
1563 wc_printf("\n<li>");
1564 wc_printf(_("Anonymous messages"));
1565 wc_printf("<ul>\n");
1567 wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1568 if (((er_flags & QR_ANONONLY) == 0)
1569 && ((er_flags & QR_ANONOPT) == 0))
1570 wc_printf("CHECKED ");
1572 wc_printf(_("No anonymous messages"));
1574 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1575 if (er_flags & QR_ANONONLY)
1576 wc_printf("CHECKED ");
1578 wc_printf(_("All messages are anonymous"));
1580 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1581 if (er_flags & QR_ANONOPT)
1582 wc_printf("CHECKED ");
1584 wc_printf(_("Prompt user when entering messages"));
1585 wc_printf("</ul>\n");
1587 /* end of anon options */
1590 wc_printf(_("Room aide: "));
1592 serv_getln(buf, sizeof buf);
1593 if (buf[0] != '2') {
1594 wc_printf("<em>%s</em>\n", &buf[4]);
1596 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1597 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1600 wc_printf("</ul><CENTER>\n");
1601 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1602 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1604 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1610 wc_printf("</div>");
1614 /* Sharing the room with other Citadel nodes... */
1615 if (!strcmp(tab, "sharing")) {
1616 wc_printf("<div class=\"tabcontent\">");
1618 shared_with = strdup("");
1619 not_shared_with = strdup("");
1621 /** Learn the current configuration */
1622 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1623 serv_getln(buf, sizeof buf);
1624 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1625 extract_token(node, buf, 0, '|', sizeof node);
1626 not_shared_with = realloc(not_shared_with,
1627 strlen(not_shared_with) + 32);
1628 strcat(not_shared_with, node);
1629 strcat(not_shared_with, "\n");
1633 serv_getln(buf, sizeof buf);
1634 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1635 extract_token(cmd, buf, 0, '|', sizeof cmd);
1636 extract_token(node, buf, 1, '|', sizeof node);
1637 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1638 if (!strcasecmp(cmd, "ignet_push_share")) {
1639 shared_with = realloc(shared_with,
1640 strlen(shared_with) + 32);
1641 strcat(shared_with, node);
1642 if (!IsEmptyStr(remote_room)) {
1643 strcat(shared_with, "|");
1644 strcat(shared_with, remote_room);
1646 strcat(shared_with, "\n");
1650 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1651 extract_token(buf, shared_with, i, '\n', sizeof buf);
1652 extract_token(node, buf, 0, '|', sizeof node);
1653 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1654 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1655 if (!strcasecmp(node, cmd)) {
1656 remove_token(not_shared_with, j, '\n');
1661 /* Display the stuff */
1662 wc_printf("<CENTER><br />"
1663 "<table border=1 cellpadding=5><tr>"
1665 wc_printf(_("Shared with"));
1666 wc_printf("</I></B></td>"
1668 wc_printf(_("Not shared with"));
1669 wc_printf("</I></B></td></tr>\n"
1670 "<tr><td VALIGN=TOP>\n");
1672 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1673 wc_printf(_("Remote node name"));
1674 wc_printf("</td><td>");
1675 wc_printf(_("Remote room name"));
1676 wc_printf("</td><td>");
1677 wc_printf(_("Actions"));
1678 wc_printf("</td></tr>\n");
1680 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1681 extract_token(buf, shared_with, i, '\n', sizeof buf);
1682 extract_token(node, buf, 0, '|', sizeof node);
1683 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1684 if (!IsEmptyStr(node)) {
1685 wc_printf("<form method=\"POST\" action=\"netedit\">");
1686 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1687 wc_printf("<tr><td>%s</td>\n", node);
1690 if (!IsEmptyStr(remote_room)) {
1691 escputs(remote_room);
1697 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1698 "VALUE=\"ignet_push_share|");
1700 if (!IsEmptyStr(remote_room)) {
1702 urlescputs(remote_room);
1705 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1706 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1707 wc_printf("<input type=\"submit\" "
1708 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1709 wc_printf("</td></tr></form>\n");
1713 wc_printf("</table>\n");
1714 wc_printf("</td><td VALIGN=TOP>\n");
1715 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1716 wc_printf(_("Remote node name"));
1717 wc_printf("</td><td>");
1718 wc_printf(_("Remote room name"));
1719 wc_printf("</td><td>");
1720 wc_printf(_("Actions"));
1721 wc_printf("</td></tr>\n");
1723 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1724 extract_token(node, not_shared_with, i, '\n', sizeof node);
1725 if (!IsEmptyStr(node)) {
1726 wc_printf("<form method=\"POST\" action=\"netedit\">");
1727 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1728 wc_printf("<tr><td>");
1730 wc_printf("</td><td>"
1731 "<input type=\"INPUT\" "
1735 wc_printf("<input type=\"hidden\" "
1737 "VALUE=\"ignet_push_share|");
1740 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1741 "VALUE=\"sharing\">\n");
1742 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1743 "VALUE=\"add\">\n");
1744 wc_printf("<input type=\"submit\" "
1745 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1746 wc_printf("</td></tr></form>\n");
1750 wc_printf("</table>\n");
1751 wc_printf("</td></tr>"
1752 "</table></CENTER><br />\n"
1753 "<I><B>%s</B><ul><li>", _("Notes:"));
1754 wc_printf(_("When sharing a room, "
1755 "it must be shared from both ends. Adding a node to "
1756 "the 'shared' list sends messages out, but in order to"
1757 " receive messages, the other nodes must be configured"
1758 " to send messages out to your system as well. "
1759 "<li>If the remote room name is blank, it is assumed "
1760 "that the room name is identical on the remote node."
1761 "<li>If the remote room name is different, the remote "
1762 "node must also configure the name of the room here."
1766 wc_printf("</div>");
1769 if (not_shared_with != NULL)
1770 free (not_shared_with);
1772 /* Mailing list management */
1773 if (!strcmp(tab, "listserv")) {
1774 room_states RoomFlags;
1775 wc_printf("<div class=\"tabcontent\">");
1777 wc_printf("<br /><center>"
1778 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1779 "<tr><td VALIGN=TOP>");
1781 wc_printf(_("<i>The contents of this room are being "
1782 "mailed <b>as individual messages</b> "
1783 "to the following list recipients:"
1784 "</i><br /><br />\n"));
1787 serv_getln(buf, sizeof buf);
1788 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1789 extract_token(cmd, buf, 0, '|', sizeof cmd);
1790 if (!strcasecmp(cmd, "listrecp")) {
1791 extract_token(recp, buf, 1, '|', sizeof recp);
1794 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1797 wc_printf(_("(remove)"));
1798 wc_printf("</A><br />");
1801 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1802 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1803 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1804 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1805 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1806 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1807 wc_printf("</form>\n");
1809 wc_printf("</td><td VALIGN=TOP>\n");
1811 wc_printf(_("<i>The contents of this room are being "
1812 "mailed <b>in digest form</b> "
1813 "to the following list recipients:"
1814 "</i><br /><br />\n"));
1817 serv_getln(buf, sizeof buf);
1818 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1819 extract_token(cmd, buf, 0, '|', sizeof cmd);
1820 if (!strcasecmp(cmd, "digestrecp")) {
1821 extract_token(recp, buf, 1, '|', sizeof recp);
1824 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1828 wc_printf(_("(remove)"));
1829 wc_printf("</A><br />");
1832 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1833 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1834 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1835 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1836 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1837 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1838 wc_printf("</form>\n");
1840 wc_printf("</td></tr></table>\n");
1842 /** Pop open an address book -- begin **/
1843 wc_printf("<div align=right>"
1844 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1846 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1851 _("Add recipients from Contacts or other address books"),
1852 _("Add recipients from Contacts or other address books")
1854 /* Pop open an address book -- end **/
1856 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1858 get_roomflags (&RoomFlags);
1860 /* Self Service subscription? */
1861 wc_printf("<table><tr><td>\n");
1862 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1863 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1864 " <tr><td colspan=\"2\">\n",
1865 (is_selflist(&RoomFlags))?"checked":"");
1866 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1867 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1868 (is_https ? "https" : "http"),
1869 ChrPtr(WC->Hdr->HR.http_host));
1870 /* Public posting? */
1871 wc_printf("<tr><td>");
1872 wc_printf(_("Allow non-subscribers to mail to this room."));
1873 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1874 (is_publiclist(&RoomFlags))?"checked":"");
1876 /* Moderated List? */
1877 wc_printf("<tr><td>");
1878 wc_printf(_("Room post publication needs Aide permission."));
1879 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1880 (is_moderatedlist(&RoomFlags))?"checked":"");
1883 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1884 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1885 wc_printf("</table></form>");
1888 wc_printf("</CENTER>\n");
1889 wc_printf("</div>");
1893 /* Configuration of The Dreaded Auto-Purger */
1894 if (!strcmp(tab, "expire")) {
1895 wc_printf("<div class=\"tabcontent\">");
1897 serv_puts("GPEX room");
1898 serv_getln(buf, sizeof buf);
1899 if (!strncmp(buf, "550", 3)) {
1900 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1901 _("Higher access is required to access this function.")
1904 else if (buf[0] != '2') {
1905 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1908 roompolicy = extract_int(&buf[4], 0);
1909 roomvalue = extract_int(&buf[4], 1);
1911 serv_puts("GPEX floor");
1912 serv_getln(buf, sizeof buf);
1913 if (buf[0] == '2') {
1914 floorpolicy = extract_int(&buf[4], 0);
1915 floorvalue = extract_int(&buf[4], 1);
1918 wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1919 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1920 wc_printf("<table border=0 cellspacing=5>\n");
1921 wc_printf("<tr><td>");
1922 wc_printf(_("Message expire policy for this room"));
1923 wc_printf("<br />(");
1924 escputs(ChrPtr(WC->CurRoom.name));
1925 wc_printf(")</td><td>");
1926 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1927 ((roompolicy == 0) ? "CHECKED" : "") );
1928 wc_printf(_("Use the default policy for this floor"));
1929 wc_printf("<br />\n");
1930 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1931 ((roompolicy == 1) ? "CHECKED" : "") );
1932 wc_printf(_("Never automatically expire messages"));
1933 wc_printf("<br />\n");
1934 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1935 ((roompolicy == 2) ? "CHECKED" : "") );
1936 wc_printf(_("Expire by message count"));
1937 wc_printf("<br />\n");
1938 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1939 ((roompolicy == 3) ? "CHECKED" : "") );
1940 wc_printf(_("Expire by message age"));
1941 wc_printf("<br />");
1942 wc_printf(_("Number of messages or days: "));
1943 wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1944 wc_printf("</td></tr>\n");
1946 if (WC->axlevel >= 6) {
1947 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1948 wc_printf("<tr><td>");
1949 wc_printf(_("Message expire policy for this floor"));
1950 wc_printf("<br />(");
1951 escputs(floorlist[WC->CurRoom.floorid]);
1952 wc_printf(")</td><td>");
1953 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1954 ((floorpolicy == 0) ? "CHECKED" : "") );
1955 wc_printf(_("Use the system default"));
1956 wc_printf("<br />\n");
1957 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1958 ((floorpolicy == 1) ? "CHECKED" : "") );
1959 wc_printf(_("Never automatically expire messages"));
1960 wc_printf("<br />\n");
1961 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1962 ((floorpolicy == 2) ? "CHECKED" : "") );
1963 wc_printf(_("Expire by message count"));
1964 wc_printf("<br />\n");
1965 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1966 ((floorpolicy == 3) ? "CHECKED" : "") );
1967 wc_printf(_("Expire by message age"));
1968 wc_printf("<br />");
1969 wc_printf(_("Number of messages or days: "));
1970 wc_printf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1974 wc_printf("<CENTER>\n");
1975 wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1976 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1977 wc_printf(" ");
1978 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1979 wc_printf("</CENTER></td><tr>\n");
1981 wc_printf("</table>\n"
1982 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1987 wc_printf("</div>");
1990 /* Access controls */
1991 if (!strcmp(tab, "access")) {
1992 wc_printf("<div class=\"tabcontent\">");
1994 wc_printf("</div>");
1997 /* Fetch messages from remote locations */
1998 if (!strcmp(tab, "feeds")) {
1999 wc_printf("<div class=\"tabcontent\">");
2002 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
2003 wc_printf("</i><br />\n");
2005 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2006 "<tr class=\"even\"><th>");
2007 wc_printf(_("Remote host"));
2008 wc_printf("</th><th>");
2009 wc_printf(_("User name"));
2010 wc_printf("</th><th>");
2011 wc_printf(_("Password"));
2012 wc_printf("</th><th>");
2013 wc_printf(_("Keep messages on server?"));
2014 wc_printf("</th><th>");
2015 wc_printf(_("Interval"));
2016 wc_printf("</th><th> </th></tr>");
2019 serv_getln(buf, sizeof buf);
2021 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2022 extract_token(cmd, buf, 0, '|', sizeof cmd);
2023 if (!strcasecmp(cmd, "pop3client")) {
2024 safestrncpy(recp, &buf[11], sizeof recp);
2027 wc_printf("<tr class=\"%s\">",
2028 (bg ? "even" : "odd")
2032 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2037 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2041 wc_printf("<td>*****</td>"); /* Don't show the password */
2043 wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2045 wc_printf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2047 wc_printf("<td class=\"button_link\">");
2048 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2051 wc_printf(_("(remove)"));
2052 wc_printf("</a></td>");
2058 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2060 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2061 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2062 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2064 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2067 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2070 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2073 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2076 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2079 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2080 wc_printf("</td></tr>");
2081 wc_printf("</form></table>\n");
2083 wc_printf("<hr>\n");
2086 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2087 wc_printf("</i><br />\n");
2089 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2090 "<tr class=\"even\"><th>");
2091 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2092 wc_printf(_("Feed URL"));
2093 wc_printf("</th><th>");
2094 wc_printf("</th></tr>");
2097 serv_getln(buf, sizeof buf);
2099 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2100 extract_token(cmd, buf, 0, '|', sizeof cmd);
2101 if (!strcasecmp(cmd, "rssclient")) {
2102 safestrncpy(recp, &buf[10], sizeof recp);
2105 wc_printf("<tr class=\"%s\">",
2106 (bg ? "even" : "odd")
2110 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2114 wc_printf("<td class=\"button_link\">");
2115 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2118 wc_printf(_("(remove)"));
2119 wc_printf("</a></td>");
2125 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2127 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2128 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2129 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2131 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2132 "maxlength=\"256\" name=\"line_pop3host\">\n");
2135 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2136 wc_printf("</td></tr>");
2137 wc_printf("</form></table>\n");
2139 wc_printf("</div>");
2143 /* end content of whatever tab is open now */
2144 wc_printf("</div>\n");
2146 address_book_popup();
2152 * Toggle self-service list subscription
2154 void toggle_self_service(void) {
2155 room_states RoomFlags;
2157 get_roomflags (&RoomFlags);
2159 if (yesbstr("QR2_SelfList"))
2160 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2162 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2164 if (yesbstr("QR2_SMTP_PUBLIC"))
2165 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2167 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2169 if (yesbstr("QR2_Moderated"))
2170 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2172 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2173 if (yesbstr("QR2_SubsOnly"))
2174 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2176 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2178 set_roomflags (&RoomFlags);
2186 * save new parameters for a room
2193 StrBuf *er_password;
2195 StrBuf *er_roomaide;
2198 int er_listingorder;
2204 if (!havebstr("ok_button")) {
2205 strcpy(WC->ImportantMessage,
2206 _("Cancelled. Changes were not saved."));
2212 StrBuf_ServGetln(Buf);
2213 if (GetServerStatus(Buf, NULL) != 2) {
2214 StrBufCutLeft(Buf, 4);
2215 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2221 er_name = NewStrBuf();
2222 er_password = NewStrBuf();
2223 er_dirname = NewStrBuf();
2224 er_roomaide = NewStrBuf();
2226 StrBufCutLeft(Buf, 4);
2227 StrBufExtract_token(er_name, Buf, 0, '|');
2228 StrBufExtract_token(er_password, Buf, 1, '|');
2229 StrBufExtract_token(er_dirname, Buf, 2, '|');
2230 er_flags = StrBufExtract_int(Buf, 3, '|');
2231 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2232 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2233 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2235 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2236 if (StrLength(er_roomaide) == 0) {
2238 StrBuf_ServGetln(Buf);
2239 if (GetServerStatus(Buf, NULL) != 2) {
2240 FlushStrBuf(er_roomaide);
2242 StrBufCutLeft(Buf, 4);
2243 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2246 Ptr = sbstr("er_name");
2247 if (StrLength(Ptr) > 0) {
2248 FlushStrBuf(er_name);
2249 StrBufAppendBuf(er_name, Ptr, 0);
2252 Ptr = sbstr("er_password");
2253 if (StrLength(Ptr) > 0) {
2254 FlushStrBuf(er_password);
2255 StrBufAppendBuf(er_password, Ptr, 0);
2259 Ptr = sbstr("er_dirname");
2260 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2261 FlushStrBuf(er_dirname);
2262 StrBufAppendBuf(er_dirname, Ptr, 0);
2266 Ptr = sbstr("type");
2267 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2269 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2270 er_flags |= (QR_PRIVATE);
2272 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2273 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2275 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2276 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2278 if (!strcmp(ChrPtr(Ptr), "personal")) {
2279 er_flags |= QR_MAILBOX;
2281 er_flags &= ~QR_MAILBOX;
2284 if (yesbstr("prefonly")) {
2285 er_flags |= QR_PREFONLY;
2287 er_flags &= ~QR_PREFONLY;
2290 if (yesbstr("readonly")) {
2291 er_flags |= QR_READONLY;
2293 er_flags &= ~QR_READONLY;
2297 if (yesbstr("collabdel")) {
2298 er_flags2 |= QR2_COLLABDEL;
2300 er_flags2 &= ~QR2_COLLABDEL;
2303 if (yesbstr("permanent")) {
2304 er_flags |= QR_PERMANENT;
2306 er_flags &= ~QR_PERMANENT;
2309 if (yesbstr("subjectreq")) {
2310 er_flags2 |= QR2_SUBJECTREQ;
2312 er_flags2 &= ~QR2_SUBJECTREQ;
2315 if (yesbstr("network")) {
2316 er_flags |= QR_NETWORK;
2318 er_flags &= ~QR_NETWORK;
2321 if (yesbstr("directory")) {
2322 er_flags |= QR_DIRECTORY;
2324 er_flags &= ~QR_DIRECTORY;
2327 if (yesbstr("ulallowed")) {
2328 er_flags |= QR_UPLOAD;
2330 er_flags &= ~QR_UPLOAD;
2333 if (yesbstr("dlallowed")) {
2334 er_flags |= QR_DOWNLOAD;
2336 er_flags &= ~QR_DOWNLOAD;
2339 if (yesbstr("visdir")) {
2340 er_flags |= QR_VISDIR;
2342 er_flags &= ~QR_VISDIR;
2345 Ptr = sbstr("anon");
2347 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2348 if (!strcmp(ChrPtr(Ptr), "anononly"))
2349 er_flags |= QR_ANONONLY;
2350 if (!strcmp(ChrPtr(Ptr), "anon2"))
2351 er_flags |= QR_ANONOPT;
2353 bump = yesbstr("bump");
2355 er_floor = ibstr("er_floor");
2357 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2359 ChrPtr(er_password),
2368 StrBuf_ServGetln(Buf);
2369 if (GetServerStatus(Buf, NULL) != 2) {
2370 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2373 FreeStrBuf(&er_name);
2374 FreeStrBuf(&er_password);
2375 FreeStrBuf(&er_dirname);
2376 FreeStrBuf(&er_roomaide);
2381 if (StrLength(er_roomaide) > 0) {
2382 serv_printf("SETA %s", ChrPtr(er_roomaide));
2383 StrBuf_ServGetln(Buf);
2384 if (GetServerStatus(Buf, NULL) != 2) {
2385 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2386 display_main_menu();
2388 FreeStrBuf(&er_name);
2389 FreeStrBuf(&er_password);
2390 FreeStrBuf(&er_dirname);
2391 FreeStrBuf(&er_roomaide);
2396 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2399 FreeStrBuf(&er_name);
2400 FreeStrBuf(&er_password);
2401 FreeStrBuf(&er_dirname);
2402 FreeStrBuf(&er_roomaide);
2408 * Display form for Invite, Kick, and show Who Knows a room
2410 void do_invt_kick(void) {
2411 char buf[SIZ], room[SIZ], username[SIZ];
2414 serv_getln(buf, sizeof buf);
2416 if (buf[0] != '2') {
2420 extract_token(room, &buf[4], 0, '|', sizeof room);
2422 strcpy(username, bstr("username"));
2424 if (havebstr("kick_button")) {
2425 sprintf(buf, "KICK %s", username);
2427 serv_getln(buf, sizeof buf);
2429 if (buf[0] != '2') {
2430 strcpy(WC->ImportantMessage, &buf[4]);
2432 sprintf(WC->ImportantMessage,
2433 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2438 if (havebstr("invite_button")) {
2439 sprintf(buf, "INVT %s", username);
2441 serv_getln(buf, sizeof buf);
2443 if (buf[0] != '2') {
2444 strcpy(WC->ImportantMessage, &buf[4]);
2446 sprintf(WC->ImportantMessage,
2447 _("<B><I>User %s invited to room %s.</I></B>\n"),
2458 * Display form for Invite, Kick, and show Who Knows a room
2460 void display_whok(void)
2462 char buf[SIZ], room[SIZ], username[SIZ];
2465 serv_getln(buf, sizeof buf);
2467 if (buf[0] != '2') {
2471 extract_token(room, &buf[4], 0, '|', sizeof room);
2474 wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2475 wc_printf(_("The users listed below have access to this room. "
2476 "To remove a user from the access list, select the user "
2477 "name from the list and click 'Kick'."));
2478 wc_printf("<br /><br />");
2480 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2481 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2482 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2483 wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2485 serv_getln(buf, sizeof buf);
2486 if (buf[0] == '1') {
2487 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2488 extract_token(username, buf, 0, '|', sizeof username);
2489 wc_printf("<OPTION>");
2494 wc_printf("</select><br />\n");
2496 wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2497 wc_printf("</form></CENTER>\n");
2499 wc_printf("</td><td>");
2500 wc_printf(_("To grant another user access to this room, enter the "
2501 "user name in the box below and click 'Invite'."));
2502 wc_printf("<br /><br />");
2504 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2505 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2506 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2507 wc_printf(_("Invite:"));
2509 wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2510 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2511 "<input type=\"submit\" value=\"%s\">"
2512 "</form></CENTER>\n", _("Invite"));
2513 /* Pop open an address book -- begin **/
2515 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2517 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2520 _("Users"), _("Users")
2522 /* Pop open an address book -- end **/
2524 wc_printf("</td></tr></table>\n");
2525 address_book_popup();
2532 * display the form for entering a new room
2534 void display_entroom(void)
2541 serv_puts("CRE8 0");
2542 serv_getln(buf, sizeof buf);
2544 if (buf[0] != '2') {
2545 strcpy(WC->ImportantMessage, &buf[4]);
2546 display_main_menu();
2551 output_headers(1, 1, 1, 0, 0, 0);
2553 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2554 do_template("beginbox", NULL);
2556 wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2557 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2559 wc_printf("<table class=\"altern\"> ");
2561 wc_printf("<tr class=\"even\"><td>");
2562 wc_printf(_("Name of room: "));
2563 wc_printf("</td><td>");
2564 wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2565 wc_printf("</td></tr>");
2567 wc_printf("<tr class=\"odd\"><td>");
2568 wc_printf(_("Resides on floor: "));
2569 wc_printf("</td><td>");
2570 load_floorlist(Buf);
2571 wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2572 for (i = 0; i < 128; ++i)
2573 if (!IsEmptyStr(floorlist[i])) {
2574 wc_printf("<option ");
2575 wc_printf("value=\"%d\">", i);
2576 escputs(floorlist[i]);
2577 wc_printf("</option>\n");
2579 wc_printf("</select>\n");
2580 wc_printf("</td></tr>");
2583 * Our clever little snippet of JavaScript automatically selects
2584 * a public room if the view is set to Bulletin Board or wiki, and
2585 * it selects a mailbox room otherwise. The user can override this,
2586 * of course. We also disable the floor selector for mailboxes.
2588 wc_printf("<tr class=\"even\"><td>");
2589 wc_printf(_("Default view for room: "));
2590 wc_printf("</td><td>");
2591 wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2592 " if ( (this.form.er_view.value == 0) "
2593 " || (this.form.er_view.value == 6) ) { "
2594 " this.form.type[0].checked=true; "
2595 " this.form.er_floor.disabled = false; "
2598 " this.form.type[4].checked=true; "
2599 " this.form.er_floor.disabled = true; "
2602 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2603 if (is_view_allowed_as_default(i)) {
2604 wc_printf("<option %s value=\"%d\">",
2605 ((i == 0) ? "selected" : ""), i );
2606 escputs(viewdefs[i]);
2607 wc_printf("</option>\n");
2610 wc_printf("</select>\n");
2611 wc_printf("</td></tr>");
2613 wc_printf("<tr class=\"even\"><td>");
2614 wc_printf(_("Type of room:"));
2615 wc_printf("</td><td>");
2616 wc_printf("<ul class=\"adminlist\">\n");
2618 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2619 wc_printf("CHECKED OnChange=\""
2620 " if (this.form.type[0].checked == true) { "
2621 " this.form.er_floor.disabled = false; "
2624 wc_printf(_("Public (automatically appears to everyone)"));
2627 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2628 " if (this.form.type[1].checked == true) { "
2629 " this.form.er_floor.disabled = false; "
2632 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2635 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2636 " if (this.form.type[2].checked == true) { "
2637 " this.form.er_floor.disabled = false; "
2640 wc_printf(_("Private - require password: "));
2641 wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2644 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2645 " if (this.form.type[3].checked == true) { "
2646 " this.form.er_floor.disabled = false; "
2649 wc_printf(_("Private - invitation only"));
2652 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2654 " if (this.form.type[4].checked == true) { "
2655 " this.form.er_floor.disabled = true; "
2658 wc_printf(_("Personal (mailbox for you only)"));
2661 wc_printf("\n</ul>\n");
2662 wc_printf("</td></tr></table>\n");
2664 wc_printf("<div class=\"buttons\">\n");
2665 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2666 wc_printf(" ");
2667 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2668 wc_printf("</div>\n");
2669 wc_printf("</form>\n<hr />");
2670 serv_printf("MESG roomaccess");
2671 serv_getln(buf, sizeof buf);
2672 if (buf[0] == '1') {
2676 do_template("endbox", NULL);
2686 * support function for entroom() -- sets the default view
2688 void er_set_default_view(int newview) {
2701 serv_getln(buf, sizeof buf);
2702 if (buf[0] != '2') return;
2704 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2705 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2706 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2707 rm_bits1 = extract_int(&buf[4], 3);
2708 rm_floor = extract_int(&buf[4], 4);
2709 rm_listorder = extract_int(&buf[4], 5);
2710 rm_bits2 = extract_int(&buf[4], 7);
2712 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2713 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2714 rm_listorder, newview, rm_bits2
2716 serv_getln(buf, sizeof buf);
2727 const StrBuf *er_name;
2728 const StrBuf *er_type;
2729 const StrBuf *er_password;
2733 wcsession *WCC = WC;
2735 if (!havebstr("ok_button")) {
2736 strcpy(WC->ImportantMessage,
2737 _("Cancelled. No new room was created."));
2738 display_main_menu();
2741 er_name = sbstr("er_name");
2742 er_type = sbstr("type");
2743 er_password = sbstr("er_password");
2744 er_floor = ibstr("er_floor");
2745 er_view = ibstr("er_view");
2748 if (!strcmp(ChrPtr(er_type), "hidden"))
2750 else if (!strcmp(ChrPtr(er_type), "passworded"))
2752 else if (!strcmp(ChrPtr(er_type), "invonly"))
2754 else if (!strcmp(ChrPtr(er_type), "personal"))
2757 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2760 ChrPtr(er_password),
2765 serv_getln(buf, sizeof buf);
2766 if (buf[0] != '2') {
2767 strcpy(WCC->ImportantMessage, &buf[4]);
2768 display_main_menu();
2771 /** TODO: Room created, now update the left hand icon bar for this user */
2772 burn_folder_cache(0); /* burn the old folder cache */
2776 serv_printf("VIEW %d", er_view);
2777 serv_getln(buf, sizeof buf);
2778 WCC->CurRoom.view = er_view;
2780 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
2781 display_editroom ();
2783 do_change_view(er_view); /* Now go there */
2790 * \brief display the screen to enter a private room
2792 void display_private(char *rname, int req_pass)
2794 WCTemplputParams SubTP;
2796 output_headers(1, 1, 1, 0, 0, 0);
2798 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2799 memset(&SubTP, 0, sizeof(WCTemplputParams));
2800 SubTP.Filter.ContextType = CTX_STRBUF;
2801 SubTP.Context = Buf;
2802 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2807 wc_printf(_("If you know the name of a hidden (guess-name) or "
2808 "passworded room, you can enter that room by typing "
2809 "its name below. Once you gain access to a private "
2810 "room, it will appear in your regular room listings "
2811 "so you don't have to keep returning here."));
2814 wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2815 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2817 wc_printf("<table class=\"altern\"> "
2818 "<tr class=\"even\"><td>");
2819 wc_printf(_("Enter room name:"));
2820 wc_printf("</td><td>"
2821 "<input type=\"text\" name=\"gr_name\" "
2822 "value=\"%s\" maxlength=\"128\">\n", rname);
2825 wc_printf("</td></tr><tr class=\"odd\"><td>");
2826 wc_printf(_("Enter room password:"));
2827 wc_printf("</td><td>");
2828 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2830 wc_printf("</td></tr></table>\n");
2832 wc_printf("<div class=\"buttons\">\n");
2833 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2835 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2839 wc_printf("</div></form>\n");
2841 do_template("endbox", NULL);
2847 * \brief goto a private room
2849 void goto_private(void)
2854 if (!havebstr("ok_button")) {
2855 display_main_menu();
2858 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2859 serv_printf("GOTO %s|%s",
2862 serv_getln(buf, sizeof buf);
2864 if (buf[0] == '2') {
2865 smart_goto(sbstr("gr_name"));
2868 if (!strncmp(buf, "540", 3)) {
2869 display_private(bstr("gr_name"), 1);
2872 output_headers(1, 1, 1, 0, 0, 0);
2873 wc_printf("%s\n", &buf[4]);
2880 * \brief display the screen to zap a room
2882 void display_zap(void)
2884 output_headers(1, 1, 2, 0, 0, 0);
2886 wc_printf("<div id=\"banner\">\n");
2888 wc_printf(_("Zap (forget/unsubscribe) the current room"));
2889 wc_printf("</h1>\n");
2890 wc_printf("</div>\n");
2892 wc_printf("<div id=\"content\" class=\"service\">\n");
2894 wc_printf(_("If you select this option, <em>%s</em> will "
2895 "disappear from your room list. Is this what you wish "
2896 "to do?<br />\n"), ChrPtr(WC->CurRoom.name));
2898 wc_printf("<form method=\"POST\" action=\"zap\">\n");
2899 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2900 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2901 wc_printf(" ");
2902 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2903 wc_printf("</form>\n");
2914 StrBuf *final_destination;
2917 * If the forget-room routine fails for any reason, we fall back
2918 * to the current room; otherwise, we go to the Lobby
2920 final_destination = NewStrBufDup(WC->CurRoom.name);
2922 if (havebstr("ok_button")) {
2923 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
2924 serv_getln(buf, sizeof buf);
2925 if (buf[0] == '2') {
2927 serv_getln(buf, sizeof buf);
2928 if (buf[0] == '2') {
2929 FlushStrBuf(final_destination);
2930 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2934 smart_goto(final_destination);
2935 FreeStrBuf(&final_destination);
2941 * \brief Delete the current room
2943 void delete_room(void)
2948 serv_puts("KILL 1");
2949 serv_getln(buf, sizeof buf);
2950 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2951 if (buf[0] != '2') {
2952 strcpy(WC->ImportantMessage, &buf[4]);
2953 display_main_menu();
2958 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2967 * \brief Perform changes to a room's network configuration
2969 void netedit(void) {
2978 /*/ TODO: do line dynamic! */
2979 if (havebstr("line_pop3host")) {
2980 strcpy(line, bstr("prefix"));
2981 strcat(line, bstr("line_pop3host"));
2983 strcat(line, bstr("line_pop3user"));
2985 strcat(line, bstr("line_pop3pass"));
2987 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2989 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2990 strcat(line, bstr("suffix"));
2992 else if (havebstr("line")) {
2993 strcpy(line, bstr("prefix"));
2994 strcat(line, bstr("line"));
2995 strcat(line, bstr("suffix"));
3010 serv_getln(buf, sizeof buf);
3011 if (buf[0] != '1') {
3017 /** This loop works for add *or* remove. Spiffy, eh? */
3018 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3019 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
3020 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
3021 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
3022 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
3023 if ( (strcasecmp(cmpa0, cmpb0))
3024 || (strcasecmp(cmpa1, cmpb1)) ) {
3025 fprintf(fp, "%s\n", buf);
3031 serv_getln(buf, sizeof buf);
3032 if (buf[0] != '4') {
3038 while (fgets(buf, sizeof buf, fp) != NULL) {
3039 buf[strlen(buf)-1] = 0;
3043 if (havebstr("add_button")) {
3044 num_addrs = num_tokens(bstr("line"), ',');
3045 if (num_addrs < 2) {
3046 /* just adding one node or address */
3050 /* adding multiple addresses separated by commas */
3051 for (i=0; i<num_addrs; ++i) {
3052 strcpy(line, bstr("prefix"));
3053 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3056 strcat(line, bstr("suffix"));
3070 * \brief Convert a room name to a folder-ish-looking name.
3071 * \param folder the folderish name
3072 * \param room the room name
3073 * \param floor the floor name
3074 * \param is_mailbox is it a mailbox?
3076 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3081 * For mailboxes, just do it straight...
3084 sprintf(folder, "My folders|%s", room);
3088 * Otherwise, prefix the floor name as a "public folders" moniker
3091 if (floor > MAX_FLOORS) {
3093 sprintf(folder, "%%%%%%|%s", room);
3096 sprintf(folder, "%s|%s", floorlist[floor], room);
3101 * Replace "\" characters with "|" for pseudo-folder-delimiting
3103 len = strlen (folder);
3104 for (i=0; i<len; ++i) {
3105 if (folder[i] == '\\') folder[i] = '|';
3113 * \brief Back end for change_view()
3114 * \param newview set newview???
3116 void do_change_view(int newview) {
3119 serv_printf("VIEW %d", newview);
3120 serv_getln(buf, sizeof buf);
3121 WC->CurRoom.view = newview;
3122 smart_goto(WC->CurRoom.name);
3128 * \brief Change the view for this room
3130 void change_view(void) {
3133 view = lbstr("view");
3134 do_change_view(view);
3138 * \brief Burn the cached folder list.
3139 * \param age How old the cahce needs to be before we burn it.
3142 void burn_folder_cache(time_t age)
3144 /** If our cached folder list is very old, burn it. */
3145 if (WC->cache_fold != NULL) {
3146 if ((time(NULL) - WC->cache_timestamp) > age) {
3147 free(WC->cache_fold);
3148 WC->cache_fold = NULL;
3156 * \brief Do either a known rooms list or a folders list, depending on the
3161 StrBuf *ListView = NULL;
3163 /** Determine whether the user is trying to change views */
3164 if (havebstr("view")) {
3165 ListView = NewStrBufDup(SBSTR("view"));
3166 set_preference("roomlistview", ListView, 1);
3168 /** Sanitize the input so its safe */
3169 if((get_preference("roomlistview", &ListView) != 0)||
3170 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3171 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3173 if (ListView == NULL) {
3174 ListView = NewStrBufPlain(HKEY("rooms"));
3175 set_preference("roomlistview", ListView, 0);
3179 ListView = NewStrBufPlain(HKEY("rooms"));
3180 set_preference("roomlistview", ListView, 0);
3184 FreeStrBuf(&ListView);
3191 * \brief Set the message expire policy for this room and/or floor
3193 void set_room_policy(void) {
3196 if (!havebstr("ok_button")) {
3197 strcpy(WC->ImportantMessage,
3198 _("Cancelled. Changes were not saved."));
3203 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3204 serv_getln(buf, sizeof buf);
3205 strcpy(WC->ImportantMessage, &buf[4]);
3207 if (WC->axlevel >= 6) {
3208 strcat(WC->ImportantMessage, "<br />\n");
3209 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3210 serv_getln(buf, sizeof buf);
3211 strcat(WC->ImportantMessage, &buf[4]);
3217 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3219 StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3223 void _display_private(void) {
3224 display_private("", 0);
3227 void dotgoto(void) {
3228 if (!havebstr("room")) {
3229 readloop(readnew, eUseDefault);
3232 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3235 smart_goto(sbstr("room"));
3240 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3242 wcsession *WCC = WC;
3245 StrBufAppendTemplate(Target, TP,
3250 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3252 wc_printf("<div id=\"banner\">\n");
3253 embed_room_banner(NULL, navbar_default);
3254 wc_printf("</div>\n");
3258 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3260 wcsession *WCC = WC;
3263 (!IsEmptyStr(WCC->ugname)))
3264 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3267 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3269 wcsession *WCC = WC;
3270 return (WCC != NULL)?
3271 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3274 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3276 wcsession *WCC = WC;
3277 return (WCC == NULL)? 0 :
3278 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3279 (WCC->CurRoom.is_inbox) ||
3280 (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3283 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3285 wcsession *WCC = WC;
3287 return ((WCC!=NULL) &&
3288 (!IsEmptyStr(WCC->ugname)) &&
3289 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3292 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3295 wcsession *WCC = WC;
3297 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3298 if (QR_CheckFlag == 0)
3299 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3300 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3302 return ((WCC!=NULL) &&
3303 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3306 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3309 folder *Folder = (folder *)(TP->Context);
3311 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3312 if (QR_CheckFlag == 0)
3313 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3314 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3315 return ((Folder->QRFlags & QR_CheckFlag) != 0);
3319 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3322 wcsession *WCC = WC;
3324 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3325 if (QR2_CheckFlag == 0)
3326 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3327 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3329 return ((WCC!=NULL) &&
3330 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3333 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3336 folder *Folder = (folder *)(TP->Context);
3338 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3339 if (QR2_CheckFlag == 0)
3340 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3341 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3342 return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3346 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3348 wcsession *WCC = WC;
3350 return ( (WCC!= NULL) &&
3351 ((WCC->axlevel >= 6) ||
3352 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3353 (WCC->CurRoom.is_inbox) ));
3356 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3358 wcsession *WCC = WC;
3360 if ((WCC == NULL) ||
3361 (TP->Tokens->nParameters < 3))
3363 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3370 RegisterPreference("roomlistview",
3371 _("Room list view"),
3374 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3376 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3378 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3379 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3380 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3381 WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3382 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3383 WebcitAddUrlHandler(HKEY("zapped_list"), "", 0, zapped_list, 0);
3384 WebcitAddUrlHandler(HKEY("display_zap"), "", 0, display_zap, 0);
3385 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3386 WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3387 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3388 WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3389 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3390 WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3391 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3392 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3393 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3394 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3395 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3396 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3397 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3399 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3400 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3401 RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3403 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3404 RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3406 RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3409 RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3410 RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3411 RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3412 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3413 RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3414 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3417 REGISTERTokenParamDefine(QR_PERMANENT);
3418 REGISTERTokenParamDefine(QR_INUSE);
3419 REGISTERTokenParamDefine(QR_PRIVATE);
3420 REGISTERTokenParamDefine(QR_PASSWORDED);
3421 REGISTERTokenParamDefine(QR_GUESSNAME);
3422 REGISTERTokenParamDefine(QR_DIRECTORY);
3423 REGISTERTokenParamDefine(QR_UPLOAD);
3424 REGISTERTokenParamDefine(QR_DOWNLOAD);
3425 REGISTERTokenParamDefine(QR_VISDIR);
3426 REGISTERTokenParamDefine(QR_ANONONLY);
3427 REGISTERTokenParamDefine(QR_ANONOPT);
3428 REGISTERTokenParamDefine(QR_NETWORK);
3429 REGISTERTokenParamDefine(QR_PREFONLY);
3430 REGISTERTokenParamDefine(QR_READONLY);
3431 REGISTERTokenParamDefine(QR_MAILBOX);
3432 REGISTERTokenParamDefine(QR2_SYSTEM);
3433 REGISTERTokenParamDefine(QR2_SELFLIST);
3434 REGISTERTokenParamDefine(QR2_COLLABDEL);
3435 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3436 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3437 REGISTERTokenParamDefine(QR2_MODERATED);
3439 REGISTERTokenParamDefine(UA_KNOWN);
3440 REGISTERTokenParamDefine(UA_GOTOALLOWED);
3441 REGISTERTokenParamDefine(UA_HASNEWMSGS);
3442 REGISTERTokenParamDefine(UA_ZAPPED);
3443 REGISTERTokenParamDefine(UA_POSTALLOWED);
3444 REGISTERTokenParamDefine(UA_ADMINALLOWED);
3445 REGISTERTokenParamDefine(UA_DELETEALLOWED);
3446 REGISTERTokenParamDefine(UA_ISTRASH);
3448 REGISTERTokenParamDefine(US_NEEDVALID);
3449 REGISTERTokenParamDefine(US_PERM);
3450 REGISTERTokenParamDefine(US_LASTOLD);
3451 REGISTERTokenParamDefine(US_EXPERT);
3452 REGISTERTokenParamDefine(US_UNLISTED);
3453 REGISTERTokenParamDefine(US_NOPROMPT);
3454 REGISTERTokenParamDefine(US_PROMPTCTL);
3455 REGISTERTokenParamDefine(US_DISAPPEAR);
3456 REGISTERTokenParamDefine(US_REGIS);
3457 REGISTERTokenParamDefine(US_PAGINATOR);
3458 REGISTERTokenParamDefine(US_INTERNET);
3459 REGISTERTokenParamDefine(US_FLOORS);
3460 REGISTERTokenParamDefine(US_COLOR);
3461 REGISTERTokenParamDefine(US_USER_SET);
3463 REGISTERTokenParamDefine(VIEW_BBS);
3464 REGISTERTokenParamDefine(VIEW_MAILBOX);
3465 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3466 REGISTERTokenParamDefine(VIEW_CALENDAR);
3467 REGISTERTokenParamDefine(VIEW_TASKS);
3468 REGISTERTokenParamDefine(VIEW_NOTES);
3469 REGISTERTokenParamDefine(VIEW_WIKI);
3470 REGISTERTokenParamDefine(VIEW_CALBRIEF);
3471 REGISTERTokenParamDefine(VIEW_JOURNAL);
3472 REGISTERTokenParamDefine(VIEW_BLOG);
3475 REGISTERTokenParamDefine(ignet_push_share);
3476 REGISTERTokenParamDefine(listrecp);
3477 REGISTERTokenParamDefine(digestrecp);
3478 REGISTERTokenParamDefine(pop3client);
3479 REGISTERTokenParamDefine(rssclient);
3480 REGISTERTokenParamDefine(participate);
3482 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3483 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3485 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3486 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3488 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3489 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3490 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3497 SessionDestroyModule_ROOMOPS
3500 FlushFolder(&sess->CurRoom);
3501 if (sess->cache_fold != NULL) {
3502 free(sess->cache_fold);
3505 free_march_list(sess);
3506 DeleteHash(&sess->Floors);