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(void)
266 /* refresh current room states... */
269 /* The browser needs some information for its own use */
270 wc_printf("<script type=\"text/javascript\"> \n"
271 " room_is_trash = %d; \n"
273 ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
277 * If the user happens to select the "make this my start page" link,
278 * we want it to remember the URL as a "/dotskip" one instead of
279 * a "skip" or "gotonext" or something like that.
281 if (WCC->Hdr->this_page == NULL) {
282 WCC->Hdr->this_page = NewStrBuf();
284 StrBufPrintf(WCC->Hdr->this_page,
286 ChrPtr(WC->CurRoom.name)
289 do_template("roombanner", NULL);
290 /* roombanner contains this for mobile */
295 wc_printf("<div id=\"navbar\"><ul>");
298 "<li class=\"ungoto\">"
299 "<a href=\"ungoto\">"
300 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
301 "<span class=\"navbar_link\">%s</span></A>"
302 "</li>\n", _("Ungoto")
305 if (WC->CurRoom.view == VIEW_BBS) {
307 "<li class=\"newmess\">"
308 "<a href=\"readnew\">"
309 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
310 "<span class=\"navbar_link\">%s</span></A>"
311 "</li>\n", _("Read new messages")
315 switch(WC->CurRoom.view) {
316 case VIEW_ADDRESSBOOK:
318 "<li class=\"viewcontacts\">"
319 "<a href=\"readfwd\">"
320 "<img src=\"static/viewcontacts_24x.gif\" "
321 "alt=\"\" width=\"24\" height=\"24\">"
322 "<span class=\"navbar_link\">"
324 "</span></a></li>\n", _("View contacts")
329 "<li class=\"staskday\">"
330 "<a href=\"readfwd?calview=day\">"
331 "<img src=\"static/taskday2_24x.gif\" "
332 "alt=\"\" width=\"24\" height=\"24\">"
333 "<span class=\"navbar_link\">"
335 "</span></a></li>\n", _("Day view")
338 "<li class=\"monthview\">"
339 "<a href=\"readfwd?calview=month\">"
340 "<img src=\"static/monthview2_24x.gif\" "
341 "alt=\"\" width=\"24\" height=\"24\">"
342 "<span class=\"navbar_link\">"
344 "</span></a></li>\n", _("Month 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", _("Calendar list")
360 "<li class=\"taskmanag\">"
361 "<a href=\"readfwd\">"
362 "<img src=\"static/taskmanag_24x.gif\" "
363 "alt=\"\" width=\"24\" height=\"24\">"
364 "<span class=\"navbar_link\">"
366 "</span></a></li>\n", _("View tasks")
371 "<li class=\"viewnotes\">"
372 "<a href=\"readfwd\">"
373 "<img src=\"static/viewnotes_24x.gif\" "
374 "alt=\"\" width=\"24\" height=\"24\">"
375 "<span class=\"navbar_link\">"
377 "</span></a></li>\n", _("View notes")
382 "<li class=\"readallmess\">"
383 "<a id=\"m_refresh\" href=\"readfwd\">"
384 "<img src=\"static/readallmess3_24x.gif\" "
385 "alt=\"\" width=\"24\" height=\"24\">"
386 "<span class=\"navbar_link\">"
388 "</span></a></li>\n", _("Refresh message list")
393 "<li class=\"readallmess\">"
394 "<a href=\"wiki?page=home\">"
395 "<img src=\"static/readallmess3_24x.gif\" "
396 "alt=\"\" width=\"24\" height=\"24\">"
397 "<span class=\"navbar_link\">"
399 "</span></a></li>\n", _("Wiki home")
404 "<li class=\"readallmess\">"
405 "<a href=\"readfwd\">"
406 "<img src=\"static/readallmess3_24x.gif\" "
407 "alt=\"\" width=\"24\" height=\"24\">"
408 "<span class=\"navbar_link\">"
410 "</span></a></li>\n", _("Read all messages")
415 switch(WC->CurRoom.view) {
416 case VIEW_ADDRESSBOOK:
418 "<li class=\"addnewcontact\">"
419 "<a href=\"display_enter\">"
420 "<img src=\"static/addnewcontact_24x.gif\" "
421 "alt=\"\" width=\"24\" height=\"24\">"
422 "<span class=\"navbar_link\">"
424 "</span></a></li>\n", _("Add new contact")
429 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
430 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
431 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
432 if (havebstr("day" )) wc_printf("?day=%s", bstr("day"));
434 "<img src=\"static/addevent_24x.gif\" "
435 "alt=\"\" width=\"24\" height=\"24\">"
436 "<span class=\"navbar_link\">"
438 "</span></a></li>\n", _("Add new event")
443 "<li class=\"newmess\">"
444 "<a href=\"display_enter\">"
445 "<img src=\"static/newmess3_24x.gif\" "
446 "alt=\"\" width=\"24\" height=\"24\">"
447 "<span class=\"navbar_link\">"
449 "</span></a></li>\n", _("Add new task")
454 "<li class=\"enternewnote\">"
455 "<a href=\"add_new_note\">"
456 "<img src=\"static/enternewnote_24x.gif\" "
457 "alt=\"\" width=\"24\" height=\"24\">"
458 "<span class=\"navbar_link\">"
460 "</span></a></li>\n", _("Add new note")
464 safestrncpy(buf, bstr("page"), sizeof buf);
465 if (IsEmptyStr(buf)) {
466 safestrncpy(buf, "home", sizeof buf);
470 "<li class=\"newmess\">"
471 "<a href=\"display_enter?page=%s\">"
472 "<img src=\"static/newmess3_24x.gif\" "
473 "alt=\"\" width=\"24\" height=\"24\">"
474 "<span class=\"navbar_link\">"
476 "</span></a></li>\n", buf, _("Edit this page")
479 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
480 /* already viewing history; display a link to the current page */
482 "<li class=\"newmess\">"
483 "<a href=\"wiki?page=%s\">"
484 "<img src=\"static/newmess3_24x.gif\" "
485 "alt=\"\" width=\"24\" height=\"24\">"
486 "<span class=\"navbar_link\">"
488 "</span></a></li>\n", buf, _("Current version")
492 /* display a link to the history */
494 "<li class=\"newmess\">"
495 "<a href=\"wiki_history?page=%s\">"
496 "<img src=\"static/newmess3_24x.gif\" "
497 "alt=\"\" width=\"24\" height=\"24\">"
498 "<span class=\"navbar_link\">"
500 "</span></a></li>\n", buf, _("History")
506 "<li class=\"newmess\">"
507 "<a href=\"display_enter\">"
508 "<img src=\"static/newmess3_24x.gif\" "
509 "alt=\"\" width=\"24\" height=\"24\">"
510 "<span class=\"navbar_link\">"
512 "</span></a></li>\n", _("Write mail")
515 "<li class=\"newmess\">"
516 "<a href=\"javascript:deleteAllSelectedMessages();\">"
517 "<img src=\"static/delete.gif\" "
518 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
520 "</span></a></li>\n", _("Delete")
525 "<li class=\"newmess\">"
526 "<a href=\"display_enter\">"
527 "<img src=\"static/newmess3_24x.gif\" "
528 "alt=\"\" width=\"24\" height=\"24\">"
529 "<span class=\"navbar_link\">"
531 "</span></a></li>\n", _("Enter a message")
537 "<li class=\"skipthisroom\">"
540 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
541 "width=\"24\" height=\"24\">"
542 "<span class=\"navbar_link\">%s</span></a>"
544 _("Leave all messages marked as unread, go to next room with unread messages"),
549 "<li class=\"markngo\">"
550 "<a href=\"gotonext\" "
552 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
553 "width=\"24\" height=\"24\">"
554 "<span class=\"navbar_link\">%s</span></a>"
556 _("Mark all messages as read, go to next room with unread messages"),
560 wc_printf("</ul></div>\n");
565 * back end routine to take the session to a new room
567 long gotoroom(const StrBuf *gname)
571 static long ls = (-1L);
574 /* store ungoto information */
575 if (StrLength(gname) > 0)
576 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
580 /* move to the new room */
581 if (StrLength(gname) > 0)
582 serv_printf("GOTO %s", ChrPtr(gname));
583 else /* or just refresh the current state... */
585 StrBuf_ServGetln(Buf);
586 if (GetServerStatus(Buf, &err) != 2) {
587 serv_puts("GOTO _BASEROOM_");
588 StrBuf_ServGetln(Buf);
590 * well, we know that this is the fallback case,
591 * but we're interested that the first command
592 * didn't work out in first place.
594 if (GetServerStatus(Buf, NULL) != 2) {
599 ParseGoto(&WCC->CurRoom, Buf);
601 if (StrLength(gname) > 0)
603 remove_march(WCC->CurRoom.name);
604 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
613 void ParseGoto(folder *room, StrBuf *Line)
621 if (StrLength(Line) < 4) {
625 /* ignore the commandstate... */
626 Pos = ChrPtr(Line) + 4;
628 if (room->RoomNameParts != NULL)
631 for (i=0; i < room->nRoomNameParts; i++)
632 FreeStrBuf(&room->RoomNameParts[i]);
633 free(room->RoomNameParts);
634 room->RoomNameParts = NULL;
639 pBuf = NewStrBufPlain(NULL, StrLength(Line));
642 memset(room, 0, sizeof(folder));
645 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
647 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
648 if (room->nNewMessages > 0)
649 room->RAFlags |= UA_HASNEWMSGS;
651 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
653 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
655 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
657 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
658 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
660 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
662 flag = StrBufExtractNext_long(Line, &Pos, '|');
663 if (WCC->is_aide || flag) {
664 room->RAFlags |= UA_ADMINALLOWED;
667 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
669 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
671 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
673 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
675 flag = StrBufExtractNext_long(Line, &Pos, '|');
677 room->RAFlags |= UA_ISTRASH; // wc_is_trash
679 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
681 /* find out, whether we are in a sub-room */
682 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
683 if (room->nRoomNameParts > 1)
688 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
689 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
690 for (i=0; i < room->nRoomNameParts; i++)
692 room->RoomNameParts[i] = NewStrBuf();
693 StrBufExtract_NextToken(room->RoomNameParts[i],
694 room->name, &Pos, '\\');
698 /* Private mailboxes on the main floor get remapped to the personal folder */
699 if ((room->QRFlags & QR_MAILBOX) &&
700 (room->floorid == 0))
702 room->floorid = VIRTUAL_MY_FLOOR;
703 if ((room->nRoomNameParts == 1) &&
704 (StrLength(room->name) == 4) &&
705 (strcmp(ChrPtr(room->name), "Mail") == 0))
711 /* get a pointer to the floor we're on: */
712 if (WCC->Floors == NULL)
713 GetFloorListHash(NULL, NULL);
715 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
716 room->Floor = (const Floor*) vFloor;
719 void LoadRoomAide(void)
724 if (WCC->CurRoom.RoomAideLoaded)
727 WCC->CurRoom.RoomAideLoaded = 1;
730 StrBuf_ServGetln(Buf);
731 if (GetServerStatus(Buf, NULL) != 2) {
732 FlushStrBuf(WCC->CurRoom.RoomAide);
733 AppendImportantMessage (ChrPtr(Buf) + 4,
738 Pos = ChrPtr(Buf) + 4;
740 FreeStrBuf(&WCC->CurRoom.RoomAide);
741 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
743 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
747 void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
750 folder *Folder = &WCC->CurRoom;
751 const Floor *pFloor = Folder->Floor;
756 StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
759 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
765 StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
769 void LoadRoomXA (void)
774 if (WCC->CurRoom.XALoaded)
777 WCC->CurRoom.XALoaded = 1;
780 StrBuf_ServGetln(Buf);
781 if (GetServerStatus(Buf, NULL) != 2) {
782 FlushStrBuf(WCC->CurRoom.XAPass);
783 FlushStrBuf(WCC->CurRoom.Directory);
785 AppendImportantMessage (ChrPtr(Buf) + 4,
790 Pos = ChrPtr(Buf) + 4;
792 FreeStrBuf(&WCC->CurRoom.XAPass);
793 FreeStrBuf(&WCC->CurRoom.Directory);
795 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
796 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
798 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
799 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
800 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
801 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
802 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
803 /* defview, we already know you. */
804 /* QR2Flags, we already know them... */
811 void LoadXRoomPic(void)
816 if (WCC->CurRoom.XHaveRoomPicLoaded)
819 WCC->CurRoom.XHaveRoomPicLoaded = 1;
821 serv_puts("OIMG _roompic_");
822 StrBuf_ServGetln(Buf);
823 if (GetServerStatus(Buf, NULL) != 2) {
824 WCC->CurRoom.XHaveRoomPic = 0;
826 WCC->CurRoom.XHaveRoomPic = 1;
829 StrBuf_ServGetln(Buf);
830 GetServerStatus(Buf, NULL);
834 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
842 return WCC->CurRoom.XHaveRoomPic == 1;
845 void LoadXRoomInfoText(void)
851 if (WCC->CurRoom.XHaveInfoTextLoaded)
854 WCC->CurRoom.XHaveInfoTextLoaded = 1;
859 StrBuf_ServGetln(Buf);
860 if (GetServerStatus(Buf, NULL) == 1) {
861 WCC->CurRoom.XInfoText = NewStrBuf ();
863 while (!Done && StrBuf_ServGetln(Buf)>=0) {
864 if ( (StrLength(Buf)==3) &&
865 !strcmp(ChrPtr(Buf), "000"))
868 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
875 int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
883 return (StrLength(WCC->CurRoom.XInfoText)>0);
886 void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
892 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1);
895 void LoadXRoomXCountFiles(void)
901 if (WCC->CurRoom.XHaveDownloadCount)
904 WCC->CurRoom.XHaveDownloadCount = 1;
908 StrBuf_ServGetln(Buf);
909 if (GetServerStatus(Buf, NULL) == 1) {
911 while (!Done && StrBuf_ServGetln(Buf)>=0) {
912 if ( (StrLength(Buf)==3) &&
913 !strcmp(ChrPtr(Buf), "000"))
916 WCC->CurRoom.XDownloadCount++;
923 void tmplput_CurrentRoomXNFiles(StrBuf *Target, WCTemplputParams *TP)
927 LoadXRoomXCountFiles();
929 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.XDownloadCount);
932 void tmplput_CurrentRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
936 LoadXRoomXCountFiles();
938 if (WCC->CurRoom.XDownloadCount == 1)
939 StrBufAppendBufPlain(Target, _("file"), -1, 0);
941 StrBufAppendBufPlain(Target, _("files"), -1, 0);
944 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
950 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
952 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
958 StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
960 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
966 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
968 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
972 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.defview);
975 void tmplput_CurrentRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP)
981 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
984 void tmplput_CurrentRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP)
990 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nTotalMessages);
993 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
1003 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1004 return CheckThis == WCC->CurRoom.Order;
1007 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1009 wcsession *WCC = WC;
1015 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1016 return CheckThis == WCC->CurRoom.defview;
1019 int ConditionalThisRoomHaveView(StrBuf *Target, WCTemplputParams *TP)
1021 wcsession *WCC = WC;
1027 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1028 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
1030 LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
1031 "Roomview [%ld] not valid\n",
1036 return exchangeable_views [WCC->CurRoom.defview][CheckThis] != VIEW_MAX;
1039 void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
1041 wcsession *WCC = WC;
1044 if ((WCC == NULL) ||
1045 (WCC->CurRoom.defview >= VIEW_MAX) ||
1046 (WCC->CurRoom.defview < VIEW_BBS))
1048 LogTemplateError(Target, "Token", ERR_PARM2, TP,
1049 "Roomview [%ld] not valid\n",
1051 WCC->CurRoom.defview : -1);
1055 Buf = NewStrBufPlain(_(viewdefs[WCC->CurRoom.defview]), -1);
1056 StrBufAppendTemplate(Target, TP, Buf, 0);
1060 void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
1065 CheckThis = GetTemplateTokenNumber(Target, TP, 0, 0);
1066 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
1068 LogTemplateError(Target, "Token", ERR_PARM2, TP,
1069 "Roomview [%ld] not valid\n",
1074 Buf = NewStrBufPlain(_(viewdefs[CheckThis]), -1);
1075 StrBufAppendTemplate(Target, TP, Buf, 0);
1083 void smart_goto(const StrBuf *next_room) {
1084 gotoroom(next_room);
1085 readloop(readnew, eUseDefault);
1091 * mark all messages in current room as having been read
1093 void slrp_highest(void)
1097 serv_puts("SLRP HIGHEST");
1098 serv_getln(buf, sizeof buf);
1102 typedef struct __room_states {
1117 * Set/clear/read the "self-service list subscribe" flag for a room
1119 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1120 * returns the new value.
1123 int self_service(int newval) {
1124 int current_value = 0;
1130 int flags, floor, order, view, flags2;
1133 serv_getln(buf, sizeof buf);
1134 if (buf[0] != '2') return(0);
1136 extract_token(name, &buf[4], 0, '|', sizeof name);
1137 extract_token(password, &buf[4], 1, '|', sizeof password);
1138 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1139 flags = extract_int(&buf[4], 3);
1140 floor = extract_int(&buf[4], 4);
1141 order = extract_int(&buf[4], 5);
1142 view = extract_int(&buf[4], 6);
1143 flags2 = extract_int(&buf[4], 7);
1145 if (flags2 & QR2_SELFLIST) {
1153 flags2 = flags2 | QR2_SELFLIST;
1155 else if (newval == 0) {
1156 flags2 = flags2 & ~QR2_SELFLIST;
1159 return(current_value);
1162 if (newval != current_value) {
1163 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1164 name, password, dirname, flags,
1165 floor, order, view, flags2);
1166 serv_getln(buf, sizeof buf);
1173 int is_selflist(room_states *RoomFlags)
1175 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1178 int is_publiclist(room_states *RoomFlags)
1180 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1183 int is_moderatedlist(room_states *RoomFlags)
1185 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1189 * Set/clear/read the "self-service list subscribe" flag for a room
1191 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1192 * returns the new value.
1195 int get_roomflags(room_states *RoomOps)
1200 serv_getln(buf, sizeof buf);
1201 if (buf[0] != '2') return(0);
1203 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1204 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1205 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1206 RoomOps->flags = extract_int(&buf[4], 3);
1207 RoomOps->floor = extract_int(&buf[4], 4);
1208 RoomOps->order = extract_int(&buf[4], 5);
1209 RoomOps->view = extract_int(&buf[4], 6);
1210 RoomOps->flags2 = extract_int(&buf[4], 7);
1214 int set_roomflags(room_states *RoomOps)
1218 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1227 serv_getln(buf, sizeof buf);
1237 * display the form for editing a room
1239 void display_editroom(void)
1245 char remote_room[128];
1248 char er_password[10];
1249 char er_dirname[15];
1250 char er_roomaide[26];
1257 char *not_shared_with = NULL;
1260 int floorpolicy = 0;
1262 char pop3_host[128];
1267 if (IsEmptyStr(tab)) tab = "admin";
1270 load_floorlist(Buf);
1272 output_headers(1, 1, 1, 0, 0, 0);
1274 wc_printf("<div class=\"fix_scrollbar_bug\">");
1276 wc_printf("<br />\n");
1278 /* print the tabbed dialog */
1279 wc_printf("<div align=\"center\">");
1280 wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1281 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1284 wc_printf("<td class=\"");
1285 if (!strcmp(tab, "admin")) {
1286 wc_printf(" tab_cell_label\">");
1287 wc_printf(_("Administration"));
1290 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1291 wc_printf(_("Administration"));
1294 wc_printf("</td>\n");
1295 wc_printf("<td> </td>\n");
1297 if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1299 wc_printf("<td class=\"");
1300 if (!strcmp(tab, "config")) {
1301 wc_printf(" tab_cell_label\">");
1302 wc_printf(_("Configuration"));
1305 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1306 wc_printf(_("Configuration"));
1309 wc_printf("</td>\n");
1310 wc_printf("<td> </td>\n");
1312 wc_printf("<td class=\"");
1313 if (!strcmp(tab, "expire")) {
1314 wc_printf(" tab_cell_label\">");
1315 wc_printf(_("Message expire policy"));
1318 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1319 wc_printf(_("Message expire policy"));
1322 wc_printf("</td>\n");
1323 wc_printf("<td> </td>\n");
1325 wc_printf("<td class=\"");
1326 if (!strcmp(tab, "access")) {
1327 wc_printf(" tab_cell_label\">");
1328 wc_printf(_("Access controls"));
1331 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1332 wc_printf(_("Access controls"));
1335 wc_printf("</td>\n");
1336 wc_printf("<td> </td>\n");
1338 wc_printf("<td class=\"");
1339 if (!strcmp(tab, "sharing")) {
1340 wc_printf(" tab_cell_label\">");
1341 wc_printf(_("Sharing"));
1344 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1345 wc_printf(_("Sharing"));
1348 wc_printf("</td>\n");
1349 wc_printf("<td> </td>\n");
1351 wc_printf("<td class=\"");
1352 if (!strcmp(tab, "listserv")) {
1353 wc_printf(" tab_cell_label\">");
1354 wc_printf(_("Mailing list service"));
1357 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1358 wc_printf(_("Mailing list service"));
1361 wc_printf("</td>\n");
1362 wc_printf("<td> </td>\n");
1366 wc_printf("<td class=\"");
1367 if (!strcmp(tab, "feeds")) {
1368 wc_printf(" tab_cell_label\">");
1369 wc_printf(_("Remote retrieval"));
1372 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1373 wc_printf(_("Remote retrieval"));
1376 wc_printf("</td>\n");
1377 wc_printf("<td> </td>\n");
1379 wc_printf("</tr></table>\n");
1380 wc_printf("</div>\n");
1381 /* end tabbed dialog */
1383 wc_printf("<script type=\"text/javascript\">"
1384 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1388 /* begin content of whatever tab is open now */
1390 if (!strcmp(tab, "admin")) {
1391 wc_printf("<div class=\"tabcontent\">");
1393 "<li><a href=\"delete_room\" "
1394 "onClick=\"return confirm('");
1395 wc_printf(_("Are you sure you want to delete this room?"));
1396 wc_printf("');\">\n");
1397 wc_printf(_("Delete this room"));
1399 "<li><a href=\"display_editroompic?which_room=");
1400 urlescputs(ChrPtr(WC->CurRoom.name));
1402 wc_printf(_("Set or change the icon for this room's banner"));
1404 "<li><a href=\"display_editinfo\">\n");
1405 wc_printf(_("Edit this room's Info file"));
1408 wc_printf("</div>");
1411 if (!strcmp(tab, "config")) {
1412 wc_printf("<div class=\"tabcontent\">");
1414 serv_getln(buf, sizeof buf);
1416 if (!strncmp(buf, "550", 3)) {
1417 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1418 _("Higher access is required to access this function.")
1421 else if (buf[0] != '2') {
1422 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1425 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1426 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1427 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1428 er_flags = extract_int(&buf[4], 3);
1429 er_floor = extract_int(&buf[4], 4);
1430 er_flags2 = extract_int(&buf[4], 7);
1432 wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1433 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1435 wc_printf("<ul><li>");
1436 wc_printf(_("Name of room: "));
1437 wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1443 wc_printf(_("Resides on floor: "));
1444 wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1445 if (er_flags & QR_MAILBOX)
1446 wc_printf("disabled >\n");
1447 for (i = 0; i < 128; ++i)
1448 if (!IsEmptyStr(floorlist[i])) {
1449 wc_printf("<OPTION ");
1451 wc_printf("SELECTED ");
1452 wc_printf("VALUE=\"%d\">", i);
1453 escputs(floorlist[i]);
1454 wc_printf("</OPTION>\n");
1456 wc_printf("</select>\n");
1459 wc_printf(_("Type of room:"));
1460 wc_printf("<ul>\n");
1462 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1463 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1464 wc_printf("CHECKED ");
1465 wc_printf("OnChange=\""
1466 " if (this.form.type[0].checked == true) { "
1467 " this.form.er_floor.disabled = false; "
1470 wc_printf(_("Public (automatically appears to everyone)"));
1473 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1474 if ((er_flags & QR_PRIVATE) &&
1475 (er_flags & QR_GUESSNAME))
1476 wc_printf("CHECKED ");
1477 wc_printf(" OnChange=\""
1478 " if (this.form.type[1].checked == true) { "
1479 " this.form.er_floor.disabled = false; "
1482 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1484 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1485 if ((er_flags & QR_PRIVATE) &&
1486 (er_flags & QR_PASSWORDED))
1487 wc_printf("CHECKED ");
1488 wc_printf(" OnChange=\""
1489 " if (this.form.type[2].checked == true) { "
1490 " this.form.er_floor.disabled = false; "
1493 wc_printf(_("Private - require password: "));
1494 wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1497 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1498 if ((er_flags & QR_PRIVATE)
1499 && ((er_flags & QR_GUESSNAME) == 0)
1500 && ((er_flags & QR_PASSWORDED) == 0))
1501 wc_printf("CHECKED ");
1502 wc_printf(" OnChange=\""
1503 " if (this.form.type[3].checked == true) { "
1504 " this.form.er_floor.disabled = false; "
1507 wc_printf(_("Private - invitation only"));
1509 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1510 if (er_flags & QR_MAILBOX)
1511 wc_printf("CHECKED ");
1512 wc_printf (" OnChange=\""
1513 " if (this.form.type[4].checked == true) { "
1514 " this.form.er_floor.disabled = true; "
1517 wc_printf(_("Personal (mailbox for you only)"));
1519 wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1521 wc_printf(_("If private, cause current users to forget room"));
1523 wc_printf("\n</ul>\n");
1525 wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1526 if (er_flags & QR_PREFONLY)
1527 wc_printf("CHECKED ");
1529 wc_printf(_("Preferred users only"));
1531 wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1532 if (er_flags & QR_READONLY)
1533 wc_printf("CHECKED ");
1535 wc_printf(_("Read-only room"));
1537 wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1538 if (er_flags2 & QR2_COLLABDEL)
1539 wc_printf("CHECKED ");
1541 wc_printf(_("All users allowed to post may also delete messages"));
1543 /** directory stuff */
1544 wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1545 if (er_flags & QR_DIRECTORY)
1546 wc_printf("CHECKED ");
1548 wc_printf(_("File directory room"));
1550 wc_printf("\n<ul><li>");
1551 wc_printf(_("Directory name: "));
1552 wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1555 wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1556 if (er_flags & QR_UPLOAD)
1557 wc_printf("CHECKED ");
1559 wc_printf(_("Uploading allowed"));
1561 wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1562 if (er_flags & QR_DOWNLOAD)
1563 wc_printf("CHECKED ");
1565 wc_printf(_("Downloading allowed"));
1567 wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1568 if (er_flags & QR_VISDIR)
1569 wc_printf("CHECKED ");
1571 wc_printf(_("Visible directory"));
1572 wc_printf("</ul>\n");
1574 /** end of directory stuff */
1576 wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1577 if (er_flags & QR_NETWORK)
1578 wc_printf("CHECKED ");
1580 wc_printf(_("Network shared room"));
1582 wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1583 if (er_flags & QR_PERMANENT)
1584 wc_printf("CHECKED ");
1586 wc_printf(_("Permanent (does not auto-purge)"));
1588 wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1589 if (er_flags2 & QR2_SUBJECTREQ)
1590 wc_printf("CHECKED ");
1592 wc_printf(_("Subject Required (Force users to specify a message subject)"));
1594 /** start of anon options */
1596 wc_printf("\n<li>");
1597 wc_printf(_("Anonymous messages"));
1598 wc_printf("<ul>\n");
1600 wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1601 if (((er_flags & QR_ANONONLY) == 0)
1602 && ((er_flags & QR_ANONOPT) == 0))
1603 wc_printf("CHECKED ");
1605 wc_printf(_("No anonymous messages"));
1607 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1608 if (er_flags & QR_ANONONLY)
1609 wc_printf("CHECKED ");
1611 wc_printf(_("All messages are anonymous"));
1613 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1614 if (er_flags & QR_ANONOPT)
1615 wc_printf("CHECKED ");
1617 wc_printf(_("Prompt user when entering messages"));
1618 wc_printf("</ul>\n");
1620 /* end of anon options */
1623 wc_printf(_("Room aide: "));
1625 serv_getln(buf, sizeof buf);
1626 if (buf[0] != '2') {
1627 wc_printf("<em>%s</em>\n", &buf[4]);
1629 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1630 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1633 wc_printf("</ul><CENTER>\n");
1634 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1635 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1637 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1643 wc_printf("</div>");
1647 /* Sharing the room with other Citadel nodes... */
1648 if (!strcmp(tab, "sharing")) {
1649 wc_printf("<div class=\"tabcontent\">");
1651 shared_with = strdup("");
1652 not_shared_with = strdup("");
1654 /** Learn the current configuration */
1655 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1656 serv_getln(buf, sizeof buf);
1657 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1658 extract_token(node, buf, 0, '|', sizeof node);
1659 not_shared_with = realloc(not_shared_with,
1660 strlen(not_shared_with) + 32);
1661 strcat(not_shared_with, node);
1662 strcat(not_shared_with, "\n");
1666 serv_getln(buf, sizeof buf);
1667 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1668 extract_token(cmd, buf, 0, '|', sizeof cmd);
1669 extract_token(node, buf, 1, '|', sizeof node);
1670 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1671 if (!strcasecmp(cmd, "ignet_push_share")) {
1672 shared_with = realloc(shared_with,
1673 strlen(shared_with) + 32);
1674 strcat(shared_with, node);
1675 if (!IsEmptyStr(remote_room)) {
1676 strcat(shared_with, "|");
1677 strcat(shared_with, remote_room);
1679 strcat(shared_with, "\n");
1683 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1684 extract_token(buf, shared_with, i, '\n', sizeof buf);
1685 extract_token(node, buf, 0, '|', sizeof node);
1686 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1687 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1688 if (!strcasecmp(node, cmd)) {
1689 remove_token(not_shared_with, j, '\n');
1694 /* Display the stuff */
1695 wc_printf("<CENTER><br />"
1696 "<table border=1 cellpadding=5><tr>"
1698 wc_printf(_("Shared with"));
1699 wc_printf("</I></B></td>"
1701 wc_printf(_("Not shared with"));
1702 wc_printf("</I></B></td></tr>\n"
1703 "<tr><td VALIGN=TOP>\n");
1705 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1706 wc_printf(_("Remote node name"));
1707 wc_printf("</td><td>");
1708 wc_printf(_("Remote room name"));
1709 wc_printf("</td><td>");
1710 wc_printf(_("Actions"));
1711 wc_printf("</td></tr>\n");
1713 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1714 extract_token(buf, shared_with, i, '\n', sizeof buf);
1715 extract_token(node, buf, 0, '|', sizeof node);
1716 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1717 if (!IsEmptyStr(node)) {
1718 wc_printf("<form method=\"POST\" action=\"netedit\">");
1719 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1720 wc_printf("<tr><td>%s</td>\n", node);
1723 if (!IsEmptyStr(remote_room)) {
1724 escputs(remote_room);
1730 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1731 "VALUE=\"ignet_push_share|");
1733 if (!IsEmptyStr(remote_room)) {
1735 urlescputs(remote_room);
1738 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1739 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1740 wc_printf("<input type=\"submit\" "
1741 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1742 wc_printf("</td></tr></form>\n");
1746 wc_printf("</table>\n");
1747 wc_printf("</td><td VALIGN=TOP>\n");
1748 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1749 wc_printf(_("Remote node name"));
1750 wc_printf("</td><td>");
1751 wc_printf(_("Remote room name"));
1752 wc_printf("</td><td>");
1753 wc_printf(_("Actions"));
1754 wc_printf("</td></tr>\n");
1756 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1757 extract_token(node, not_shared_with, i, '\n', sizeof node);
1758 if (!IsEmptyStr(node)) {
1759 wc_printf("<form method=\"POST\" action=\"netedit\">");
1760 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1761 wc_printf("<tr><td>");
1763 wc_printf("</td><td>"
1764 "<input type=\"INPUT\" "
1768 wc_printf("<input type=\"hidden\" "
1770 "VALUE=\"ignet_push_share|");
1773 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1774 "VALUE=\"sharing\">\n");
1775 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1776 "VALUE=\"add\">\n");
1777 wc_printf("<input type=\"submit\" "
1778 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1779 wc_printf("</td></tr></form>\n");
1783 wc_printf("</table>\n");
1784 wc_printf("</td></tr>"
1785 "</table></CENTER><br />\n"
1786 "<I><B>%s</B><ul><li>", _("Notes:"));
1787 wc_printf(_("When sharing a room, "
1788 "it must be shared from both ends. Adding a node to "
1789 "the 'shared' list sends messages out, but in order to"
1790 " receive messages, the other nodes must be configured"
1791 " to send messages out to your system as well. "
1792 "<li>If the remote room name is blank, it is assumed "
1793 "that the room name is identical on the remote node."
1794 "<li>If the remote room name is different, the remote "
1795 "node must also configure the name of the room here."
1799 wc_printf("</div>");
1802 if (not_shared_with != NULL)
1803 free (not_shared_with);
1805 /* Mailing list management */
1806 if (!strcmp(tab, "listserv")) {
1807 room_states RoomFlags;
1808 wc_printf("<div class=\"tabcontent\">");
1810 wc_printf("<br /><center>"
1811 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1812 "<tr><td VALIGN=TOP>");
1814 wc_printf(_("<i>The contents of this room are being "
1815 "mailed <b>as individual messages</b> "
1816 "to the following list recipients:"
1817 "</i><br /><br />\n"));
1820 serv_getln(buf, sizeof buf);
1821 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1822 extract_token(cmd, buf, 0, '|', sizeof cmd);
1823 if (!strcasecmp(cmd, "listrecp")) {
1824 extract_token(recp, buf, 1, '|', sizeof recp);
1827 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1830 wc_printf(_("(remove)"));
1831 wc_printf("</A><br />");
1834 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1835 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1836 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1837 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1838 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1839 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1840 wc_printf("</form>\n");
1842 wc_printf("</td><td VALIGN=TOP>\n");
1844 wc_printf(_("<i>The contents of this room are being "
1845 "mailed <b>in digest form</b> "
1846 "to the following list recipients:"
1847 "</i><br /><br />\n"));
1850 serv_getln(buf, sizeof buf);
1851 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1852 extract_token(cmd, buf, 0, '|', sizeof cmd);
1853 if (!strcasecmp(cmd, "digestrecp")) {
1854 extract_token(recp, buf, 1, '|', sizeof recp);
1857 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1861 wc_printf(_("(remove)"));
1862 wc_printf("</A><br />");
1865 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1866 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1867 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1868 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1869 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1870 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1871 wc_printf("</form>\n");
1873 wc_printf("</td></tr></table>\n");
1875 /** Pop open an address book -- begin **/
1876 wc_printf("<div align=right>"
1877 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1879 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1884 _("Add recipients from Contacts or other address books"),
1885 _("Add recipients from Contacts or other address books")
1887 /* Pop open an address book -- end **/
1889 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1891 get_roomflags (&RoomFlags);
1893 /* Self Service subscription? */
1894 wc_printf("<table><tr><td>\n");
1895 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1896 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1897 " <tr><td colspan=\"2\">\n",
1898 (is_selflist(&RoomFlags))?"checked":"");
1899 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1900 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1901 (is_https ? "https" : "http"),
1902 ChrPtr(WC->Hdr->HR.http_host));
1903 /* Public posting? */
1904 wc_printf("<tr><td>");
1905 wc_printf(_("Allow non-subscribers to mail to this room."));
1906 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1907 (is_publiclist(&RoomFlags))?"checked":"");
1909 /* Moderated List? */
1910 wc_printf("<tr><td>");
1911 wc_printf(_("Room post publication needs Aide permission."));
1912 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1913 (is_moderatedlist(&RoomFlags))?"checked":"");
1916 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1917 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1918 wc_printf("</table></form>");
1921 wc_printf("</CENTER>\n");
1922 wc_printf("</div>");
1926 /* Configuration of The Dreaded Auto-Purger */
1927 if (!strcmp(tab, "expire")) {
1928 wc_printf("<div class=\"tabcontent\">");
1930 serv_puts("GPEX room");
1931 serv_getln(buf, sizeof buf);
1932 if (!strncmp(buf, "550", 3)) {
1933 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1934 _("Higher access is required to access this function.")
1937 else if (buf[0] != '2') {
1938 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1941 roompolicy = extract_int(&buf[4], 0);
1942 roomvalue = extract_int(&buf[4], 1);
1944 serv_puts("GPEX floor");
1945 serv_getln(buf, sizeof buf);
1946 if (buf[0] == '2') {
1947 floorpolicy = extract_int(&buf[4], 0);
1948 floorvalue = extract_int(&buf[4], 1);
1951 wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1952 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1953 wc_printf("<table border=0 cellspacing=5>\n");
1954 wc_printf("<tr><td>");
1955 wc_printf(_("Message expire policy for this room"));
1956 wc_printf("<br />(");
1957 escputs(ChrPtr(WC->CurRoom.name));
1958 wc_printf(")</td><td>");
1959 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1960 ((roompolicy == 0) ? "CHECKED" : "") );
1961 wc_printf(_("Use the default policy for this floor"));
1962 wc_printf("<br />\n");
1963 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1964 ((roompolicy == 1) ? "CHECKED" : "") );
1965 wc_printf(_("Never automatically expire messages"));
1966 wc_printf("<br />\n");
1967 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1968 ((roompolicy == 2) ? "CHECKED" : "") );
1969 wc_printf(_("Expire by message count"));
1970 wc_printf("<br />\n");
1971 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1972 ((roompolicy == 3) ? "CHECKED" : "") );
1973 wc_printf(_("Expire by message age"));
1974 wc_printf("<br />");
1975 wc_printf(_("Number of messages or days: "));
1976 wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1977 wc_printf("</td></tr>\n");
1979 if (WC->axlevel >= 6) {
1980 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1981 wc_printf("<tr><td>");
1982 wc_printf(_("Message expire policy for this floor"));
1983 wc_printf("<br />(");
1984 escputs(floorlist[WC->CurRoom.floorid]);
1985 wc_printf(")</td><td>");
1986 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1987 ((floorpolicy == 0) ? "CHECKED" : "") );
1988 wc_printf(_("Use the system default"));
1989 wc_printf("<br />\n");
1990 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1991 ((floorpolicy == 1) ? "CHECKED" : "") );
1992 wc_printf(_("Never automatically expire messages"));
1993 wc_printf("<br />\n");
1994 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1995 ((floorpolicy == 2) ? "CHECKED" : "") );
1996 wc_printf(_("Expire by message count"));
1997 wc_printf("<br />\n");
1998 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1999 ((floorpolicy == 3) ? "CHECKED" : "") );
2000 wc_printf(_("Expire by message age"));
2001 wc_printf("<br />");
2002 wc_printf(_("Number of messages or days: "));
2003 wc_printf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
2007 wc_printf("<CENTER>\n");
2008 wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
2009 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
2010 wc_printf(" ");
2011 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2012 wc_printf("</CENTER></td><tr>\n");
2014 wc_printf("</table>\n"
2015 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
2020 wc_printf("</div>");
2023 /* Access controls */
2024 if (!strcmp(tab, "access")) {
2025 wc_printf("<div class=\"tabcontent\">");
2027 wc_printf("</div>");
2030 /* Fetch messages from remote locations */
2031 if (!strcmp(tab, "feeds")) {
2032 wc_printf("<div class=\"tabcontent\">");
2035 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
2036 wc_printf("</i><br />\n");
2038 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2039 "<tr class=\"even\"><th>");
2040 wc_printf(_("Remote host"));
2041 wc_printf("</th><th>");
2042 wc_printf(_("User name"));
2043 wc_printf("</th><th>");
2044 wc_printf(_("Password"));
2045 wc_printf("</th><th>");
2046 wc_printf(_("Keep messages on server?"));
2047 wc_printf("</th><th>");
2048 wc_printf(_("Interval"));
2049 wc_printf("</th><th> </th></tr>");
2052 serv_getln(buf, sizeof buf);
2054 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2055 extract_token(cmd, buf, 0, '|', sizeof cmd);
2056 if (!strcasecmp(cmd, "pop3client")) {
2057 safestrncpy(recp, &buf[11], sizeof recp);
2060 wc_printf("<tr class=\"%s\">",
2061 (bg ? "even" : "odd")
2065 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2070 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2074 wc_printf("<td>*****</td>"); /* Don't show the password */
2076 wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2078 wc_printf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2080 wc_printf("<td class=\"button_link\">");
2081 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2084 wc_printf(_("(remove)"));
2085 wc_printf("</a></td>");
2091 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2093 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2094 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2095 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2097 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2100 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2103 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2106 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2109 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2112 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2113 wc_printf("</td></tr>");
2114 wc_printf("</form></table>\n");
2116 wc_printf("<hr>\n");
2119 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2120 wc_printf("</i><br />\n");
2122 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2123 "<tr class=\"even\"><th>");
2124 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2125 wc_printf(_("Feed URL"));
2126 wc_printf("</th><th>");
2127 wc_printf("</th></tr>");
2130 serv_getln(buf, sizeof buf);
2132 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2133 extract_token(cmd, buf, 0, '|', sizeof cmd);
2134 if (!strcasecmp(cmd, "rssclient")) {
2135 safestrncpy(recp, &buf[10], sizeof recp);
2138 wc_printf("<tr class=\"%s\">",
2139 (bg ? "even" : "odd")
2143 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2147 wc_printf("<td class=\"button_link\">");
2148 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2151 wc_printf(_("(remove)"));
2152 wc_printf("</a></td>");
2158 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2160 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2161 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2162 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2164 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2165 "maxlength=\"256\" name=\"line_pop3host\">\n");
2168 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2169 wc_printf("</td></tr>");
2170 wc_printf("</form></table>\n");
2172 wc_printf("</div>");
2176 /* end content of whatever tab is open now */
2177 wc_printf("</div>\n");
2179 address_book_popup();
2185 * Toggle self-service list subscription
2187 void toggle_self_service(void) {
2188 room_states RoomFlags;
2190 get_roomflags (&RoomFlags);
2192 if (yesbstr("QR2_SelfList"))
2193 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2195 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2197 if (yesbstr("QR2_SMTP_PUBLIC"))
2198 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2200 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2202 if (yesbstr("QR2_Moderated"))
2203 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2205 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2206 if (yesbstr("QR2_SubsOnly"))
2207 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2209 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2211 set_roomflags (&RoomFlags);
2219 * save new parameters for a room
2226 StrBuf *er_password;
2228 StrBuf *er_roomaide;
2231 int er_listingorder;
2237 if (!havebstr("ok_button")) {
2238 strcpy(WC->ImportantMessage,
2239 _("Cancelled. Changes were not saved."));
2245 StrBuf_ServGetln(Buf);
2246 if (GetServerStatus(Buf, NULL) != 2) {
2247 StrBufCutLeft(Buf, 4);
2248 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2254 er_name = NewStrBuf();
2255 er_password = NewStrBuf();
2256 er_dirname = NewStrBuf();
2257 er_roomaide = NewStrBuf();
2259 StrBufCutLeft(Buf, 4);
2260 StrBufExtract_token(er_name, Buf, 0, '|');
2261 StrBufExtract_token(er_password, Buf, 1, '|');
2262 StrBufExtract_token(er_dirname, Buf, 2, '|');
2263 er_flags = StrBufExtract_int(Buf, 3, '|');
2264 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2265 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2266 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2268 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2269 if (StrLength(er_roomaide) == 0) {
2271 StrBuf_ServGetln(Buf);
2272 if (GetServerStatus(Buf, NULL) != 2) {
2273 FlushStrBuf(er_roomaide);
2275 StrBufCutLeft(Buf, 4);
2276 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2279 Ptr = sbstr("er_name");
2280 if (StrLength(Ptr) > 0) {
2281 FlushStrBuf(er_name);
2282 StrBufAppendBuf(er_name, Ptr, 0);
2285 Ptr = sbstr("er_password");
2286 if (StrLength(Ptr) > 0) {
2287 FlushStrBuf(er_password);
2288 StrBufAppendBuf(er_password, Ptr, 0);
2292 Ptr = sbstr("er_dirname");
2293 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2294 FlushStrBuf(er_dirname);
2295 StrBufAppendBuf(er_dirname, Ptr, 0);
2299 Ptr = sbstr("type");
2300 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2302 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2303 er_flags |= (QR_PRIVATE);
2305 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2306 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2308 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2309 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2311 if (!strcmp(ChrPtr(Ptr), "personal")) {
2312 er_flags |= QR_MAILBOX;
2314 er_flags &= ~QR_MAILBOX;
2317 if (yesbstr("prefonly")) {
2318 er_flags |= QR_PREFONLY;
2320 er_flags &= ~QR_PREFONLY;
2323 if (yesbstr("readonly")) {
2324 er_flags |= QR_READONLY;
2326 er_flags &= ~QR_READONLY;
2330 if (yesbstr("collabdel")) {
2331 er_flags2 |= QR2_COLLABDEL;
2333 er_flags2 &= ~QR2_COLLABDEL;
2336 if (yesbstr("permanent")) {
2337 er_flags |= QR_PERMANENT;
2339 er_flags &= ~QR_PERMANENT;
2342 if (yesbstr("subjectreq")) {
2343 er_flags2 |= QR2_SUBJECTREQ;
2345 er_flags2 &= ~QR2_SUBJECTREQ;
2348 if (yesbstr("network")) {
2349 er_flags |= QR_NETWORK;
2351 er_flags &= ~QR_NETWORK;
2354 if (yesbstr("directory")) {
2355 er_flags |= QR_DIRECTORY;
2357 er_flags &= ~QR_DIRECTORY;
2360 if (yesbstr("ulallowed")) {
2361 er_flags |= QR_UPLOAD;
2363 er_flags &= ~QR_UPLOAD;
2366 if (yesbstr("dlallowed")) {
2367 er_flags |= QR_DOWNLOAD;
2369 er_flags &= ~QR_DOWNLOAD;
2372 if (yesbstr("visdir")) {
2373 er_flags |= QR_VISDIR;
2375 er_flags &= ~QR_VISDIR;
2378 Ptr = sbstr("anon");
2380 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2381 if (!strcmp(ChrPtr(Ptr), "anononly"))
2382 er_flags |= QR_ANONONLY;
2383 if (!strcmp(ChrPtr(Ptr), "anon2"))
2384 er_flags |= QR_ANONOPT;
2386 bump = yesbstr("bump");
2388 er_floor = ibstr("er_floor");
2390 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2392 ChrPtr(er_password),
2401 StrBuf_ServGetln(Buf);
2402 if (GetServerStatus(Buf, NULL) != 2) {
2403 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2406 FreeStrBuf(&er_name);
2407 FreeStrBuf(&er_password);
2408 FreeStrBuf(&er_dirname);
2409 FreeStrBuf(&er_roomaide);
2414 if (StrLength(er_roomaide) > 0) {
2415 serv_printf("SETA %s", ChrPtr(er_roomaide));
2416 StrBuf_ServGetln(Buf);
2417 if (GetServerStatus(Buf, NULL) != 2) {
2418 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2419 display_main_menu();
2421 FreeStrBuf(&er_name);
2422 FreeStrBuf(&er_password);
2423 FreeStrBuf(&er_dirname);
2424 FreeStrBuf(&er_roomaide);
2429 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2432 FreeStrBuf(&er_name);
2433 FreeStrBuf(&er_password);
2434 FreeStrBuf(&er_dirname);
2435 FreeStrBuf(&er_roomaide);
2441 * Display form for Invite, Kick, and show Who Knows a room
2443 void do_invt_kick(void) {
2444 char buf[SIZ], room[SIZ], username[SIZ];
2447 serv_getln(buf, sizeof buf);
2449 if (buf[0] != '2') {
2453 extract_token(room, &buf[4], 0, '|', sizeof room);
2455 strcpy(username, bstr("username"));
2457 if (havebstr("kick_button")) {
2458 sprintf(buf, "KICK %s", username);
2460 serv_getln(buf, sizeof buf);
2462 if (buf[0] != '2') {
2463 strcpy(WC->ImportantMessage, &buf[4]);
2465 sprintf(WC->ImportantMessage,
2466 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2471 if (havebstr("invite_button")) {
2472 sprintf(buf, "INVT %s", username);
2474 serv_getln(buf, sizeof buf);
2476 if (buf[0] != '2') {
2477 strcpy(WC->ImportantMessage, &buf[4]);
2479 sprintf(WC->ImportantMessage,
2480 _("<B><I>User %s invited to room %s.</I></B>\n"),
2491 * Display form for Invite, Kick, and show Who Knows a room
2493 void display_whok(void)
2495 char buf[SIZ], room[SIZ], username[SIZ];
2498 serv_getln(buf, sizeof buf);
2500 if (buf[0] != '2') {
2504 extract_token(room, &buf[4], 0, '|', sizeof room);
2507 wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2508 wc_printf(_("The users listed below have access to this room. "
2509 "To remove a user from the access list, select the user "
2510 "name from the list and click 'Kick'."));
2511 wc_printf("<br /><br />");
2513 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2514 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2515 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2516 wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2518 serv_getln(buf, sizeof buf);
2519 if (buf[0] == '1') {
2520 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2521 extract_token(username, buf, 0, '|', sizeof username);
2522 wc_printf("<OPTION>");
2527 wc_printf("</select><br />\n");
2529 wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2530 wc_printf("</form></CENTER>\n");
2532 wc_printf("</td><td>");
2533 wc_printf(_("To grant another user access to this room, enter the "
2534 "user name in the box below and click 'Invite'."));
2535 wc_printf("<br /><br />");
2537 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2538 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2539 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2540 wc_printf(_("Invite:"));
2542 wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2543 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2544 "<input type=\"submit\" value=\"%s\">"
2545 "</form></CENTER>\n", _("Invite"));
2546 /* Pop open an address book -- begin **/
2548 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2550 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2553 _("Users"), _("Users")
2555 /* Pop open an address book -- end **/
2557 wc_printf("</td></tr></table>\n");
2558 address_book_popup();
2565 * display the form for entering a new room
2567 void display_entroom(void)
2574 serv_puts("CRE8 0");
2575 serv_getln(buf, sizeof buf);
2577 if (buf[0] != '2') {
2578 strcpy(WC->ImportantMessage, &buf[4]);
2579 display_main_menu();
2584 output_headers(1, 1, 1, 0, 0, 0);
2586 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2587 do_template("beginbox", NULL);
2589 wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2590 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2592 wc_printf("<table class=\"altern\"> ");
2594 wc_printf("<tr class=\"even\"><td>");
2595 wc_printf(_("Name of room: "));
2596 wc_printf("</td><td>");
2597 wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2598 wc_printf("</td></tr>");
2600 wc_printf("<tr class=\"odd\"><td>");
2601 wc_printf(_("Resides on floor: "));
2602 wc_printf("</td><td>");
2603 load_floorlist(Buf);
2604 wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2605 for (i = 0; i < 128; ++i)
2606 if (!IsEmptyStr(floorlist[i])) {
2607 wc_printf("<option ");
2608 wc_printf("value=\"%d\">", i);
2609 escputs(floorlist[i]);
2610 wc_printf("</option>\n");
2612 wc_printf("</select>\n");
2613 wc_printf("</td></tr>");
2616 * Our clever little snippet of JavaScript automatically selects
2617 * a public room if the view is set to Bulletin Board or wiki, and
2618 * it selects a mailbox room otherwise. The user can override this,
2619 * of course. We also disable the floor selector for mailboxes.
2621 wc_printf("<tr class=\"even\"><td>");
2622 wc_printf(_("Default view for room: "));
2623 wc_printf("</td><td>");
2624 wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2625 " if ( (this.form.er_view.value == 0) "
2626 " || (this.form.er_view.value == 6) ) { "
2627 " this.form.type[0].checked=true; "
2628 " this.form.er_floor.disabled = false; "
2631 " this.form.type[4].checked=true; "
2632 " this.form.er_floor.disabled = true; "
2635 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2636 if (is_view_allowed_as_default(i)) {
2637 wc_printf("<option %s value=\"%d\">",
2638 ((i == 0) ? "selected" : ""), i );
2639 escputs(viewdefs[i]);
2640 wc_printf("</option>\n");
2643 wc_printf("</select>\n");
2644 wc_printf("</td></tr>");
2646 wc_printf("<tr class=\"even\"><td>");
2647 wc_printf(_("Type of room:"));
2648 wc_printf("</td><td>");
2649 wc_printf("<ul class=\"adminlist\">\n");
2651 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2652 wc_printf("CHECKED OnChange=\""
2653 " if (this.form.type[0].checked == true) { "
2654 " this.form.er_floor.disabled = false; "
2657 wc_printf(_("Public (automatically appears to everyone)"));
2660 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2661 " if (this.form.type[1].checked == true) { "
2662 " this.form.er_floor.disabled = false; "
2665 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2668 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2669 " if (this.form.type[2].checked == true) { "
2670 " this.form.er_floor.disabled = false; "
2673 wc_printf(_("Private - require password: "));
2674 wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2677 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2678 " if (this.form.type[3].checked == true) { "
2679 " this.form.er_floor.disabled = false; "
2682 wc_printf(_("Private - invitation only"));
2685 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2687 " if (this.form.type[4].checked == true) { "
2688 " this.form.er_floor.disabled = true; "
2691 wc_printf(_("Personal (mailbox for you only)"));
2694 wc_printf("\n</ul>\n");
2695 wc_printf("</td></tr></table>\n");
2697 wc_printf("<div class=\"buttons\">\n");
2698 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2699 wc_printf(" ");
2700 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2701 wc_printf("</div>\n");
2702 wc_printf("</form>\n<hr />");
2703 serv_printf("MESG roomaccess");
2704 serv_getln(buf, sizeof buf);
2705 if (buf[0] == '1') {
2709 do_template("endbox", NULL);
2719 * support function for entroom() -- sets the default view
2721 void er_set_default_view(int newview) {
2734 serv_getln(buf, sizeof buf);
2735 if (buf[0] != '2') return;
2737 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2738 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2739 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2740 rm_bits1 = extract_int(&buf[4], 3);
2741 rm_floor = extract_int(&buf[4], 4);
2742 rm_listorder = extract_int(&buf[4], 5);
2743 rm_bits2 = extract_int(&buf[4], 7);
2745 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2746 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2747 rm_listorder, newview, rm_bits2
2749 serv_getln(buf, sizeof buf);
2760 const StrBuf *er_name;
2761 const StrBuf *er_type;
2762 const StrBuf *er_password;
2766 wcsession *WCC = WC;
2768 if (!havebstr("ok_button")) {
2769 strcpy(WC->ImportantMessage,
2770 _("Cancelled. No new room was created."));
2771 display_main_menu();
2774 er_name = sbstr("er_name");
2775 er_type = sbstr("type");
2776 er_password = sbstr("er_password");
2777 er_floor = ibstr("er_floor");
2778 er_view = ibstr("er_view");
2781 if (!strcmp(ChrPtr(er_type), "hidden"))
2783 else if (!strcmp(ChrPtr(er_type), "passworded"))
2785 else if (!strcmp(ChrPtr(er_type), "invonly"))
2787 else if (!strcmp(ChrPtr(er_type), "personal"))
2790 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2793 ChrPtr(er_password),
2798 serv_getln(buf, sizeof buf);
2799 if (buf[0] != '2') {
2800 strcpy(WCC->ImportantMessage, &buf[4]);
2801 display_main_menu();
2804 /** TODO: Room created, now update the left hand icon bar for this user */
2805 burn_folder_cache(0); /* burn the old folder cache */
2809 serv_printf("VIEW %d", er_view);
2810 serv_getln(buf, sizeof buf);
2811 WCC->CurRoom.view = er_view;
2813 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
2814 display_editroom ();
2816 do_change_view(er_view); /* Now go there */
2823 * \brief display the screen to enter a private room
2825 void display_private(char *rname, int req_pass)
2827 WCTemplputParams SubTP;
2829 output_headers(1, 1, 1, 0, 0, 0);
2831 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2832 memset(&SubTP, 0, sizeof(WCTemplputParams));
2833 SubTP.Filter.ContextType = CTX_STRBUF;
2834 SubTP.Context = Buf;
2835 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2840 wc_printf(_("If you know the name of a hidden (guess-name) or "
2841 "passworded room, you can enter that room by typing "
2842 "its name below. Once you gain access to a private "
2843 "room, it will appear in your regular room listings "
2844 "so you don't have to keep returning here."));
2847 wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2848 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2850 wc_printf("<table class=\"altern\"> "
2851 "<tr class=\"even\"><td>");
2852 wc_printf(_("Enter room name:"));
2853 wc_printf("</td><td>"
2854 "<input type=\"text\" name=\"gr_name\" "
2855 "value=\"%s\" maxlength=\"128\">\n", rname);
2858 wc_printf("</td></tr><tr class=\"odd\"><td>");
2859 wc_printf(_("Enter room password:"));
2860 wc_printf("</td><td>");
2861 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2863 wc_printf("</td></tr></table>\n");
2865 wc_printf("<div class=\"buttons\">\n");
2866 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2868 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2872 wc_printf("</div></form>\n");
2874 do_template("endbox", NULL);
2880 * \brief goto a private room
2882 void goto_private(void)
2887 if (!havebstr("ok_button")) {
2888 display_main_menu();
2891 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2892 serv_printf("GOTO %s|%s",
2895 serv_getln(buf, sizeof buf);
2897 if (buf[0] == '2') {
2898 smart_goto(sbstr("gr_name"));
2901 if (!strncmp(buf, "540", 3)) {
2902 display_private(bstr("gr_name"), 1);
2905 output_headers(1, 1, 1, 0, 0, 0);
2906 wc_printf("%s\n", &buf[4]);
2913 * \brief display the screen to zap a room
2915 void display_zap(void)
2917 output_headers(1, 1, 2, 0, 0, 0);
2919 wc_printf("<div id=\"banner\">\n");
2921 wc_printf(_("Zap (forget/unsubscribe) the current room"));
2922 wc_printf("</h1>\n");
2923 wc_printf("</div>\n");
2925 wc_printf("<div id=\"content\" class=\"service\">\n");
2927 wc_printf(_("If you select this option, <em>%s</em> will "
2928 "disappear from your room list. Is this what you wish "
2929 "to do?<br />\n"), ChrPtr(WC->CurRoom.name));
2931 wc_printf("<form method=\"POST\" action=\"zap\">\n");
2932 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2933 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2934 wc_printf(" ");
2935 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2936 wc_printf("</form>\n");
2947 StrBuf *final_destination;
2950 * If the forget-room routine fails for any reason, we fall back
2951 * to the current room; otherwise, we go to the Lobby
2953 final_destination = NewStrBufDup(WC->CurRoom.name);
2955 if (havebstr("ok_button")) {
2956 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
2957 serv_getln(buf, sizeof buf);
2958 if (buf[0] == '2') {
2960 serv_getln(buf, sizeof buf);
2961 if (buf[0] == '2') {
2962 FlushStrBuf(final_destination);
2963 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2967 smart_goto(final_destination);
2968 FreeStrBuf(&final_destination);
2974 * \brief Delete the current room
2976 void delete_room(void)
2981 serv_puts("KILL 1");
2982 serv_getln(buf, sizeof buf);
2983 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2984 if (buf[0] != '2') {
2985 strcpy(WC->ImportantMessage, &buf[4]);
2986 display_main_menu();
2991 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
3000 * \brief Perform changes to a room's network configuration
3002 void netedit(void) {
3011 /*/ TODO: do line dynamic! */
3012 if (havebstr("line_pop3host")) {
3013 strcpy(line, bstr("prefix"));
3014 strcat(line, bstr("line_pop3host"));
3016 strcat(line, bstr("line_pop3user"));
3018 strcat(line, bstr("line_pop3pass"));
3020 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
3022 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
3023 strcat(line, bstr("suffix"));
3025 else if (havebstr("line")) {
3026 strcpy(line, bstr("prefix"));
3027 strcat(line, bstr("line"));
3028 strcat(line, bstr("suffix"));
3043 serv_getln(buf, sizeof buf);
3044 if (buf[0] != '1') {
3050 /** This loop works for add *or* remove. Spiffy, eh? */
3051 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3052 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
3053 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
3054 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
3055 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
3056 if ( (strcasecmp(cmpa0, cmpb0))
3057 || (strcasecmp(cmpa1, cmpb1)) ) {
3058 fprintf(fp, "%s\n", buf);
3064 serv_getln(buf, sizeof buf);
3065 if (buf[0] != '4') {
3071 while (fgets(buf, sizeof buf, fp) != NULL) {
3072 buf[strlen(buf)-1] = 0;
3076 if (havebstr("add_button")) {
3077 num_addrs = num_tokens(bstr("line"), ',');
3078 if (num_addrs < 2) {
3079 /* just adding one node or address */
3083 /* adding multiple addresses separated by commas */
3084 for (i=0; i<num_addrs; ++i) {
3085 strcpy(line, bstr("prefix"));
3086 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3089 strcat(line, bstr("suffix"));
3103 * \brief Convert a room name to a folder-ish-looking name.
3104 * \param folder the folderish name
3105 * \param room the room name
3106 * \param floor the floor name
3107 * \param is_mailbox is it a mailbox?
3109 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3114 * For mailboxes, just do it straight...
3117 sprintf(folder, "My folders|%s", room);
3121 * Otherwise, prefix the floor name as a "public folders" moniker
3124 if (floor > MAX_FLOORS) {
3126 sprintf(folder, "%%%%%%|%s", room);
3129 sprintf(folder, "%s|%s", floorlist[floor], room);
3134 * Replace "\" characters with "|" for pseudo-folder-delimiting
3136 len = strlen (folder);
3137 for (i=0; i<len; ++i) {
3138 if (folder[i] == '\\') folder[i] = '|';
3146 * \brief Back end for change_view()
3147 * \param newview set newview???
3149 void do_change_view(int newview) {
3152 serv_printf("VIEW %d", newview);
3153 serv_getln(buf, sizeof buf);
3154 WC->CurRoom.view = newview;
3155 smart_goto(WC->CurRoom.name);
3161 * \brief Change the view for this room
3163 void change_view(void) {
3166 view = lbstr("view");
3167 do_change_view(view);
3171 * \brief Burn the cached folder list.
3172 * \param age How old the cahce needs to be before we burn it.
3175 void burn_folder_cache(time_t age)
3177 /** If our cached folder list is very old, burn it. */
3178 if (WC->cache_fold != NULL) {
3179 if ((time(NULL) - WC->cache_timestamp) > age) {
3180 free(WC->cache_fold);
3181 WC->cache_fold = NULL;
3189 * \brief Do either a known rooms list or a folders list, depending on the
3194 StrBuf *ListView = NULL;
3196 /** Determine whether the user is trying to change views */
3197 if (havebstr("view")) {
3198 ListView = NewStrBufDup(SBSTR("view"));
3199 set_preference("roomlistview", ListView, 1);
3201 /** Sanitize the input so its safe */
3202 if((get_preference("roomlistview", &ListView) != 0)||
3203 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3204 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3206 if (ListView == NULL) {
3207 ListView = NewStrBufPlain(HKEY("rooms"));
3208 set_preference("roomlistview", ListView, 0);
3212 ListView = NewStrBufPlain(HKEY("rooms"));
3213 set_preference("roomlistview", ListView, 0);
3217 FreeStrBuf(&ListView);
3224 * \brief Set the message expire policy for this room and/or floor
3226 void set_room_policy(void) {
3229 if (!havebstr("ok_button")) {
3230 strcpy(WC->ImportantMessage,
3231 _("Cancelled. Changes were not saved."));
3236 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3237 serv_getln(buf, sizeof buf);
3238 strcpy(WC->ImportantMessage, &buf[4]);
3240 if (WC->axlevel >= 6) {
3241 strcat(WC->ImportantMessage, "<br />\n");
3242 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3243 serv_getln(buf, sizeof buf);
3244 strcat(WC->ImportantMessage, &buf[4]);
3250 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3252 StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3256 void _display_private(void) {
3257 display_private("", 0);
3260 void dotgoto(void) {
3261 if (!havebstr("room")) {
3262 readloop(readnew, eUseDefault);
3265 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3268 smart_goto(sbstr("room"));
3273 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3275 wcsession *WCC = WC;
3278 StrBufAppendTemplate(Target, TP,
3283 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3285 wc_printf("<div id=\"banner\">\n");
3286 embed_room_banner();
3287 wc_printf("</div>\n");
3291 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3293 wcsession *WCC = WC;
3296 (!IsEmptyStr(WCC->ugname)))
3297 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3300 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3302 wcsession *WCC = WC;
3303 return (WCC != NULL)?
3304 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3307 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3309 wcsession *WCC = WC;
3310 return (WCC == NULL)? 0 :
3311 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3312 (WCC->CurRoom.is_inbox) ||
3313 (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3316 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3318 wcsession *WCC = WC;
3320 return ((WCC!=NULL) &&
3321 (!IsEmptyStr(WCC->ugname)) &&
3322 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3326 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
3328 folder *Folder = (folder *)(TP->Context);
3331 UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3332 if (UA_CheckFlag == 0)
3333 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3334 "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
3336 return ((Folder->RAFlags & UA_CheckFlag) != 0);
3341 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3344 wcsession *WCC = WC;
3346 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3347 if (QR_CheckFlag == 0)
3348 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3349 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3351 return ((WCC!=NULL) &&
3352 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3355 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3358 folder *Folder = (folder *)(TP->Context);
3360 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3361 if (QR_CheckFlag == 0)
3362 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3363 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3364 return ((Folder->QRFlags & QR_CheckFlag) != 0);
3368 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3371 wcsession *WCC = WC;
3373 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3374 if (QR2_CheckFlag == 0)
3375 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3376 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3378 return ((WCC!=NULL) &&
3379 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3382 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3385 folder *Folder = (folder *)(TP->Context);
3387 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3388 if (QR2_CheckFlag == 0)
3389 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3390 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3391 return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3395 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3397 wcsession *WCC = WC;
3399 return ( (WCC!= NULL) &&
3400 ((WCC->axlevel >= 6) ||
3401 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3402 (WCC->CurRoom.is_inbox) ));
3405 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3407 wcsession *WCC = WC;
3409 if ((WCC == NULL) ||
3410 (TP->Tokens->nParameters < 3))
3412 return ((WCC->CurRoom.view < VIEW_BBS) ||
3413 (WCC->CurRoom.view > VIEW_MAX));
3416 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3420 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
3422 wcsession *WCC = WC;
3426 HashList *Whok = NULL;
3432 Token = NewStrBuf();
3433 StrBuf_ServGetln(Line);
3434 if (GetServerStatus(Line, &State) == 1)
3436 Whok = NewHash(1, Flathash);
3437 while(!Done && StrBuf_ServGetln(Line))
3438 if ( (StrLength(Line)==3) &&
3439 !strcmp(ChrPtr(Line), "000"))
3446 const char *Pos = NULL;
3447 Token = NewStrBufPlain (NULL, StrLength(Line));
3448 StrBufExtract_NextToken(Token, Line, &Pos, '|');
3456 else if (State == 550)
3457 StrBufAppendBufPlain(WCC->ImportantMsg,
3458 _("Higher access is required to access this function."), -1, 0);
3468 initialize_viewdefs();
3469 RegisterPreference("roomlistview",
3470 _("Room list view"),
3473 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3475 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3478 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3479 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3480 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3481 WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3482 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3483 WebcitAddUrlHandler(HKEY("zapped_list"), "", 0, zapped_list, 0);
3484 WebcitAddUrlHandler(HKEY("display_zap"), "", 0, display_zap, 0);
3485 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3486 WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3487 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3488 WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3489 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3490 WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3491 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3492 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3493 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3494 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3495 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3496 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3497 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3499 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3500 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3501 RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3503 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3504 RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3505 RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
3507 RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
3508 RegisterNamespace("THISROOM:MSGS:NEW", 0, 0, tmplput_CurrentRoom_nNewMessages, NULL, CTX_NONE);
3509 RegisterNamespace("THISROOM:MSGS:TOTAL", 0, 0, tmplput_CurrentRoom_nTotalMessages, NULL, CTX_NONE);
3511 RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
3512 RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3513 RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3514 RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3515 RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3516 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3517 RegisterConditional(HKEY("COND:THISROOM:HAVE_VIEW"), 0, ConditionalThisRoomHaveView, CTX_NONE);
3518 RegisterNamespace("THISROOM:VIEW_STRING", 0, 1, tmplput_CurrentRoomViewString, NULL, CTX_NONE);
3519 RegisterNamespace("ROOM:VIEW_STRING", 1, 2, tmplput_RoomViewString, NULL, CTX_NONE);
3521 RegisterNamespace("THISROOM:INFOTEXT", 1, 2, tmplput_CurrentRoomInfoText, NULL, CTX_NONE);
3522 RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3523 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3524 RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
3525 RegisterConditional(HKEY("COND:THISROOM:HAVE_INFOTEXT"), 0, ConditionalThisRoomXHaveInfoText, CTX_NONE);
3526 RegisterNamespace("THISROOM:FILES:N", 0, 1, tmplput_CurrentRoomXNFiles, NULL, CTX_NONE);
3527 RegisterNamespace("THISROOM:FILES:STR", 0, 1, tmplput_CurrentRoomX_FileString, NULL, CTX_NONE);
3529 REGISTERTokenParamDefine(QR_PERMANENT);
3530 REGISTERTokenParamDefine(QR_INUSE);
3531 REGISTERTokenParamDefine(QR_PRIVATE);
3532 REGISTERTokenParamDefine(QR_PASSWORDED);
3533 REGISTERTokenParamDefine(QR_GUESSNAME);
3534 REGISTERTokenParamDefine(QR_DIRECTORY);
3535 REGISTERTokenParamDefine(QR_UPLOAD);
3536 REGISTERTokenParamDefine(QR_DOWNLOAD);
3537 REGISTERTokenParamDefine(QR_VISDIR);
3538 REGISTERTokenParamDefine(QR_ANONONLY);
3539 REGISTERTokenParamDefine(QR_ANONOPT);
3540 REGISTERTokenParamDefine(QR_NETWORK);
3541 REGISTERTokenParamDefine(QR_PREFONLY);
3542 REGISTERTokenParamDefine(QR_READONLY);
3543 REGISTERTokenParamDefine(QR_MAILBOX);
3544 REGISTERTokenParamDefine(QR2_SYSTEM);
3545 REGISTERTokenParamDefine(QR2_SELFLIST);
3546 REGISTERTokenParamDefine(QR2_COLLABDEL);
3547 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3548 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3549 REGISTERTokenParamDefine(QR2_MODERATED);
3551 REGISTERTokenParamDefine(UA_KNOWN);
3552 REGISTERTokenParamDefine(UA_GOTOALLOWED);
3553 REGISTERTokenParamDefine(UA_HASNEWMSGS);
3554 REGISTERTokenParamDefine(UA_ZAPPED);
3555 REGISTERTokenParamDefine(UA_POSTALLOWED);
3556 REGISTERTokenParamDefine(UA_ADMINALLOWED);
3557 REGISTERTokenParamDefine(UA_DELETEALLOWED);
3558 REGISTERTokenParamDefine(UA_ISTRASH);
3560 REGISTERTokenParamDefine(US_NEEDVALID);
3561 REGISTERTokenParamDefine(US_PERM);
3562 REGISTERTokenParamDefine(US_LASTOLD);
3563 REGISTERTokenParamDefine(US_EXPERT);
3564 REGISTERTokenParamDefine(US_UNLISTED);
3565 REGISTERTokenParamDefine(US_NOPROMPT);
3566 REGISTERTokenParamDefine(US_PROMPTCTL);
3567 REGISTERTokenParamDefine(US_DISAPPEAR);
3568 REGISTERTokenParamDefine(US_REGIS);
3569 REGISTERTokenParamDefine(US_PAGINATOR);
3570 REGISTERTokenParamDefine(US_INTERNET);
3571 REGISTERTokenParamDefine(US_FLOORS);
3572 REGISTERTokenParamDefine(US_COLOR);
3573 REGISTERTokenParamDefine(US_USER_SET);
3575 REGISTERTokenParamDefine(VIEW_BBS);
3576 REGISTERTokenParamDefine(VIEW_MAILBOX);
3577 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3578 REGISTERTokenParamDefine(VIEW_CALENDAR);
3579 REGISTERTokenParamDefine(VIEW_TASKS);
3580 REGISTERTokenParamDefine(VIEW_NOTES);
3581 REGISTERTokenParamDefine(VIEW_WIKI);
3582 REGISTERTokenParamDefine(VIEW_CALBRIEF);
3583 REGISTERTokenParamDefine(VIEW_JOURNAL);
3584 REGISTERTokenParamDefine(VIEW_BLOG);
3587 REGISTERTokenParamDefine(ignet_push_share);
3588 { /* these are the parts of an IGNET push config */
3589 REGISTERTokenParamDefine(GNET_IGNET_NODE);
3590 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
3592 REGISTERTokenParamDefine(listrecp);
3593 REGISTERTokenParamDefine(digestrecp);
3594 REGISTERTokenParamDefine(pop3client);
3595 { /* These are the parts of a pop3 client line... */
3596 REGISTERTokenParamDefine(GNET_POP3_HOST);
3597 REGISTERTokenParamDefine(GNET_POP3_USER);
3598 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
3599 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
3601 REGISTERTokenParamDefine(rssclient);
3602 REGISTERTokenParamDefine(participate);
3604 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3605 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3607 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3608 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3610 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3611 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3612 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3619 SessionDestroyModule_ROOMOPS
3622 FlushFolder(&sess->CurRoom);
3623 if (sess->cache_fold != NULL) {
3624 free(sess->cache_fold);
3627 free_march_list(sess);
3628 DeleteHash(&sess->Floors);
3629 DeleteHash(&sess->Rooms);
3630 DeleteHash(&sess->FloorsByName);