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, int navbar_style) {
265 char with_files[256];
269 * We need to have the information returned by a GOTO server command.
270 * If it isn't supplied, we fake it by issuing our own GOTO.
273 memset(buf, '0', 20);
275 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
276 serv_getln(buf, sizeof buf);
280 /* The browser needs some information for its own use */
281 wc_printf("<script type=\"text/javascript\"> \n"
282 " room_is_trash = %d; \n"
284 ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
288 * If the user happens to select the "make this my start page" link,
289 * we want it to remember the URL as a "/dotskip" one instead of
290 * a "skip" or "gotonext" or something like that.
292 if (WCC->Hdr->this_page == NULL) {
293 WCC->Hdr->this_page = NewStrBuf();
295 StrBufPrintf(WCC->Hdr->this_page,
297 ChrPtr(WC->CurRoom.name)
300 /* Check for new mail. */
301 WC->new_mail = extract_int(&got[4], 9);
302 WC->CurRoom.view = extract_int(&got[4], 11);
304 do_template("roombanner", NULL);
305 /* roombanner contains this for mobile */
306 if (navbar_style != navbar_none && (WC->is_mobile < 1)) {
308 wc_printf("<div id=\"navbar\"><ul>");
310 if (navbar_style == navbar_default) wc_printf(
311 "<li class=\"ungoto\">"
312 "<a href=\"ungoto\">"
313 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
314 "<span class=\"navbar_link\">%s</span></A>"
315 "</li>\n", _("Ungoto")
318 if ( (navbar_style == navbar_default) && (WC->CurRoom.view == VIEW_BBS) ) {
320 "<li class=\"newmess\">"
321 "<a href=\"readnew\">"
322 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
323 "<span class=\"navbar_link\">%s</span></A>"
324 "</li>\n", _("Read new messages")
328 if (navbar_style == navbar_default) {
329 switch(WC->CurRoom.view) {
330 case VIEW_ADDRESSBOOK:
332 "<li class=\"viewcontacts\">"
333 "<a href=\"readfwd\">"
334 "<img src=\"static/viewcontacts_24x.gif\" "
335 "alt=\"\" width=\"24\" height=\"24\">"
336 "<span class=\"navbar_link\">"
338 "</span></a></li>\n", _("View contacts")
343 "<li class=\"staskday\">"
344 "<a href=\"readfwd?calview=day\">"
345 "<img src=\"static/taskday2_24x.gif\" "
346 "alt=\"\" width=\"24\" height=\"24\">"
347 "<span class=\"navbar_link\">"
349 "</span></a></li>\n", _("Day view")
352 "<li class=\"monthview\">"
353 "<a href=\"readfwd?calview=month\">"
354 "<img src=\"static/monthview2_24x.gif\" "
355 "alt=\"\" width=\"24\" height=\"24\">"
356 "<span class=\"navbar_link\">"
358 "</span></a></li>\n", _("Month view")
363 "<li class=\"monthview\">"
364 "<a href=\"readfwd?calview=month\">"
365 "<img src=\"static/monthview2_24x.gif\" "
366 "alt=\"\" width=\"24\" height=\"24\">"
367 "<span class=\"navbar_link\">"
369 "</span></a></li>\n", _("Calendar list")
374 "<li class=\"taskmanag\">"
375 "<a href=\"readfwd\">"
376 "<img src=\"static/taskmanag_24x.gif\" "
377 "alt=\"\" width=\"24\" height=\"24\">"
378 "<span class=\"navbar_link\">"
380 "</span></a></li>\n", _("View tasks")
385 "<li class=\"viewnotes\">"
386 "<a href=\"readfwd\">"
387 "<img src=\"static/viewnotes_24x.gif\" "
388 "alt=\"\" width=\"24\" height=\"24\">"
389 "<span class=\"navbar_link\">"
391 "</span></a></li>\n", _("View notes")
396 "<li class=\"readallmess\">"
397 "<a id=\"m_refresh\" href=\"readfwd\">"
398 "<img src=\"static/readallmess3_24x.gif\" "
399 "alt=\"\" width=\"24\" height=\"24\">"
400 "<span class=\"navbar_link\">"
402 "</span></a></li>\n", _("Refresh message list")
407 "<li class=\"readallmess\">"
408 "<a href=\"wiki?page=home\">"
409 "<img src=\"static/readallmess3_24x.gif\" "
410 "alt=\"\" width=\"24\" height=\"24\">"
411 "<span class=\"navbar_link\">"
413 "</span></a></li>\n", _("Wiki home")
418 "<li class=\"readallmess\">"
419 "<a href=\"readfwd\">"
420 "<img src=\"static/readallmess3_24x.gif\" "
421 "alt=\"\" width=\"24\" height=\"24\">"
422 "<span class=\"navbar_link\">"
424 "</span></a></li>\n", _("Read all messages")
430 if (navbar_style == navbar_default) {
431 switch(WC->CurRoom.view) {
432 case VIEW_ADDRESSBOOK:
434 "<li class=\"addnewcontact\">"
435 "<a href=\"display_enter\">"
436 "<img src=\"static/addnewcontact_24x.gif\" "
437 "alt=\"\" width=\"24\" height=\"24\">"
438 "<span class=\"navbar_link\">"
440 "</span></a></li>\n", _("Add new contact")
445 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
446 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
447 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
448 if (havebstr("day" )) wc_printf("?day=%s", bstr("day"));
450 "<img src=\"static/addevent_24x.gif\" "
451 "alt=\"\" width=\"24\" height=\"24\">"
452 "<span class=\"navbar_link\">"
454 "</span></a></li>\n", _("Add new event")
459 "<li class=\"newmess\">"
460 "<a href=\"display_enter\">"
461 "<img src=\"static/newmess3_24x.gif\" "
462 "alt=\"\" width=\"24\" height=\"24\">"
463 "<span class=\"navbar_link\">"
465 "</span></a></li>\n", _("Add new task")
470 "<li class=\"enternewnote\">"
471 "<a href=\"add_new_note\">"
472 "<img src=\"static/enternewnote_24x.gif\" "
473 "alt=\"\" width=\"24\" height=\"24\">"
474 "<span class=\"navbar_link\">"
476 "</span></a></li>\n", _("Add new note")
480 safestrncpy(buf, bstr("page"), sizeof buf);
481 if (IsEmptyStr(buf)) {
482 safestrncpy(buf, "home", sizeof buf);
486 "<li class=\"newmess\">"
487 "<a href=\"display_enter?page=%s\">"
488 "<img src=\"static/newmess3_24x.gif\" "
489 "alt=\"\" width=\"24\" height=\"24\">"
490 "<span class=\"navbar_link\">"
492 "</span></a></li>\n", buf, _("Edit this page")
495 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
496 /* already viewing history; display a link to the current page */
498 "<li class=\"newmess\">"
499 "<a href=\"wiki?page=%s\">"
500 "<img src=\"static/newmess3_24x.gif\" "
501 "alt=\"\" width=\"24\" height=\"24\">"
502 "<span class=\"navbar_link\">"
504 "</span></a></li>\n", buf, _("Current version")
508 /* display a link to the history */
510 "<li class=\"newmess\">"
511 "<a href=\"wiki_history?page=%s\">"
512 "<img src=\"static/newmess3_24x.gif\" "
513 "alt=\"\" width=\"24\" height=\"24\">"
514 "<span class=\"navbar_link\">"
516 "</span></a></li>\n", buf, _("History")
522 "<li class=\"newmess\">"
523 "<a href=\"display_enter\">"
524 "<img src=\"static/newmess3_24x.gif\" "
525 "alt=\"\" width=\"24\" height=\"24\">"
526 "<span class=\"navbar_link\">"
528 "</span></a></li>\n", _("Write mail")
531 "<li class=\"newmess\">"
532 "<a href=\"javascript:deleteAllSelectedMessages();\">"
533 "<img src=\"static/delete.gif\" "
534 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
536 "</span></a></li>\n", _("Delete")
541 "<li class=\"newmess\">"
542 "<a href=\"display_enter\">"
543 "<img src=\"static/newmess3_24x.gif\" "
544 "alt=\"\" width=\"24\" height=\"24\">"
545 "<span class=\"navbar_link\">"
547 "</span></a></li>\n", _("Enter a message")
553 if (navbar_style == navbar_default) wc_printf(
554 "<li class=\"skipthisroom\">"
557 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
558 "width=\"24\" height=\"24\">"
559 "<span class=\"navbar_link\">%s</span></a>"
561 _("Leave all messages marked as unread, go to next room with unread messages"),
565 if (navbar_style == navbar_default) wc_printf(
566 "<li class=\"markngo\">"
567 "<a href=\"gotonext\" "
569 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
570 "width=\"24\" height=\"24\">"
571 "<span class=\"navbar_link\">%s</span></a>"
573 _("Mark all messages as read, go to next room with unread messages"),
577 wc_printf("</ul></div>\n");
584 * back end routine to take the session to a new room
586 long gotoroom(const StrBuf *gname)
590 static long ls = (-1L);
593 /* store ungoto information */
594 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
598 /* move to the new room */
599 serv_printf("GOTO %s", ChrPtr(gname));
600 StrBuf_ServGetln(Buf);
601 if (GetServerStatus(Buf, &err) != 2) {
602 serv_puts("GOTO _BASEROOM_");
603 StrBuf_ServGetln(Buf);
605 * well, we know that this is the fallback case,
606 * but we're interested that the first command
607 * didn't work out in first place.
609 if (GetServerStatus(Buf, NULL) != 2) {
614 ParseGoto(&WCC->CurRoom, Buf);
616 remove_march(WCC->CurRoom.name);
617 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
625 void ParseGoto(folder *room, StrBuf *Line)
633 if (StrLength(Line) < 4) {
637 /* ignore the commandstate... */
638 Pos = ChrPtr(Line) + 4;
640 if (room->RoomNameParts != NULL)
643 for (i=0; i < room->nRoomNameParts; i++)
644 FreeStrBuf(&room->RoomNameParts[i]);
645 free(room->RoomNameParts);
646 room->RoomNameParts = NULL;
651 pBuf = NewStrBufPlain(NULL, StrLength(Line));
654 memset(room, 0, sizeof(folder));
657 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
659 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
660 if (room->nNewMessages > 0)
661 room->RAFlags |= UA_HASNEWMSGS;
663 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
665 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
667 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
669 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
670 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
672 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
674 flag = StrBufExtractNext_long(Line, &Pos, '|');
675 if (WCC->is_aide || flag) {
676 room->RAFlags |= UA_ADMINALLOWED;
679 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
681 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
683 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
685 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
687 flag = StrBufExtractNext_long(Line, &Pos, '|');
689 room->RAFlags |= UA_ISTRASH; // wc_is_trash
691 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
693 /* find out, whether we are in a sub-room */
694 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
695 if (room->nRoomNameParts > 1)
700 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
701 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
702 for (i=0; i < room->nRoomNameParts; i++)
704 room->RoomNameParts[i] = NewStrBuf();
705 StrBufExtract_NextToken(room->RoomNameParts[i],
706 room->name, &Pos, '\\');
710 /* Private mailboxes on the main floor get remapped to the personal folder */
711 if ((room->QRFlags & QR_MAILBOX) &&
712 (room->floorid == 0))
714 room->floorid = VIRTUAL_MY_FLOOR;
715 if ((room->nRoomNameParts == 1) &&
716 (StrLength(room->name) == 4) &&
717 (strcmp(ChrPtr(room->name), "Mail") == 0))
723 /* get a pointer to the floor we're on: */
724 if (WCC->Floors == NULL)
725 GetFloorListHash(NULL, NULL);
727 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
728 room->Floor = (const Floor*) vFloor;
731 void LoadRoomAide(void)
736 if (WCC->CurRoom.RoomAideLoaded)
739 WCC->CurRoom.RoomAideLoaded = 1;
742 StrBuf_ServGetln(Buf);
743 if (GetServerStatus(Buf, NULL) != 2) {
744 FlushStrBuf(WCC->CurRoom.RoomAide);
745 AppendImportantMessage (ChrPtr(Buf) + 4,
750 Pos = ChrPtr(Buf) + 4;
752 FreeStrBuf(&WCC->CurRoom.RoomAide);
753 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
755 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
759 void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
762 folder *Folder = &WCC->CurRoom;
763 const Floor *pFloor = Folder->Floor;
768 StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
771 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
777 StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
781 void LoadRoomXA (void)
786 if (WCC->CurRoom.XALoaded)
789 WCC->CurRoom.XALoaded = 1;
792 StrBuf_ServGetln(Buf);
793 if (GetServerStatus(Buf, NULL) != 2) {
794 FlushStrBuf(WCC->CurRoom.XAPass);
795 FlushStrBuf(WCC->CurRoom.Directory);
797 AppendImportantMessage (ChrPtr(Buf) + 4,
802 Pos = ChrPtr(Buf) + 4;
804 FreeStrBuf(&WCC->CurRoom.XAPass);
805 FreeStrBuf(&WCC->CurRoom.Directory);
807 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
808 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
810 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
811 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
812 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
813 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
814 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
815 /* defview, we already know you. */
816 /* QR2Flags, we already know them... */
823 void LoadXRoomPic(void)
828 if (WCC->CurRoom.XHaveRoomPicLoaded)
831 WCC->CurRoom.XHaveRoomPicLoaded = 1;
833 serv_puts("OIMG _roompic_");
834 StrBuf_ServGetln(Buf);
835 if (GetServerStatus(Buf, NULL) != 2) {
836 WCC->CurRoom.XHaveRoomPic = 0;
838 WCC->CurRoom.XHaveRoomPic = 1;
841 StrBuf_ServGetln(Buf);
842 GetServerStatus(Buf, NULL);
846 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
854 return WCC->CurRoom.XHaveRoomPic == 1;
857 void LoadXRoomInfoText(void)
863 if (WCC->CurRoom.XHaveInfoTextLoaded)
866 WCC->CurRoom.XHaveInfoTextLoaded = 1;
871 StrBuf_ServGetln(Buf);
872 if (GetServerStatus(Buf, NULL) == 1) {
873 WCC->CurRoom.XInfoText = NewStrBuf ();
875 while (!Done && StrBuf_ServGetln(Buf)>=0) {
876 if ( (StrLength(Buf)==3) &&
877 !strcmp(ChrPtr(Buf), "000"))
880 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
887 int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
895 return (StrLength(WCC->CurRoom.XInfoText)>0);
898 void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
904 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1);
907 void LoadXRoomXCountFiles(void)
913 if (WCC->CurRoom.XHaveDownloadCount)
916 WCC->CurRoom.XHaveDownloadCount = 1;
920 StrBuf_ServGetln(Buf);
921 if (GetServerStatus(Buf, NULL) == 1) {
923 while (!Done && StrBuf_ServGetln(Buf)>=0) {
924 if ( (StrLength(Buf)==3) &&
925 !strcmp(ChrPtr(Buf), "000"))
928 WCC->CurRoom.XDownloadCount++;
935 void tmplput_CurrentRoomXNFiles(StrBuf *Target, WCTemplputParams *TP)
939 LoadXRoomXCountFiles();
941 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.XDownloadCount);
944 void tmplput_CurrentRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
948 LoadXRoomXCountFiles();
950 if (WCC->CurRoom.XDownloadCount == 1)
951 StrBufAppendBufPlain(Target, _("file"), -1, 0);
953 StrBufAppendBufPlain(Target, _("files"), -1, 0);
956 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
962 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
964 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
970 StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
972 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
978 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
980 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
984 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.defview);
987 void tmplput_CurrentRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP)
993 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
996 void tmplput_CurrentRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP)
1002 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nTotalMessages);
1005 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
1007 wcsession *WCC = WC;
1015 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1016 return CheckThis == WCC->CurRoom.Order;
1019 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1021 wcsession *WCC = WC;
1027 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1028 return CheckThis == WCC->CurRoom.defview;
1031 int ConditionalThisRoomHaveView(StrBuf *Target, WCTemplputParams *TP)
1033 wcsession *WCC = WC;
1039 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1040 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
1042 LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
1043 "Roomview [%ld] not valid\n",
1048 return exchangeable_views [WCC->CurRoom.defview][CheckThis] != VIEW_MAX;
1051 void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
1053 wcsession *WCC = WC;
1056 if ((WCC == NULL) ||
1057 (WCC->CurRoom.defview >= VIEW_MAX) ||
1058 (WCC->CurRoom.defview < VIEW_BBS))
1060 LogTemplateError(Target, "Token", ERR_PARM2, TP,
1061 "Roomview [%ld] not valid\n",
1063 WCC->CurRoom.defview : -1);
1067 Buf = NewStrBufPlain(_(viewdefs[WCC->CurRoom.defview]), -1);
1068 StrBufAppendTemplate(Target, TP, Buf, 0);
1072 void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
1077 CheckThis = GetTemplateTokenNumber(Target, TP, 0, 0);
1078 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
1080 LogTemplateError(Target, "Token", ERR_PARM2, TP,
1081 "Roomview [%ld] not valid\n",
1086 Buf = NewStrBufPlain(_(viewdefs[CheckThis]), -1);
1087 StrBufAppendTemplate(Target, TP, Buf, 0);
1095 void smart_goto(const StrBuf *next_room) {
1096 gotoroom(next_room);
1097 readloop(readnew, eUseDefault);
1103 * mark all messages in current room as having been read
1105 void slrp_highest(void)
1109 serv_puts("SLRP HIGHEST");
1110 serv_getln(buf, sizeof buf);
1114 typedef struct __room_states {
1129 * Set/clear/read the "self-service list subscribe" flag for a room
1131 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1132 * returns the new value.
1135 int self_service(int newval) {
1136 int current_value = 0;
1142 int flags, floor, order, view, flags2;
1145 serv_getln(buf, sizeof buf);
1146 if (buf[0] != '2') return(0);
1148 extract_token(name, &buf[4], 0, '|', sizeof name);
1149 extract_token(password, &buf[4], 1, '|', sizeof password);
1150 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1151 flags = extract_int(&buf[4], 3);
1152 floor = extract_int(&buf[4], 4);
1153 order = extract_int(&buf[4], 5);
1154 view = extract_int(&buf[4], 6);
1155 flags2 = extract_int(&buf[4], 7);
1157 if (flags2 & QR2_SELFLIST) {
1165 flags2 = flags2 | QR2_SELFLIST;
1167 else if (newval == 0) {
1168 flags2 = flags2 & ~QR2_SELFLIST;
1171 return(current_value);
1174 if (newval != current_value) {
1175 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1176 name, password, dirname, flags,
1177 floor, order, view, flags2);
1178 serv_getln(buf, sizeof buf);
1185 int is_selflist(room_states *RoomFlags)
1187 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1190 int is_publiclist(room_states *RoomFlags)
1192 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1195 int is_moderatedlist(room_states *RoomFlags)
1197 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1201 * Set/clear/read the "self-service list subscribe" flag for a room
1203 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1204 * returns the new value.
1207 int get_roomflags(room_states *RoomOps)
1212 serv_getln(buf, sizeof buf);
1213 if (buf[0] != '2') return(0);
1215 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1216 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1217 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1218 RoomOps->flags = extract_int(&buf[4], 3);
1219 RoomOps->floor = extract_int(&buf[4], 4);
1220 RoomOps->order = extract_int(&buf[4], 5);
1221 RoomOps->view = extract_int(&buf[4], 6);
1222 RoomOps->flags2 = extract_int(&buf[4], 7);
1226 int set_roomflags(room_states *RoomOps)
1230 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1239 serv_getln(buf, sizeof buf);
1249 * display the form for editing a room
1251 void display_editroom(void)
1257 char remote_room[128];
1260 char er_password[10];
1261 char er_dirname[15];
1262 char er_roomaide[26];
1269 char *not_shared_with = NULL;
1272 int floorpolicy = 0;
1274 char pop3_host[128];
1279 if (IsEmptyStr(tab)) tab = "admin";
1282 load_floorlist(Buf);
1284 output_headers(1, 1, 1, 0, 0, 0);
1286 wc_printf("<div class=\"fix_scrollbar_bug\">");
1288 wc_printf("<br />\n");
1290 /* print the tabbed dialog */
1291 wc_printf("<div align=\"center\">");
1292 wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1293 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1296 wc_printf("<td class=\"");
1297 if (!strcmp(tab, "admin")) {
1298 wc_printf(" tab_cell_label\">");
1299 wc_printf(_("Administration"));
1302 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1303 wc_printf(_("Administration"));
1306 wc_printf("</td>\n");
1307 wc_printf("<td> </td>\n");
1309 if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1311 wc_printf("<td class=\"");
1312 if (!strcmp(tab, "config")) {
1313 wc_printf(" tab_cell_label\">");
1314 wc_printf(_("Configuration"));
1317 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1318 wc_printf(_("Configuration"));
1321 wc_printf("</td>\n");
1322 wc_printf("<td> </td>\n");
1324 wc_printf("<td class=\"");
1325 if (!strcmp(tab, "expire")) {
1326 wc_printf(" tab_cell_label\">");
1327 wc_printf(_("Message expire policy"));
1330 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1331 wc_printf(_("Message expire policy"));
1334 wc_printf("</td>\n");
1335 wc_printf("<td> </td>\n");
1337 wc_printf("<td class=\"");
1338 if (!strcmp(tab, "access")) {
1339 wc_printf(" tab_cell_label\">");
1340 wc_printf(_("Access controls"));
1343 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1344 wc_printf(_("Access controls"));
1347 wc_printf("</td>\n");
1348 wc_printf("<td> </td>\n");
1350 wc_printf("<td class=\"");
1351 if (!strcmp(tab, "sharing")) {
1352 wc_printf(" tab_cell_label\">");
1353 wc_printf(_("Sharing"));
1356 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1357 wc_printf(_("Sharing"));
1360 wc_printf("</td>\n");
1361 wc_printf("<td> </td>\n");
1363 wc_printf("<td class=\"");
1364 if (!strcmp(tab, "listserv")) {
1365 wc_printf(" tab_cell_label\">");
1366 wc_printf(_("Mailing list service"));
1369 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1370 wc_printf(_("Mailing list service"));
1373 wc_printf("</td>\n");
1374 wc_printf("<td> </td>\n");
1378 wc_printf("<td class=\"");
1379 if (!strcmp(tab, "feeds")) {
1380 wc_printf(" tab_cell_label\">");
1381 wc_printf(_("Remote retrieval"));
1384 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1385 wc_printf(_("Remote retrieval"));
1388 wc_printf("</td>\n");
1389 wc_printf("<td> </td>\n");
1391 wc_printf("</tr></table>\n");
1392 wc_printf("</div>\n");
1393 /* end tabbed dialog */
1395 wc_printf("<script type=\"text/javascript\">"
1396 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1400 /* begin content of whatever tab is open now */
1402 if (!strcmp(tab, "admin")) {
1403 wc_printf("<div class=\"tabcontent\">");
1405 "<li><a href=\"delete_room\" "
1406 "onClick=\"return confirm('");
1407 wc_printf(_("Are you sure you want to delete this room?"));
1408 wc_printf("');\">\n");
1409 wc_printf(_("Delete this room"));
1411 "<li><a href=\"display_editroompic?which_room=");
1412 urlescputs(ChrPtr(WC->CurRoom.name));
1414 wc_printf(_("Set or change the icon for this room's banner"));
1416 "<li><a href=\"display_editinfo\">\n");
1417 wc_printf(_("Edit this room's Info file"));
1420 wc_printf("</div>");
1423 if (!strcmp(tab, "config")) {
1424 wc_printf("<div class=\"tabcontent\">");
1426 serv_getln(buf, sizeof buf);
1428 if (!strncmp(buf, "550", 3)) {
1429 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1430 _("Higher access is required to access this function.")
1433 else if (buf[0] != '2') {
1434 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1437 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1438 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1439 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1440 er_flags = extract_int(&buf[4], 3);
1441 er_floor = extract_int(&buf[4], 4);
1442 er_flags2 = extract_int(&buf[4], 7);
1444 wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1445 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1447 wc_printf("<ul><li>");
1448 wc_printf(_("Name of room: "));
1449 wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1455 wc_printf(_("Resides on floor: "));
1456 wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1457 if (er_flags & QR_MAILBOX)
1458 wc_printf("disabled >\n");
1459 for (i = 0; i < 128; ++i)
1460 if (!IsEmptyStr(floorlist[i])) {
1461 wc_printf("<OPTION ");
1463 wc_printf("SELECTED ");
1464 wc_printf("VALUE=\"%d\">", i);
1465 escputs(floorlist[i]);
1466 wc_printf("</OPTION>\n");
1468 wc_printf("</select>\n");
1471 wc_printf(_("Type of room:"));
1472 wc_printf("<ul>\n");
1474 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1475 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1476 wc_printf("CHECKED ");
1477 wc_printf("OnChange=\""
1478 " if (this.form.type[0].checked == true) { "
1479 " this.form.er_floor.disabled = false; "
1482 wc_printf(_("Public (automatically appears to everyone)"));
1485 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1486 if ((er_flags & QR_PRIVATE) &&
1487 (er_flags & QR_GUESSNAME))
1488 wc_printf("CHECKED ");
1489 wc_printf(" OnChange=\""
1490 " if (this.form.type[1].checked == true) { "
1491 " this.form.er_floor.disabled = false; "
1494 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1496 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1497 if ((er_flags & QR_PRIVATE) &&
1498 (er_flags & QR_PASSWORDED))
1499 wc_printf("CHECKED ");
1500 wc_printf(" OnChange=\""
1501 " if (this.form.type[2].checked == true) { "
1502 " this.form.er_floor.disabled = false; "
1505 wc_printf(_("Private - require password: "));
1506 wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1509 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1510 if ((er_flags & QR_PRIVATE)
1511 && ((er_flags & QR_GUESSNAME) == 0)
1512 && ((er_flags & QR_PASSWORDED) == 0))
1513 wc_printf("CHECKED ");
1514 wc_printf(" OnChange=\""
1515 " if (this.form.type[3].checked == true) { "
1516 " this.form.er_floor.disabled = false; "
1519 wc_printf(_("Private - invitation only"));
1521 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1522 if (er_flags & QR_MAILBOX)
1523 wc_printf("CHECKED ");
1524 wc_printf (" OnChange=\""
1525 " if (this.form.type[4].checked == true) { "
1526 " this.form.er_floor.disabled = true; "
1529 wc_printf(_("Personal (mailbox for you only)"));
1531 wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1533 wc_printf(_("If private, cause current users to forget room"));
1535 wc_printf("\n</ul>\n");
1537 wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1538 if (er_flags & QR_PREFONLY)
1539 wc_printf("CHECKED ");
1541 wc_printf(_("Preferred users only"));
1543 wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1544 if (er_flags & QR_READONLY)
1545 wc_printf("CHECKED ");
1547 wc_printf(_("Read-only room"));
1549 wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1550 if (er_flags2 & QR2_COLLABDEL)
1551 wc_printf("CHECKED ");
1553 wc_printf(_("All users allowed to post may also delete messages"));
1555 /** directory stuff */
1556 wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1557 if (er_flags & QR_DIRECTORY)
1558 wc_printf("CHECKED ");
1560 wc_printf(_("File directory room"));
1562 wc_printf("\n<ul><li>");
1563 wc_printf(_("Directory name: "));
1564 wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1567 wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1568 if (er_flags & QR_UPLOAD)
1569 wc_printf("CHECKED ");
1571 wc_printf(_("Uploading allowed"));
1573 wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1574 if (er_flags & QR_DOWNLOAD)
1575 wc_printf("CHECKED ");
1577 wc_printf(_("Downloading allowed"));
1579 wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1580 if (er_flags & QR_VISDIR)
1581 wc_printf("CHECKED ");
1583 wc_printf(_("Visible directory"));
1584 wc_printf("</ul>\n");
1586 /** end of directory stuff */
1588 wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1589 if (er_flags & QR_NETWORK)
1590 wc_printf("CHECKED ");
1592 wc_printf(_("Network shared room"));
1594 wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1595 if (er_flags & QR_PERMANENT)
1596 wc_printf("CHECKED ");
1598 wc_printf(_("Permanent (does not auto-purge)"));
1600 wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1601 if (er_flags2 & QR2_SUBJECTREQ)
1602 wc_printf("CHECKED ");
1604 wc_printf(_("Subject Required (Force users to specify a message subject)"));
1606 /** start of anon options */
1608 wc_printf("\n<li>");
1609 wc_printf(_("Anonymous messages"));
1610 wc_printf("<ul>\n");
1612 wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1613 if (((er_flags & QR_ANONONLY) == 0)
1614 && ((er_flags & QR_ANONOPT) == 0))
1615 wc_printf("CHECKED ");
1617 wc_printf(_("No anonymous messages"));
1619 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1620 if (er_flags & QR_ANONONLY)
1621 wc_printf("CHECKED ");
1623 wc_printf(_("All messages are anonymous"));
1625 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1626 if (er_flags & QR_ANONOPT)
1627 wc_printf("CHECKED ");
1629 wc_printf(_("Prompt user when entering messages"));
1630 wc_printf("</ul>\n");
1632 /* end of anon options */
1635 wc_printf(_("Room aide: "));
1637 serv_getln(buf, sizeof buf);
1638 if (buf[0] != '2') {
1639 wc_printf("<em>%s</em>\n", &buf[4]);
1641 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1642 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1645 wc_printf("</ul><CENTER>\n");
1646 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1647 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1649 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1655 wc_printf("</div>");
1659 /* Sharing the room with other Citadel nodes... */
1660 if (!strcmp(tab, "sharing")) {
1661 wc_printf("<div class=\"tabcontent\">");
1663 shared_with = strdup("");
1664 not_shared_with = strdup("");
1666 /** Learn the current configuration */
1667 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1668 serv_getln(buf, sizeof buf);
1669 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1670 extract_token(node, buf, 0, '|', sizeof node);
1671 not_shared_with = realloc(not_shared_with,
1672 strlen(not_shared_with) + 32);
1673 strcat(not_shared_with, node);
1674 strcat(not_shared_with, "\n");
1678 serv_getln(buf, sizeof buf);
1679 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1680 extract_token(cmd, buf, 0, '|', sizeof cmd);
1681 extract_token(node, buf, 1, '|', sizeof node);
1682 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1683 if (!strcasecmp(cmd, "ignet_push_share")) {
1684 shared_with = realloc(shared_with,
1685 strlen(shared_with) + 32);
1686 strcat(shared_with, node);
1687 if (!IsEmptyStr(remote_room)) {
1688 strcat(shared_with, "|");
1689 strcat(shared_with, remote_room);
1691 strcat(shared_with, "\n");
1695 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1696 extract_token(buf, shared_with, i, '\n', sizeof buf);
1697 extract_token(node, buf, 0, '|', sizeof node);
1698 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1699 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1700 if (!strcasecmp(node, cmd)) {
1701 remove_token(not_shared_with, j, '\n');
1706 /* Display the stuff */
1707 wc_printf("<CENTER><br />"
1708 "<table border=1 cellpadding=5><tr>"
1710 wc_printf(_("Shared with"));
1711 wc_printf("</I></B></td>"
1713 wc_printf(_("Not shared with"));
1714 wc_printf("</I></B></td></tr>\n"
1715 "<tr><td VALIGN=TOP>\n");
1717 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1718 wc_printf(_("Remote node name"));
1719 wc_printf("</td><td>");
1720 wc_printf(_("Remote room name"));
1721 wc_printf("</td><td>");
1722 wc_printf(_("Actions"));
1723 wc_printf("</td></tr>\n");
1725 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1726 extract_token(buf, shared_with, i, '\n', sizeof buf);
1727 extract_token(node, buf, 0, '|', sizeof node);
1728 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1729 if (!IsEmptyStr(node)) {
1730 wc_printf("<form method=\"POST\" action=\"netedit\">");
1731 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1732 wc_printf("<tr><td>%s</td>\n", node);
1735 if (!IsEmptyStr(remote_room)) {
1736 escputs(remote_room);
1742 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1743 "VALUE=\"ignet_push_share|");
1745 if (!IsEmptyStr(remote_room)) {
1747 urlescputs(remote_room);
1750 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1751 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1752 wc_printf("<input type=\"submit\" "
1753 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1754 wc_printf("</td></tr></form>\n");
1758 wc_printf("</table>\n");
1759 wc_printf("</td><td VALIGN=TOP>\n");
1760 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1761 wc_printf(_("Remote node name"));
1762 wc_printf("</td><td>");
1763 wc_printf(_("Remote room name"));
1764 wc_printf("</td><td>");
1765 wc_printf(_("Actions"));
1766 wc_printf("</td></tr>\n");
1768 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1769 extract_token(node, not_shared_with, i, '\n', sizeof node);
1770 if (!IsEmptyStr(node)) {
1771 wc_printf("<form method=\"POST\" action=\"netedit\">");
1772 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1773 wc_printf("<tr><td>");
1775 wc_printf("</td><td>"
1776 "<input type=\"INPUT\" "
1780 wc_printf("<input type=\"hidden\" "
1782 "VALUE=\"ignet_push_share|");
1785 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1786 "VALUE=\"sharing\">\n");
1787 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1788 "VALUE=\"add\">\n");
1789 wc_printf("<input type=\"submit\" "
1790 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1791 wc_printf("</td></tr></form>\n");
1795 wc_printf("</table>\n");
1796 wc_printf("</td></tr>"
1797 "</table></CENTER><br />\n"
1798 "<I><B>%s</B><ul><li>", _("Notes:"));
1799 wc_printf(_("When sharing a room, "
1800 "it must be shared from both ends. Adding a node to "
1801 "the 'shared' list sends messages out, but in order to"
1802 " receive messages, the other nodes must be configured"
1803 " to send messages out to your system as well. "
1804 "<li>If the remote room name is blank, it is assumed "
1805 "that the room name is identical on the remote node."
1806 "<li>If the remote room name is different, the remote "
1807 "node must also configure the name of the room here."
1811 wc_printf("</div>");
1814 if (not_shared_with != NULL)
1815 free (not_shared_with);
1817 /* Mailing list management */
1818 if (!strcmp(tab, "listserv")) {
1819 room_states RoomFlags;
1820 wc_printf("<div class=\"tabcontent\">");
1822 wc_printf("<br /><center>"
1823 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1824 "<tr><td VALIGN=TOP>");
1826 wc_printf(_("<i>The contents of this room are being "
1827 "mailed <b>as individual messages</b> "
1828 "to the following list recipients:"
1829 "</i><br /><br />\n"));
1832 serv_getln(buf, sizeof buf);
1833 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1834 extract_token(cmd, buf, 0, '|', sizeof cmd);
1835 if (!strcasecmp(cmd, "listrecp")) {
1836 extract_token(recp, buf, 1, '|', sizeof recp);
1839 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1842 wc_printf(_("(remove)"));
1843 wc_printf("</A><br />");
1846 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1847 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1848 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1849 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1850 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1851 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1852 wc_printf("</form>\n");
1854 wc_printf("</td><td VALIGN=TOP>\n");
1856 wc_printf(_("<i>The contents of this room are being "
1857 "mailed <b>in digest form</b> "
1858 "to the following list recipients:"
1859 "</i><br /><br />\n"));
1862 serv_getln(buf, sizeof buf);
1863 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1864 extract_token(cmd, buf, 0, '|', sizeof cmd);
1865 if (!strcasecmp(cmd, "digestrecp")) {
1866 extract_token(recp, buf, 1, '|', sizeof recp);
1869 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1873 wc_printf(_("(remove)"));
1874 wc_printf("</A><br />");
1877 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1878 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1879 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1880 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1881 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1882 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1883 wc_printf("</form>\n");
1885 wc_printf("</td></tr></table>\n");
1887 /** Pop open an address book -- begin **/
1888 wc_printf("<div align=right>"
1889 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1891 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1896 _("Add recipients from Contacts or other address books"),
1897 _("Add recipients from Contacts or other address books")
1899 /* Pop open an address book -- end **/
1901 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1903 get_roomflags (&RoomFlags);
1905 /* Self Service subscription? */
1906 wc_printf("<table><tr><td>\n");
1907 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1908 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1909 " <tr><td colspan=\"2\">\n",
1910 (is_selflist(&RoomFlags))?"checked":"");
1911 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1912 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1913 (is_https ? "https" : "http"),
1914 ChrPtr(WC->Hdr->HR.http_host));
1915 /* Public posting? */
1916 wc_printf("<tr><td>");
1917 wc_printf(_("Allow non-subscribers to mail to this room."));
1918 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1919 (is_publiclist(&RoomFlags))?"checked":"");
1921 /* Moderated List? */
1922 wc_printf("<tr><td>");
1923 wc_printf(_("Room post publication needs Aide permission."));
1924 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1925 (is_moderatedlist(&RoomFlags))?"checked":"");
1928 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1929 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1930 wc_printf("</table></form>");
1933 wc_printf("</CENTER>\n");
1934 wc_printf("</div>");
1938 /* Configuration of The Dreaded Auto-Purger */
1939 if (!strcmp(tab, "expire")) {
1940 wc_printf("<div class=\"tabcontent\">");
1942 serv_puts("GPEX room");
1943 serv_getln(buf, sizeof buf);
1944 if (!strncmp(buf, "550", 3)) {
1945 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1946 _("Higher access is required to access this function.")
1949 else if (buf[0] != '2') {
1950 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1953 roompolicy = extract_int(&buf[4], 0);
1954 roomvalue = extract_int(&buf[4], 1);
1956 serv_puts("GPEX floor");
1957 serv_getln(buf, sizeof buf);
1958 if (buf[0] == '2') {
1959 floorpolicy = extract_int(&buf[4], 0);
1960 floorvalue = extract_int(&buf[4], 1);
1963 wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1964 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1965 wc_printf("<table border=0 cellspacing=5>\n");
1966 wc_printf("<tr><td>");
1967 wc_printf(_("Message expire policy for this room"));
1968 wc_printf("<br />(");
1969 escputs(ChrPtr(WC->CurRoom.name));
1970 wc_printf(")</td><td>");
1971 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1972 ((roompolicy == 0) ? "CHECKED" : "") );
1973 wc_printf(_("Use the default policy for this floor"));
1974 wc_printf("<br />\n");
1975 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1976 ((roompolicy == 1) ? "CHECKED" : "") );
1977 wc_printf(_("Never automatically expire messages"));
1978 wc_printf("<br />\n");
1979 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1980 ((roompolicy == 2) ? "CHECKED" : "") );
1981 wc_printf(_("Expire by message count"));
1982 wc_printf("<br />\n");
1983 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1984 ((roompolicy == 3) ? "CHECKED" : "") );
1985 wc_printf(_("Expire by message age"));
1986 wc_printf("<br />");
1987 wc_printf(_("Number of messages or days: "));
1988 wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1989 wc_printf("</td></tr>\n");
1991 if (WC->axlevel >= 6) {
1992 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1993 wc_printf("<tr><td>");
1994 wc_printf(_("Message expire policy for this floor"));
1995 wc_printf("<br />(");
1996 escputs(floorlist[WC->CurRoom.floorid]);
1997 wc_printf(")</td><td>");
1998 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1999 ((floorpolicy == 0) ? "CHECKED" : "") );
2000 wc_printf(_("Use the system default"));
2001 wc_printf("<br />\n");
2002 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
2003 ((floorpolicy == 1) ? "CHECKED" : "") );
2004 wc_printf(_("Never automatically expire messages"));
2005 wc_printf("<br />\n");
2006 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
2007 ((floorpolicy == 2) ? "CHECKED" : "") );
2008 wc_printf(_("Expire by message count"));
2009 wc_printf("<br />\n");
2010 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
2011 ((floorpolicy == 3) ? "CHECKED" : "") );
2012 wc_printf(_("Expire by message age"));
2013 wc_printf("<br />");
2014 wc_printf(_("Number of messages or days: "));
2015 wc_printf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
2019 wc_printf("<CENTER>\n");
2020 wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
2021 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
2022 wc_printf(" ");
2023 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2024 wc_printf("</CENTER></td><tr>\n");
2026 wc_printf("</table>\n"
2027 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
2032 wc_printf("</div>");
2035 /* Access controls */
2036 if (!strcmp(tab, "access")) {
2037 wc_printf("<div class=\"tabcontent\">");
2039 wc_printf("</div>");
2042 /* Fetch messages from remote locations */
2043 if (!strcmp(tab, "feeds")) {
2044 wc_printf("<div class=\"tabcontent\">");
2047 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
2048 wc_printf("</i><br />\n");
2050 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2051 "<tr class=\"even\"><th>");
2052 wc_printf(_("Remote host"));
2053 wc_printf("</th><th>");
2054 wc_printf(_("User name"));
2055 wc_printf("</th><th>");
2056 wc_printf(_("Password"));
2057 wc_printf("</th><th>");
2058 wc_printf(_("Keep messages on server?"));
2059 wc_printf("</th><th>");
2060 wc_printf(_("Interval"));
2061 wc_printf("</th><th> </th></tr>");
2064 serv_getln(buf, sizeof buf);
2066 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2067 extract_token(cmd, buf, 0, '|', sizeof cmd);
2068 if (!strcasecmp(cmd, "pop3client")) {
2069 safestrncpy(recp, &buf[11], sizeof recp);
2072 wc_printf("<tr class=\"%s\">",
2073 (bg ? "even" : "odd")
2077 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2082 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2086 wc_printf("<td>*****</td>"); /* Don't show the password */
2088 wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2090 wc_printf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2092 wc_printf("<td class=\"button_link\">");
2093 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2096 wc_printf(_("(remove)"));
2097 wc_printf("</a></td>");
2103 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2105 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2106 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2107 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2109 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2112 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2115 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2118 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2121 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2124 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2125 wc_printf("</td></tr>");
2126 wc_printf("</form></table>\n");
2128 wc_printf("<hr>\n");
2131 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2132 wc_printf("</i><br />\n");
2134 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2135 "<tr class=\"even\"><th>");
2136 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2137 wc_printf(_("Feed URL"));
2138 wc_printf("</th><th>");
2139 wc_printf("</th></tr>");
2142 serv_getln(buf, sizeof buf);
2144 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2145 extract_token(cmd, buf, 0, '|', sizeof cmd);
2146 if (!strcasecmp(cmd, "rssclient")) {
2147 safestrncpy(recp, &buf[10], sizeof recp);
2150 wc_printf("<tr class=\"%s\">",
2151 (bg ? "even" : "odd")
2155 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2159 wc_printf("<td class=\"button_link\">");
2160 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2163 wc_printf(_("(remove)"));
2164 wc_printf("</a></td>");
2170 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2172 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2173 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2174 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2176 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2177 "maxlength=\"256\" name=\"line_pop3host\">\n");
2180 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2181 wc_printf("</td></tr>");
2182 wc_printf("</form></table>\n");
2184 wc_printf("</div>");
2188 /* end content of whatever tab is open now */
2189 wc_printf("</div>\n");
2191 address_book_popup();
2197 * Toggle self-service list subscription
2199 void toggle_self_service(void) {
2200 room_states RoomFlags;
2202 get_roomflags (&RoomFlags);
2204 if (yesbstr("QR2_SelfList"))
2205 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2207 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2209 if (yesbstr("QR2_SMTP_PUBLIC"))
2210 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2212 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2214 if (yesbstr("QR2_Moderated"))
2215 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2217 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2218 if (yesbstr("QR2_SubsOnly"))
2219 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2221 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2223 set_roomflags (&RoomFlags);
2231 * save new parameters for a room
2238 StrBuf *er_password;
2240 StrBuf *er_roomaide;
2243 int er_listingorder;
2249 if (!havebstr("ok_button")) {
2250 strcpy(WC->ImportantMessage,
2251 _("Cancelled. Changes were not saved."));
2257 StrBuf_ServGetln(Buf);
2258 if (GetServerStatus(Buf, NULL) != 2) {
2259 StrBufCutLeft(Buf, 4);
2260 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2266 er_name = NewStrBuf();
2267 er_password = NewStrBuf();
2268 er_dirname = NewStrBuf();
2269 er_roomaide = NewStrBuf();
2271 StrBufCutLeft(Buf, 4);
2272 StrBufExtract_token(er_name, Buf, 0, '|');
2273 StrBufExtract_token(er_password, Buf, 1, '|');
2274 StrBufExtract_token(er_dirname, Buf, 2, '|');
2275 er_flags = StrBufExtract_int(Buf, 3, '|');
2276 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2277 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2278 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2280 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2281 if (StrLength(er_roomaide) == 0) {
2283 StrBuf_ServGetln(Buf);
2284 if (GetServerStatus(Buf, NULL) != 2) {
2285 FlushStrBuf(er_roomaide);
2287 StrBufCutLeft(Buf, 4);
2288 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2291 Ptr = sbstr("er_name");
2292 if (StrLength(Ptr) > 0) {
2293 FlushStrBuf(er_name);
2294 StrBufAppendBuf(er_name, Ptr, 0);
2297 Ptr = sbstr("er_password");
2298 if (StrLength(Ptr) > 0) {
2299 FlushStrBuf(er_password);
2300 StrBufAppendBuf(er_password, Ptr, 0);
2304 Ptr = sbstr("er_dirname");
2305 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2306 FlushStrBuf(er_dirname);
2307 StrBufAppendBuf(er_dirname, Ptr, 0);
2311 Ptr = sbstr("type");
2312 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2314 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2315 er_flags |= (QR_PRIVATE);
2317 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2318 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2320 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2321 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2323 if (!strcmp(ChrPtr(Ptr), "personal")) {
2324 er_flags |= QR_MAILBOX;
2326 er_flags &= ~QR_MAILBOX;
2329 if (yesbstr("prefonly")) {
2330 er_flags |= QR_PREFONLY;
2332 er_flags &= ~QR_PREFONLY;
2335 if (yesbstr("readonly")) {
2336 er_flags |= QR_READONLY;
2338 er_flags &= ~QR_READONLY;
2342 if (yesbstr("collabdel")) {
2343 er_flags2 |= QR2_COLLABDEL;
2345 er_flags2 &= ~QR2_COLLABDEL;
2348 if (yesbstr("permanent")) {
2349 er_flags |= QR_PERMANENT;
2351 er_flags &= ~QR_PERMANENT;
2354 if (yesbstr("subjectreq")) {
2355 er_flags2 |= QR2_SUBJECTREQ;
2357 er_flags2 &= ~QR2_SUBJECTREQ;
2360 if (yesbstr("network")) {
2361 er_flags |= QR_NETWORK;
2363 er_flags &= ~QR_NETWORK;
2366 if (yesbstr("directory")) {
2367 er_flags |= QR_DIRECTORY;
2369 er_flags &= ~QR_DIRECTORY;
2372 if (yesbstr("ulallowed")) {
2373 er_flags |= QR_UPLOAD;
2375 er_flags &= ~QR_UPLOAD;
2378 if (yesbstr("dlallowed")) {
2379 er_flags |= QR_DOWNLOAD;
2381 er_flags &= ~QR_DOWNLOAD;
2384 if (yesbstr("visdir")) {
2385 er_flags |= QR_VISDIR;
2387 er_flags &= ~QR_VISDIR;
2390 Ptr = sbstr("anon");
2392 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2393 if (!strcmp(ChrPtr(Ptr), "anononly"))
2394 er_flags |= QR_ANONONLY;
2395 if (!strcmp(ChrPtr(Ptr), "anon2"))
2396 er_flags |= QR_ANONOPT;
2398 bump = yesbstr("bump");
2400 er_floor = ibstr("er_floor");
2402 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2404 ChrPtr(er_password),
2413 StrBuf_ServGetln(Buf);
2414 if (GetServerStatus(Buf, NULL) != 2) {
2415 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2418 FreeStrBuf(&er_name);
2419 FreeStrBuf(&er_password);
2420 FreeStrBuf(&er_dirname);
2421 FreeStrBuf(&er_roomaide);
2426 if (StrLength(er_roomaide) > 0) {
2427 serv_printf("SETA %s", ChrPtr(er_roomaide));
2428 StrBuf_ServGetln(Buf);
2429 if (GetServerStatus(Buf, NULL) != 2) {
2430 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2431 display_main_menu();
2433 FreeStrBuf(&er_name);
2434 FreeStrBuf(&er_password);
2435 FreeStrBuf(&er_dirname);
2436 FreeStrBuf(&er_roomaide);
2441 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2444 FreeStrBuf(&er_name);
2445 FreeStrBuf(&er_password);
2446 FreeStrBuf(&er_dirname);
2447 FreeStrBuf(&er_roomaide);
2453 * Display form for Invite, Kick, and show Who Knows a room
2455 void do_invt_kick(void) {
2456 char buf[SIZ], room[SIZ], username[SIZ];
2459 serv_getln(buf, sizeof buf);
2461 if (buf[0] != '2') {
2465 extract_token(room, &buf[4], 0, '|', sizeof room);
2467 strcpy(username, bstr("username"));
2469 if (havebstr("kick_button")) {
2470 sprintf(buf, "KICK %s", username);
2472 serv_getln(buf, sizeof buf);
2474 if (buf[0] != '2') {
2475 strcpy(WC->ImportantMessage, &buf[4]);
2477 sprintf(WC->ImportantMessage,
2478 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2483 if (havebstr("invite_button")) {
2484 sprintf(buf, "INVT %s", username);
2486 serv_getln(buf, sizeof buf);
2488 if (buf[0] != '2') {
2489 strcpy(WC->ImportantMessage, &buf[4]);
2491 sprintf(WC->ImportantMessage,
2492 _("<B><I>User %s invited to room %s.</I></B>\n"),
2503 * Display form for Invite, Kick, and show Who Knows a room
2505 void display_whok(void)
2507 char buf[SIZ], room[SIZ], username[SIZ];
2510 serv_getln(buf, sizeof buf);
2512 if (buf[0] != '2') {
2516 extract_token(room, &buf[4], 0, '|', sizeof room);
2519 wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2520 wc_printf(_("The users listed below have access to this room. "
2521 "To remove a user from the access list, select the user "
2522 "name from the list and click 'Kick'."));
2523 wc_printf("<br /><br />");
2525 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2526 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2527 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2528 wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2530 serv_getln(buf, sizeof buf);
2531 if (buf[0] == '1') {
2532 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2533 extract_token(username, buf, 0, '|', sizeof username);
2534 wc_printf("<OPTION>");
2539 wc_printf("</select><br />\n");
2541 wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2542 wc_printf("</form></CENTER>\n");
2544 wc_printf("</td><td>");
2545 wc_printf(_("To grant another user access to this room, enter the "
2546 "user name in the box below and click 'Invite'."));
2547 wc_printf("<br /><br />");
2549 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2550 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2551 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2552 wc_printf(_("Invite:"));
2554 wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2555 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2556 "<input type=\"submit\" value=\"%s\">"
2557 "</form></CENTER>\n", _("Invite"));
2558 /* Pop open an address book -- begin **/
2560 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2562 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2565 _("Users"), _("Users")
2567 /* Pop open an address book -- end **/
2569 wc_printf("</td></tr></table>\n");
2570 address_book_popup();
2577 * display the form for entering a new room
2579 void display_entroom(void)
2586 serv_puts("CRE8 0");
2587 serv_getln(buf, sizeof buf);
2589 if (buf[0] != '2') {
2590 strcpy(WC->ImportantMessage, &buf[4]);
2591 display_main_menu();
2596 output_headers(1, 1, 1, 0, 0, 0);
2598 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2599 do_template("beginbox", NULL);
2601 wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2602 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2604 wc_printf("<table class=\"altern\"> ");
2606 wc_printf("<tr class=\"even\"><td>");
2607 wc_printf(_("Name of room: "));
2608 wc_printf("</td><td>");
2609 wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2610 wc_printf("</td></tr>");
2612 wc_printf("<tr class=\"odd\"><td>");
2613 wc_printf(_("Resides on floor: "));
2614 wc_printf("</td><td>");
2615 load_floorlist(Buf);
2616 wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2617 for (i = 0; i < 128; ++i)
2618 if (!IsEmptyStr(floorlist[i])) {
2619 wc_printf("<option ");
2620 wc_printf("value=\"%d\">", i);
2621 escputs(floorlist[i]);
2622 wc_printf("</option>\n");
2624 wc_printf("</select>\n");
2625 wc_printf("</td></tr>");
2628 * Our clever little snippet of JavaScript automatically selects
2629 * a public room if the view is set to Bulletin Board or wiki, and
2630 * it selects a mailbox room otherwise. The user can override this,
2631 * of course. We also disable the floor selector for mailboxes.
2633 wc_printf("<tr class=\"even\"><td>");
2634 wc_printf(_("Default view for room: "));
2635 wc_printf("</td><td>");
2636 wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2637 " if ( (this.form.er_view.value == 0) "
2638 " || (this.form.er_view.value == 6) ) { "
2639 " this.form.type[0].checked=true; "
2640 " this.form.er_floor.disabled = false; "
2643 " this.form.type[4].checked=true; "
2644 " this.form.er_floor.disabled = true; "
2647 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2648 if (is_view_allowed_as_default(i)) {
2649 wc_printf("<option %s value=\"%d\">",
2650 ((i == 0) ? "selected" : ""), i );
2651 escputs(viewdefs[i]);
2652 wc_printf("</option>\n");
2655 wc_printf("</select>\n");
2656 wc_printf("</td></tr>");
2658 wc_printf("<tr class=\"even\"><td>");
2659 wc_printf(_("Type of room:"));
2660 wc_printf("</td><td>");
2661 wc_printf("<ul class=\"adminlist\">\n");
2663 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2664 wc_printf("CHECKED OnChange=\""
2665 " if (this.form.type[0].checked == true) { "
2666 " this.form.er_floor.disabled = false; "
2669 wc_printf(_("Public (automatically appears to everyone)"));
2672 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2673 " if (this.form.type[1].checked == true) { "
2674 " this.form.er_floor.disabled = false; "
2677 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2680 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2681 " if (this.form.type[2].checked == true) { "
2682 " this.form.er_floor.disabled = false; "
2685 wc_printf(_("Private - require password: "));
2686 wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2689 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2690 " if (this.form.type[3].checked == true) { "
2691 " this.form.er_floor.disabled = false; "
2694 wc_printf(_("Private - invitation only"));
2697 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2699 " if (this.form.type[4].checked == true) { "
2700 " this.form.er_floor.disabled = true; "
2703 wc_printf(_("Personal (mailbox for you only)"));
2706 wc_printf("\n</ul>\n");
2707 wc_printf("</td></tr></table>\n");
2709 wc_printf("<div class=\"buttons\">\n");
2710 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2711 wc_printf(" ");
2712 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2713 wc_printf("</div>\n");
2714 wc_printf("</form>\n<hr />");
2715 serv_printf("MESG roomaccess");
2716 serv_getln(buf, sizeof buf);
2717 if (buf[0] == '1') {
2721 do_template("endbox", NULL);
2731 * support function for entroom() -- sets the default view
2733 void er_set_default_view(int newview) {
2746 serv_getln(buf, sizeof buf);
2747 if (buf[0] != '2') return;
2749 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2750 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2751 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2752 rm_bits1 = extract_int(&buf[4], 3);
2753 rm_floor = extract_int(&buf[4], 4);
2754 rm_listorder = extract_int(&buf[4], 5);
2755 rm_bits2 = extract_int(&buf[4], 7);
2757 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2758 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2759 rm_listorder, newview, rm_bits2
2761 serv_getln(buf, sizeof buf);
2772 const StrBuf *er_name;
2773 const StrBuf *er_type;
2774 const StrBuf *er_password;
2778 wcsession *WCC = WC;
2780 if (!havebstr("ok_button")) {
2781 strcpy(WC->ImportantMessage,
2782 _("Cancelled. No new room was created."));
2783 display_main_menu();
2786 er_name = sbstr("er_name");
2787 er_type = sbstr("type");
2788 er_password = sbstr("er_password");
2789 er_floor = ibstr("er_floor");
2790 er_view = ibstr("er_view");
2793 if (!strcmp(ChrPtr(er_type), "hidden"))
2795 else if (!strcmp(ChrPtr(er_type), "passworded"))
2797 else if (!strcmp(ChrPtr(er_type), "invonly"))
2799 else if (!strcmp(ChrPtr(er_type), "personal"))
2802 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2805 ChrPtr(er_password),
2810 serv_getln(buf, sizeof buf);
2811 if (buf[0] != '2') {
2812 strcpy(WCC->ImportantMessage, &buf[4]);
2813 display_main_menu();
2816 /** TODO: Room created, now update the left hand icon bar for this user */
2817 burn_folder_cache(0); /* burn the old folder cache */
2821 serv_printf("VIEW %d", er_view);
2822 serv_getln(buf, sizeof buf);
2823 WCC->CurRoom.view = er_view;
2825 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
2826 display_editroom ();
2828 do_change_view(er_view); /* Now go there */
2835 * \brief display the screen to enter a private room
2837 void display_private(char *rname, int req_pass)
2839 WCTemplputParams SubTP;
2841 output_headers(1, 1, 1, 0, 0, 0);
2843 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2844 memset(&SubTP, 0, sizeof(WCTemplputParams));
2845 SubTP.Filter.ContextType = CTX_STRBUF;
2846 SubTP.Context = Buf;
2847 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2852 wc_printf(_("If you know the name of a hidden (guess-name) or "
2853 "passworded room, you can enter that room by typing "
2854 "its name below. Once you gain access to a private "
2855 "room, it will appear in your regular room listings "
2856 "so you don't have to keep returning here."));
2859 wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2860 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2862 wc_printf("<table class=\"altern\"> "
2863 "<tr class=\"even\"><td>");
2864 wc_printf(_("Enter room name:"));
2865 wc_printf("</td><td>"
2866 "<input type=\"text\" name=\"gr_name\" "
2867 "value=\"%s\" maxlength=\"128\">\n", rname);
2870 wc_printf("</td></tr><tr class=\"odd\"><td>");
2871 wc_printf(_("Enter room password:"));
2872 wc_printf("</td><td>");
2873 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2875 wc_printf("</td></tr></table>\n");
2877 wc_printf("<div class=\"buttons\">\n");
2878 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2880 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2884 wc_printf("</div></form>\n");
2886 do_template("endbox", NULL);
2892 * \brief goto a private room
2894 void goto_private(void)
2899 if (!havebstr("ok_button")) {
2900 display_main_menu();
2903 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2904 serv_printf("GOTO %s|%s",
2907 serv_getln(buf, sizeof buf);
2909 if (buf[0] == '2') {
2910 smart_goto(sbstr("gr_name"));
2913 if (!strncmp(buf, "540", 3)) {
2914 display_private(bstr("gr_name"), 1);
2917 output_headers(1, 1, 1, 0, 0, 0);
2918 wc_printf("%s\n", &buf[4]);
2925 * \brief display the screen to zap a room
2927 void display_zap(void)
2929 output_headers(1, 1, 2, 0, 0, 0);
2931 wc_printf("<div id=\"banner\">\n");
2933 wc_printf(_("Zap (forget/unsubscribe) the current room"));
2934 wc_printf("</h1>\n");
2935 wc_printf("</div>\n");
2937 wc_printf("<div id=\"content\" class=\"service\">\n");
2939 wc_printf(_("If you select this option, <em>%s</em> will "
2940 "disappear from your room list. Is this what you wish "
2941 "to do?<br />\n"), ChrPtr(WC->CurRoom.name));
2943 wc_printf("<form method=\"POST\" action=\"zap\">\n");
2944 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2945 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2946 wc_printf(" ");
2947 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2948 wc_printf("</form>\n");
2959 StrBuf *final_destination;
2962 * If the forget-room routine fails for any reason, we fall back
2963 * to the current room; otherwise, we go to the Lobby
2965 final_destination = NewStrBufDup(WC->CurRoom.name);
2967 if (havebstr("ok_button")) {
2968 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
2969 serv_getln(buf, sizeof buf);
2970 if (buf[0] == '2') {
2972 serv_getln(buf, sizeof buf);
2973 if (buf[0] == '2') {
2974 FlushStrBuf(final_destination);
2975 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2979 smart_goto(final_destination);
2980 FreeStrBuf(&final_destination);
2986 * \brief Delete the current room
2988 void delete_room(void)
2993 serv_puts("KILL 1");
2994 serv_getln(buf, sizeof buf);
2995 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2996 if (buf[0] != '2') {
2997 strcpy(WC->ImportantMessage, &buf[4]);
2998 display_main_menu();
3003 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
3012 * \brief Perform changes to a room's network configuration
3014 void netedit(void) {
3023 /*/ TODO: do line dynamic! */
3024 if (havebstr("line_pop3host")) {
3025 strcpy(line, bstr("prefix"));
3026 strcat(line, bstr("line_pop3host"));
3028 strcat(line, bstr("line_pop3user"));
3030 strcat(line, bstr("line_pop3pass"));
3032 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
3034 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
3035 strcat(line, bstr("suffix"));
3037 else if (havebstr("line")) {
3038 strcpy(line, bstr("prefix"));
3039 strcat(line, bstr("line"));
3040 strcat(line, bstr("suffix"));
3055 serv_getln(buf, sizeof buf);
3056 if (buf[0] != '1') {
3062 /** This loop works for add *or* remove. Spiffy, eh? */
3063 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3064 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
3065 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
3066 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
3067 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
3068 if ( (strcasecmp(cmpa0, cmpb0))
3069 || (strcasecmp(cmpa1, cmpb1)) ) {
3070 fprintf(fp, "%s\n", buf);
3076 serv_getln(buf, sizeof buf);
3077 if (buf[0] != '4') {
3083 while (fgets(buf, sizeof buf, fp) != NULL) {
3084 buf[strlen(buf)-1] = 0;
3088 if (havebstr("add_button")) {
3089 num_addrs = num_tokens(bstr("line"), ',');
3090 if (num_addrs < 2) {
3091 /* just adding one node or address */
3095 /* adding multiple addresses separated by commas */
3096 for (i=0; i<num_addrs; ++i) {
3097 strcpy(line, bstr("prefix"));
3098 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3101 strcat(line, bstr("suffix"));
3115 * \brief Convert a room name to a folder-ish-looking name.
3116 * \param folder the folderish name
3117 * \param room the room name
3118 * \param floor the floor name
3119 * \param is_mailbox is it a mailbox?
3121 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3126 * For mailboxes, just do it straight...
3129 sprintf(folder, "My folders|%s", room);
3133 * Otherwise, prefix the floor name as a "public folders" moniker
3136 if (floor > MAX_FLOORS) {
3138 sprintf(folder, "%%%%%%|%s", room);
3141 sprintf(folder, "%s|%s", floorlist[floor], room);
3146 * Replace "\" characters with "|" for pseudo-folder-delimiting
3148 len = strlen (folder);
3149 for (i=0; i<len; ++i) {
3150 if (folder[i] == '\\') folder[i] = '|';
3158 * \brief Back end for change_view()
3159 * \param newview set newview???
3161 void do_change_view(int newview) {
3164 serv_printf("VIEW %d", newview);
3165 serv_getln(buf, sizeof buf);
3166 WC->CurRoom.view = newview;
3167 smart_goto(WC->CurRoom.name);
3173 * \brief Change the view for this room
3175 void change_view(void) {
3178 view = lbstr("view");
3179 do_change_view(view);
3183 * \brief Burn the cached folder list.
3184 * \param age How old the cahce needs to be before we burn it.
3187 void burn_folder_cache(time_t age)
3189 /** If our cached folder list is very old, burn it. */
3190 if (WC->cache_fold != NULL) {
3191 if ((time(NULL) - WC->cache_timestamp) > age) {
3192 free(WC->cache_fold);
3193 WC->cache_fold = NULL;
3201 * \brief Do either a known rooms list or a folders list, depending on the
3206 StrBuf *ListView = NULL;
3208 /** Determine whether the user is trying to change views */
3209 if (havebstr("view")) {
3210 ListView = NewStrBufDup(SBSTR("view"));
3211 set_preference("roomlistview", ListView, 1);
3213 /** Sanitize the input so its safe */
3214 if((get_preference("roomlistview", &ListView) != 0)||
3215 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3216 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3218 if (ListView == NULL) {
3219 ListView = NewStrBufPlain(HKEY("rooms"));
3220 set_preference("roomlistview", ListView, 0);
3224 ListView = NewStrBufPlain(HKEY("rooms"));
3225 set_preference("roomlistview", ListView, 0);
3229 FreeStrBuf(&ListView);
3236 * \brief Set the message expire policy for this room and/or floor
3238 void set_room_policy(void) {
3241 if (!havebstr("ok_button")) {
3242 strcpy(WC->ImportantMessage,
3243 _("Cancelled. Changes were not saved."));
3248 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3249 serv_getln(buf, sizeof buf);
3250 strcpy(WC->ImportantMessage, &buf[4]);
3252 if (WC->axlevel >= 6) {
3253 strcat(WC->ImportantMessage, "<br />\n");
3254 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3255 serv_getln(buf, sizeof buf);
3256 strcat(WC->ImportantMessage, &buf[4]);
3262 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3264 StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3268 void _display_private(void) {
3269 display_private("", 0);
3272 void dotgoto(void) {
3273 if (!havebstr("room")) {
3274 readloop(readnew, eUseDefault);
3277 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3280 smart_goto(sbstr("room"));
3285 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3287 wcsession *WCC = WC;
3290 StrBufAppendTemplate(Target, TP,
3295 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3297 wc_printf("<div id=\"banner\">\n");
3298 embed_room_banner(NULL, navbar_default);
3299 wc_printf("</div>\n");
3303 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3305 wcsession *WCC = WC;
3308 (!IsEmptyStr(WCC->ugname)))
3309 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3312 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3314 wcsession *WCC = WC;
3315 return (WCC != NULL)?
3316 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3319 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3321 wcsession *WCC = WC;
3322 return (WCC == NULL)? 0 :
3323 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3324 (WCC->CurRoom.is_inbox) ||
3325 (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3328 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3330 wcsession *WCC = WC;
3332 return ((WCC!=NULL) &&
3333 (!IsEmptyStr(WCC->ugname)) &&
3334 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3338 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
3340 folder *Folder = (folder *)(TP->Context);
3343 UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3344 if (UA_CheckFlag == 0)
3345 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3346 "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
3348 return ((Folder->RAFlags & UA_CheckFlag) != 0);
3353 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3356 wcsession *WCC = WC;
3358 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3359 if (QR_CheckFlag == 0)
3360 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3361 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3363 return ((WCC!=NULL) &&
3364 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3367 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3370 folder *Folder = (folder *)(TP->Context);
3372 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3373 if (QR_CheckFlag == 0)
3374 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3375 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3376 return ((Folder->QRFlags & QR_CheckFlag) != 0);
3380 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3383 wcsession *WCC = WC;
3385 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3386 if (QR2_CheckFlag == 0)
3387 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3388 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3390 return ((WCC!=NULL) &&
3391 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3394 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3397 folder *Folder = (folder *)(TP->Context);
3399 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3400 if (QR2_CheckFlag == 0)
3401 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3402 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3403 return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3407 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3409 wcsession *WCC = WC;
3411 return ( (WCC!= NULL) &&
3412 ((WCC->axlevel >= 6) ||
3413 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3414 (WCC->CurRoom.is_inbox) ));
3417 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3419 wcsession *WCC = WC;
3421 if ((WCC == NULL) ||
3422 (TP->Tokens->nParameters < 3))
3424 return ((WCC->CurRoom.view < VIEW_BBS) ||
3425 (WCC->CurRoom.view > VIEW_MAX));
3428 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3432 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
3434 wcsession *WCC = WC;
3438 HashList *Whok = NULL;
3444 Token = NewStrBuf();
3445 StrBuf_ServGetln(Line);
3446 if (GetServerStatus(Line, &State) == 1)
3448 Whok = NewHash(1, Flathash);
3449 while(!Done && StrBuf_ServGetln(Line))
3450 if ( (StrLength(Line)==3) &&
3451 !strcmp(ChrPtr(Line), "000"))
3458 const char *Pos = NULL;
3459 Token = NewStrBufPlain (NULL, StrLength(Line));
3460 StrBufExtract_NextToken(Token, Line, &Pos, '|');
3468 else if (State == 550)
3469 StrBufAppendBufPlain(WCC->ImportantMsg,
3470 _("Higher access is required to access this function."), -1, 0);
3480 initialize_viewdefs();
3481 RegisterPreference("roomlistview",
3482 _("Room list view"),
3485 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3487 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3490 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3491 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3492 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3493 WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3494 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3495 WebcitAddUrlHandler(HKEY("zapped_list"), "", 0, zapped_list, 0);
3496 WebcitAddUrlHandler(HKEY("display_zap"), "", 0, display_zap, 0);
3497 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3498 WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3499 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3500 WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3501 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3502 WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3503 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3504 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3505 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3506 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3507 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3508 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3509 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3511 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3512 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3513 RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3515 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3516 RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3517 RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
3519 RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
3520 RegisterNamespace("THISROOM:MSGS:NEW", 0, 0, tmplput_CurrentRoom_nNewMessages, NULL, CTX_NONE);
3521 RegisterNamespace("THISROOM:MSGS:TOTAL", 0, 0, tmplput_CurrentRoom_nTotalMessages, NULL, CTX_NONE);
3523 RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
3524 RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3525 RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3526 RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3527 RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3528 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3529 RegisterConditional(HKEY("COND:THISROOM:HAVE_VIEW"), 0, ConditionalThisRoomHaveView, CTX_NONE);
3530 RegisterNamespace("THISROOM:VIEW_STRING", 0, 1, tmplput_CurrentRoomViewString, NULL, CTX_NONE);
3531 RegisterNamespace("ROOM:VIEW_STRING", 1, 2, tmplput_RoomViewString, NULL, CTX_NONE);
3533 RegisterNamespace("THISROOM:INFOTEXT", 1, 2, tmplput_CurrentRoomInfoText, NULL, CTX_NONE);
3534 RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3535 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3536 RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
3537 RegisterConditional(HKEY("COND:THISROOM:HAVE_INFOTEXT"), 0, ConditionalThisRoomXHaveInfoText, CTX_NONE);
3538 RegisterNamespace("THISROOM:FILES:N", 0, 1, tmplput_CurrentRoomXNFiles, NULL, CTX_NONE);
3539 RegisterNamespace("THISROOM:FILES:STR", 0, 1, tmplput_CurrentRoomX_FileString, NULL, CTX_NONE);
3541 REGISTERTokenParamDefine(QR_PERMANENT);
3542 REGISTERTokenParamDefine(QR_INUSE);
3543 REGISTERTokenParamDefine(QR_PRIVATE);
3544 REGISTERTokenParamDefine(QR_PASSWORDED);
3545 REGISTERTokenParamDefine(QR_GUESSNAME);
3546 REGISTERTokenParamDefine(QR_DIRECTORY);
3547 REGISTERTokenParamDefine(QR_UPLOAD);
3548 REGISTERTokenParamDefine(QR_DOWNLOAD);
3549 REGISTERTokenParamDefine(QR_VISDIR);
3550 REGISTERTokenParamDefine(QR_ANONONLY);
3551 REGISTERTokenParamDefine(QR_ANONOPT);
3552 REGISTERTokenParamDefine(QR_NETWORK);
3553 REGISTERTokenParamDefine(QR_PREFONLY);
3554 REGISTERTokenParamDefine(QR_READONLY);
3555 REGISTERTokenParamDefine(QR_MAILBOX);
3556 REGISTERTokenParamDefine(QR2_SYSTEM);
3557 REGISTERTokenParamDefine(QR2_SELFLIST);
3558 REGISTERTokenParamDefine(QR2_COLLABDEL);
3559 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3560 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3561 REGISTERTokenParamDefine(QR2_MODERATED);
3563 REGISTERTokenParamDefine(UA_KNOWN);
3564 REGISTERTokenParamDefine(UA_GOTOALLOWED);
3565 REGISTERTokenParamDefine(UA_HASNEWMSGS);
3566 REGISTERTokenParamDefine(UA_ZAPPED);
3567 REGISTERTokenParamDefine(UA_POSTALLOWED);
3568 REGISTERTokenParamDefine(UA_ADMINALLOWED);
3569 REGISTERTokenParamDefine(UA_DELETEALLOWED);
3570 REGISTERTokenParamDefine(UA_ISTRASH);
3572 REGISTERTokenParamDefine(US_NEEDVALID);
3573 REGISTERTokenParamDefine(US_PERM);
3574 REGISTERTokenParamDefine(US_LASTOLD);
3575 REGISTERTokenParamDefine(US_EXPERT);
3576 REGISTERTokenParamDefine(US_UNLISTED);
3577 REGISTERTokenParamDefine(US_NOPROMPT);
3578 REGISTERTokenParamDefine(US_PROMPTCTL);
3579 REGISTERTokenParamDefine(US_DISAPPEAR);
3580 REGISTERTokenParamDefine(US_REGIS);
3581 REGISTERTokenParamDefine(US_PAGINATOR);
3582 REGISTERTokenParamDefine(US_INTERNET);
3583 REGISTERTokenParamDefine(US_FLOORS);
3584 REGISTERTokenParamDefine(US_COLOR);
3585 REGISTERTokenParamDefine(US_USER_SET);
3587 REGISTERTokenParamDefine(VIEW_BBS);
3588 REGISTERTokenParamDefine(VIEW_MAILBOX);
3589 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3590 REGISTERTokenParamDefine(VIEW_CALENDAR);
3591 REGISTERTokenParamDefine(VIEW_TASKS);
3592 REGISTERTokenParamDefine(VIEW_NOTES);
3593 REGISTERTokenParamDefine(VIEW_WIKI);
3594 REGISTERTokenParamDefine(VIEW_CALBRIEF);
3595 REGISTERTokenParamDefine(VIEW_JOURNAL);
3596 REGISTERTokenParamDefine(VIEW_BLOG);
3599 REGISTERTokenParamDefine(ignet_push_share);
3600 { /* these are the parts of an IGNET push config */
3601 REGISTERTokenParamDefine(GNET_IGNET_NODE);
3602 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
3604 REGISTERTokenParamDefine(listrecp);
3605 REGISTERTokenParamDefine(digestrecp);
3606 REGISTERTokenParamDefine(pop3client);
3607 { /* These are the parts of a pop3 client line... */
3608 REGISTERTokenParamDefine(GNET_POP3_HOST);
3609 REGISTERTokenParamDefine(GNET_POP3_USER);
3610 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
3611 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
3613 REGISTERTokenParamDefine(rssclient);
3614 REGISTERTokenParamDefine(participate);
3616 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3617 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3619 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3620 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3622 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3623 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3624 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3631 SessionDestroyModule_ROOMOPS
3634 FlushFolder(&sess->CurRoom);
3635 if (sess->cache_fold != NULL) {
3636 free(sess->cache_fold);
3639 free_march_list(sess);
3640 DeleteHash(&sess->Floors);
3641 DeleteHash(&sess->Rooms);
3642 DeleteHash(&sess->FloorsByName);