3 * Lots of different room-related operations.
10 char floorlist[MAX_FLOORS][SIZ]; /* list of our floor names */
12 /* See GetFloorListHash and GetRoomListHash for info on these.
13 * Basically we pull LFLR/LKRA etc. and set up a room HashList with these keys.
16 void display_whok(void);
17 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP);
20 char *viewdefs[VIEW_MAX]; /* the different kinds of available views */
22 ROOM_VIEWS exchangeable_views[VIEW_MAX][VIEW_MAX] = { /* the different kinds of available views for a view */
23 {VIEW_BBS, VIEW_MAILBOX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX },
24 {VIEW_BBS, VIEW_MAILBOX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX },
25 {VIEW_MAX, VIEW_MAX, VIEW_ADDRESSBOOK, VIEW_CALENDAR, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX },
26 {VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_CALENDAR, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX /*VIEW_CALBRIEF*/, VIEW_MAX, VIEW_MAX },
27 {VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_TASKS, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, },
28 {VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_NOTES, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, },
29 {VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_WIKI, VIEW_MAX, VIEW_MAX, VIEW_MAX},
30 {VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_CALENDAR, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX/*VIEW_CALBRIEF*/, VIEW_MAX, VIEW_MAX},
31 {VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_JOURNAL, VIEW_MAX },
32 {VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_BLOG },
34 /* the brief calendar view is disabled: VIEW_CALBRIEF */
37 * Initialize the viewdefs with localized strings
39 void initialize_viewdefs(void) {
40 viewdefs[VIEW_BBS] = _("Bulletin Board");
41 viewdefs[VIEW_MAILBOX] = _("Mail Folder");
42 viewdefs[VIEW_ADDRESSBOOK] = _("Address Book");
43 viewdefs[VIEW_CALENDAR] = _("Calendar");
44 viewdefs[VIEW_TASKS] = _("Task List");
45 viewdefs[VIEW_NOTES] = _("Notes List");
46 viewdefs[VIEW_WIKI] = _("Wiki");
47 viewdefs[VIEW_CALBRIEF] = _("Calendar List");
48 viewdefs[VIEW_JOURNAL] = _("Journal");
49 viewdefs[VIEW_BLOG] = _("Blog");
53 * Determine which views are allowed as the default for creating a new room.
55 int is_view_allowed_as_default(int which_view)
58 case VIEW_BBS: return(1);
59 case VIEW_MAILBOX: return(1);
60 case VIEW_ADDRESSBOOK: return(1);
61 case VIEW_CALENDAR: return(1);
62 case VIEW_TASKS: return(1);
63 case VIEW_NOTES: return(1);
64 case VIEW_WIKI: return(1);
65 case VIEW_CALBRIEF: return(0);
66 case VIEW_JOURNAL: return(0);
67 default: return(0); /* should never get here */
73 * load the list of floors
75 void load_floorlist(StrBuf *Buf)
80 for (a = 0; a < MAX_FLOORS; ++a)
84 StrBuf_ServGetln(Buf);
85 if (GetServerStatus(Buf, NULL) != 1) {
86 strcpy(floorlist[0], "Main Floor");
89 while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
90 if ( (StrLength(Buf)==3) &&
91 !strcmp(ChrPtr(Buf), "000")) {
95 extract_token(floorlist[StrBufExtract_int(Buf, 0, '|')], ChrPtr(Buf), 1, '|', sizeof floorlist[0]);
103 * display rooms in tree structure
105 void room_tree_list(struct roomlisting *rp)
114 room_tree_list(rp->lnext);
116 strcpy(rmname, rp->rlname);
119 wc_printf("<a href=\"dotgoto?room=");
123 escputs1(rmname, 1, 1);
124 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
126 else if (f & QR_DIRECTORY)
128 else if (f & QR_NETWORK)
132 wc_printf("</a><tt> </tt>\n");
134 room_tree_list(rp->rnext);
140 * Room ordering stuff (compare first by floor, then by order)
142 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
144 if ((r1 == NULL) && (r2 == NULL))
150 if (r1->rlfloor < r2->rlfloor)
152 if (r1->rlfloor > r2->rlfloor)
154 if (r1->rlorder < r2->rlorder)
156 if (r1->rlorder > r2->rlorder)
163 * Common code for all room listings
165 void listrms(char *variety)
170 struct roomlisting *rl = NULL;
171 struct roomlisting *rp;
172 struct roomlisting *rs;
174 /* Ask the server for a room list */
176 serv_getln(buf, sizeof buf);
182 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
184 rp = malloc(sizeof(struct roomlisting));
185 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
186 rp->rlflags = extract_int(buf, 1);
187 rp->rlfloor = extract_int(buf, 2);
188 rp->rlorder = extract_int(buf, 3);
197 if (rordercmp(rp, rs) < 0) {
198 if (rs->lnext == NULL) {
205 if (rs->rnext == NULL) {
218 * If no rooms were listed, print an nbsp to make the cell
219 * borders show up anyway.
221 if (num_rooms == 0) wc_printf(" ");
226 * list all forgotten rooms
228 void zapped_list(void)
230 WCTemplputParams SubTP;
233 output_headers(1, 1, 1, 0, 0, 0);
234 memset(&SubTP, 0, sizeof(WCTemplputParams));
235 Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
236 SubTP.Filter.ContextType = CTX_STRBUF;
238 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
244 wc_printf("<br /><br />\n");
245 wc_printf(_("Click on any room to un-zap it and goto that room.\n"));
246 do_template("endbox", NULL);
251 * Display the current view and offer an option to change it
253 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
257 wc_printf("<form name=\"viewomatic\" action=\"changeview\">\n");
258 wc_printf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
259 wc_printf("<label for=\"view_name\">");
260 wc_printf(_("View as:"));
261 wc_printf("</label> "
262 "<select name=\"newview\" size=\"1\" "
263 "id=\"view_name\" class=\"selectbox\" "
264 "OnChange=\"location.href=viewomatic.newview.options"
265 "[selectedIndex].value\">\n");
267 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
269 * Only offer the views that make sense, given the default
270 * view for the room. For example, don't offer a Calendar
271 * view in a non-Calendar room.
274 (i == WC->CurRoom.view)
275 || (i == WC->CurRoom.defview) /* default */
276 || ( (i == 0) && (WC->CurRoom.defview == 1) ) /* mail or bulletin */
277 || ( (i == 1) && (WC->CurRoom.defview == 0) ) /* mail or bulletin */
278 /* || ( (i == 7) && (WC->CurRoom.defview == 3) ) (calendar list temporarily disabled) */
281 wc_printf("<option %s value=\"changeview?view=%d\">",
282 ((i == WC->CurRoom.view) ? "selected" : ""),
284 escputs(viewdefs[i]);
285 wc_printf("</option>\n");
288 wc_printf("</select></div></form>\n");
294 * Embed the room banner
296 * got The information returned from a GOTO server command
297 * navbar_style Determines which navigation buttons to display
301 void embed_room_banner(char *got, int navbar_style) {
305 char with_files[256];
309 * We need to have the information returned by a GOTO server command.
310 * If it isn't supplied, we fake it by issuing our own GOTO.
313 memset(buf, '0', 20);
315 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
316 serv_getln(buf, sizeof buf);
320 /* The browser needs some information for its own use */
321 wc_printf("<script type=\"text/javascript\"> \n"
322 " room_is_trash = %d; \n"
324 ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
328 * If the user happens to select the "make this my start page" link,
329 * we want it to remember the URL as a "/dotskip" one instead of
330 * a "skip" or "gotonext" or something like that.
332 if (WCC->Hdr->this_page == NULL) {
333 WCC->Hdr->this_page = NewStrBuf();
335 StrBufPrintf(WCC->Hdr->this_page,
337 ChrPtr(WC->CurRoom.name)
340 /* Check for new mail. */
341 WC->new_mail = extract_int(&got[4], 9);
342 WC->CurRoom.view = extract_int(&got[4], 11);
344 do_template("roombanner", NULL);
345 /* roombanner contains this for mobile */
346 if (navbar_style != navbar_none && (WC->is_mobile < 1)) {
348 wc_printf("<div id=\"navbar\"><ul>");
350 if (navbar_style == navbar_default) wc_printf(
351 "<li class=\"ungoto\">"
352 "<a href=\"ungoto\">"
353 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
354 "<span class=\"navbar_link\">%s</span></A>"
355 "</li>\n", _("Ungoto")
358 if ( (navbar_style == navbar_default) && (WC->CurRoom.view == VIEW_BBS) ) {
360 "<li class=\"newmess\">"
361 "<a href=\"readnew\">"
362 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
363 "<span class=\"navbar_link\">%s</span></A>"
364 "</li>\n", _("Read new messages")
368 if (navbar_style == navbar_default) {
369 switch(WC->CurRoom.view) {
370 case VIEW_ADDRESSBOOK:
372 "<li class=\"viewcontacts\">"
373 "<a href=\"readfwd\">"
374 "<img src=\"static/viewcontacts_24x.gif\" "
375 "alt=\"\" width=\"24\" height=\"24\">"
376 "<span class=\"navbar_link\">"
378 "</span></a></li>\n", _("View contacts")
383 "<li class=\"staskday\">"
384 "<a href=\"readfwd?calview=day\">"
385 "<img src=\"static/taskday2_24x.gif\" "
386 "alt=\"\" width=\"24\" height=\"24\">"
387 "<span class=\"navbar_link\">"
389 "</span></a></li>\n", _("Day view")
392 "<li class=\"monthview\">"
393 "<a href=\"readfwd?calview=month\">"
394 "<img src=\"static/monthview2_24x.gif\" "
395 "alt=\"\" width=\"24\" height=\"24\">"
396 "<span class=\"navbar_link\">"
398 "</span></a></li>\n", _("Month view")
403 "<li class=\"monthview\">"
404 "<a href=\"readfwd?calview=month\">"
405 "<img src=\"static/monthview2_24x.gif\" "
406 "alt=\"\" width=\"24\" height=\"24\">"
407 "<span class=\"navbar_link\">"
409 "</span></a></li>\n", _("Calendar list")
414 "<li class=\"taskmanag\">"
415 "<a href=\"readfwd\">"
416 "<img src=\"static/taskmanag_24x.gif\" "
417 "alt=\"\" width=\"24\" height=\"24\">"
418 "<span class=\"navbar_link\">"
420 "</span></a></li>\n", _("View tasks")
425 "<li class=\"viewnotes\">"
426 "<a href=\"readfwd\">"
427 "<img src=\"static/viewnotes_24x.gif\" "
428 "alt=\"\" width=\"24\" height=\"24\">"
429 "<span class=\"navbar_link\">"
431 "</span></a></li>\n", _("View notes")
436 "<li class=\"readallmess\">"
437 "<a id=\"m_refresh\" href=\"readfwd\">"
438 "<img src=\"static/readallmess3_24x.gif\" "
439 "alt=\"\" width=\"24\" height=\"24\">"
440 "<span class=\"navbar_link\">"
442 "</span></a></li>\n", _("Refresh message list")
447 "<li class=\"readallmess\">"
448 "<a href=\"wiki?page=home\">"
449 "<img src=\"static/readallmess3_24x.gif\" "
450 "alt=\"\" width=\"24\" height=\"24\">"
451 "<span class=\"navbar_link\">"
453 "</span></a></li>\n", _("Wiki home")
458 "<li class=\"readallmess\">"
459 "<a href=\"readfwd\">"
460 "<img src=\"static/readallmess3_24x.gif\" "
461 "alt=\"\" width=\"24\" height=\"24\">"
462 "<span class=\"navbar_link\">"
464 "</span></a></li>\n", _("Read all messages")
470 if (navbar_style == navbar_default) {
471 switch(WC->CurRoom.view) {
472 case VIEW_ADDRESSBOOK:
474 "<li class=\"addnewcontact\">"
475 "<a href=\"display_enter\">"
476 "<img src=\"static/addnewcontact_24x.gif\" "
477 "alt=\"\" width=\"24\" height=\"24\">"
478 "<span class=\"navbar_link\">"
480 "</span></a></li>\n", _("Add new contact")
485 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
486 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
487 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
488 if (havebstr("day" )) wc_printf("?day=%s", bstr("day"));
490 "<img src=\"static/addevent_24x.gif\" "
491 "alt=\"\" width=\"24\" height=\"24\">"
492 "<span class=\"navbar_link\">"
494 "</span></a></li>\n", _("Add new event")
499 "<li class=\"newmess\">"
500 "<a href=\"display_enter\">"
501 "<img src=\"static/newmess3_24x.gif\" "
502 "alt=\"\" width=\"24\" height=\"24\">"
503 "<span class=\"navbar_link\">"
505 "</span></a></li>\n", _("Add new task")
510 "<li class=\"enternewnote\">"
511 "<a href=\"add_new_note\">"
512 "<img src=\"static/enternewnote_24x.gif\" "
513 "alt=\"\" width=\"24\" height=\"24\">"
514 "<span class=\"navbar_link\">"
516 "</span></a></li>\n", _("Add new note")
520 safestrncpy(buf, bstr("page"), sizeof buf);
521 if (IsEmptyStr(buf)) {
522 safestrncpy(buf, "home", sizeof buf);
526 "<li class=\"newmess\">"
527 "<a href=\"display_enter?page=%s\">"
528 "<img src=\"static/newmess3_24x.gif\" "
529 "alt=\"\" width=\"24\" height=\"24\">"
530 "<span class=\"navbar_link\">"
532 "</span></a></li>\n", buf, _("Edit this page")
535 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
536 /* already viewing history; display a link to the current page */
538 "<li class=\"newmess\">"
539 "<a href=\"wiki?page=%s\">"
540 "<img src=\"static/newmess3_24x.gif\" "
541 "alt=\"\" width=\"24\" height=\"24\">"
542 "<span class=\"navbar_link\">"
544 "</span></a></li>\n", buf, _("Current version")
548 /* display a link to the history */
550 "<li class=\"newmess\">"
551 "<a href=\"wiki_history?page=%s\">"
552 "<img src=\"static/newmess3_24x.gif\" "
553 "alt=\"\" width=\"24\" height=\"24\">"
554 "<span class=\"navbar_link\">"
556 "</span></a></li>\n", buf, _("History")
562 "<li class=\"newmess\">"
563 "<a href=\"display_enter\">"
564 "<img src=\"static/newmess3_24x.gif\" "
565 "alt=\"\" width=\"24\" height=\"24\">"
566 "<span class=\"navbar_link\">"
568 "</span></a></li>\n", _("Write mail")
571 "<li class=\"newmess\">"
572 "<a href=\"javascript:deleteAllSelectedMessages();\">"
573 "<img src=\"static/delete.gif\" "
574 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
576 "</span></a></li>\n", _("Delete")
581 "<li class=\"newmess\">"
582 "<a href=\"display_enter\">"
583 "<img src=\"static/newmess3_24x.gif\" "
584 "alt=\"\" width=\"24\" height=\"24\">"
585 "<span class=\"navbar_link\">"
587 "</span></a></li>\n", _("Enter a message")
593 if (navbar_style == navbar_default) wc_printf(
594 "<li class=\"skipthisroom\">"
597 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
598 "width=\"24\" height=\"24\">"
599 "<span class=\"navbar_link\">%s</span></a>"
601 _("Leave all messages marked as unread, go to next room with unread messages"),
605 if (navbar_style == navbar_default) wc_printf(
606 "<li class=\"markngo\">"
607 "<a href=\"gotonext\" "
609 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
610 "width=\"24\" height=\"24\">"
611 "<span class=\"navbar_link\">%s</span></a>"
613 _("Mark all messages as read, go to next room with unread messages"),
617 wc_printf("</ul></div>\n");
624 * back end routine to take the session to a new room
626 long gotoroom(const StrBuf *gname)
630 static long ls = (-1L);
633 /* store ungoto information */
634 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
638 /* move to the new room */
639 serv_printf("GOTO %s", ChrPtr(gname));
640 StrBuf_ServGetln(Buf);
641 if (GetServerStatus(Buf, &err) != 2) {
642 serv_puts("GOTO _BASEROOM_");
643 StrBuf_ServGetln(Buf);
645 * well, we know that this is the fallback case,
646 * but we're interested that the first command
647 * didn't work out in first place.
649 if (GetServerStatus(Buf, NULL) != 2) {
654 ParseGoto(&WCC->CurRoom, Buf);
656 remove_march(WCC->CurRoom.name);
657 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
665 void ParseGoto(folder *room, StrBuf *Line)
673 if (StrLength(Line) < 4) {
677 /* ignore the commandstate... */
678 Pos = ChrPtr(Line) + 4;
680 if (room->RoomNameParts != NULL)
683 for (i=0; i < room->nRoomNameParts; i++)
684 FreeStrBuf(&room->RoomNameParts[i]);
685 free(room->RoomNameParts);
686 room->RoomNameParts = NULL;
691 pBuf = NewStrBufPlain(NULL, StrLength(Line));
694 memset(room, 0, sizeof(folder));
697 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
699 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
700 if (room->nNewMessages > 0)
701 room->RAFlags |= UA_HASNEWMSGS;
703 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
705 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
707 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
709 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
710 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
712 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
714 flag = StrBufExtractNext_long(Line, &Pos, '|');
715 if (WCC->is_aide || flag) {
716 room->RAFlags |= UA_ADMINALLOWED;
719 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
721 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
723 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
725 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
727 flag = StrBufExtractNext_long(Line, &Pos, '|');
729 room->RAFlags |= UA_ISTRASH; // wc_is_trash
731 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
733 /* find out, whether we are in a sub-room */
734 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
735 if (room->nRoomNameParts > 1)
740 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
741 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
742 for (i=0; i < room->nRoomNameParts; i++)
744 room->RoomNameParts[i] = NewStrBuf();
745 StrBufExtract_NextToken(room->RoomNameParts[i],
746 room->name, &Pos, '\\');
750 /* Private mailboxes on the main floor get remapped to the personal folder */
751 if ((room->QRFlags & QR_MAILBOX) &&
752 (room->floorid == 0))
754 room->floorid = VIRTUAL_MY_FLOOR;
755 if ((room->nRoomNameParts == 1) &&
756 (StrLength(room->name) == 4) &&
757 (strcmp(ChrPtr(room->name), "Mail") == 0))
763 /* get a pointer to the floor we're on: */
764 if (WCC->Floors == NULL)
765 GetFloorListHash(NULL, NULL);
767 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
768 room->Floor = (const Floor*) vFloor;
771 void LoadRoomAide(void)
776 if (WCC->CurRoom.RoomAideLoaded)
779 WCC->CurRoom.RoomAideLoaded = 1;
782 StrBuf_ServGetln(Buf);
783 if (GetServerStatus(Buf, NULL) != 2) {
784 FlushStrBuf(WCC->CurRoom.RoomAide);
785 AppendImportantMessage (ChrPtr(Buf) + 4,
790 Pos = ChrPtr(Buf) + 4;
792 FreeStrBuf(&WCC->CurRoom.RoomAide);
793 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
795 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
799 void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
802 folder *Folder = &WCC->CurRoom;
803 const Floor *pFloor = Folder->Floor;
808 StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
811 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
817 StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
821 void LoadRoomXA (void)
826 if (WCC->CurRoom.XALoaded)
829 WCC->CurRoom.XALoaded = 1;
832 StrBuf_ServGetln(Buf);
833 if (GetServerStatus(Buf, NULL) != 2) {
834 FlushStrBuf(WCC->CurRoom.XAPass);
835 FlushStrBuf(WCC->CurRoom.Directory);
837 AppendImportantMessage (ChrPtr(Buf) + 4,
842 Pos = ChrPtr(Buf) + 4;
844 FreeStrBuf(&WCC->CurRoom.XAPass);
845 FreeStrBuf(&WCC->CurRoom.Directory);
847 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
848 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
850 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
851 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
852 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
853 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
854 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
855 /* defview, we already know you. */
856 /* QR2Flags, we already know them... */
863 void LoadXRoomPic(void)
868 if (WCC->CurRoom.XHaveRoomPicLoaded)
871 WCC->CurRoom.XHaveRoomPicLoaded = 1;
873 serv_puts("OIMG _roompic_");
874 StrBuf_ServGetln(Buf);
875 if (GetServerStatus(Buf, NULL) != 2) {
876 WCC->CurRoom.XHaveRoomPic = 0;
878 WCC->CurRoom.XHaveRoomPic = 1;
881 StrBuf_ServGetln(Buf);
882 GetServerStatus(Buf, NULL);
886 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
894 return WCC->CurRoom.XHaveRoomPic == 1;
897 void LoadXRoomInfoText(void)
903 if (WCC->CurRoom.XHaveInfoTextLoaded)
906 WCC->CurRoom.XHaveInfoTextLoaded = 1;
911 StrBuf_ServGetln(Buf);
912 if (GetServerStatus(Buf, NULL) == 1) {
913 WCC->CurRoom.XInfoText = NewStrBuf ();
915 while (!Done && StrBuf_ServGetln(Buf)>=0) {
916 if ( (StrLength(Buf)==3) &&
917 !strcmp(ChrPtr(Buf), "000"))
920 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
927 int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
935 return (StrLength(WCC->CurRoom.XInfoText)>0);
938 void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
944 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1);
947 void LoadXRoomXCountFiles(void)
953 if (WCC->CurRoom.XHaveDownloadCount)
956 WCC->CurRoom.XHaveDownloadCount = 1;
960 StrBuf_ServGetln(Buf);
961 if (GetServerStatus(Buf, NULL) == 1) {
963 while (!Done && StrBuf_ServGetln(Buf)>=0) {
964 if ( (StrLength(Buf)==3) &&
965 !strcmp(ChrPtr(Buf), "000"))
968 WCC->CurRoom.XDownloadCount++;
975 void tmplput_CurrentRoomXNFiles(StrBuf *Target, WCTemplputParams *TP)
979 LoadXRoomXCountFiles();
981 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.XDownloadCount);
984 void tmplput_CurrentRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
988 LoadXRoomXCountFiles();
990 if (WCC->CurRoom.XDownloadCount == 1)
991 StrBufAppendBufPlain(Target, _("file"), -1, 0);
993 StrBufAppendBufPlain(Target, _("files"), -1, 0);
996 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
1002 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
1004 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
1006 wcsession *WCC = WC;
1010 StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
1012 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
1014 wcsession *WCC = WC;
1018 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
1020 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1022 wcsession *WCC = WC;
1024 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.defview);
1027 void tmplput_CurrentRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP)
1029 wcsession *WCC = WC;
1033 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
1036 void tmplput_CurrentRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP)
1038 wcsession *WCC = WC;
1042 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nTotalMessages);
1045 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
1047 wcsession *WCC = WC;
1055 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1056 return CheckThis == WCC->CurRoom.Order;
1059 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1061 wcsession *WCC = WC;
1067 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1068 return CheckThis == WCC->CurRoom.defview;
1071 int ConditionalThisRoomHaveView(StrBuf *Target, WCTemplputParams *TP)
1073 wcsession *WCC = WC;
1079 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1080 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
1082 LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
1083 "Roomview [%ld] not valid\n",
1088 return exchangeable_views [WCC->CurRoom.defview][CheckThis] != VIEW_MAX;
1091 void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
1093 wcsession *WCC = WC;
1096 if ((WCC == NULL) ||
1097 (WCC->CurRoom.defview >= VIEW_MAX) ||
1098 (WCC->CurRoom.defview < VIEW_BBS))
1100 LogTemplateError(Target, "Token", ERR_PARM2, TP,
1101 "Roomview [%ld] not valid\n",
1103 WCC->CurRoom.defview : -1);
1107 Buf = NewStrBufPlain(_(viewdefs[WCC->CurRoom.defview]), -1);
1108 StrBufAppendTemplate(Target, TP, Buf, 0);
1112 void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
1117 CheckThis = GetTemplateTokenNumber(Target, TP, 0, 0);
1118 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
1120 LogTemplateError(Target, "Token", ERR_PARM2, TP,
1121 "Roomview [%ld] not valid\n",
1126 Buf = NewStrBufPlain(_(viewdefs[CheckThis]), -1);
1127 StrBufAppendTemplate(Target, TP, Buf, 0);
1135 void smart_goto(const StrBuf *next_room) {
1136 gotoroom(next_room);
1137 readloop(readnew, eUseDefault);
1143 * mark all messages in current room as having been read
1145 void slrp_highest(void)
1149 serv_puts("SLRP HIGHEST");
1150 serv_getln(buf, sizeof buf);
1154 typedef struct __room_states {
1169 * Set/clear/read the "self-service list subscribe" flag for a room
1171 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1172 * returns the new value.
1175 int self_service(int newval) {
1176 int current_value = 0;
1182 int flags, floor, order, view, flags2;
1185 serv_getln(buf, sizeof buf);
1186 if (buf[0] != '2') return(0);
1188 extract_token(name, &buf[4], 0, '|', sizeof name);
1189 extract_token(password, &buf[4], 1, '|', sizeof password);
1190 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1191 flags = extract_int(&buf[4], 3);
1192 floor = extract_int(&buf[4], 4);
1193 order = extract_int(&buf[4], 5);
1194 view = extract_int(&buf[4], 6);
1195 flags2 = extract_int(&buf[4], 7);
1197 if (flags2 & QR2_SELFLIST) {
1205 flags2 = flags2 | QR2_SELFLIST;
1207 else if (newval == 0) {
1208 flags2 = flags2 & ~QR2_SELFLIST;
1211 return(current_value);
1214 if (newval != current_value) {
1215 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1216 name, password, dirname, flags,
1217 floor, order, view, flags2);
1218 serv_getln(buf, sizeof buf);
1225 int is_selflist(room_states *RoomFlags)
1227 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1230 int is_publiclist(room_states *RoomFlags)
1232 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1235 int is_moderatedlist(room_states *RoomFlags)
1237 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1241 * Set/clear/read the "self-service list subscribe" flag for a room
1243 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1244 * returns the new value.
1247 int get_roomflags(room_states *RoomOps)
1252 serv_getln(buf, sizeof buf);
1253 if (buf[0] != '2') return(0);
1255 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1256 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1257 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1258 RoomOps->flags = extract_int(&buf[4], 3);
1259 RoomOps->floor = extract_int(&buf[4], 4);
1260 RoomOps->order = extract_int(&buf[4], 5);
1261 RoomOps->view = extract_int(&buf[4], 6);
1262 RoomOps->flags2 = extract_int(&buf[4], 7);
1266 int set_roomflags(room_states *RoomOps)
1270 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1279 serv_getln(buf, sizeof buf);
1289 * display the form for editing a room
1291 void display_editroom(void)
1297 char remote_room[128];
1300 char er_password[10];
1301 char er_dirname[15];
1302 char er_roomaide[26];
1309 char *not_shared_with = NULL;
1312 int floorpolicy = 0;
1314 char pop3_host[128];
1319 if (IsEmptyStr(tab)) tab = "admin";
1322 load_floorlist(Buf);
1324 output_headers(1, 1, 1, 0, 0, 0);
1326 wc_printf("<div class=\"fix_scrollbar_bug\">");
1328 wc_printf("<br />\n");
1330 /* print the tabbed dialog */
1331 wc_printf("<div align=\"center\">");
1332 wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1333 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1336 wc_printf("<td class=\"");
1337 if (!strcmp(tab, "admin")) {
1338 wc_printf(" tab_cell_label\">");
1339 wc_printf(_("Administration"));
1342 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1343 wc_printf(_("Administration"));
1346 wc_printf("</td>\n");
1347 wc_printf("<td> </td>\n");
1349 if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1351 wc_printf("<td class=\"");
1352 if (!strcmp(tab, "config")) {
1353 wc_printf(" tab_cell_label\">");
1354 wc_printf(_("Configuration"));
1357 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1358 wc_printf(_("Configuration"));
1361 wc_printf("</td>\n");
1362 wc_printf("<td> </td>\n");
1364 wc_printf("<td class=\"");
1365 if (!strcmp(tab, "expire")) {
1366 wc_printf(" tab_cell_label\">");
1367 wc_printf(_("Message expire policy"));
1370 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1371 wc_printf(_("Message expire policy"));
1374 wc_printf("</td>\n");
1375 wc_printf("<td> </td>\n");
1377 wc_printf("<td class=\"");
1378 if (!strcmp(tab, "access")) {
1379 wc_printf(" tab_cell_label\">");
1380 wc_printf(_("Access controls"));
1383 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1384 wc_printf(_("Access controls"));
1387 wc_printf("</td>\n");
1388 wc_printf("<td> </td>\n");
1390 wc_printf("<td class=\"");
1391 if (!strcmp(tab, "sharing")) {
1392 wc_printf(" tab_cell_label\">");
1393 wc_printf(_("Sharing"));
1396 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1397 wc_printf(_("Sharing"));
1400 wc_printf("</td>\n");
1401 wc_printf("<td> </td>\n");
1403 wc_printf("<td class=\"");
1404 if (!strcmp(tab, "listserv")) {
1405 wc_printf(" tab_cell_label\">");
1406 wc_printf(_("Mailing list service"));
1409 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1410 wc_printf(_("Mailing list service"));
1413 wc_printf("</td>\n");
1414 wc_printf("<td> </td>\n");
1418 wc_printf("<td class=\"");
1419 if (!strcmp(tab, "feeds")) {
1420 wc_printf(" tab_cell_label\">");
1421 wc_printf(_("Remote retrieval"));
1424 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1425 wc_printf(_("Remote retrieval"));
1428 wc_printf("</td>\n");
1429 wc_printf("<td> </td>\n");
1431 wc_printf("</tr></table>\n");
1432 wc_printf("</div>\n");
1433 /* end tabbed dialog */
1435 wc_printf("<script type=\"text/javascript\">"
1436 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1440 /* begin content of whatever tab is open now */
1442 if (!strcmp(tab, "admin")) {
1443 wc_printf("<div class=\"tabcontent\">");
1445 "<li><a href=\"delete_room\" "
1446 "onClick=\"return confirm('");
1447 wc_printf(_("Are you sure you want to delete this room?"));
1448 wc_printf("');\">\n");
1449 wc_printf(_("Delete this room"));
1451 "<li><a href=\"display_editroompic?which_room=");
1452 urlescputs(ChrPtr(WC->CurRoom.name));
1454 wc_printf(_("Set or change the icon for this room's banner"));
1456 "<li><a href=\"display_editinfo\">\n");
1457 wc_printf(_("Edit this room's Info file"));
1460 wc_printf("</div>");
1463 if (!strcmp(tab, "config")) {
1464 wc_printf("<div class=\"tabcontent\">");
1466 serv_getln(buf, sizeof buf);
1468 if (!strncmp(buf, "550", 3)) {
1469 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1470 _("Higher access is required to access this function.")
1473 else if (buf[0] != '2') {
1474 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1477 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1478 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1479 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1480 er_flags = extract_int(&buf[4], 3);
1481 er_floor = extract_int(&buf[4], 4);
1482 er_flags2 = extract_int(&buf[4], 7);
1484 wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1485 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1487 wc_printf("<ul><li>");
1488 wc_printf(_("Name of room: "));
1489 wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1495 wc_printf(_("Resides on floor: "));
1496 wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1497 if (er_flags & QR_MAILBOX)
1498 wc_printf("disabled >\n");
1499 for (i = 0; i < 128; ++i)
1500 if (!IsEmptyStr(floorlist[i])) {
1501 wc_printf("<OPTION ");
1503 wc_printf("SELECTED ");
1504 wc_printf("VALUE=\"%d\">", i);
1505 escputs(floorlist[i]);
1506 wc_printf("</OPTION>\n");
1508 wc_printf("</select>\n");
1511 wc_printf(_("Type of room:"));
1512 wc_printf("<ul>\n");
1514 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1515 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1516 wc_printf("CHECKED ");
1517 wc_printf("OnChange=\""
1518 " if (this.form.type[0].checked == true) { "
1519 " this.form.er_floor.disabled = false; "
1522 wc_printf(_("Public (automatically appears to everyone)"));
1525 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1526 if ((er_flags & QR_PRIVATE) &&
1527 (er_flags & QR_GUESSNAME))
1528 wc_printf("CHECKED ");
1529 wc_printf(" OnChange=\""
1530 " if (this.form.type[1].checked == true) { "
1531 " this.form.er_floor.disabled = false; "
1534 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1536 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1537 if ((er_flags & QR_PRIVATE) &&
1538 (er_flags & QR_PASSWORDED))
1539 wc_printf("CHECKED ");
1540 wc_printf(" OnChange=\""
1541 " if (this.form.type[2].checked == true) { "
1542 " this.form.er_floor.disabled = false; "
1545 wc_printf(_("Private - require password: "));
1546 wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1549 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1550 if ((er_flags & QR_PRIVATE)
1551 && ((er_flags & QR_GUESSNAME) == 0)
1552 && ((er_flags & QR_PASSWORDED) == 0))
1553 wc_printf("CHECKED ");
1554 wc_printf(" OnChange=\""
1555 " if (this.form.type[3].checked == true) { "
1556 " this.form.er_floor.disabled = false; "
1559 wc_printf(_("Private - invitation only"));
1561 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1562 if (er_flags & QR_MAILBOX)
1563 wc_printf("CHECKED ");
1564 wc_printf (" OnChange=\""
1565 " if (this.form.type[4].checked == true) { "
1566 " this.form.er_floor.disabled = true; "
1569 wc_printf(_("Personal (mailbox for you only)"));
1571 wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1573 wc_printf(_("If private, cause current users to forget room"));
1575 wc_printf("\n</ul>\n");
1577 wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1578 if (er_flags & QR_PREFONLY)
1579 wc_printf("CHECKED ");
1581 wc_printf(_("Preferred users only"));
1583 wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1584 if (er_flags & QR_READONLY)
1585 wc_printf("CHECKED ");
1587 wc_printf(_("Read-only room"));
1589 wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1590 if (er_flags2 & QR2_COLLABDEL)
1591 wc_printf("CHECKED ");
1593 wc_printf(_("All users allowed to post may also delete messages"));
1595 /** directory stuff */
1596 wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1597 if (er_flags & QR_DIRECTORY)
1598 wc_printf("CHECKED ");
1600 wc_printf(_("File directory room"));
1602 wc_printf("\n<ul><li>");
1603 wc_printf(_("Directory name: "));
1604 wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1607 wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1608 if (er_flags & QR_UPLOAD)
1609 wc_printf("CHECKED ");
1611 wc_printf(_("Uploading allowed"));
1613 wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1614 if (er_flags & QR_DOWNLOAD)
1615 wc_printf("CHECKED ");
1617 wc_printf(_("Downloading allowed"));
1619 wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1620 if (er_flags & QR_VISDIR)
1621 wc_printf("CHECKED ");
1623 wc_printf(_("Visible directory"));
1624 wc_printf("</ul>\n");
1626 /** end of directory stuff */
1628 wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1629 if (er_flags & QR_NETWORK)
1630 wc_printf("CHECKED ");
1632 wc_printf(_("Network shared room"));
1634 wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1635 if (er_flags & QR_PERMANENT)
1636 wc_printf("CHECKED ");
1638 wc_printf(_("Permanent (does not auto-purge)"));
1640 wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1641 if (er_flags2 & QR2_SUBJECTREQ)
1642 wc_printf("CHECKED ");
1644 wc_printf(_("Subject Required (Force users to specify a message subject)"));
1646 /** start of anon options */
1648 wc_printf("\n<li>");
1649 wc_printf(_("Anonymous messages"));
1650 wc_printf("<ul>\n");
1652 wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1653 if (((er_flags & QR_ANONONLY) == 0)
1654 && ((er_flags & QR_ANONOPT) == 0))
1655 wc_printf("CHECKED ");
1657 wc_printf(_("No anonymous messages"));
1659 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1660 if (er_flags & QR_ANONONLY)
1661 wc_printf("CHECKED ");
1663 wc_printf(_("All messages are anonymous"));
1665 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1666 if (er_flags & QR_ANONOPT)
1667 wc_printf("CHECKED ");
1669 wc_printf(_("Prompt user when entering messages"));
1670 wc_printf("</ul>\n");
1672 /* end of anon options */
1675 wc_printf(_("Room aide: "));
1677 serv_getln(buf, sizeof buf);
1678 if (buf[0] != '2') {
1679 wc_printf("<em>%s</em>\n", &buf[4]);
1681 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1682 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1685 wc_printf("</ul><CENTER>\n");
1686 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1687 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1689 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1695 wc_printf("</div>");
1699 /* Sharing the room with other Citadel nodes... */
1700 if (!strcmp(tab, "sharing")) {
1701 wc_printf("<div class=\"tabcontent\">");
1703 shared_with = strdup("");
1704 not_shared_with = strdup("");
1706 /** Learn the current configuration */
1707 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1708 serv_getln(buf, sizeof buf);
1709 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1710 extract_token(node, buf, 0, '|', sizeof node);
1711 not_shared_with = realloc(not_shared_with,
1712 strlen(not_shared_with) + 32);
1713 strcat(not_shared_with, node);
1714 strcat(not_shared_with, "\n");
1718 serv_getln(buf, sizeof buf);
1719 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1720 extract_token(cmd, buf, 0, '|', sizeof cmd);
1721 extract_token(node, buf, 1, '|', sizeof node);
1722 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1723 if (!strcasecmp(cmd, "ignet_push_share")) {
1724 shared_with = realloc(shared_with,
1725 strlen(shared_with) + 32);
1726 strcat(shared_with, node);
1727 if (!IsEmptyStr(remote_room)) {
1728 strcat(shared_with, "|");
1729 strcat(shared_with, remote_room);
1731 strcat(shared_with, "\n");
1735 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1736 extract_token(buf, shared_with, i, '\n', sizeof buf);
1737 extract_token(node, buf, 0, '|', sizeof node);
1738 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1739 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1740 if (!strcasecmp(node, cmd)) {
1741 remove_token(not_shared_with, j, '\n');
1746 /* Display the stuff */
1747 wc_printf("<CENTER><br />"
1748 "<table border=1 cellpadding=5><tr>"
1750 wc_printf(_("Shared with"));
1751 wc_printf("</I></B></td>"
1753 wc_printf(_("Not shared with"));
1754 wc_printf("</I></B></td></tr>\n"
1755 "<tr><td VALIGN=TOP>\n");
1757 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1758 wc_printf(_("Remote node name"));
1759 wc_printf("</td><td>");
1760 wc_printf(_("Remote room name"));
1761 wc_printf("</td><td>");
1762 wc_printf(_("Actions"));
1763 wc_printf("</td></tr>\n");
1765 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1766 extract_token(buf, shared_with, i, '\n', sizeof buf);
1767 extract_token(node, buf, 0, '|', sizeof node);
1768 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1769 if (!IsEmptyStr(node)) {
1770 wc_printf("<form method=\"POST\" action=\"netedit\">");
1771 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1772 wc_printf("<tr><td>%s</td>\n", node);
1775 if (!IsEmptyStr(remote_room)) {
1776 escputs(remote_room);
1782 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1783 "VALUE=\"ignet_push_share|");
1785 if (!IsEmptyStr(remote_room)) {
1787 urlescputs(remote_room);
1790 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1791 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1792 wc_printf("<input type=\"submit\" "
1793 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1794 wc_printf("</td></tr></form>\n");
1798 wc_printf("</table>\n");
1799 wc_printf("</td><td VALIGN=TOP>\n");
1800 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1801 wc_printf(_("Remote node name"));
1802 wc_printf("</td><td>");
1803 wc_printf(_("Remote room name"));
1804 wc_printf("</td><td>");
1805 wc_printf(_("Actions"));
1806 wc_printf("</td></tr>\n");
1808 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1809 extract_token(node, not_shared_with, i, '\n', sizeof node);
1810 if (!IsEmptyStr(node)) {
1811 wc_printf("<form method=\"POST\" action=\"netedit\">");
1812 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1813 wc_printf("<tr><td>");
1815 wc_printf("</td><td>"
1816 "<input type=\"INPUT\" "
1820 wc_printf("<input type=\"hidden\" "
1822 "VALUE=\"ignet_push_share|");
1825 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1826 "VALUE=\"sharing\">\n");
1827 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1828 "VALUE=\"add\">\n");
1829 wc_printf("<input type=\"submit\" "
1830 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1831 wc_printf("</td></tr></form>\n");
1835 wc_printf("</table>\n");
1836 wc_printf("</td></tr>"
1837 "</table></CENTER><br />\n"
1838 "<I><B>%s</B><ul><li>", _("Notes:"));
1839 wc_printf(_("When sharing a room, "
1840 "it must be shared from both ends. Adding a node to "
1841 "the 'shared' list sends messages out, but in order to"
1842 " receive messages, the other nodes must be configured"
1843 " to send messages out to your system as well. "
1844 "<li>If the remote room name is blank, it is assumed "
1845 "that the room name is identical on the remote node."
1846 "<li>If the remote room name is different, the remote "
1847 "node must also configure the name of the room here."
1851 wc_printf("</div>");
1854 if (not_shared_with != NULL)
1855 free (not_shared_with);
1857 /* Mailing list management */
1858 if (!strcmp(tab, "listserv")) {
1859 room_states RoomFlags;
1860 wc_printf("<div class=\"tabcontent\">");
1862 wc_printf("<br /><center>"
1863 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1864 "<tr><td VALIGN=TOP>");
1866 wc_printf(_("<i>The contents of this room are being "
1867 "mailed <b>as individual messages</b> "
1868 "to the following list recipients:"
1869 "</i><br /><br />\n"));
1872 serv_getln(buf, sizeof buf);
1873 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1874 extract_token(cmd, buf, 0, '|', sizeof cmd);
1875 if (!strcasecmp(cmd, "listrecp")) {
1876 extract_token(recp, buf, 1, '|', sizeof recp);
1879 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1882 wc_printf(_("(remove)"));
1883 wc_printf("</A><br />");
1886 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1887 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1888 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1889 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1890 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1891 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1892 wc_printf("</form>\n");
1894 wc_printf("</td><td VALIGN=TOP>\n");
1896 wc_printf(_("<i>The contents of this room are being "
1897 "mailed <b>in digest form</b> "
1898 "to the following list recipients:"
1899 "</i><br /><br />\n"));
1902 serv_getln(buf, sizeof buf);
1903 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1904 extract_token(cmd, buf, 0, '|', sizeof cmd);
1905 if (!strcasecmp(cmd, "digestrecp")) {
1906 extract_token(recp, buf, 1, '|', sizeof recp);
1909 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1913 wc_printf(_("(remove)"));
1914 wc_printf("</A><br />");
1917 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1918 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1919 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1920 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1921 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1922 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1923 wc_printf("</form>\n");
1925 wc_printf("</td></tr></table>\n");
1927 /** Pop open an address book -- begin **/
1928 wc_printf("<div align=right>"
1929 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1931 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1936 _("Add recipients from Contacts or other address books"),
1937 _("Add recipients from Contacts or other address books")
1939 /* Pop open an address book -- end **/
1941 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1943 get_roomflags (&RoomFlags);
1945 /* Self Service subscription? */
1946 wc_printf("<table><tr><td>\n");
1947 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1948 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1949 " <tr><td colspan=\"2\">\n",
1950 (is_selflist(&RoomFlags))?"checked":"");
1951 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1952 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1953 (is_https ? "https" : "http"),
1954 ChrPtr(WC->Hdr->HR.http_host));
1955 /* Public posting? */
1956 wc_printf("<tr><td>");
1957 wc_printf(_("Allow non-subscribers to mail to this room."));
1958 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1959 (is_publiclist(&RoomFlags))?"checked":"");
1961 /* Moderated List? */
1962 wc_printf("<tr><td>");
1963 wc_printf(_("Room post publication needs Aide permission."));
1964 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1965 (is_moderatedlist(&RoomFlags))?"checked":"");
1968 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1969 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1970 wc_printf("</table></form>");
1973 wc_printf("</CENTER>\n");
1974 wc_printf("</div>");
1978 /* Configuration of The Dreaded Auto-Purger */
1979 if (!strcmp(tab, "expire")) {
1980 wc_printf("<div class=\"tabcontent\">");
1982 serv_puts("GPEX room");
1983 serv_getln(buf, sizeof buf);
1984 if (!strncmp(buf, "550", 3)) {
1985 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1986 _("Higher access is required to access this function.")
1989 else if (buf[0] != '2') {
1990 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1993 roompolicy = extract_int(&buf[4], 0);
1994 roomvalue = extract_int(&buf[4], 1);
1996 serv_puts("GPEX floor");
1997 serv_getln(buf, sizeof buf);
1998 if (buf[0] == '2') {
1999 floorpolicy = extract_int(&buf[4], 0);
2000 floorvalue = extract_int(&buf[4], 1);
2003 wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
2004 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2005 wc_printf("<table border=0 cellspacing=5>\n");
2006 wc_printf("<tr><td>");
2007 wc_printf(_("Message expire policy for this room"));
2008 wc_printf("<br />(");
2009 escputs(ChrPtr(WC->CurRoom.name));
2010 wc_printf(")</td><td>");
2011 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
2012 ((roompolicy == 0) ? "CHECKED" : "") );
2013 wc_printf(_("Use the default policy for this floor"));
2014 wc_printf("<br />\n");
2015 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
2016 ((roompolicy == 1) ? "CHECKED" : "") );
2017 wc_printf(_("Never automatically expire messages"));
2018 wc_printf("<br />\n");
2019 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
2020 ((roompolicy == 2) ? "CHECKED" : "") );
2021 wc_printf(_("Expire by message count"));
2022 wc_printf("<br />\n");
2023 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
2024 ((roompolicy == 3) ? "CHECKED" : "") );
2025 wc_printf(_("Expire by message age"));
2026 wc_printf("<br />");
2027 wc_printf(_("Number of messages or days: "));
2028 wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
2029 wc_printf("</td></tr>\n");
2031 if (WC->axlevel >= 6) {
2032 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
2033 wc_printf("<tr><td>");
2034 wc_printf(_("Message expire policy for this floor"));
2035 wc_printf("<br />(");
2036 escputs(floorlist[WC->CurRoom.floorid]);
2037 wc_printf(")</td><td>");
2038 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
2039 ((floorpolicy == 0) ? "CHECKED" : "") );
2040 wc_printf(_("Use the system default"));
2041 wc_printf("<br />\n");
2042 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
2043 ((floorpolicy == 1) ? "CHECKED" : "") );
2044 wc_printf(_("Never automatically expire messages"));
2045 wc_printf("<br />\n");
2046 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
2047 ((floorpolicy == 2) ? "CHECKED" : "") );
2048 wc_printf(_("Expire by message count"));
2049 wc_printf("<br />\n");
2050 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
2051 ((floorpolicy == 3) ? "CHECKED" : "") );
2052 wc_printf(_("Expire by message age"));
2053 wc_printf("<br />");
2054 wc_printf(_("Number of messages or days: "));
2055 wc_printf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
2059 wc_printf("<CENTER>\n");
2060 wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
2061 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
2062 wc_printf(" ");
2063 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2064 wc_printf("</CENTER></td><tr>\n");
2066 wc_printf("</table>\n"
2067 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
2072 wc_printf("</div>");
2075 /* Access controls */
2076 if (!strcmp(tab, "access")) {
2077 wc_printf("<div class=\"tabcontent\">");
2079 wc_printf("</div>");
2082 /* Fetch messages from remote locations */
2083 if (!strcmp(tab, "feeds")) {
2084 wc_printf("<div class=\"tabcontent\">");
2087 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
2088 wc_printf("</i><br />\n");
2090 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2091 "<tr class=\"even\"><th>");
2092 wc_printf(_("Remote host"));
2093 wc_printf("</th><th>");
2094 wc_printf(_("User name"));
2095 wc_printf("</th><th>");
2096 wc_printf(_("Password"));
2097 wc_printf("</th><th>");
2098 wc_printf(_("Keep messages on server?"));
2099 wc_printf("</th><th>");
2100 wc_printf(_("Interval"));
2101 wc_printf("</th><th> </th></tr>");
2104 serv_getln(buf, sizeof buf);
2106 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2107 extract_token(cmd, buf, 0, '|', sizeof cmd);
2108 if (!strcasecmp(cmd, "pop3client")) {
2109 safestrncpy(recp, &buf[11], sizeof recp);
2112 wc_printf("<tr class=\"%s\">",
2113 (bg ? "even" : "odd")
2117 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2122 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2126 wc_printf("<td>*****</td>"); /* Don't show the password */
2128 wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2130 wc_printf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2132 wc_printf("<td class=\"button_link\">");
2133 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2136 wc_printf(_("(remove)"));
2137 wc_printf("</a></td>");
2143 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2145 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2146 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2147 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2149 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2152 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2155 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2158 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2161 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2164 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2165 wc_printf("</td></tr>");
2166 wc_printf("</form></table>\n");
2168 wc_printf("<hr>\n");
2171 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2172 wc_printf("</i><br />\n");
2174 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2175 "<tr class=\"even\"><th>");
2176 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2177 wc_printf(_("Feed URL"));
2178 wc_printf("</th><th>");
2179 wc_printf("</th></tr>");
2182 serv_getln(buf, sizeof buf);
2184 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2185 extract_token(cmd, buf, 0, '|', sizeof cmd);
2186 if (!strcasecmp(cmd, "rssclient")) {
2187 safestrncpy(recp, &buf[10], sizeof recp);
2190 wc_printf("<tr class=\"%s\">",
2191 (bg ? "even" : "odd")
2195 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2199 wc_printf("<td class=\"button_link\">");
2200 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2203 wc_printf(_("(remove)"));
2204 wc_printf("</a></td>");
2210 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2212 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2213 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2214 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2216 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2217 "maxlength=\"256\" name=\"line_pop3host\">\n");
2220 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2221 wc_printf("</td></tr>");
2222 wc_printf("</form></table>\n");
2224 wc_printf("</div>");
2228 /* end content of whatever tab is open now */
2229 wc_printf("</div>\n");
2231 address_book_popup();
2237 * Toggle self-service list subscription
2239 void toggle_self_service(void) {
2240 room_states RoomFlags;
2242 get_roomflags (&RoomFlags);
2244 if (yesbstr("QR2_SelfList"))
2245 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2247 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2249 if (yesbstr("QR2_SMTP_PUBLIC"))
2250 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2252 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2254 if (yesbstr("QR2_Moderated"))
2255 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2257 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2258 if (yesbstr("QR2_SubsOnly"))
2259 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2261 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2263 set_roomflags (&RoomFlags);
2271 * save new parameters for a room
2278 StrBuf *er_password;
2280 StrBuf *er_roomaide;
2283 int er_listingorder;
2289 if (!havebstr("ok_button")) {
2290 strcpy(WC->ImportantMessage,
2291 _("Cancelled. Changes were not saved."));
2297 StrBuf_ServGetln(Buf);
2298 if (GetServerStatus(Buf, NULL) != 2) {
2299 StrBufCutLeft(Buf, 4);
2300 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2306 er_name = NewStrBuf();
2307 er_password = NewStrBuf();
2308 er_dirname = NewStrBuf();
2309 er_roomaide = NewStrBuf();
2311 StrBufCutLeft(Buf, 4);
2312 StrBufExtract_token(er_name, Buf, 0, '|');
2313 StrBufExtract_token(er_password, Buf, 1, '|');
2314 StrBufExtract_token(er_dirname, Buf, 2, '|');
2315 er_flags = StrBufExtract_int(Buf, 3, '|');
2316 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2317 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2318 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2320 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2321 if (StrLength(er_roomaide) == 0) {
2323 StrBuf_ServGetln(Buf);
2324 if (GetServerStatus(Buf, NULL) != 2) {
2325 FlushStrBuf(er_roomaide);
2327 StrBufCutLeft(Buf, 4);
2328 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2331 Ptr = sbstr("er_name");
2332 if (StrLength(Ptr) > 0) {
2333 FlushStrBuf(er_name);
2334 StrBufAppendBuf(er_name, Ptr, 0);
2337 Ptr = sbstr("er_password");
2338 if (StrLength(Ptr) > 0) {
2339 FlushStrBuf(er_password);
2340 StrBufAppendBuf(er_password, Ptr, 0);
2344 Ptr = sbstr("er_dirname");
2345 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2346 FlushStrBuf(er_dirname);
2347 StrBufAppendBuf(er_dirname, Ptr, 0);
2351 Ptr = sbstr("type");
2352 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2354 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2355 er_flags |= (QR_PRIVATE);
2357 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2358 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2360 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2361 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2363 if (!strcmp(ChrPtr(Ptr), "personal")) {
2364 er_flags |= QR_MAILBOX;
2366 er_flags &= ~QR_MAILBOX;
2369 if (yesbstr("prefonly")) {
2370 er_flags |= QR_PREFONLY;
2372 er_flags &= ~QR_PREFONLY;
2375 if (yesbstr("readonly")) {
2376 er_flags |= QR_READONLY;
2378 er_flags &= ~QR_READONLY;
2382 if (yesbstr("collabdel")) {
2383 er_flags2 |= QR2_COLLABDEL;
2385 er_flags2 &= ~QR2_COLLABDEL;
2388 if (yesbstr("permanent")) {
2389 er_flags |= QR_PERMANENT;
2391 er_flags &= ~QR_PERMANENT;
2394 if (yesbstr("subjectreq")) {
2395 er_flags2 |= QR2_SUBJECTREQ;
2397 er_flags2 &= ~QR2_SUBJECTREQ;
2400 if (yesbstr("network")) {
2401 er_flags |= QR_NETWORK;
2403 er_flags &= ~QR_NETWORK;
2406 if (yesbstr("directory")) {
2407 er_flags |= QR_DIRECTORY;
2409 er_flags &= ~QR_DIRECTORY;
2412 if (yesbstr("ulallowed")) {
2413 er_flags |= QR_UPLOAD;
2415 er_flags &= ~QR_UPLOAD;
2418 if (yesbstr("dlallowed")) {
2419 er_flags |= QR_DOWNLOAD;
2421 er_flags &= ~QR_DOWNLOAD;
2424 if (yesbstr("visdir")) {
2425 er_flags |= QR_VISDIR;
2427 er_flags &= ~QR_VISDIR;
2430 Ptr = sbstr("anon");
2432 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2433 if (!strcmp(ChrPtr(Ptr), "anononly"))
2434 er_flags |= QR_ANONONLY;
2435 if (!strcmp(ChrPtr(Ptr), "anon2"))
2436 er_flags |= QR_ANONOPT;
2438 bump = yesbstr("bump");
2440 er_floor = ibstr("er_floor");
2442 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2444 ChrPtr(er_password),
2453 StrBuf_ServGetln(Buf);
2454 if (GetServerStatus(Buf, NULL) != 2) {
2455 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2458 FreeStrBuf(&er_name);
2459 FreeStrBuf(&er_password);
2460 FreeStrBuf(&er_dirname);
2461 FreeStrBuf(&er_roomaide);
2466 if (StrLength(er_roomaide) > 0) {
2467 serv_printf("SETA %s", ChrPtr(er_roomaide));
2468 StrBuf_ServGetln(Buf);
2469 if (GetServerStatus(Buf, NULL) != 2) {
2470 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2471 display_main_menu();
2473 FreeStrBuf(&er_name);
2474 FreeStrBuf(&er_password);
2475 FreeStrBuf(&er_dirname);
2476 FreeStrBuf(&er_roomaide);
2481 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2484 FreeStrBuf(&er_name);
2485 FreeStrBuf(&er_password);
2486 FreeStrBuf(&er_dirname);
2487 FreeStrBuf(&er_roomaide);
2493 * Display form for Invite, Kick, and show Who Knows a room
2495 void do_invt_kick(void) {
2496 char buf[SIZ], room[SIZ], username[SIZ];
2499 serv_getln(buf, sizeof buf);
2501 if (buf[0] != '2') {
2505 extract_token(room, &buf[4], 0, '|', sizeof room);
2507 strcpy(username, bstr("username"));
2509 if (havebstr("kick_button")) {
2510 sprintf(buf, "KICK %s", username);
2512 serv_getln(buf, sizeof buf);
2514 if (buf[0] != '2') {
2515 strcpy(WC->ImportantMessage, &buf[4]);
2517 sprintf(WC->ImportantMessage,
2518 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2523 if (havebstr("invite_button")) {
2524 sprintf(buf, "INVT %s", username);
2526 serv_getln(buf, sizeof buf);
2528 if (buf[0] != '2') {
2529 strcpy(WC->ImportantMessage, &buf[4]);
2531 sprintf(WC->ImportantMessage,
2532 _("<B><I>User %s invited to room %s.</I></B>\n"),
2543 * Display form for Invite, Kick, and show Who Knows a room
2545 void display_whok(void)
2547 char buf[SIZ], room[SIZ], username[SIZ];
2550 serv_getln(buf, sizeof buf);
2552 if (buf[0] != '2') {
2556 extract_token(room, &buf[4], 0, '|', sizeof room);
2559 wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2560 wc_printf(_("The users listed below have access to this room. "
2561 "To remove a user from the access list, select the user "
2562 "name from the list and click 'Kick'."));
2563 wc_printf("<br /><br />");
2565 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2566 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2567 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2568 wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2570 serv_getln(buf, sizeof buf);
2571 if (buf[0] == '1') {
2572 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2573 extract_token(username, buf, 0, '|', sizeof username);
2574 wc_printf("<OPTION>");
2579 wc_printf("</select><br />\n");
2581 wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2582 wc_printf("</form></CENTER>\n");
2584 wc_printf("</td><td>");
2585 wc_printf(_("To grant another user access to this room, enter the "
2586 "user name in the box below and click 'Invite'."));
2587 wc_printf("<br /><br />");
2589 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2590 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2591 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2592 wc_printf(_("Invite:"));
2594 wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2595 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2596 "<input type=\"submit\" value=\"%s\">"
2597 "</form></CENTER>\n", _("Invite"));
2598 /* Pop open an address book -- begin **/
2600 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2602 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2605 _("Users"), _("Users")
2607 /* Pop open an address book -- end **/
2609 wc_printf("</td></tr></table>\n");
2610 address_book_popup();
2617 * display the form for entering a new room
2619 void display_entroom(void)
2626 serv_puts("CRE8 0");
2627 serv_getln(buf, sizeof buf);
2629 if (buf[0] != '2') {
2630 strcpy(WC->ImportantMessage, &buf[4]);
2631 display_main_menu();
2636 output_headers(1, 1, 1, 0, 0, 0);
2638 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2639 do_template("beginbox", NULL);
2641 wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2642 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2644 wc_printf("<table class=\"altern\"> ");
2646 wc_printf("<tr class=\"even\"><td>");
2647 wc_printf(_("Name of room: "));
2648 wc_printf("</td><td>");
2649 wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2650 wc_printf("</td></tr>");
2652 wc_printf("<tr class=\"odd\"><td>");
2653 wc_printf(_("Resides on floor: "));
2654 wc_printf("</td><td>");
2655 load_floorlist(Buf);
2656 wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2657 for (i = 0; i < 128; ++i)
2658 if (!IsEmptyStr(floorlist[i])) {
2659 wc_printf("<option ");
2660 wc_printf("value=\"%d\">", i);
2661 escputs(floorlist[i]);
2662 wc_printf("</option>\n");
2664 wc_printf("</select>\n");
2665 wc_printf("</td></tr>");
2668 * Our clever little snippet of JavaScript automatically selects
2669 * a public room if the view is set to Bulletin Board or wiki, and
2670 * it selects a mailbox room otherwise. The user can override this,
2671 * of course. We also disable the floor selector for mailboxes.
2673 wc_printf("<tr class=\"even\"><td>");
2674 wc_printf(_("Default view for room: "));
2675 wc_printf("</td><td>");
2676 wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2677 " if ( (this.form.er_view.value == 0) "
2678 " || (this.form.er_view.value == 6) ) { "
2679 " this.form.type[0].checked=true; "
2680 " this.form.er_floor.disabled = false; "
2683 " this.form.type[4].checked=true; "
2684 " this.form.er_floor.disabled = true; "
2687 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2688 if (is_view_allowed_as_default(i)) {
2689 wc_printf("<option %s value=\"%d\">",
2690 ((i == 0) ? "selected" : ""), i );
2691 escputs(viewdefs[i]);
2692 wc_printf("</option>\n");
2695 wc_printf("</select>\n");
2696 wc_printf("</td></tr>");
2698 wc_printf("<tr class=\"even\"><td>");
2699 wc_printf(_("Type of room:"));
2700 wc_printf("</td><td>");
2701 wc_printf("<ul class=\"adminlist\">\n");
2703 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2704 wc_printf("CHECKED OnChange=\""
2705 " if (this.form.type[0].checked == true) { "
2706 " this.form.er_floor.disabled = false; "
2709 wc_printf(_("Public (automatically appears to everyone)"));
2712 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2713 " if (this.form.type[1].checked == true) { "
2714 " this.form.er_floor.disabled = false; "
2717 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2720 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2721 " if (this.form.type[2].checked == true) { "
2722 " this.form.er_floor.disabled = false; "
2725 wc_printf(_("Private - require password: "));
2726 wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2729 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2730 " if (this.form.type[3].checked == true) { "
2731 " this.form.er_floor.disabled = false; "
2734 wc_printf(_("Private - invitation only"));
2737 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2739 " if (this.form.type[4].checked == true) { "
2740 " this.form.er_floor.disabled = true; "
2743 wc_printf(_("Personal (mailbox for you only)"));
2746 wc_printf("\n</ul>\n");
2747 wc_printf("</td></tr></table>\n");
2749 wc_printf("<div class=\"buttons\">\n");
2750 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2751 wc_printf(" ");
2752 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2753 wc_printf("</div>\n");
2754 wc_printf("</form>\n<hr />");
2755 serv_printf("MESG roomaccess");
2756 serv_getln(buf, sizeof buf);
2757 if (buf[0] == '1') {
2761 do_template("endbox", NULL);
2771 * support function for entroom() -- sets the default view
2773 void er_set_default_view(int newview) {
2786 serv_getln(buf, sizeof buf);
2787 if (buf[0] != '2') return;
2789 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2790 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2791 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2792 rm_bits1 = extract_int(&buf[4], 3);
2793 rm_floor = extract_int(&buf[4], 4);
2794 rm_listorder = extract_int(&buf[4], 5);
2795 rm_bits2 = extract_int(&buf[4], 7);
2797 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2798 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2799 rm_listorder, newview, rm_bits2
2801 serv_getln(buf, sizeof buf);
2812 const StrBuf *er_name;
2813 const StrBuf *er_type;
2814 const StrBuf *er_password;
2818 wcsession *WCC = WC;
2820 if (!havebstr("ok_button")) {
2821 strcpy(WC->ImportantMessage,
2822 _("Cancelled. No new room was created."));
2823 display_main_menu();
2826 er_name = sbstr("er_name");
2827 er_type = sbstr("type");
2828 er_password = sbstr("er_password");
2829 er_floor = ibstr("er_floor");
2830 er_view = ibstr("er_view");
2833 if (!strcmp(ChrPtr(er_type), "hidden"))
2835 else if (!strcmp(ChrPtr(er_type), "passworded"))
2837 else if (!strcmp(ChrPtr(er_type), "invonly"))
2839 else if (!strcmp(ChrPtr(er_type), "personal"))
2842 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2845 ChrPtr(er_password),
2850 serv_getln(buf, sizeof buf);
2851 if (buf[0] != '2') {
2852 strcpy(WCC->ImportantMessage, &buf[4]);
2853 display_main_menu();
2856 /** TODO: Room created, now update the left hand icon bar for this user */
2857 burn_folder_cache(0); /* burn the old folder cache */
2861 serv_printf("VIEW %d", er_view);
2862 serv_getln(buf, sizeof buf);
2863 WCC->CurRoom.view = er_view;
2865 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
2866 display_editroom ();
2868 do_change_view(er_view); /* Now go there */
2875 * \brief display the screen to enter a private room
2877 void display_private(char *rname, int req_pass)
2879 WCTemplputParams SubTP;
2881 output_headers(1, 1, 1, 0, 0, 0);
2883 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2884 memset(&SubTP, 0, sizeof(WCTemplputParams));
2885 SubTP.Filter.ContextType = CTX_STRBUF;
2886 SubTP.Context = Buf;
2887 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2892 wc_printf(_("If you know the name of a hidden (guess-name) or "
2893 "passworded room, you can enter that room by typing "
2894 "its name below. Once you gain access to a private "
2895 "room, it will appear in your regular room listings "
2896 "so you don't have to keep returning here."));
2899 wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2900 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2902 wc_printf("<table class=\"altern\"> "
2903 "<tr class=\"even\"><td>");
2904 wc_printf(_("Enter room name:"));
2905 wc_printf("</td><td>"
2906 "<input type=\"text\" name=\"gr_name\" "
2907 "value=\"%s\" maxlength=\"128\">\n", rname);
2910 wc_printf("</td></tr><tr class=\"odd\"><td>");
2911 wc_printf(_("Enter room password:"));
2912 wc_printf("</td><td>");
2913 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2915 wc_printf("</td></tr></table>\n");
2917 wc_printf("<div class=\"buttons\">\n");
2918 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2920 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2924 wc_printf("</div></form>\n");
2926 do_template("endbox", NULL);
2932 * \brief goto a private room
2934 void goto_private(void)
2939 if (!havebstr("ok_button")) {
2940 display_main_menu();
2943 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2944 serv_printf("GOTO %s|%s",
2947 serv_getln(buf, sizeof buf);
2949 if (buf[0] == '2') {
2950 smart_goto(sbstr("gr_name"));
2953 if (!strncmp(buf, "540", 3)) {
2954 display_private(bstr("gr_name"), 1);
2957 output_headers(1, 1, 1, 0, 0, 0);
2958 wc_printf("%s\n", &buf[4]);
2965 * \brief display the screen to zap a room
2967 void display_zap(void)
2969 output_headers(1, 1, 2, 0, 0, 0);
2971 wc_printf("<div id=\"banner\">\n");
2973 wc_printf(_("Zap (forget/unsubscribe) the current room"));
2974 wc_printf("</h1>\n");
2975 wc_printf("</div>\n");
2977 wc_printf("<div id=\"content\" class=\"service\">\n");
2979 wc_printf(_("If you select this option, <em>%s</em> will "
2980 "disappear from your room list. Is this what you wish "
2981 "to do?<br />\n"), ChrPtr(WC->CurRoom.name));
2983 wc_printf("<form method=\"POST\" action=\"zap\">\n");
2984 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2985 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2986 wc_printf(" ");
2987 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2988 wc_printf("</form>\n");
2999 StrBuf *final_destination;
3002 * If the forget-room routine fails for any reason, we fall back
3003 * to the current room; otherwise, we go to the Lobby
3005 final_destination = NewStrBufDup(WC->CurRoom.name);
3007 if (havebstr("ok_button")) {
3008 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
3009 serv_getln(buf, sizeof buf);
3010 if (buf[0] == '2') {
3012 serv_getln(buf, sizeof buf);
3013 if (buf[0] == '2') {
3014 FlushStrBuf(final_destination);
3015 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
3019 smart_goto(final_destination);
3020 FreeStrBuf(&final_destination);
3026 * \brief Delete the current room
3028 void delete_room(void)
3033 serv_puts("KILL 1");
3034 serv_getln(buf, sizeof buf);
3035 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
3036 if (buf[0] != '2') {
3037 strcpy(WC->ImportantMessage, &buf[4]);
3038 display_main_menu();
3043 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
3052 * \brief Perform changes to a room's network configuration
3054 void netedit(void) {
3063 /*/ TODO: do line dynamic! */
3064 if (havebstr("line_pop3host")) {
3065 strcpy(line, bstr("prefix"));
3066 strcat(line, bstr("line_pop3host"));
3068 strcat(line, bstr("line_pop3user"));
3070 strcat(line, bstr("line_pop3pass"));
3072 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
3074 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
3075 strcat(line, bstr("suffix"));
3077 else if (havebstr("line")) {
3078 strcpy(line, bstr("prefix"));
3079 strcat(line, bstr("line"));
3080 strcat(line, bstr("suffix"));
3095 serv_getln(buf, sizeof buf);
3096 if (buf[0] != '1') {
3102 /** This loop works for add *or* remove. Spiffy, eh? */
3103 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3104 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
3105 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
3106 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
3107 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
3108 if ( (strcasecmp(cmpa0, cmpb0))
3109 || (strcasecmp(cmpa1, cmpb1)) ) {
3110 fprintf(fp, "%s\n", buf);
3116 serv_getln(buf, sizeof buf);
3117 if (buf[0] != '4') {
3123 while (fgets(buf, sizeof buf, fp) != NULL) {
3124 buf[strlen(buf)-1] = 0;
3128 if (havebstr("add_button")) {
3129 num_addrs = num_tokens(bstr("line"), ',');
3130 if (num_addrs < 2) {
3131 /* just adding one node or address */
3135 /* adding multiple addresses separated by commas */
3136 for (i=0; i<num_addrs; ++i) {
3137 strcpy(line, bstr("prefix"));
3138 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3141 strcat(line, bstr("suffix"));
3155 * \brief Convert a room name to a folder-ish-looking name.
3156 * \param folder the folderish name
3157 * \param room the room name
3158 * \param floor the floor name
3159 * \param is_mailbox is it a mailbox?
3161 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3166 * For mailboxes, just do it straight...
3169 sprintf(folder, "My folders|%s", room);
3173 * Otherwise, prefix the floor name as a "public folders" moniker
3176 if (floor > MAX_FLOORS) {
3178 sprintf(folder, "%%%%%%|%s", room);
3181 sprintf(folder, "%s|%s", floorlist[floor], room);
3186 * Replace "\" characters with "|" for pseudo-folder-delimiting
3188 len = strlen (folder);
3189 for (i=0; i<len; ++i) {
3190 if (folder[i] == '\\') folder[i] = '|';
3198 * \brief Back end for change_view()
3199 * \param newview set newview???
3201 void do_change_view(int newview) {
3204 serv_printf("VIEW %d", newview);
3205 serv_getln(buf, sizeof buf);
3206 WC->CurRoom.view = newview;
3207 smart_goto(WC->CurRoom.name);
3213 * \brief Change the view for this room
3215 void change_view(void) {
3218 view = lbstr("view");
3219 do_change_view(view);
3223 * \brief Burn the cached folder list.
3224 * \param age How old the cahce needs to be before we burn it.
3227 void burn_folder_cache(time_t age)
3229 /** If our cached folder list is very old, burn it. */
3230 if (WC->cache_fold != NULL) {
3231 if ((time(NULL) - WC->cache_timestamp) > age) {
3232 free(WC->cache_fold);
3233 WC->cache_fold = NULL;
3241 * \brief Do either a known rooms list or a folders list, depending on the
3246 StrBuf *ListView = NULL;
3248 /** Determine whether the user is trying to change views */
3249 if (havebstr("view")) {
3250 ListView = NewStrBufDup(SBSTR("view"));
3251 set_preference("roomlistview", ListView, 1);
3253 /** Sanitize the input so its safe */
3254 if((get_preference("roomlistview", &ListView) != 0)||
3255 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3256 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3258 if (ListView == NULL) {
3259 ListView = NewStrBufPlain(HKEY("rooms"));
3260 set_preference("roomlistview", ListView, 0);
3264 ListView = NewStrBufPlain(HKEY("rooms"));
3265 set_preference("roomlistview", ListView, 0);
3269 FreeStrBuf(&ListView);
3276 * \brief Set the message expire policy for this room and/or floor
3278 void set_room_policy(void) {
3281 if (!havebstr("ok_button")) {
3282 strcpy(WC->ImportantMessage,
3283 _("Cancelled. Changes were not saved."));
3288 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3289 serv_getln(buf, sizeof buf);
3290 strcpy(WC->ImportantMessage, &buf[4]);
3292 if (WC->axlevel >= 6) {
3293 strcat(WC->ImportantMessage, "<br />\n");
3294 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3295 serv_getln(buf, sizeof buf);
3296 strcat(WC->ImportantMessage, &buf[4]);
3302 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3304 StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3308 void _display_private(void) {
3309 display_private("", 0);
3312 void dotgoto(void) {
3313 if (!havebstr("room")) {
3314 readloop(readnew, eUseDefault);
3317 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3320 smart_goto(sbstr("room"));
3325 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3327 wcsession *WCC = WC;
3330 StrBufAppendTemplate(Target, TP,
3335 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3337 wc_printf("<div id=\"banner\">\n");
3338 embed_room_banner(NULL, navbar_default);
3339 wc_printf("</div>\n");
3343 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3345 wcsession *WCC = WC;
3348 (!IsEmptyStr(WCC->ugname)))
3349 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3352 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3354 wcsession *WCC = WC;
3355 return (WCC != NULL)?
3356 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3359 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3361 wcsession *WCC = WC;
3362 return (WCC == NULL)? 0 :
3363 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3364 (WCC->CurRoom.is_inbox) ||
3365 (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3368 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3370 wcsession *WCC = WC;
3372 return ((WCC!=NULL) &&
3373 (!IsEmptyStr(WCC->ugname)) &&
3374 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3378 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
3380 folder *Folder = (folder *)(TP->Context);
3383 UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3384 if (UA_CheckFlag == 0)
3385 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3386 "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
3388 return ((Folder->RAFlags & UA_CheckFlag) != 0);
3393 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3396 wcsession *WCC = WC;
3398 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3399 if (QR_CheckFlag == 0)
3400 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3401 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3403 return ((WCC!=NULL) &&
3404 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3407 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3410 folder *Folder = (folder *)(TP->Context);
3412 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3413 if (QR_CheckFlag == 0)
3414 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3415 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3416 return ((Folder->QRFlags & QR_CheckFlag) != 0);
3420 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3423 wcsession *WCC = WC;
3425 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3426 if (QR2_CheckFlag == 0)
3427 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3428 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3430 return ((WCC!=NULL) &&
3431 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3434 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3437 folder *Folder = (folder *)(TP->Context);
3439 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3440 if (QR2_CheckFlag == 0)
3441 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3442 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3443 return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3447 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3449 wcsession *WCC = WC;
3451 return ( (WCC!= NULL) &&
3452 ((WCC->axlevel >= 6) ||
3453 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3454 (WCC->CurRoom.is_inbox) ));
3457 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3459 wcsession *WCC = WC;
3461 if ((WCC == NULL) ||
3462 (TP->Tokens->nParameters < 3))
3464 return ((WCC->CurRoom.view < VIEW_BBS) ||
3465 (WCC->CurRoom.view > VIEW_MAX));
3468 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3472 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
3474 wcsession *WCC = WC;
3478 HashList *Whok = NULL;
3484 Token = NewStrBuf();
3485 StrBuf_ServGetln(Line);
3486 if (GetServerStatus(Line, &State) == 1)
3488 Whok = NewHash(1, Flathash);
3489 while(!Done && StrBuf_ServGetln(Line))
3490 if ( (StrLength(Line)==3) &&
3491 !strcmp(ChrPtr(Line), "000"))
3498 const char *Pos = NULL;
3499 Token = NewStrBufPlain (NULL, StrLength(Line));
3500 StrBufExtract_NextToken(Token, Line, &Pos, '|');
3508 else if (State == 550)
3509 StrBufAppendBufPlain(WCC->ImportantMsg,
3510 _("Higher access is required to access this function."), -1, 0);
3520 initialize_viewdefs();
3521 RegisterPreference("roomlistview",
3522 _("Room list view"),
3525 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3527 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3530 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3531 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3532 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3533 WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3534 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3535 WebcitAddUrlHandler(HKEY("zapped_list"), "", 0, zapped_list, 0);
3536 WebcitAddUrlHandler(HKEY("display_zap"), "", 0, display_zap, 0);
3537 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3538 WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3539 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3540 WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3541 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3542 WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3543 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3544 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3545 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3546 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3547 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3548 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3549 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3551 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3552 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3553 RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3555 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3556 RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3557 RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
3559 RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
3560 RegisterNamespace("THISROOM:MSGS:NEW", 0, 0, tmplput_CurrentRoom_nNewMessages, NULL, CTX_NONE);
3561 RegisterNamespace("THISROOM:MSGS:TOTAL", 0, 0, tmplput_CurrentRoom_nTotalMessages, NULL, CTX_NONE);
3563 RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
3564 RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3565 RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3566 RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3567 RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3568 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3569 RegisterConditional(HKEY("COND:THISROOM:HAVE_VIEW"), 0, ConditionalThisRoomHaveView, CTX_NONE);
3570 RegisterNamespace("THISROOM:VIEW_STRING", 0, 1, tmplput_CurrentRoomViewString, NULL, CTX_NONE);
3571 RegisterNamespace("ROOM:VIEW_STRING", 1, 2, tmplput_RoomViewString, NULL, CTX_NONE);
3573 RegisterNamespace("THISROOM:INFOTEXT", 1, 2, tmplput_CurrentRoomInfoText, NULL, CTX_NONE);
3574 RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3575 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3576 RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
3577 RegisterConditional(HKEY("COND:THISROOM:HAVE_INFOTEXT"), 0, ConditionalThisRoomXHaveInfoText, CTX_NONE);
3578 RegisterNamespace("THISROOM:FILES:N", 0, 1, tmplput_CurrentRoomXNFiles, NULL, CTX_NONE);
3579 RegisterNamespace("THISROOM:FILES:STR", 0, 1, tmplput_CurrentRoomX_FileString, NULL, CTX_NONE);
3581 REGISTERTokenParamDefine(QR_PERMANENT);
3582 REGISTERTokenParamDefine(QR_INUSE);
3583 REGISTERTokenParamDefine(QR_PRIVATE);
3584 REGISTERTokenParamDefine(QR_PASSWORDED);
3585 REGISTERTokenParamDefine(QR_GUESSNAME);
3586 REGISTERTokenParamDefine(QR_DIRECTORY);
3587 REGISTERTokenParamDefine(QR_UPLOAD);
3588 REGISTERTokenParamDefine(QR_DOWNLOAD);
3589 REGISTERTokenParamDefine(QR_VISDIR);
3590 REGISTERTokenParamDefine(QR_ANONONLY);
3591 REGISTERTokenParamDefine(QR_ANONOPT);
3592 REGISTERTokenParamDefine(QR_NETWORK);
3593 REGISTERTokenParamDefine(QR_PREFONLY);
3594 REGISTERTokenParamDefine(QR_READONLY);
3595 REGISTERTokenParamDefine(QR_MAILBOX);
3596 REGISTERTokenParamDefine(QR2_SYSTEM);
3597 REGISTERTokenParamDefine(QR2_SELFLIST);
3598 REGISTERTokenParamDefine(QR2_COLLABDEL);
3599 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3600 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3601 REGISTERTokenParamDefine(QR2_MODERATED);
3603 REGISTERTokenParamDefine(UA_KNOWN);
3604 REGISTERTokenParamDefine(UA_GOTOALLOWED);
3605 REGISTERTokenParamDefine(UA_HASNEWMSGS);
3606 REGISTERTokenParamDefine(UA_ZAPPED);
3607 REGISTERTokenParamDefine(UA_POSTALLOWED);
3608 REGISTERTokenParamDefine(UA_ADMINALLOWED);
3609 REGISTERTokenParamDefine(UA_DELETEALLOWED);
3610 REGISTERTokenParamDefine(UA_ISTRASH);
3612 REGISTERTokenParamDefine(US_NEEDVALID);
3613 REGISTERTokenParamDefine(US_PERM);
3614 REGISTERTokenParamDefine(US_LASTOLD);
3615 REGISTERTokenParamDefine(US_EXPERT);
3616 REGISTERTokenParamDefine(US_UNLISTED);
3617 REGISTERTokenParamDefine(US_NOPROMPT);
3618 REGISTERTokenParamDefine(US_PROMPTCTL);
3619 REGISTERTokenParamDefine(US_DISAPPEAR);
3620 REGISTERTokenParamDefine(US_REGIS);
3621 REGISTERTokenParamDefine(US_PAGINATOR);
3622 REGISTERTokenParamDefine(US_INTERNET);
3623 REGISTERTokenParamDefine(US_FLOORS);
3624 REGISTERTokenParamDefine(US_COLOR);
3625 REGISTERTokenParamDefine(US_USER_SET);
3627 REGISTERTokenParamDefine(VIEW_BBS);
3628 REGISTERTokenParamDefine(VIEW_MAILBOX);
3629 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3630 REGISTERTokenParamDefine(VIEW_CALENDAR);
3631 REGISTERTokenParamDefine(VIEW_TASKS);
3632 REGISTERTokenParamDefine(VIEW_NOTES);
3633 REGISTERTokenParamDefine(VIEW_WIKI);
3634 REGISTERTokenParamDefine(VIEW_CALBRIEF);
3635 REGISTERTokenParamDefine(VIEW_JOURNAL);
3636 REGISTERTokenParamDefine(VIEW_BLOG);
3639 REGISTERTokenParamDefine(ignet_push_share);
3640 { /* these are the parts of an IGNET push config */
3641 REGISTERTokenParamDefine(GNET_IGNET_NODE);
3642 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
3644 REGISTERTokenParamDefine(listrecp);
3645 REGISTERTokenParamDefine(digestrecp);
3646 REGISTERTokenParamDefine(pop3client);
3647 { /* These are the parts of a pop3 client line... */
3648 REGISTERTokenParamDefine(GNET_POP3_HOST);
3649 REGISTERTokenParamDefine(GNET_POP3_USER);
3650 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
3651 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
3653 REGISTERTokenParamDefine(rssclient);
3654 REGISTERTokenParamDefine(participate);
3656 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3657 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3659 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3660 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3662 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3663 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3664 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3671 SessionDestroyModule_ROOMOPS
3674 FlushFolder(&sess->CurRoom);
3675 if (sess->cache_fold != NULL) {
3676 free(sess->cache_fold);
3679 free_march_list(sess);
3680 DeleteHash(&sess->Floors);
3681 DeleteHash(&sess->Rooms);
3682 DeleteHash(&sess->FloorsByName);