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);
254 * Embed the room banner
256 * got The information returned from a GOTO server command
257 * navbar_style Determines which navigation buttons to display
261 void embed_room_banner(char *got)
267 * We need to have the information returned by a GOTO server command.
268 * If it isn't supplied, we fake it by issuing our own GOTO.
271 memset(buf, '0', 20);
273 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
274 serv_getln(buf, sizeof buf);
278 /* The browser needs some information for its own use */
279 wc_printf("<script type=\"text/javascript\"> \n"
280 " room_is_trash = %d; \n"
282 ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
286 * If the user happens to select the "make this my start page" link,
287 * we want it to remember the URL as a "/dotskip" one instead of
288 * a "skip" or "gotonext" or something like that.
290 if (WCC->Hdr->this_page == NULL) {
291 WCC->Hdr->this_page = NewStrBuf();
293 StrBufPrintf(WCC->Hdr->this_page,
295 ChrPtr(WC->CurRoom.name)
298 /* Check for new mail. */
299 WC->new_mail = extract_int(&got[4], 9);
300 WC->CurRoom.view = extract_int(&got[4], 11);
302 do_template("roombanner", NULL);
303 /* roombanner contains this for mobile */
304 if (WC->is_mobile < 1) {
306 wc_printf("<div id=\"navbar\"><ul>");
309 "<li class=\"ungoto\">"
310 "<a href=\"ungoto\">"
311 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
312 "<span class=\"navbar_link\">%s</span></A>"
313 "</li>\n", _("Ungoto")
316 if (WC->CurRoom.view == VIEW_BBS) {
318 "<li class=\"newmess\">"
319 "<a href=\"readnew\">"
320 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
321 "<span class=\"navbar_link\">%s</span></A>"
322 "</li>\n", _("Read new messages")
326 switch(WC->CurRoom.view) {
327 case VIEW_ADDRESSBOOK:
329 "<li class=\"viewcontacts\">"
330 "<a href=\"readfwd\">"
331 "<img src=\"static/viewcontacts_24x.gif\" "
332 "alt=\"\" width=\"24\" height=\"24\">"
333 "<span class=\"navbar_link\">"
335 "</span></a></li>\n", _("View contacts")
340 "<li class=\"staskday\">"
341 "<a href=\"readfwd?calview=day\">"
342 "<img src=\"static/taskday2_24x.gif\" "
343 "alt=\"\" width=\"24\" height=\"24\">"
344 "<span class=\"navbar_link\">"
346 "</span></a></li>\n", _("Day view")
349 "<li class=\"monthview\">"
350 "<a href=\"readfwd?calview=month\">"
351 "<img src=\"static/monthview2_24x.gif\" "
352 "alt=\"\" width=\"24\" height=\"24\">"
353 "<span class=\"navbar_link\">"
355 "</span></a></li>\n", _("Month view")
360 "<li class=\"monthview\">"
361 "<a href=\"readfwd?calview=month\">"
362 "<img src=\"static/monthview2_24x.gif\" "
363 "alt=\"\" width=\"24\" height=\"24\">"
364 "<span class=\"navbar_link\">"
366 "</span></a></li>\n", _("Calendar list")
371 "<li class=\"taskmanag\">"
372 "<a href=\"readfwd\">"
373 "<img src=\"static/taskmanag_24x.gif\" "
374 "alt=\"\" width=\"24\" height=\"24\">"
375 "<span class=\"navbar_link\">"
377 "</span></a></li>\n", _("View tasks")
382 "<li class=\"viewnotes\">"
383 "<a href=\"readfwd\">"
384 "<img src=\"static/viewnotes_24x.gif\" "
385 "alt=\"\" width=\"24\" height=\"24\">"
386 "<span class=\"navbar_link\">"
388 "</span></a></li>\n", _("View notes")
393 "<li class=\"readallmess\">"
394 "<a id=\"m_refresh\" href=\"readfwd\">"
395 "<img src=\"static/readallmess3_24x.gif\" "
396 "alt=\"\" width=\"24\" height=\"24\">"
397 "<span class=\"navbar_link\">"
399 "</span></a></li>\n", _("Refresh message list")
404 "<li class=\"readallmess\">"
405 "<a href=\"wiki?page=home\">"
406 "<img src=\"static/readallmess3_24x.gif\" "
407 "alt=\"\" width=\"24\" height=\"24\">"
408 "<span class=\"navbar_link\">"
410 "</span></a></li>\n", _("Wiki home")
415 "<li class=\"readallmess\">"
416 "<a href=\"readfwd\">"
417 "<img src=\"static/readallmess3_24x.gif\" "
418 "alt=\"\" width=\"24\" height=\"24\">"
419 "<span class=\"navbar_link\">"
421 "</span></a></li>\n", _("Read all messages")
426 switch(WC->CurRoom.view) {
427 case VIEW_ADDRESSBOOK:
429 "<li class=\"addnewcontact\">"
430 "<a href=\"display_enter\">"
431 "<img src=\"static/addnewcontact_24x.gif\" "
432 "alt=\"\" width=\"24\" height=\"24\">"
433 "<span class=\"navbar_link\">"
435 "</span></a></li>\n", _("Add new contact")
440 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
441 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
442 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
443 if (havebstr("day" )) wc_printf("?day=%s", bstr("day"));
445 "<img src=\"static/addevent_24x.gif\" "
446 "alt=\"\" width=\"24\" height=\"24\">"
447 "<span class=\"navbar_link\">"
449 "</span></a></li>\n", _("Add new event")
454 "<li class=\"newmess\">"
455 "<a href=\"display_enter\">"
456 "<img src=\"static/newmess3_24x.gif\" "
457 "alt=\"\" width=\"24\" height=\"24\">"
458 "<span class=\"navbar_link\">"
460 "</span></a></li>\n", _("Add new task")
465 "<li class=\"enternewnote\">"
466 "<a href=\"add_new_note\">"
467 "<img src=\"static/enternewnote_24x.gif\" "
468 "alt=\"\" width=\"24\" height=\"24\">"
469 "<span class=\"navbar_link\">"
471 "</span></a></li>\n", _("Add new note")
475 safestrncpy(buf, bstr("page"), sizeof buf);
476 if (IsEmptyStr(buf)) {
477 safestrncpy(buf, "home", sizeof buf);
481 "<li class=\"newmess\">"
482 "<a href=\"display_enter?page=%s\">"
483 "<img src=\"static/newmess3_24x.gif\" "
484 "alt=\"\" width=\"24\" height=\"24\">"
485 "<span class=\"navbar_link\">"
487 "</span></a></li>\n", buf, _("Edit this page")
490 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
491 /* already viewing history; display a link to the current page */
493 "<li class=\"newmess\">"
494 "<a href=\"wiki?page=%s\">"
495 "<img src=\"static/newmess3_24x.gif\" "
496 "alt=\"\" width=\"24\" height=\"24\">"
497 "<span class=\"navbar_link\">"
499 "</span></a></li>\n", buf, _("Current version")
503 /* display a link to the history */
505 "<li class=\"newmess\">"
506 "<a href=\"wiki_history?page=%s\">"
507 "<img src=\"static/newmess3_24x.gif\" "
508 "alt=\"\" width=\"24\" height=\"24\">"
509 "<span class=\"navbar_link\">"
511 "</span></a></li>\n", buf, _("History")
517 "<li class=\"newmess\">"
518 "<a href=\"display_enter\">"
519 "<img src=\"static/newmess3_24x.gif\" "
520 "alt=\"\" width=\"24\" height=\"24\">"
521 "<span class=\"navbar_link\">"
523 "</span></a></li>\n", _("Write mail")
526 "<li class=\"newmess\">"
527 "<a href=\"javascript:deleteAllSelectedMessages();\">"
528 "<img src=\"static/delete.gif\" "
529 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
531 "</span></a></li>\n", _("Delete")
536 "<li class=\"newmess\">"
537 "<a href=\"display_enter\">"
538 "<img src=\"static/newmess3_24x.gif\" "
539 "alt=\"\" width=\"24\" height=\"24\">"
540 "<span class=\"navbar_link\">"
542 "</span></a></li>\n", _("Enter a message")
548 "<li class=\"skipthisroom\">"
551 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
552 "width=\"24\" height=\"24\">"
553 "<span class=\"navbar_link\">%s</span></a>"
555 _("Leave all messages marked as unread, go to next room with unread messages"),
560 "<li class=\"markngo\">"
561 "<a href=\"gotonext\" "
563 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
564 "width=\"24\" height=\"24\">"
565 "<span class=\"navbar_link\">%s</span></a>"
567 _("Mark all messages as read, go to next room with unread messages"),
571 wc_printf("</ul></div>\n");
577 * back end routine to take the session to a new room
579 long gotoroom(const StrBuf *gname)
583 static long ls = (-1L);
586 /* store ungoto information */
587 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
591 /* move to the new room */
592 serv_printf("GOTO %s", ChrPtr(gname));
593 StrBuf_ServGetln(Buf);
594 if (GetServerStatus(Buf, &err) != 2) {
595 serv_puts("GOTO _BASEROOM_");
596 StrBuf_ServGetln(Buf);
598 * well, we know that this is the fallback case,
599 * but we're interested that the first command
600 * didn't work out in first place.
602 if (GetServerStatus(Buf, NULL) != 2) {
607 ParseGoto(&WCC->CurRoom, Buf);
609 remove_march(WCC->CurRoom.name);
610 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
618 void ParseGoto(folder *room, StrBuf *Line)
626 if (StrLength(Line) < 4) {
630 /* ignore the commandstate... */
631 Pos = ChrPtr(Line) + 4;
633 if (room->RoomNameParts != NULL)
636 for (i=0; i < room->nRoomNameParts; i++)
637 FreeStrBuf(&room->RoomNameParts[i]);
638 free(room->RoomNameParts);
639 room->RoomNameParts = NULL;
644 pBuf = NewStrBufPlain(NULL, StrLength(Line));
647 memset(room, 0, sizeof(folder));
650 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
652 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
653 if (room->nNewMessages > 0)
654 room->RAFlags |= UA_HASNEWMSGS;
656 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
658 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
660 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
662 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
663 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
665 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
667 flag = StrBufExtractNext_long(Line, &Pos, '|');
668 if (WCC->is_aide || flag) {
669 room->RAFlags |= UA_ADMINALLOWED;
672 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
674 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
676 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
678 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
680 flag = StrBufExtractNext_long(Line, &Pos, '|');
682 room->RAFlags |= UA_ISTRASH; // wc_is_trash
684 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
686 /* find out, whether we are in a sub-room */
687 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
688 if (room->nRoomNameParts > 1)
693 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
694 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
695 for (i=0; i < room->nRoomNameParts; i++)
697 room->RoomNameParts[i] = NewStrBuf();
698 StrBufExtract_NextToken(room->RoomNameParts[i],
699 room->name, &Pos, '\\');
703 /* Private mailboxes on the main floor get remapped to the personal folder */
704 if ((room->QRFlags & QR_MAILBOX) &&
705 (room->floorid == 0))
707 room->floorid = VIRTUAL_MY_FLOOR;
708 if ((room->nRoomNameParts == 1) &&
709 (StrLength(room->name) == 4) &&
710 (strcmp(ChrPtr(room->name), "Mail") == 0))
716 /* get a pointer to the floor we're on: */
717 if (WCC->Floors == NULL)
718 GetFloorListHash(NULL, NULL);
720 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
721 room->Floor = (const Floor*) vFloor;
724 void LoadRoomAide(void)
729 if (WCC->CurRoom.RoomAideLoaded)
732 WCC->CurRoom.RoomAideLoaded = 1;
735 StrBuf_ServGetln(Buf);
736 if (GetServerStatus(Buf, NULL) != 2) {
737 FlushStrBuf(WCC->CurRoom.RoomAide);
738 AppendImportantMessage (ChrPtr(Buf) + 4,
743 Pos = ChrPtr(Buf) + 4;
745 FreeStrBuf(&WCC->CurRoom.RoomAide);
746 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
748 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
752 void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
755 folder *Folder = &WCC->CurRoom;
756 const Floor *pFloor = Folder->Floor;
761 StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
764 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
770 StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
774 void LoadRoomXA (void)
779 if (WCC->CurRoom.XALoaded)
782 WCC->CurRoom.XALoaded = 1;
785 StrBuf_ServGetln(Buf);
786 if (GetServerStatus(Buf, NULL) != 2) {
787 FlushStrBuf(WCC->CurRoom.XAPass);
788 FlushStrBuf(WCC->CurRoom.Directory);
790 AppendImportantMessage (ChrPtr(Buf) + 4,
795 Pos = ChrPtr(Buf) + 4;
797 FreeStrBuf(&WCC->CurRoom.XAPass);
798 FreeStrBuf(&WCC->CurRoom.Directory);
800 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
801 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
803 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
804 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
805 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
806 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
807 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
808 /* defview, we already know you. */
809 /* QR2Flags, we already know them... */
816 void LoadXRoomPic(void)
821 if (WCC->CurRoom.XHaveRoomPicLoaded)
824 WCC->CurRoom.XHaveRoomPicLoaded = 1;
826 serv_puts("OIMG _roompic_");
827 StrBuf_ServGetln(Buf);
828 if (GetServerStatus(Buf, NULL) != 2) {
829 WCC->CurRoom.XHaveRoomPic = 0;
831 WCC->CurRoom.XHaveRoomPic = 1;
834 StrBuf_ServGetln(Buf);
835 GetServerStatus(Buf, NULL);
839 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
847 return WCC->CurRoom.XHaveRoomPic == 1;
850 void LoadXRoomInfoText(void)
856 if (WCC->CurRoom.XHaveInfoTextLoaded)
859 WCC->CurRoom.XHaveInfoTextLoaded = 1;
864 StrBuf_ServGetln(Buf);
865 if (GetServerStatus(Buf, NULL) == 1) {
866 WCC->CurRoom.XInfoText = NewStrBuf ();
868 while (!Done && StrBuf_ServGetln(Buf)>=0) {
869 if ( (StrLength(Buf)==3) &&
870 !strcmp(ChrPtr(Buf), "000"))
873 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
880 int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
888 return (StrLength(WCC->CurRoom.XInfoText)>0);
891 void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
897 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1);
900 void LoadXRoomXCountFiles(void)
906 if (WCC->CurRoom.XHaveDownloadCount)
909 WCC->CurRoom.XHaveDownloadCount = 1;
913 StrBuf_ServGetln(Buf);
914 if (GetServerStatus(Buf, NULL) == 1) {
916 while (!Done && StrBuf_ServGetln(Buf)>=0) {
917 if ( (StrLength(Buf)==3) &&
918 !strcmp(ChrPtr(Buf), "000"))
921 WCC->CurRoom.XDownloadCount++;
928 void tmplput_CurrentRoomXNFiles(StrBuf *Target, WCTemplputParams *TP)
932 LoadXRoomXCountFiles();
934 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.XDownloadCount);
937 void tmplput_CurrentRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
941 LoadXRoomXCountFiles();
943 if (WCC->CurRoom.XDownloadCount == 1)
944 StrBufAppendBufPlain(Target, _("file"), -1, 0);
946 StrBufAppendBufPlain(Target, _("files"), -1, 0);
949 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
955 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
957 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
963 StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
965 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
971 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
973 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
977 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.defview);
980 void tmplput_CurrentRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP)
986 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
989 void tmplput_CurrentRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP)
995 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nTotalMessages);
998 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
1000 wcsession *WCC = WC;
1008 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1009 return CheckThis == WCC->CurRoom.Order;
1012 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1014 wcsession *WCC = WC;
1020 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1021 return CheckThis == WCC->CurRoom.defview;
1024 int ConditionalThisRoomHaveView(StrBuf *Target, WCTemplputParams *TP)
1026 wcsession *WCC = WC;
1032 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1033 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
1035 LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
1036 "Roomview [%ld] not valid\n",
1041 return exchangeable_views [WCC->CurRoom.defview][CheckThis] != VIEW_MAX;
1044 void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
1046 wcsession *WCC = WC;
1049 if ((WCC == NULL) ||
1050 (WCC->CurRoom.defview >= VIEW_MAX) ||
1051 (WCC->CurRoom.defview < VIEW_BBS))
1053 LogTemplateError(Target, "Token", ERR_PARM2, TP,
1054 "Roomview [%ld] not valid\n",
1056 WCC->CurRoom.defview : -1);
1060 Buf = NewStrBufPlain(_(viewdefs[WCC->CurRoom.defview]), -1);
1061 StrBufAppendTemplate(Target, TP, Buf, 0);
1065 void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
1070 CheckThis = GetTemplateTokenNumber(Target, TP, 0, 0);
1071 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
1073 LogTemplateError(Target, "Token", ERR_PARM2, TP,
1074 "Roomview [%ld] not valid\n",
1079 Buf = NewStrBufPlain(_(viewdefs[CheckThis]), -1);
1080 StrBufAppendTemplate(Target, TP, Buf, 0);
1088 void smart_goto(const StrBuf *next_room) {
1089 gotoroom(next_room);
1090 readloop(readnew, eUseDefault);
1096 * mark all messages in current room as having been read
1098 void slrp_highest(void)
1102 serv_puts("SLRP HIGHEST");
1103 serv_getln(buf, sizeof buf);
1107 typedef struct __room_states {
1122 * Set/clear/read the "self-service list subscribe" flag for a room
1124 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1125 * returns the new value.
1128 int self_service(int newval) {
1129 int current_value = 0;
1135 int flags, floor, order, view, flags2;
1138 serv_getln(buf, sizeof buf);
1139 if (buf[0] != '2') return(0);
1141 extract_token(name, &buf[4], 0, '|', sizeof name);
1142 extract_token(password, &buf[4], 1, '|', sizeof password);
1143 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1144 flags = extract_int(&buf[4], 3);
1145 floor = extract_int(&buf[4], 4);
1146 order = extract_int(&buf[4], 5);
1147 view = extract_int(&buf[4], 6);
1148 flags2 = extract_int(&buf[4], 7);
1150 if (flags2 & QR2_SELFLIST) {
1158 flags2 = flags2 | QR2_SELFLIST;
1160 else if (newval == 0) {
1161 flags2 = flags2 & ~QR2_SELFLIST;
1164 return(current_value);
1167 if (newval != current_value) {
1168 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1169 name, password, dirname, flags,
1170 floor, order, view, flags2);
1171 serv_getln(buf, sizeof buf);
1178 int is_selflist(room_states *RoomFlags)
1180 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1183 int is_publiclist(room_states *RoomFlags)
1185 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1188 int is_moderatedlist(room_states *RoomFlags)
1190 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1194 * Set/clear/read the "self-service list subscribe" flag for a room
1196 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1197 * returns the new value.
1200 int get_roomflags(room_states *RoomOps)
1205 serv_getln(buf, sizeof buf);
1206 if (buf[0] != '2') return(0);
1208 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1209 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1210 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1211 RoomOps->flags = extract_int(&buf[4], 3);
1212 RoomOps->floor = extract_int(&buf[4], 4);
1213 RoomOps->order = extract_int(&buf[4], 5);
1214 RoomOps->view = extract_int(&buf[4], 6);
1215 RoomOps->flags2 = extract_int(&buf[4], 7);
1219 int set_roomflags(room_states *RoomOps)
1223 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1232 serv_getln(buf, sizeof buf);
1242 * display the form for editing a room
1244 void display_editroom(void)
1250 char remote_room[128];
1253 char er_password[10];
1254 char er_dirname[15];
1255 char er_roomaide[26];
1262 char *not_shared_with = NULL;
1265 int floorpolicy = 0;
1267 char pop3_host[128];
1272 if (IsEmptyStr(tab)) tab = "admin";
1275 load_floorlist(Buf);
1277 output_headers(1, 1, 1, 0, 0, 0);
1279 wc_printf("<div class=\"fix_scrollbar_bug\">");
1281 wc_printf("<br />\n");
1283 /* print the tabbed dialog */
1284 wc_printf("<div align=\"center\">");
1285 wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1286 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1289 wc_printf("<td class=\"");
1290 if (!strcmp(tab, "admin")) {
1291 wc_printf(" tab_cell_label\">");
1292 wc_printf(_("Administration"));
1295 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1296 wc_printf(_("Administration"));
1299 wc_printf("</td>\n");
1300 wc_printf("<td> </td>\n");
1302 if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1304 wc_printf("<td class=\"");
1305 if (!strcmp(tab, "config")) {
1306 wc_printf(" tab_cell_label\">");
1307 wc_printf(_("Configuration"));
1310 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1311 wc_printf(_("Configuration"));
1314 wc_printf("</td>\n");
1315 wc_printf("<td> </td>\n");
1317 wc_printf("<td class=\"");
1318 if (!strcmp(tab, "expire")) {
1319 wc_printf(" tab_cell_label\">");
1320 wc_printf(_("Message expire policy"));
1323 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1324 wc_printf(_("Message expire policy"));
1327 wc_printf("</td>\n");
1328 wc_printf("<td> </td>\n");
1330 wc_printf("<td class=\"");
1331 if (!strcmp(tab, "access")) {
1332 wc_printf(" tab_cell_label\">");
1333 wc_printf(_("Access controls"));
1336 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1337 wc_printf(_("Access controls"));
1340 wc_printf("</td>\n");
1341 wc_printf("<td> </td>\n");
1343 wc_printf("<td class=\"");
1344 if (!strcmp(tab, "sharing")) {
1345 wc_printf(" tab_cell_label\">");
1346 wc_printf(_("Sharing"));
1349 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1350 wc_printf(_("Sharing"));
1353 wc_printf("</td>\n");
1354 wc_printf("<td> </td>\n");
1356 wc_printf("<td class=\"");
1357 if (!strcmp(tab, "listserv")) {
1358 wc_printf(" tab_cell_label\">");
1359 wc_printf(_("Mailing list service"));
1362 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1363 wc_printf(_("Mailing list service"));
1366 wc_printf("</td>\n");
1367 wc_printf("<td> </td>\n");
1371 wc_printf("<td class=\"");
1372 if (!strcmp(tab, "feeds")) {
1373 wc_printf(" tab_cell_label\">");
1374 wc_printf(_("Remote retrieval"));
1377 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1378 wc_printf(_("Remote retrieval"));
1381 wc_printf("</td>\n");
1382 wc_printf("<td> </td>\n");
1384 wc_printf("</tr></table>\n");
1385 wc_printf("</div>\n");
1386 /* end tabbed dialog */
1388 wc_printf("<script type=\"text/javascript\">"
1389 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1393 /* begin content of whatever tab is open now */
1395 if (!strcmp(tab, "admin")) {
1396 wc_printf("<div class=\"tabcontent\">");
1398 "<li><a href=\"delete_room\" "
1399 "onClick=\"return confirm('");
1400 wc_printf(_("Are you sure you want to delete this room?"));
1401 wc_printf("');\">\n");
1402 wc_printf(_("Delete this room"));
1404 "<li><a href=\"display_editroompic?which_room=");
1405 urlescputs(ChrPtr(WC->CurRoom.name));
1407 wc_printf(_("Set or change the icon for this room's banner"));
1409 "<li><a href=\"display_editinfo\">\n");
1410 wc_printf(_("Edit this room's Info file"));
1413 wc_printf("</div>");
1416 if (!strcmp(tab, "config")) {
1417 wc_printf("<div class=\"tabcontent\">");
1419 serv_getln(buf, sizeof buf);
1421 if (!strncmp(buf, "550", 3)) {
1422 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1423 _("Higher access is required to access this function.")
1426 else if (buf[0] != '2') {
1427 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1430 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1431 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1432 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1433 er_flags = extract_int(&buf[4], 3);
1434 er_floor = extract_int(&buf[4], 4);
1435 er_flags2 = extract_int(&buf[4], 7);
1437 wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1438 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1440 wc_printf("<ul><li>");
1441 wc_printf(_("Name of room: "));
1442 wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1448 wc_printf(_("Resides on floor: "));
1449 wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1450 if (er_flags & QR_MAILBOX)
1451 wc_printf("disabled >\n");
1452 for (i = 0; i < 128; ++i)
1453 if (!IsEmptyStr(floorlist[i])) {
1454 wc_printf("<OPTION ");
1456 wc_printf("SELECTED ");
1457 wc_printf("VALUE=\"%d\">", i);
1458 escputs(floorlist[i]);
1459 wc_printf("</OPTION>\n");
1461 wc_printf("</select>\n");
1464 wc_printf(_("Type of room:"));
1465 wc_printf("<ul>\n");
1467 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1468 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1469 wc_printf("CHECKED ");
1470 wc_printf("OnChange=\""
1471 " if (this.form.type[0].checked == true) { "
1472 " this.form.er_floor.disabled = false; "
1475 wc_printf(_("Public (automatically appears to everyone)"));
1478 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1479 if ((er_flags & QR_PRIVATE) &&
1480 (er_flags & QR_GUESSNAME))
1481 wc_printf("CHECKED ");
1482 wc_printf(" OnChange=\""
1483 " if (this.form.type[1].checked == true) { "
1484 " this.form.er_floor.disabled = false; "
1487 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1489 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1490 if ((er_flags & QR_PRIVATE) &&
1491 (er_flags & QR_PASSWORDED))
1492 wc_printf("CHECKED ");
1493 wc_printf(" OnChange=\""
1494 " if (this.form.type[2].checked == true) { "
1495 " this.form.er_floor.disabled = false; "
1498 wc_printf(_("Private - require password: "));
1499 wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1502 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1503 if ((er_flags & QR_PRIVATE)
1504 && ((er_flags & QR_GUESSNAME) == 0)
1505 && ((er_flags & QR_PASSWORDED) == 0))
1506 wc_printf("CHECKED ");
1507 wc_printf(" OnChange=\""
1508 " if (this.form.type[3].checked == true) { "
1509 " this.form.er_floor.disabled = false; "
1512 wc_printf(_("Private - invitation only"));
1514 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1515 if (er_flags & QR_MAILBOX)
1516 wc_printf("CHECKED ");
1517 wc_printf (" OnChange=\""
1518 " if (this.form.type[4].checked == true) { "
1519 " this.form.er_floor.disabled = true; "
1522 wc_printf(_("Personal (mailbox for you only)"));
1524 wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1526 wc_printf(_("If private, cause current users to forget room"));
1528 wc_printf("\n</ul>\n");
1530 wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1531 if (er_flags & QR_PREFONLY)
1532 wc_printf("CHECKED ");
1534 wc_printf(_("Preferred users only"));
1536 wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1537 if (er_flags & QR_READONLY)
1538 wc_printf("CHECKED ");
1540 wc_printf(_("Read-only room"));
1542 wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1543 if (er_flags2 & QR2_COLLABDEL)
1544 wc_printf("CHECKED ");
1546 wc_printf(_("All users allowed to post may also delete messages"));
1548 /** directory stuff */
1549 wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1550 if (er_flags & QR_DIRECTORY)
1551 wc_printf("CHECKED ");
1553 wc_printf(_("File directory room"));
1555 wc_printf("\n<ul><li>");
1556 wc_printf(_("Directory name: "));
1557 wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1560 wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1561 if (er_flags & QR_UPLOAD)
1562 wc_printf("CHECKED ");
1564 wc_printf(_("Uploading allowed"));
1566 wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1567 if (er_flags & QR_DOWNLOAD)
1568 wc_printf("CHECKED ");
1570 wc_printf(_("Downloading allowed"));
1572 wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1573 if (er_flags & QR_VISDIR)
1574 wc_printf("CHECKED ");
1576 wc_printf(_("Visible directory"));
1577 wc_printf("</ul>\n");
1579 /** end of directory stuff */
1581 wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1582 if (er_flags & QR_NETWORK)
1583 wc_printf("CHECKED ");
1585 wc_printf(_("Network shared room"));
1587 wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1588 if (er_flags & QR_PERMANENT)
1589 wc_printf("CHECKED ");
1591 wc_printf(_("Permanent (does not auto-purge)"));
1593 wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1594 if (er_flags2 & QR2_SUBJECTREQ)
1595 wc_printf("CHECKED ");
1597 wc_printf(_("Subject Required (Force users to specify a message subject)"));
1599 /** start of anon options */
1601 wc_printf("\n<li>");
1602 wc_printf(_("Anonymous messages"));
1603 wc_printf("<ul>\n");
1605 wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1606 if (((er_flags & QR_ANONONLY) == 0)
1607 && ((er_flags & QR_ANONOPT) == 0))
1608 wc_printf("CHECKED ");
1610 wc_printf(_("No anonymous messages"));
1612 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1613 if (er_flags & QR_ANONONLY)
1614 wc_printf("CHECKED ");
1616 wc_printf(_("All messages are anonymous"));
1618 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1619 if (er_flags & QR_ANONOPT)
1620 wc_printf("CHECKED ");
1622 wc_printf(_("Prompt user when entering messages"));
1623 wc_printf("</ul>\n");
1625 /* end of anon options */
1628 wc_printf(_("Room aide: "));
1630 serv_getln(buf, sizeof buf);
1631 if (buf[0] != '2') {
1632 wc_printf("<em>%s</em>\n", &buf[4]);
1634 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1635 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1638 wc_printf("</ul><CENTER>\n");
1639 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1640 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1642 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1648 wc_printf("</div>");
1652 /* Sharing the room with other Citadel nodes... */
1653 if (!strcmp(tab, "sharing")) {
1654 wc_printf("<div class=\"tabcontent\">");
1656 shared_with = strdup("");
1657 not_shared_with = strdup("");
1659 /** Learn the current configuration */
1660 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1661 serv_getln(buf, sizeof buf);
1662 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1663 extract_token(node, buf, 0, '|', sizeof node);
1664 not_shared_with = realloc(not_shared_with,
1665 strlen(not_shared_with) + 32);
1666 strcat(not_shared_with, node);
1667 strcat(not_shared_with, "\n");
1671 serv_getln(buf, sizeof buf);
1672 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1673 extract_token(cmd, buf, 0, '|', sizeof cmd);
1674 extract_token(node, buf, 1, '|', sizeof node);
1675 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1676 if (!strcasecmp(cmd, "ignet_push_share")) {
1677 shared_with = realloc(shared_with,
1678 strlen(shared_with) + 32);
1679 strcat(shared_with, node);
1680 if (!IsEmptyStr(remote_room)) {
1681 strcat(shared_with, "|");
1682 strcat(shared_with, remote_room);
1684 strcat(shared_with, "\n");
1688 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1689 extract_token(buf, shared_with, i, '\n', sizeof buf);
1690 extract_token(node, buf, 0, '|', sizeof node);
1691 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1692 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1693 if (!strcasecmp(node, cmd)) {
1694 remove_token(not_shared_with, j, '\n');
1699 /* Display the stuff */
1700 wc_printf("<CENTER><br />"
1701 "<table border=1 cellpadding=5><tr>"
1703 wc_printf(_("Shared with"));
1704 wc_printf("</I></B></td>"
1706 wc_printf(_("Not shared with"));
1707 wc_printf("</I></B></td></tr>\n"
1708 "<tr><td VALIGN=TOP>\n");
1710 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1711 wc_printf(_("Remote node name"));
1712 wc_printf("</td><td>");
1713 wc_printf(_("Remote room name"));
1714 wc_printf("</td><td>");
1715 wc_printf(_("Actions"));
1716 wc_printf("</td></tr>\n");
1718 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1719 extract_token(buf, shared_with, i, '\n', sizeof buf);
1720 extract_token(node, buf, 0, '|', sizeof node);
1721 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1722 if (!IsEmptyStr(node)) {
1723 wc_printf("<form method=\"POST\" action=\"netedit\">");
1724 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1725 wc_printf("<tr><td>%s</td>\n", node);
1728 if (!IsEmptyStr(remote_room)) {
1729 escputs(remote_room);
1735 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1736 "VALUE=\"ignet_push_share|");
1738 if (!IsEmptyStr(remote_room)) {
1740 urlescputs(remote_room);
1743 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1744 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1745 wc_printf("<input type=\"submit\" "
1746 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1747 wc_printf("</td></tr></form>\n");
1751 wc_printf("</table>\n");
1752 wc_printf("</td><td VALIGN=TOP>\n");
1753 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1754 wc_printf(_("Remote node name"));
1755 wc_printf("</td><td>");
1756 wc_printf(_("Remote room name"));
1757 wc_printf("</td><td>");
1758 wc_printf(_("Actions"));
1759 wc_printf("</td></tr>\n");
1761 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1762 extract_token(node, not_shared_with, i, '\n', sizeof node);
1763 if (!IsEmptyStr(node)) {
1764 wc_printf("<form method=\"POST\" action=\"netedit\">");
1765 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1766 wc_printf("<tr><td>");
1768 wc_printf("</td><td>"
1769 "<input type=\"INPUT\" "
1773 wc_printf("<input type=\"hidden\" "
1775 "VALUE=\"ignet_push_share|");
1778 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1779 "VALUE=\"sharing\">\n");
1780 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1781 "VALUE=\"add\">\n");
1782 wc_printf("<input type=\"submit\" "
1783 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1784 wc_printf("</td></tr></form>\n");
1788 wc_printf("</table>\n");
1789 wc_printf("</td></tr>"
1790 "</table></CENTER><br />\n"
1791 "<I><B>%s</B><ul><li>", _("Notes:"));
1792 wc_printf(_("When sharing a room, "
1793 "it must be shared from both ends. Adding a node to "
1794 "the 'shared' list sends messages out, but in order to"
1795 " receive messages, the other nodes must be configured"
1796 " to send messages out to your system as well. "
1797 "<li>If the remote room name is blank, it is assumed "
1798 "that the room name is identical on the remote node."
1799 "<li>If the remote room name is different, the remote "
1800 "node must also configure the name of the room here."
1804 wc_printf("</div>");
1807 if (not_shared_with != NULL)
1808 free (not_shared_with);
1810 /* Mailing list management */
1811 if (!strcmp(tab, "listserv")) {
1812 room_states RoomFlags;
1813 wc_printf("<div class=\"tabcontent\">");
1815 wc_printf("<br /><center>"
1816 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1817 "<tr><td VALIGN=TOP>");
1819 wc_printf(_("<i>The contents of this room are being "
1820 "mailed <b>as individual messages</b> "
1821 "to the following list recipients:"
1822 "</i><br /><br />\n"));
1825 serv_getln(buf, sizeof buf);
1826 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1827 extract_token(cmd, buf, 0, '|', sizeof cmd);
1828 if (!strcasecmp(cmd, "listrecp")) {
1829 extract_token(recp, buf, 1, '|', sizeof recp);
1832 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1835 wc_printf(_("(remove)"));
1836 wc_printf("</A><br />");
1839 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1840 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1841 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1842 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1843 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1844 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1845 wc_printf("</form>\n");
1847 wc_printf("</td><td VALIGN=TOP>\n");
1849 wc_printf(_("<i>The contents of this room are being "
1850 "mailed <b>in digest form</b> "
1851 "to the following list recipients:"
1852 "</i><br /><br />\n"));
1855 serv_getln(buf, sizeof buf);
1856 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1857 extract_token(cmd, buf, 0, '|', sizeof cmd);
1858 if (!strcasecmp(cmd, "digestrecp")) {
1859 extract_token(recp, buf, 1, '|', sizeof recp);
1862 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1866 wc_printf(_("(remove)"));
1867 wc_printf("</A><br />");
1870 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1871 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1872 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1873 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1874 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1875 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1876 wc_printf("</form>\n");
1878 wc_printf("</td></tr></table>\n");
1880 /** Pop open an address book -- begin **/
1881 wc_printf("<div align=right>"
1882 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1884 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1889 _("Add recipients from Contacts or other address books"),
1890 _("Add recipients from Contacts or other address books")
1892 /* Pop open an address book -- end **/
1894 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1896 get_roomflags (&RoomFlags);
1898 /* Self Service subscription? */
1899 wc_printf("<table><tr><td>\n");
1900 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1901 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1902 " <tr><td colspan=\"2\">\n",
1903 (is_selflist(&RoomFlags))?"checked":"");
1904 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1905 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1906 (is_https ? "https" : "http"),
1907 ChrPtr(WC->Hdr->HR.http_host));
1908 /* Public posting? */
1909 wc_printf("<tr><td>");
1910 wc_printf(_("Allow non-subscribers to mail to this room."));
1911 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1912 (is_publiclist(&RoomFlags))?"checked":"");
1914 /* Moderated List? */
1915 wc_printf("<tr><td>");
1916 wc_printf(_("Room post publication needs Aide permission."));
1917 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1918 (is_moderatedlist(&RoomFlags))?"checked":"");
1921 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1922 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1923 wc_printf("</table></form>");
1926 wc_printf("</CENTER>\n");
1927 wc_printf("</div>");
1931 /* Configuration of The Dreaded Auto-Purger */
1932 if (!strcmp(tab, "expire")) {
1933 wc_printf("<div class=\"tabcontent\">");
1935 serv_puts("GPEX room");
1936 serv_getln(buf, sizeof buf);
1937 if (!strncmp(buf, "550", 3)) {
1938 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1939 _("Higher access is required to access this function.")
1942 else if (buf[0] != '2') {
1943 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1946 roompolicy = extract_int(&buf[4], 0);
1947 roomvalue = extract_int(&buf[4], 1);
1949 serv_puts("GPEX floor");
1950 serv_getln(buf, sizeof buf);
1951 if (buf[0] == '2') {
1952 floorpolicy = extract_int(&buf[4], 0);
1953 floorvalue = extract_int(&buf[4], 1);
1956 wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1957 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1958 wc_printf("<table border=0 cellspacing=5>\n");
1959 wc_printf("<tr><td>");
1960 wc_printf(_("Message expire policy for this room"));
1961 wc_printf("<br />(");
1962 escputs(ChrPtr(WC->CurRoom.name));
1963 wc_printf(")</td><td>");
1964 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1965 ((roompolicy == 0) ? "CHECKED" : "") );
1966 wc_printf(_("Use the default policy for this floor"));
1967 wc_printf("<br />\n");
1968 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1969 ((roompolicy == 1) ? "CHECKED" : "") );
1970 wc_printf(_("Never automatically expire messages"));
1971 wc_printf("<br />\n");
1972 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1973 ((roompolicy == 2) ? "CHECKED" : "") );
1974 wc_printf(_("Expire by message count"));
1975 wc_printf("<br />\n");
1976 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1977 ((roompolicy == 3) ? "CHECKED" : "") );
1978 wc_printf(_("Expire by message age"));
1979 wc_printf("<br />");
1980 wc_printf(_("Number of messages or days: "));
1981 wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1982 wc_printf("</td></tr>\n");
1984 if (WC->axlevel >= 6) {
1985 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1986 wc_printf("<tr><td>");
1987 wc_printf(_("Message expire policy for this floor"));
1988 wc_printf("<br />(");
1989 escputs(floorlist[WC->CurRoom.floorid]);
1990 wc_printf(")</td><td>");
1991 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1992 ((floorpolicy == 0) ? "CHECKED" : "") );
1993 wc_printf(_("Use the system default"));
1994 wc_printf("<br />\n");
1995 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1996 ((floorpolicy == 1) ? "CHECKED" : "") );
1997 wc_printf(_("Never automatically expire messages"));
1998 wc_printf("<br />\n");
1999 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
2000 ((floorpolicy == 2) ? "CHECKED" : "") );
2001 wc_printf(_("Expire by message count"));
2002 wc_printf("<br />\n");
2003 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
2004 ((floorpolicy == 3) ? "CHECKED" : "") );
2005 wc_printf(_("Expire by message age"));
2006 wc_printf("<br />");
2007 wc_printf(_("Number of messages or days: "));
2008 wc_printf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
2012 wc_printf("<CENTER>\n");
2013 wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
2014 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
2015 wc_printf(" ");
2016 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2017 wc_printf("</CENTER></td><tr>\n");
2019 wc_printf("</table>\n"
2020 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
2025 wc_printf("</div>");
2028 /* Access controls */
2029 if (!strcmp(tab, "access")) {
2030 wc_printf("<div class=\"tabcontent\">");
2032 wc_printf("</div>");
2035 /* Fetch messages from remote locations */
2036 if (!strcmp(tab, "feeds")) {
2037 wc_printf("<div class=\"tabcontent\">");
2040 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
2041 wc_printf("</i><br />\n");
2043 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2044 "<tr class=\"even\"><th>");
2045 wc_printf(_("Remote host"));
2046 wc_printf("</th><th>");
2047 wc_printf(_("User name"));
2048 wc_printf("</th><th>");
2049 wc_printf(_("Password"));
2050 wc_printf("</th><th>");
2051 wc_printf(_("Keep messages on server?"));
2052 wc_printf("</th><th>");
2053 wc_printf(_("Interval"));
2054 wc_printf("</th><th> </th></tr>");
2057 serv_getln(buf, sizeof buf);
2059 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2060 extract_token(cmd, buf, 0, '|', sizeof cmd);
2061 if (!strcasecmp(cmd, "pop3client")) {
2062 safestrncpy(recp, &buf[11], sizeof recp);
2065 wc_printf("<tr class=\"%s\">",
2066 (bg ? "even" : "odd")
2070 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2075 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2079 wc_printf("<td>*****</td>"); /* Don't show the password */
2081 wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2083 wc_printf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2085 wc_printf("<td class=\"button_link\">");
2086 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2089 wc_printf(_("(remove)"));
2090 wc_printf("</a></td>");
2096 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2098 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2099 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2100 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2102 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2105 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2108 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2111 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2114 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2117 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2118 wc_printf("</td></tr>");
2119 wc_printf("</form></table>\n");
2121 wc_printf("<hr>\n");
2124 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2125 wc_printf("</i><br />\n");
2127 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2128 "<tr class=\"even\"><th>");
2129 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2130 wc_printf(_("Feed URL"));
2131 wc_printf("</th><th>");
2132 wc_printf("</th></tr>");
2135 serv_getln(buf, sizeof buf);
2137 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2138 extract_token(cmd, buf, 0, '|', sizeof cmd);
2139 if (!strcasecmp(cmd, "rssclient")) {
2140 safestrncpy(recp, &buf[10], sizeof recp);
2143 wc_printf("<tr class=\"%s\">",
2144 (bg ? "even" : "odd")
2148 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2152 wc_printf("<td class=\"button_link\">");
2153 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2156 wc_printf(_("(remove)"));
2157 wc_printf("</a></td>");
2163 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2165 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2166 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2167 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2169 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2170 "maxlength=\"256\" name=\"line_pop3host\">\n");
2173 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2174 wc_printf("</td></tr>");
2175 wc_printf("</form></table>\n");
2177 wc_printf("</div>");
2181 /* end content of whatever tab is open now */
2182 wc_printf("</div>\n");
2184 address_book_popup();
2190 * Toggle self-service list subscription
2192 void toggle_self_service(void) {
2193 room_states RoomFlags;
2195 get_roomflags (&RoomFlags);
2197 if (yesbstr("QR2_SelfList"))
2198 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2200 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2202 if (yesbstr("QR2_SMTP_PUBLIC"))
2203 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2205 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2207 if (yesbstr("QR2_Moderated"))
2208 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2210 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2211 if (yesbstr("QR2_SubsOnly"))
2212 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2214 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2216 set_roomflags (&RoomFlags);
2224 * save new parameters for a room
2231 StrBuf *er_password;
2233 StrBuf *er_roomaide;
2236 int er_listingorder;
2242 if (!havebstr("ok_button")) {
2243 strcpy(WC->ImportantMessage,
2244 _("Cancelled. Changes were not saved."));
2250 StrBuf_ServGetln(Buf);
2251 if (GetServerStatus(Buf, NULL) != 2) {
2252 StrBufCutLeft(Buf, 4);
2253 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2259 er_name = NewStrBuf();
2260 er_password = NewStrBuf();
2261 er_dirname = NewStrBuf();
2262 er_roomaide = NewStrBuf();
2264 StrBufCutLeft(Buf, 4);
2265 StrBufExtract_token(er_name, Buf, 0, '|');
2266 StrBufExtract_token(er_password, Buf, 1, '|');
2267 StrBufExtract_token(er_dirname, Buf, 2, '|');
2268 er_flags = StrBufExtract_int(Buf, 3, '|');
2269 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2270 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2271 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2273 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2274 if (StrLength(er_roomaide) == 0) {
2276 StrBuf_ServGetln(Buf);
2277 if (GetServerStatus(Buf, NULL) != 2) {
2278 FlushStrBuf(er_roomaide);
2280 StrBufCutLeft(Buf, 4);
2281 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2284 Ptr = sbstr("er_name");
2285 if (StrLength(Ptr) > 0) {
2286 FlushStrBuf(er_name);
2287 StrBufAppendBuf(er_name, Ptr, 0);
2290 Ptr = sbstr("er_password");
2291 if (StrLength(Ptr) > 0) {
2292 FlushStrBuf(er_password);
2293 StrBufAppendBuf(er_password, Ptr, 0);
2297 Ptr = sbstr("er_dirname");
2298 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2299 FlushStrBuf(er_dirname);
2300 StrBufAppendBuf(er_dirname, Ptr, 0);
2304 Ptr = sbstr("type");
2305 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2307 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2308 er_flags |= (QR_PRIVATE);
2310 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2311 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2313 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2314 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2316 if (!strcmp(ChrPtr(Ptr), "personal")) {
2317 er_flags |= QR_MAILBOX;
2319 er_flags &= ~QR_MAILBOX;
2322 if (yesbstr("prefonly")) {
2323 er_flags |= QR_PREFONLY;
2325 er_flags &= ~QR_PREFONLY;
2328 if (yesbstr("readonly")) {
2329 er_flags |= QR_READONLY;
2331 er_flags &= ~QR_READONLY;
2335 if (yesbstr("collabdel")) {
2336 er_flags2 |= QR2_COLLABDEL;
2338 er_flags2 &= ~QR2_COLLABDEL;
2341 if (yesbstr("permanent")) {
2342 er_flags |= QR_PERMANENT;
2344 er_flags &= ~QR_PERMANENT;
2347 if (yesbstr("subjectreq")) {
2348 er_flags2 |= QR2_SUBJECTREQ;
2350 er_flags2 &= ~QR2_SUBJECTREQ;
2353 if (yesbstr("network")) {
2354 er_flags |= QR_NETWORK;
2356 er_flags &= ~QR_NETWORK;
2359 if (yesbstr("directory")) {
2360 er_flags |= QR_DIRECTORY;
2362 er_flags &= ~QR_DIRECTORY;
2365 if (yesbstr("ulallowed")) {
2366 er_flags |= QR_UPLOAD;
2368 er_flags &= ~QR_UPLOAD;
2371 if (yesbstr("dlallowed")) {
2372 er_flags |= QR_DOWNLOAD;
2374 er_flags &= ~QR_DOWNLOAD;
2377 if (yesbstr("visdir")) {
2378 er_flags |= QR_VISDIR;
2380 er_flags &= ~QR_VISDIR;
2383 Ptr = sbstr("anon");
2385 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2386 if (!strcmp(ChrPtr(Ptr), "anononly"))
2387 er_flags |= QR_ANONONLY;
2388 if (!strcmp(ChrPtr(Ptr), "anon2"))
2389 er_flags |= QR_ANONOPT;
2391 bump = yesbstr("bump");
2393 er_floor = ibstr("er_floor");
2395 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2397 ChrPtr(er_password),
2406 StrBuf_ServGetln(Buf);
2407 if (GetServerStatus(Buf, NULL) != 2) {
2408 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2411 FreeStrBuf(&er_name);
2412 FreeStrBuf(&er_password);
2413 FreeStrBuf(&er_dirname);
2414 FreeStrBuf(&er_roomaide);
2419 if (StrLength(er_roomaide) > 0) {
2420 serv_printf("SETA %s", ChrPtr(er_roomaide));
2421 StrBuf_ServGetln(Buf);
2422 if (GetServerStatus(Buf, NULL) != 2) {
2423 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2424 display_main_menu();
2426 FreeStrBuf(&er_name);
2427 FreeStrBuf(&er_password);
2428 FreeStrBuf(&er_dirname);
2429 FreeStrBuf(&er_roomaide);
2434 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2437 FreeStrBuf(&er_name);
2438 FreeStrBuf(&er_password);
2439 FreeStrBuf(&er_dirname);
2440 FreeStrBuf(&er_roomaide);
2446 * Display form for Invite, Kick, and show Who Knows a room
2448 void do_invt_kick(void) {
2449 char buf[SIZ], room[SIZ], username[SIZ];
2452 serv_getln(buf, sizeof buf);
2454 if (buf[0] != '2') {
2458 extract_token(room, &buf[4], 0, '|', sizeof room);
2460 strcpy(username, bstr("username"));
2462 if (havebstr("kick_button")) {
2463 sprintf(buf, "KICK %s", username);
2465 serv_getln(buf, sizeof buf);
2467 if (buf[0] != '2') {
2468 strcpy(WC->ImportantMessage, &buf[4]);
2470 sprintf(WC->ImportantMessage,
2471 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2476 if (havebstr("invite_button")) {
2477 sprintf(buf, "INVT %s", username);
2479 serv_getln(buf, sizeof buf);
2481 if (buf[0] != '2') {
2482 strcpy(WC->ImportantMessage, &buf[4]);
2484 sprintf(WC->ImportantMessage,
2485 _("<B><I>User %s invited to room %s.</I></B>\n"),
2496 * Display form for Invite, Kick, and show Who Knows a room
2498 void display_whok(void)
2500 char buf[SIZ], room[SIZ], username[SIZ];
2503 serv_getln(buf, sizeof buf);
2505 if (buf[0] != '2') {
2509 extract_token(room, &buf[4], 0, '|', sizeof room);
2512 wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2513 wc_printf(_("The users listed below have access to this room. "
2514 "To remove a user from the access list, select the user "
2515 "name from the list and click 'Kick'."));
2516 wc_printf("<br /><br />");
2518 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2519 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2520 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2521 wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2523 serv_getln(buf, sizeof buf);
2524 if (buf[0] == '1') {
2525 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2526 extract_token(username, buf, 0, '|', sizeof username);
2527 wc_printf("<OPTION>");
2532 wc_printf("</select><br />\n");
2534 wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2535 wc_printf("</form></CENTER>\n");
2537 wc_printf("</td><td>");
2538 wc_printf(_("To grant another user access to this room, enter the "
2539 "user name in the box below and click 'Invite'."));
2540 wc_printf("<br /><br />");
2542 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2543 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2544 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2545 wc_printf(_("Invite:"));
2547 wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2548 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2549 "<input type=\"submit\" value=\"%s\">"
2550 "</form></CENTER>\n", _("Invite"));
2551 /* Pop open an address book -- begin **/
2553 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2555 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2558 _("Users"), _("Users")
2560 /* Pop open an address book -- end **/
2562 wc_printf("</td></tr></table>\n");
2563 address_book_popup();
2570 * display the form for entering a new room
2572 void display_entroom(void)
2579 serv_puts("CRE8 0");
2580 serv_getln(buf, sizeof buf);
2582 if (buf[0] != '2') {
2583 strcpy(WC->ImportantMessage, &buf[4]);
2584 display_main_menu();
2589 output_headers(1, 1, 1, 0, 0, 0);
2591 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2592 do_template("beginbox", NULL);
2594 wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2595 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2597 wc_printf("<table class=\"altern\"> ");
2599 wc_printf("<tr class=\"even\"><td>");
2600 wc_printf(_("Name of room: "));
2601 wc_printf("</td><td>");
2602 wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2603 wc_printf("</td></tr>");
2605 wc_printf("<tr class=\"odd\"><td>");
2606 wc_printf(_("Resides on floor: "));
2607 wc_printf("</td><td>");
2608 load_floorlist(Buf);
2609 wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2610 for (i = 0; i < 128; ++i)
2611 if (!IsEmptyStr(floorlist[i])) {
2612 wc_printf("<option ");
2613 wc_printf("value=\"%d\">", i);
2614 escputs(floorlist[i]);
2615 wc_printf("</option>\n");
2617 wc_printf("</select>\n");
2618 wc_printf("</td></tr>");
2621 * Our clever little snippet of JavaScript automatically selects
2622 * a public room if the view is set to Bulletin Board or wiki, and
2623 * it selects a mailbox room otherwise. The user can override this,
2624 * of course. We also disable the floor selector for mailboxes.
2626 wc_printf("<tr class=\"even\"><td>");
2627 wc_printf(_("Default view for room: "));
2628 wc_printf("</td><td>");
2629 wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2630 " if ( (this.form.er_view.value == 0) "
2631 " || (this.form.er_view.value == 6) ) { "
2632 " this.form.type[0].checked=true; "
2633 " this.form.er_floor.disabled = false; "
2636 " this.form.type[4].checked=true; "
2637 " this.form.er_floor.disabled = true; "
2640 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2641 if (is_view_allowed_as_default(i)) {
2642 wc_printf("<option %s value=\"%d\">",
2643 ((i == 0) ? "selected" : ""), i );
2644 escputs(viewdefs[i]);
2645 wc_printf("</option>\n");
2648 wc_printf("</select>\n");
2649 wc_printf("</td></tr>");
2651 wc_printf("<tr class=\"even\"><td>");
2652 wc_printf(_("Type of room:"));
2653 wc_printf("</td><td>");
2654 wc_printf("<ul class=\"adminlist\">\n");
2656 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2657 wc_printf("CHECKED OnChange=\""
2658 " if (this.form.type[0].checked == true) { "
2659 " this.form.er_floor.disabled = false; "
2662 wc_printf(_("Public (automatically appears to everyone)"));
2665 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2666 " if (this.form.type[1].checked == true) { "
2667 " this.form.er_floor.disabled = false; "
2670 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2673 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2674 " if (this.form.type[2].checked == true) { "
2675 " this.form.er_floor.disabled = false; "
2678 wc_printf(_("Private - require password: "));
2679 wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2682 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2683 " if (this.form.type[3].checked == true) { "
2684 " this.form.er_floor.disabled = false; "
2687 wc_printf(_("Private - invitation only"));
2690 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2692 " if (this.form.type[4].checked == true) { "
2693 " this.form.er_floor.disabled = true; "
2696 wc_printf(_("Personal (mailbox for you only)"));
2699 wc_printf("\n</ul>\n");
2700 wc_printf("</td></tr></table>\n");
2702 wc_printf("<div class=\"buttons\">\n");
2703 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2704 wc_printf(" ");
2705 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2706 wc_printf("</div>\n");
2707 wc_printf("</form>\n<hr />");
2708 serv_printf("MESG roomaccess");
2709 serv_getln(buf, sizeof buf);
2710 if (buf[0] == '1') {
2714 do_template("endbox", NULL);
2724 * support function for entroom() -- sets the default view
2726 void er_set_default_view(int newview) {
2739 serv_getln(buf, sizeof buf);
2740 if (buf[0] != '2') return;
2742 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2743 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2744 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2745 rm_bits1 = extract_int(&buf[4], 3);
2746 rm_floor = extract_int(&buf[4], 4);
2747 rm_listorder = extract_int(&buf[4], 5);
2748 rm_bits2 = extract_int(&buf[4], 7);
2750 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2751 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2752 rm_listorder, newview, rm_bits2
2754 serv_getln(buf, sizeof buf);
2765 const StrBuf *er_name;
2766 const StrBuf *er_type;
2767 const StrBuf *er_password;
2771 wcsession *WCC = WC;
2773 if (!havebstr("ok_button")) {
2774 strcpy(WC->ImportantMessage,
2775 _("Cancelled. No new room was created."));
2776 display_main_menu();
2779 er_name = sbstr("er_name");
2780 er_type = sbstr("type");
2781 er_password = sbstr("er_password");
2782 er_floor = ibstr("er_floor");
2783 er_view = ibstr("er_view");
2786 if (!strcmp(ChrPtr(er_type), "hidden"))
2788 else if (!strcmp(ChrPtr(er_type), "passworded"))
2790 else if (!strcmp(ChrPtr(er_type), "invonly"))
2792 else if (!strcmp(ChrPtr(er_type), "personal"))
2795 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2798 ChrPtr(er_password),
2803 serv_getln(buf, sizeof buf);
2804 if (buf[0] != '2') {
2805 strcpy(WCC->ImportantMessage, &buf[4]);
2806 display_main_menu();
2809 /** TODO: Room created, now update the left hand icon bar for this user */
2810 burn_folder_cache(0); /* burn the old folder cache */
2814 serv_printf("VIEW %d", er_view);
2815 serv_getln(buf, sizeof buf);
2816 WCC->CurRoom.view = er_view;
2818 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
2819 display_editroom ();
2821 do_change_view(er_view); /* Now go there */
2828 * \brief display the screen to enter a private room
2830 void display_private(char *rname, int req_pass)
2832 WCTemplputParams SubTP;
2834 output_headers(1, 1, 1, 0, 0, 0);
2836 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2837 memset(&SubTP, 0, sizeof(WCTemplputParams));
2838 SubTP.Filter.ContextType = CTX_STRBUF;
2839 SubTP.Context = Buf;
2840 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2845 wc_printf(_("If you know the name of a hidden (guess-name) or "
2846 "passworded room, you can enter that room by typing "
2847 "its name below. Once you gain access to a private "
2848 "room, it will appear in your regular room listings "
2849 "so you don't have to keep returning here."));
2852 wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2853 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2855 wc_printf("<table class=\"altern\"> "
2856 "<tr class=\"even\"><td>");
2857 wc_printf(_("Enter room name:"));
2858 wc_printf("</td><td>"
2859 "<input type=\"text\" name=\"gr_name\" "
2860 "value=\"%s\" maxlength=\"128\">\n", rname);
2863 wc_printf("</td></tr><tr class=\"odd\"><td>");
2864 wc_printf(_("Enter room password:"));
2865 wc_printf("</td><td>");
2866 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2868 wc_printf("</td></tr></table>\n");
2870 wc_printf("<div class=\"buttons\">\n");
2871 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2873 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2877 wc_printf("</div></form>\n");
2879 do_template("endbox", NULL);
2885 * \brief goto a private room
2887 void goto_private(void)
2892 if (!havebstr("ok_button")) {
2893 display_main_menu();
2896 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2897 serv_printf("GOTO %s|%s",
2900 serv_getln(buf, sizeof buf);
2902 if (buf[0] == '2') {
2903 smart_goto(sbstr("gr_name"));
2906 if (!strncmp(buf, "540", 3)) {
2907 display_private(bstr("gr_name"), 1);
2910 output_headers(1, 1, 1, 0, 0, 0);
2911 wc_printf("%s\n", &buf[4]);
2918 * \brief display the screen to zap a room
2920 void display_zap(void)
2922 output_headers(1, 1, 2, 0, 0, 0);
2924 wc_printf("<div id=\"banner\">\n");
2926 wc_printf(_("Zap (forget/unsubscribe) the current room"));
2927 wc_printf("</h1>\n");
2928 wc_printf("</div>\n");
2930 wc_printf("<div id=\"content\" class=\"service\">\n");
2932 wc_printf(_("If you select this option, <em>%s</em> will "
2933 "disappear from your room list. Is this what you wish "
2934 "to do?<br />\n"), ChrPtr(WC->CurRoom.name));
2936 wc_printf("<form method=\"POST\" action=\"zap\">\n");
2937 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2938 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2939 wc_printf(" ");
2940 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2941 wc_printf("</form>\n");
2952 StrBuf *final_destination;
2955 * If the forget-room routine fails for any reason, we fall back
2956 * to the current room; otherwise, we go to the Lobby
2958 final_destination = NewStrBufDup(WC->CurRoom.name);
2960 if (havebstr("ok_button")) {
2961 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
2962 serv_getln(buf, sizeof buf);
2963 if (buf[0] == '2') {
2965 serv_getln(buf, sizeof buf);
2966 if (buf[0] == '2') {
2967 FlushStrBuf(final_destination);
2968 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2972 smart_goto(final_destination);
2973 FreeStrBuf(&final_destination);
2979 * \brief Delete the current room
2981 void delete_room(void)
2986 serv_puts("KILL 1");
2987 serv_getln(buf, sizeof buf);
2988 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2989 if (buf[0] != '2') {
2990 strcpy(WC->ImportantMessage, &buf[4]);
2991 display_main_menu();
2996 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
3005 * \brief Perform changes to a room's network configuration
3007 void netedit(void) {
3016 /*/ TODO: do line dynamic! */
3017 if (havebstr("line_pop3host")) {
3018 strcpy(line, bstr("prefix"));
3019 strcat(line, bstr("line_pop3host"));
3021 strcat(line, bstr("line_pop3user"));
3023 strcat(line, bstr("line_pop3pass"));
3025 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
3027 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
3028 strcat(line, bstr("suffix"));
3030 else if (havebstr("line")) {
3031 strcpy(line, bstr("prefix"));
3032 strcat(line, bstr("line"));
3033 strcat(line, bstr("suffix"));
3048 serv_getln(buf, sizeof buf);
3049 if (buf[0] != '1') {
3055 /** This loop works for add *or* remove. Spiffy, eh? */
3056 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3057 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
3058 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
3059 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
3060 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
3061 if ( (strcasecmp(cmpa0, cmpb0))
3062 || (strcasecmp(cmpa1, cmpb1)) ) {
3063 fprintf(fp, "%s\n", buf);
3069 serv_getln(buf, sizeof buf);
3070 if (buf[0] != '4') {
3076 while (fgets(buf, sizeof buf, fp) != NULL) {
3077 buf[strlen(buf)-1] = 0;
3081 if (havebstr("add_button")) {
3082 num_addrs = num_tokens(bstr("line"), ',');
3083 if (num_addrs < 2) {
3084 /* just adding one node or address */
3088 /* adding multiple addresses separated by commas */
3089 for (i=0; i<num_addrs; ++i) {
3090 strcpy(line, bstr("prefix"));
3091 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3094 strcat(line, bstr("suffix"));
3108 * \brief Convert a room name to a folder-ish-looking name.
3109 * \param folder the folderish name
3110 * \param room the room name
3111 * \param floor the floor name
3112 * \param is_mailbox is it a mailbox?
3114 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3119 * For mailboxes, just do it straight...
3122 sprintf(folder, "My folders|%s", room);
3126 * Otherwise, prefix the floor name as a "public folders" moniker
3129 if (floor > MAX_FLOORS) {
3131 sprintf(folder, "%%%%%%|%s", room);
3134 sprintf(folder, "%s|%s", floorlist[floor], room);
3139 * Replace "\" characters with "|" for pseudo-folder-delimiting
3141 len = strlen (folder);
3142 for (i=0; i<len; ++i) {
3143 if (folder[i] == '\\') folder[i] = '|';
3151 * \brief Back end for change_view()
3152 * \param newview set newview???
3154 void do_change_view(int newview) {
3157 serv_printf("VIEW %d", newview);
3158 serv_getln(buf, sizeof buf);
3159 WC->CurRoom.view = newview;
3160 smart_goto(WC->CurRoom.name);
3166 * \brief Change the view for this room
3168 void change_view(void) {
3171 view = lbstr("view");
3172 do_change_view(view);
3176 * \brief Burn the cached folder list.
3177 * \param age How old the cahce needs to be before we burn it.
3180 void burn_folder_cache(time_t age)
3182 /** If our cached folder list is very old, burn it. */
3183 if (WC->cache_fold != NULL) {
3184 if ((time(NULL) - WC->cache_timestamp) > age) {
3185 free(WC->cache_fold);
3186 WC->cache_fold = NULL;
3194 * \brief Do either a known rooms list or a folders list, depending on the
3199 StrBuf *ListView = NULL;
3201 /** Determine whether the user is trying to change views */
3202 if (havebstr("view")) {
3203 ListView = NewStrBufDup(SBSTR("view"));
3204 set_preference("roomlistview", ListView, 1);
3206 /** Sanitize the input so its safe */
3207 if((get_preference("roomlistview", &ListView) != 0)||
3208 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3209 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3211 if (ListView == NULL) {
3212 ListView = NewStrBufPlain(HKEY("rooms"));
3213 set_preference("roomlistview", ListView, 0);
3217 ListView = NewStrBufPlain(HKEY("rooms"));
3218 set_preference("roomlistview", ListView, 0);
3222 FreeStrBuf(&ListView);
3229 * \brief Set the message expire policy for this room and/or floor
3231 void set_room_policy(void) {
3234 if (!havebstr("ok_button")) {
3235 strcpy(WC->ImportantMessage,
3236 _("Cancelled. Changes were not saved."));
3241 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3242 serv_getln(buf, sizeof buf);
3243 strcpy(WC->ImportantMessage, &buf[4]);
3245 if (WC->axlevel >= 6) {
3246 strcat(WC->ImportantMessage, "<br />\n");
3247 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3248 serv_getln(buf, sizeof buf);
3249 strcat(WC->ImportantMessage, &buf[4]);
3255 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3257 StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3261 void _display_private(void) {
3262 display_private("", 0);
3265 void dotgoto(void) {
3266 if (!havebstr("room")) {
3267 readloop(readnew, eUseDefault);
3270 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3273 smart_goto(sbstr("room"));
3278 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3280 wcsession *WCC = WC;
3283 StrBufAppendTemplate(Target, TP,
3288 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3290 wc_printf("<div id=\"banner\">\n");
3291 embed_room_banner(NULL);
3292 wc_printf("</div>\n");
3296 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3298 wcsession *WCC = WC;
3301 (!IsEmptyStr(WCC->ugname)))
3302 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3305 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3307 wcsession *WCC = WC;
3308 return (WCC != NULL)?
3309 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3312 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3314 wcsession *WCC = WC;
3315 return (WCC == NULL)? 0 :
3316 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3317 (WCC->CurRoom.is_inbox) ||
3318 (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3321 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3323 wcsession *WCC = WC;
3325 return ((WCC!=NULL) &&
3326 (!IsEmptyStr(WCC->ugname)) &&
3327 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3331 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
3333 folder *Folder = (folder *)(TP->Context);
3336 UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3337 if (UA_CheckFlag == 0)
3338 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3339 "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
3341 return ((Folder->RAFlags & UA_CheckFlag) != 0);
3346 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3349 wcsession *WCC = WC;
3351 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3352 if (QR_CheckFlag == 0)
3353 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3354 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3356 return ((WCC!=NULL) &&
3357 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3360 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3363 folder *Folder = (folder *)(TP->Context);
3365 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3366 if (QR_CheckFlag == 0)
3367 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3368 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3369 return ((Folder->QRFlags & QR_CheckFlag) != 0);
3373 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3376 wcsession *WCC = WC;
3378 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3379 if (QR2_CheckFlag == 0)
3380 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3381 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3383 return ((WCC!=NULL) &&
3384 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3387 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3390 folder *Folder = (folder *)(TP->Context);
3392 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3393 if (QR2_CheckFlag == 0)
3394 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3395 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3396 return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3400 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3402 wcsession *WCC = WC;
3404 return ( (WCC!= NULL) &&
3405 ((WCC->axlevel >= 6) ||
3406 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3407 (WCC->CurRoom.is_inbox) ));
3410 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3412 wcsession *WCC = WC;
3414 if ((WCC == NULL) ||
3415 (TP->Tokens->nParameters < 3))
3417 return ((WCC->CurRoom.view < VIEW_BBS) ||
3418 (WCC->CurRoom.view > VIEW_MAX));
3421 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3425 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
3427 wcsession *WCC = WC;
3431 HashList *Whok = NULL;
3437 Token = NewStrBuf();
3438 StrBuf_ServGetln(Line);
3439 if (GetServerStatus(Line, &State) == 1)
3441 Whok = NewHash(1, Flathash);
3442 while(!Done && StrBuf_ServGetln(Line))
3443 if ( (StrLength(Line)==3) &&
3444 !strcmp(ChrPtr(Line), "000"))
3451 const char *Pos = NULL;
3452 Token = NewStrBufPlain (NULL, StrLength(Line));
3453 StrBufExtract_NextToken(Token, Line, &Pos, '|');
3461 else if (State == 550)
3462 StrBufAppendBufPlain(WCC->ImportantMsg,
3463 _("Higher access is required to access this function."), -1, 0);
3473 initialize_viewdefs();
3474 RegisterPreference("roomlistview",
3475 _("Room list view"),
3478 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3480 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3483 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3484 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3485 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3486 WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3487 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3488 WebcitAddUrlHandler(HKEY("zapped_list"), "", 0, zapped_list, 0);
3489 WebcitAddUrlHandler(HKEY("display_zap"), "", 0, display_zap, 0);
3490 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3491 WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3492 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3493 WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3494 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3495 WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3496 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3497 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3498 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3499 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3500 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3501 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3502 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3504 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3505 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3506 RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3508 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3509 RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3510 RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
3512 RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
3513 RegisterNamespace("THISROOM:MSGS:NEW", 0, 0, tmplput_CurrentRoom_nNewMessages, NULL, CTX_NONE);
3514 RegisterNamespace("THISROOM:MSGS:TOTAL", 0, 0, tmplput_CurrentRoom_nTotalMessages, NULL, CTX_NONE);
3516 RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
3517 RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3518 RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3519 RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3520 RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3521 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3522 RegisterConditional(HKEY("COND:THISROOM:HAVE_VIEW"), 0, ConditionalThisRoomHaveView, CTX_NONE);
3523 RegisterNamespace("THISROOM:VIEW_STRING", 0, 1, tmplput_CurrentRoomViewString, NULL, CTX_NONE);
3524 RegisterNamespace("ROOM:VIEW_STRING", 1, 2, tmplput_RoomViewString, NULL, CTX_NONE);
3526 RegisterNamespace("THISROOM:INFOTEXT", 1, 2, tmplput_CurrentRoomInfoText, NULL, CTX_NONE);
3527 RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3528 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3529 RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
3530 RegisterConditional(HKEY("COND:THISROOM:HAVE_INFOTEXT"), 0, ConditionalThisRoomXHaveInfoText, CTX_NONE);
3531 RegisterNamespace("THISROOM:FILES:N", 0, 1, tmplput_CurrentRoomXNFiles, NULL, CTX_NONE);
3532 RegisterNamespace("THISROOM:FILES:STR", 0, 1, tmplput_CurrentRoomX_FileString, NULL, CTX_NONE);
3534 REGISTERTokenParamDefine(QR_PERMANENT);
3535 REGISTERTokenParamDefine(QR_INUSE);
3536 REGISTERTokenParamDefine(QR_PRIVATE);
3537 REGISTERTokenParamDefine(QR_PASSWORDED);
3538 REGISTERTokenParamDefine(QR_GUESSNAME);
3539 REGISTERTokenParamDefine(QR_DIRECTORY);
3540 REGISTERTokenParamDefine(QR_UPLOAD);
3541 REGISTERTokenParamDefine(QR_DOWNLOAD);
3542 REGISTERTokenParamDefine(QR_VISDIR);
3543 REGISTERTokenParamDefine(QR_ANONONLY);
3544 REGISTERTokenParamDefine(QR_ANONOPT);
3545 REGISTERTokenParamDefine(QR_NETWORK);
3546 REGISTERTokenParamDefine(QR_PREFONLY);
3547 REGISTERTokenParamDefine(QR_READONLY);
3548 REGISTERTokenParamDefine(QR_MAILBOX);
3549 REGISTERTokenParamDefine(QR2_SYSTEM);
3550 REGISTERTokenParamDefine(QR2_SELFLIST);
3551 REGISTERTokenParamDefine(QR2_COLLABDEL);
3552 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3553 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3554 REGISTERTokenParamDefine(QR2_MODERATED);
3556 REGISTERTokenParamDefine(UA_KNOWN);
3557 REGISTERTokenParamDefine(UA_GOTOALLOWED);
3558 REGISTERTokenParamDefine(UA_HASNEWMSGS);
3559 REGISTERTokenParamDefine(UA_ZAPPED);
3560 REGISTERTokenParamDefine(UA_POSTALLOWED);
3561 REGISTERTokenParamDefine(UA_ADMINALLOWED);
3562 REGISTERTokenParamDefine(UA_DELETEALLOWED);
3563 REGISTERTokenParamDefine(UA_ISTRASH);
3565 REGISTERTokenParamDefine(US_NEEDVALID);
3566 REGISTERTokenParamDefine(US_PERM);
3567 REGISTERTokenParamDefine(US_LASTOLD);
3568 REGISTERTokenParamDefine(US_EXPERT);
3569 REGISTERTokenParamDefine(US_UNLISTED);
3570 REGISTERTokenParamDefine(US_NOPROMPT);
3571 REGISTERTokenParamDefine(US_PROMPTCTL);
3572 REGISTERTokenParamDefine(US_DISAPPEAR);
3573 REGISTERTokenParamDefine(US_REGIS);
3574 REGISTERTokenParamDefine(US_PAGINATOR);
3575 REGISTERTokenParamDefine(US_INTERNET);
3576 REGISTERTokenParamDefine(US_FLOORS);
3577 REGISTERTokenParamDefine(US_COLOR);
3578 REGISTERTokenParamDefine(US_USER_SET);
3580 REGISTERTokenParamDefine(VIEW_BBS);
3581 REGISTERTokenParamDefine(VIEW_MAILBOX);
3582 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3583 REGISTERTokenParamDefine(VIEW_CALENDAR);
3584 REGISTERTokenParamDefine(VIEW_TASKS);
3585 REGISTERTokenParamDefine(VIEW_NOTES);
3586 REGISTERTokenParamDefine(VIEW_WIKI);
3587 REGISTERTokenParamDefine(VIEW_CALBRIEF);
3588 REGISTERTokenParamDefine(VIEW_JOURNAL);
3589 REGISTERTokenParamDefine(VIEW_BLOG);
3592 REGISTERTokenParamDefine(ignet_push_share);
3593 { /* these are the parts of an IGNET push config */
3594 REGISTERTokenParamDefine(GNET_IGNET_NODE);
3595 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
3597 REGISTERTokenParamDefine(listrecp);
3598 REGISTERTokenParamDefine(digestrecp);
3599 REGISTERTokenParamDefine(pop3client);
3600 { /* These are the parts of a pop3 client line... */
3601 REGISTERTokenParamDefine(GNET_POP3_HOST);
3602 REGISTERTokenParamDefine(GNET_POP3_USER);
3603 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
3604 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
3606 REGISTERTokenParamDefine(rssclient);
3607 REGISTERTokenParamDefine(participate);
3609 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3610 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3612 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3613 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3615 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3616 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3617 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3624 SessionDestroyModule_ROOMOPS
3627 FlushFolder(&sess->CurRoom);
3628 if (sess->cache_fold != NULL) {
3629 free(sess->cache_fold);
3632 free_march_list(sess);
3633 DeleteHash(&sess->Floors);
3634 DeleteHash(&sess->Rooms);
3635 DeleteHash(&sess->FloorsByName);