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(" ");
227 * Embed the room banner
229 * got The information returned from a GOTO server command
230 * navbar_style Determines which navigation buttons to display
234 void embed_room_banner(void)
239 /* refresh current room states... */
240 /* dosen't work??? gotoroom(NULL); */
242 /* The browser needs some information for its own use */
243 wc_printf("<script type=\"text/javascript\"> \n"
244 " room_is_trash = %d; \n"
246 ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
250 * If the user happens to select the "make this my start page" link,
251 * we want it to remember the URL as a "/dotskip" one instead of
252 * a "skip" or "gotonext" or something like that.
254 if (WCC->Hdr->this_page == NULL) {
255 WCC->Hdr->this_page = NewStrBuf();
257 StrBufPrintf(WCC->Hdr->this_page,
259 ChrPtr(WC->CurRoom.name)
262 do_template("roombanner", NULL);
263 /* roombanner contains this for mobile */
268 wc_printf("<div id=\"navbar\"><ul>");
271 "<li class=\"ungoto\">"
272 "<a href=\"ungoto\">"
273 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
274 "<span class=\"navbar_link\">%s</span></A>"
275 "</li>\n", _("Ungoto")
278 if (WC->CurRoom.view == VIEW_BBS) {
280 "<li class=\"newmess\">"
281 "<a href=\"readnew\">"
282 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
283 "<span class=\"navbar_link\">%s</span></A>"
284 "</li>\n", _("Read new messages")
288 switch(WC->CurRoom.view) {
289 case VIEW_ADDRESSBOOK:
291 "<li class=\"viewcontacts\">"
292 "<a href=\"readfwd\">"
293 "<img src=\"static/viewcontacts_24x.gif\" "
294 "alt=\"\" width=\"24\" height=\"24\">"
295 "<span class=\"navbar_link\">"
297 "</span></a></li>\n", _("View contacts")
302 "<li class=\"staskday\">"
303 "<a href=\"readfwd?calview=day\">"
304 "<img src=\"static/taskday2_24x.gif\" "
305 "alt=\"\" width=\"24\" height=\"24\">"
306 "<span class=\"navbar_link\">"
308 "</span></a></li>\n", _("Day view")
311 "<li class=\"monthview\">"
312 "<a href=\"readfwd?calview=month\">"
313 "<img src=\"static/monthview2_24x.gif\" "
314 "alt=\"\" width=\"24\" height=\"24\">"
315 "<span class=\"navbar_link\">"
317 "</span></a></li>\n", _("Month view")
322 "<li class=\"monthview\">"
323 "<a href=\"readfwd?calview=month\">"
324 "<img src=\"static/monthview2_24x.gif\" "
325 "alt=\"\" width=\"24\" height=\"24\">"
326 "<span class=\"navbar_link\">"
328 "</span></a></li>\n", _("Calendar list")
333 "<li class=\"taskmanag\">"
334 "<a href=\"readfwd\">"
335 "<img src=\"static/taskmanag_24x.gif\" "
336 "alt=\"\" width=\"24\" height=\"24\">"
337 "<span class=\"navbar_link\">"
339 "</span></a></li>\n", _("View tasks")
344 "<li class=\"viewnotes\">"
345 "<a href=\"readfwd\">"
346 "<img src=\"static/viewnotes_24x.gif\" "
347 "alt=\"\" width=\"24\" height=\"24\">"
348 "<span class=\"navbar_link\">"
350 "</span></a></li>\n", _("View notes")
355 "<li class=\"readallmess\">"
356 "<a id=\"m_refresh\" href=\"readfwd\">"
357 "<img src=\"static/readallmess3_24x.gif\" "
358 "alt=\"\" width=\"24\" height=\"24\">"
359 "<span class=\"navbar_link\">"
361 "</span></a></li>\n", _("Refresh message list")
366 "<li class=\"readallmess\">"
367 "<a href=\"wiki?page=home\">"
368 "<img src=\"static/readallmess3_24x.gif\" "
369 "alt=\"\" width=\"24\" height=\"24\">"
370 "<span class=\"navbar_link\">"
372 "</span></a></li>\n", _("Wiki home")
377 "<li class=\"readallmess\">"
378 "<a href=\"readfwd\">"
379 "<img src=\"static/readallmess3_24x.gif\" "
380 "alt=\"\" width=\"24\" height=\"24\">"
381 "<span class=\"navbar_link\">"
383 "</span></a></li>\n", _("Read all messages")
388 switch(WC->CurRoom.view) {
389 case VIEW_ADDRESSBOOK:
391 "<li class=\"addnewcontact\">"
392 "<a href=\"display_enter\">"
393 "<img src=\"static/addnewcontact_24x.gif\" "
394 "alt=\"\" width=\"24\" height=\"24\">"
395 "<span class=\"navbar_link\">"
397 "</span></a></li>\n", _("Add new contact")
402 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
403 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
404 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
405 if (havebstr("day" )) wc_printf("?day=%s", bstr("day"));
407 "<img src=\"static/addevent_24x.gif\" "
408 "alt=\"\" width=\"24\" height=\"24\">"
409 "<span class=\"navbar_link\">"
411 "</span></a></li>\n", _("Add new event")
416 "<li class=\"newmess\">"
417 "<a href=\"display_enter\">"
418 "<img src=\"static/newmess3_24x.gif\" "
419 "alt=\"\" width=\"24\" height=\"24\">"
420 "<span class=\"navbar_link\">"
422 "</span></a></li>\n", _("Add new task")
427 "<li class=\"enternewnote\">"
428 "<a href=\"add_new_note\">"
429 "<img src=\"static/enternewnote_24x.gif\" "
430 "alt=\"\" width=\"24\" height=\"24\">"
431 "<span class=\"navbar_link\">"
433 "</span></a></li>\n", _("Add new note")
437 safestrncpy(buf, bstr("page"), sizeof buf);
438 if (IsEmptyStr(buf)) {
439 safestrncpy(buf, "home", sizeof buf);
443 "<li class=\"newmess\">"
444 "<a href=\"display_enter?page=%s\">"
445 "<img src=\"static/newmess3_24x.gif\" "
446 "alt=\"\" width=\"24\" height=\"24\">"
447 "<span class=\"navbar_link\">"
449 "</span></a></li>\n", buf, _("Edit this page")
452 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
453 /* already viewing history; display a link to the current page */
455 "<li class=\"newmess\">"
456 "<a href=\"wiki?page=%s\">"
457 "<img src=\"static/newmess3_24x.gif\" "
458 "alt=\"\" width=\"24\" height=\"24\">"
459 "<span class=\"navbar_link\">"
461 "</span></a></li>\n", buf, _("Current version")
465 /* display a link to the history */
467 "<li class=\"newmess\">"
468 "<a href=\"wiki_history?page=%s\">"
469 "<img src=\"static/newmess3_24x.gif\" "
470 "alt=\"\" width=\"24\" height=\"24\">"
471 "<span class=\"navbar_link\">"
473 "</span></a></li>\n", buf, _("History")
479 "<li class=\"newmess\">"
480 "<a href=\"display_enter\">"
481 "<img src=\"static/newmess3_24x.gif\" "
482 "alt=\"\" width=\"24\" height=\"24\">"
483 "<span class=\"navbar_link\">"
485 "</span></a></li>\n", _("Write mail")
488 "<li class=\"newmess\">"
489 "<a href=\"javascript:deleteAllSelectedMessages();\">"
490 "<img src=\"static/delete.gif\" "
491 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
493 "</span></a></li>\n", _("Delete")
498 "<li class=\"newmess\">"
499 "<a href=\"display_enter\">"
500 "<img src=\"static/newmess3_24x.gif\" "
501 "alt=\"\" width=\"24\" height=\"24\">"
502 "<span class=\"navbar_link\">"
504 "</span></a></li>\n", _("Enter a message")
510 "<li class=\"skipthisroom\">"
513 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
514 "width=\"24\" height=\"24\">"
515 "<span class=\"navbar_link\">%s</span></a>"
517 _("Leave all messages marked as unread, go to next room with unread messages"),
522 "<li class=\"markngo\">"
523 "<a href=\"gotonext\" "
525 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
526 "width=\"24\" height=\"24\">"
527 "<span class=\"navbar_link\">%s</span></a>"
529 _("Mark all messages as read, go to next room with unread messages"),
533 wc_printf("</ul></div>\n");
538 * back end routine to take the session to a new room
540 long gotoroom(const StrBuf *gname)
544 static long ls = (-1L);
547 /* store ungoto information */
548 if (StrLength(gname) > 0)
549 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
553 /* move to the new room */
554 if (StrLength(gname) > 0)
555 serv_printf("GOTO %s", ChrPtr(gname));
556 else /* or just refresh the current state... */
557 serv_printf("GOTO 00000000000000000000");
558 StrBuf_ServGetln(Buf);
559 if (GetServerStatus(Buf, &err) != 2) {
560 serv_puts("GOTO _BASEROOM_");
561 StrBuf_ServGetln(Buf);
563 * well, we know that this is the fallback case,
564 * but we're interested that the first command
565 * didn't work out in first place.
567 if (GetServerStatus(Buf, NULL) != 2) {
572 ParseGoto(&WCC->CurRoom, Buf);
574 if (StrLength(gname) > 0)
576 remove_march(WCC->CurRoom.name);
577 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
586 void ParseGoto(folder *room, StrBuf *Line)
594 if (StrLength(Line) < 4) {
598 /* ignore the commandstate... */
599 Pos = ChrPtr(Line) + 4;
601 if (room->RoomNameParts != NULL)
604 for (i=0; i < room->nRoomNameParts; i++)
605 FreeStrBuf(&room->RoomNameParts[i]);
606 free(room->RoomNameParts);
607 room->RoomNameParts = NULL;
612 pBuf = NewStrBufPlain(NULL, StrLength(Line));
615 memset(room, 0, sizeof(folder));
618 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
620 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
621 if (room->nNewMessages > 0)
622 room->RAFlags |= UA_HASNEWMSGS;
624 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
626 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
628 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
630 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
631 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
633 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
635 flag = StrBufExtractNext_long(Line, &Pos, '|');
636 if (WCC->is_aide || flag) {
637 room->RAFlags |= UA_ADMINALLOWED;
640 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
642 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
644 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
646 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
648 flag = StrBufExtractNext_long(Line, &Pos, '|');
650 room->RAFlags |= UA_ISTRASH; // wc_is_trash
652 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
654 /* find out, whether we are in a sub-room */
655 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
656 if (room->nRoomNameParts > 1)
661 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
662 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
663 for (i=0; i < room->nRoomNameParts; i++)
665 room->RoomNameParts[i] = NewStrBuf();
666 StrBufExtract_NextToken(room->RoomNameParts[i],
667 room->name, &Pos, '\\');
671 /* Private mailboxes on the main floor get remapped to the personal folder */
672 if ((room->QRFlags & QR_MAILBOX) &&
673 (room->floorid == 0))
675 room->floorid = VIRTUAL_MY_FLOOR;
676 if ((room->nRoomNameParts == 1) &&
677 (StrLength(room->name) == 4) &&
678 (strcmp(ChrPtr(room->name), "Mail") == 0))
684 /* get a pointer to the floor we're on: */
685 if (WCC->Floors == NULL)
686 GetFloorListHash(NULL, NULL);
688 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
689 room->Floor = (const Floor*) vFloor;
692 void LoadRoomAide(void)
697 if (WCC->CurRoom.RoomAideLoaded)
700 WCC->CurRoom.RoomAideLoaded = 1;
703 StrBuf_ServGetln(Buf);
704 if (GetServerStatus(Buf, NULL) != 2) {
705 FlushStrBuf(WCC->CurRoom.RoomAide);
706 AppendImportantMessage (ChrPtr(Buf) + 4,
711 Pos = ChrPtr(Buf) + 4;
713 FreeStrBuf(&WCC->CurRoom.RoomAide);
714 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
716 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
720 void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
723 folder *Folder = &WCC->CurRoom;
724 const Floor *pFloor = Folder->Floor;
729 StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
732 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
738 StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
742 void LoadRoomXA (void)
747 if (WCC->CurRoom.XALoaded)
750 WCC->CurRoom.XALoaded = 1;
753 StrBuf_ServGetln(Buf);
754 if (GetServerStatus(Buf, NULL) != 2) {
755 FlushStrBuf(WCC->CurRoom.XAPass);
756 FlushStrBuf(WCC->CurRoom.Directory);
758 AppendImportantMessage (ChrPtr(Buf) + 4,
763 Pos = ChrPtr(Buf) + 4;
765 FreeStrBuf(&WCC->CurRoom.XAPass);
766 FreeStrBuf(&WCC->CurRoom.Directory);
768 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
769 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
771 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
772 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
773 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
774 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
775 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
776 /* defview, we already know you. */
777 /* QR2Flags, we already know them... */
784 void LoadXRoomPic(void)
789 if (WCC->CurRoom.XHaveRoomPicLoaded)
792 WCC->CurRoom.XHaveRoomPicLoaded = 1;
794 serv_puts("OIMG _roompic_");
795 StrBuf_ServGetln(Buf);
796 if (GetServerStatus(Buf, NULL) != 2) {
797 WCC->CurRoom.XHaveRoomPic = 0;
799 WCC->CurRoom.XHaveRoomPic = 1;
802 StrBuf_ServGetln(Buf);
803 GetServerStatus(Buf, NULL);
807 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
815 return WCC->CurRoom.XHaveRoomPic == 1;
818 void LoadXRoomInfoText(void)
824 if (WCC->CurRoom.XHaveInfoTextLoaded)
827 WCC->CurRoom.XHaveInfoTextLoaded = 1;
832 StrBuf_ServGetln(Buf);
833 if (GetServerStatus(Buf, NULL) == 1) {
834 WCC->CurRoom.XInfoText = NewStrBuf ();
836 while (!Done && StrBuf_ServGetln(Buf)>=0) {
837 if ( (StrLength(Buf)==3) &&
838 !strcmp(ChrPtr(Buf), "000"))
841 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
848 int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
856 return (StrLength(WCC->CurRoom.XInfoText)>0);
859 void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
865 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1);
868 void LoadXRoomXCountFiles(void)
874 if (WCC->CurRoom.XHaveDownloadCount)
877 WCC->CurRoom.XHaveDownloadCount = 1;
881 StrBuf_ServGetln(Buf);
882 if (GetServerStatus(Buf, NULL) == 1) {
884 while (!Done && StrBuf_ServGetln(Buf)>=0) {
885 if ( (StrLength(Buf)==3) &&
886 !strcmp(ChrPtr(Buf), "000"))
889 WCC->CurRoom.XDownloadCount++;
896 void tmplput_CurrentRoomXNFiles(StrBuf *Target, WCTemplputParams *TP)
900 LoadXRoomXCountFiles();
902 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.XDownloadCount);
905 void tmplput_CurrentRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
909 LoadXRoomXCountFiles();
911 if (WCC->CurRoom.XDownloadCount == 1)
912 StrBufAppendBufPlain(Target, _("file"), -1, 0);
914 StrBufAppendBufPlain(Target, _("files"), -1, 0);
917 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
923 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
925 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
931 StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
933 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
939 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
941 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
945 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.defview);
948 void tmplput_CurrentRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP)
954 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
957 void tmplput_CurrentRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP)
963 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nTotalMessages);
966 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
976 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
977 return CheckThis == WCC->CurRoom.Order;
980 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
988 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
989 return CheckThis == WCC->CurRoom.defview;
992 int ConditionalThisRoomCurrView(StrBuf *Target, WCTemplputParams *TP)
1000 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1001 return CheckThis == WCC->CurRoom.view;
1004 int ConditionalThisRoomHaveView(StrBuf *Target, WCTemplputParams *TP)
1006 wcsession *WCC = WC;
1012 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1013 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
1015 LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
1016 "Roomview [%ld] not valid\n",
1021 return exchangeable_views [WCC->CurRoom.defview][CheckThis] != VIEW_MAX;
1024 void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
1026 wcsession *WCC = WC;
1029 if ((WCC == NULL) ||
1030 (WCC->CurRoom.defview >= VIEW_MAX) ||
1031 (WCC->CurRoom.defview < VIEW_BBS))
1033 LogTemplateError(Target, "Token", ERR_PARM2, TP,
1034 "Roomview [%ld] not valid\n",
1036 WCC->CurRoom.defview : -1);
1040 Buf = NewStrBufPlain(_(viewdefs[WCC->CurRoom.defview]), -1);
1041 StrBufAppendTemplate(Target, TP, Buf, 0);
1045 void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
1050 CheckThis = GetTemplateTokenNumber(Target, TP, 0, 0);
1051 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
1053 LogTemplateError(Target, "Token", ERR_PARM2, TP,
1054 "Roomview [%ld] not valid\n",
1059 Buf = NewStrBufPlain(_(viewdefs[CheckThis]), -1);
1060 StrBufAppendTemplate(Target, TP, Buf, 0);
1068 void smart_goto(const StrBuf *next_room) {
1069 gotoroom(next_room);
1070 readloop(readnew, eUseDefault);
1076 * mark all messages in current room as having been read
1078 void slrp_highest(void)
1082 serv_puts("SLRP HIGHEST");
1083 serv_getln(buf, sizeof buf);
1087 typedef struct __room_states {
1102 * Set/clear/read the "self-service list subscribe" flag for a room
1104 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1105 * returns the new value.
1108 int self_service(int newval) {
1109 int current_value = 0;
1115 int flags, floor, order, view, flags2;
1118 serv_getln(buf, sizeof buf);
1119 if (buf[0] != '2') return(0);
1121 extract_token(name, &buf[4], 0, '|', sizeof name);
1122 extract_token(password, &buf[4], 1, '|', sizeof password);
1123 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1124 flags = extract_int(&buf[4], 3);
1125 floor = extract_int(&buf[4], 4);
1126 order = extract_int(&buf[4], 5);
1127 view = extract_int(&buf[4], 6);
1128 flags2 = extract_int(&buf[4], 7);
1130 if (flags2 & QR2_SELFLIST) {
1138 flags2 = flags2 | QR2_SELFLIST;
1140 else if (newval == 0) {
1141 flags2 = flags2 & ~QR2_SELFLIST;
1144 return(current_value);
1147 if (newval != current_value) {
1148 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1149 name, password, dirname, flags,
1150 floor, order, view, flags2);
1151 serv_getln(buf, sizeof buf);
1158 int is_selflist(room_states *RoomFlags)
1160 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1163 int is_publiclist(room_states *RoomFlags)
1165 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1168 int is_moderatedlist(room_states *RoomFlags)
1170 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1174 * Set/clear/read the "self-service list subscribe" flag for a room
1176 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1177 * returns the new value.
1180 int get_roomflags(room_states *RoomOps)
1185 serv_getln(buf, sizeof buf);
1186 if (buf[0] != '2') return(0);
1188 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1189 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1190 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1191 RoomOps->flags = extract_int(&buf[4], 3);
1192 RoomOps->floor = extract_int(&buf[4], 4);
1193 RoomOps->order = extract_int(&buf[4], 5);
1194 RoomOps->view = extract_int(&buf[4], 6);
1195 RoomOps->flags2 = extract_int(&buf[4], 7);
1199 int set_roomflags(room_states *RoomOps)
1203 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1212 serv_getln(buf, sizeof buf);
1222 * display the form for editing a room
1224 void display_editroom(void)
1230 char remote_room[128];
1233 char er_password[10];
1234 char er_dirname[15];
1235 char er_roomaide[26];
1242 char *not_shared_with = NULL;
1245 int floorpolicy = 0;
1247 char pop3_host[128];
1252 if (IsEmptyStr(tab)) tab = "admin";
1255 load_floorlist(Buf);
1257 output_headers(1, 1, 1, 0, 0, 0);
1259 wc_printf("<div class=\"fix_scrollbar_bug\">");
1261 wc_printf("<br />\n");
1263 /* print the tabbed dialog */
1264 wc_printf("<div align=\"center\">");
1265 wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1266 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1269 wc_printf("<td class=\"");
1270 if (!strcmp(tab, "admin")) {
1271 wc_printf(" tab_cell_label\">");
1272 wc_printf(_("Administration"));
1275 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1276 wc_printf(_("Administration"));
1279 wc_printf("</td>\n");
1280 wc_printf("<td> </td>\n");
1282 if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1284 wc_printf("<td class=\"");
1285 if (!strcmp(tab, "config")) {
1286 wc_printf(" tab_cell_label\">");
1287 wc_printf(_("Configuration"));
1290 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1291 wc_printf(_("Configuration"));
1294 wc_printf("</td>\n");
1295 wc_printf("<td> </td>\n");
1297 wc_printf("<td class=\"");
1298 if (!strcmp(tab, "expire")) {
1299 wc_printf(" tab_cell_label\">");
1300 wc_printf(_("Message expire policy"));
1303 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1304 wc_printf(_("Message expire policy"));
1307 wc_printf("</td>\n");
1308 wc_printf("<td> </td>\n");
1310 wc_printf("<td class=\"");
1311 if (!strcmp(tab, "access")) {
1312 wc_printf(" tab_cell_label\">");
1313 wc_printf(_("Access controls"));
1316 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1317 wc_printf(_("Access controls"));
1320 wc_printf("</td>\n");
1321 wc_printf("<td> </td>\n");
1323 wc_printf("<td class=\"");
1324 if (!strcmp(tab, "sharing")) {
1325 wc_printf(" tab_cell_label\">");
1326 wc_printf(_("Sharing"));
1329 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1330 wc_printf(_("Sharing"));
1333 wc_printf("</td>\n");
1334 wc_printf("<td> </td>\n");
1336 wc_printf("<td class=\"");
1337 if (!strcmp(tab, "listserv")) {
1338 wc_printf(" tab_cell_label\">");
1339 wc_printf(_("Mailing list service"));
1342 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1343 wc_printf(_("Mailing list service"));
1346 wc_printf("</td>\n");
1347 wc_printf("<td> </td>\n");
1351 wc_printf("<td class=\"");
1352 if (!strcmp(tab, "feeds")) {
1353 wc_printf(" tab_cell_label\">");
1354 wc_printf(_("Remote retrieval"));
1357 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1358 wc_printf(_("Remote retrieval"));
1361 wc_printf("</td>\n");
1362 wc_printf("<td> </td>\n");
1364 wc_printf("</tr></table>\n");
1365 wc_printf("</div>\n");
1366 /* end tabbed dialog */
1368 wc_printf("<script type=\"text/javascript\">"
1369 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1373 /* begin content of whatever tab is open now */
1375 if (!strcmp(tab, "admin")) {
1376 wc_printf("<div class=\"tabcontent\">");
1378 "<li><a href=\"delete_room\" "
1379 "onClick=\"return confirm('");
1380 wc_printf(_("Are you sure you want to delete this room?"));
1381 wc_printf("');\">\n");
1382 wc_printf(_("Delete this room"));
1384 "<li><a href=\"display_editroompic?which_room=");
1385 urlescputs(ChrPtr(WC->CurRoom.name));
1387 wc_printf(_("Set or change the icon for this room's banner"));
1389 "<li><a href=\"display_editinfo\">\n");
1390 wc_printf(_("Edit this room's Info file"));
1393 wc_printf("</div>");
1396 if (!strcmp(tab, "config")) {
1397 wc_printf("<div class=\"tabcontent\">");
1399 serv_getln(buf, sizeof buf);
1401 if (!strncmp(buf, "550", 3)) {
1402 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1403 _("Higher access is required to access this function.")
1406 else if (buf[0] != '2') {
1407 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1410 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1411 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1412 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1413 er_flags = extract_int(&buf[4], 3);
1414 er_floor = extract_int(&buf[4], 4);
1415 er_flags2 = extract_int(&buf[4], 7);
1417 wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1418 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1420 wc_printf("<ul><li>");
1421 wc_printf(_("Name of room: "));
1422 wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1428 wc_printf(_("Resides on floor: "));
1429 wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1430 if (er_flags & QR_MAILBOX)
1431 wc_printf("disabled >\n");
1432 for (i = 0; i < 128; ++i)
1433 if (!IsEmptyStr(floorlist[i])) {
1434 wc_printf("<OPTION ");
1436 wc_printf("SELECTED ");
1437 wc_printf("VALUE=\"%d\">", i);
1438 escputs(floorlist[i]);
1439 wc_printf("</OPTION>\n");
1441 wc_printf("</select>\n");
1444 wc_printf(_("Type of room:"));
1445 wc_printf("<ul>\n");
1447 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1448 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1449 wc_printf("CHECKED ");
1450 wc_printf("OnChange=\""
1451 " if (this.form.type[0].checked == true) { "
1452 " this.form.er_floor.disabled = false; "
1455 wc_printf(_("Public (automatically appears to everyone)"));
1458 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1459 if ((er_flags & QR_PRIVATE) &&
1460 (er_flags & QR_GUESSNAME))
1461 wc_printf("CHECKED ");
1462 wc_printf(" OnChange=\""
1463 " if (this.form.type[1].checked == true) { "
1464 " this.form.er_floor.disabled = false; "
1467 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1469 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1470 if ((er_flags & QR_PRIVATE) &&
1471 (er_flags & QR_PASSWORDED))
1472 wc_printf("CHECKED ");
1473 wc_printf(" OnChange=\""
1474 " if (this.form.type[2].checked == true) { "
1475 " this.form.er_floor.disabled = false; "
1478 wc_printf(_("Private - require password: "));
1479 wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1482 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1483 if ((er_flags & QR_PRIVATE)
1484 && ((er_flags & QR_GUESSNAME) == 0)
1485 && ((er_flags & QR_PASSWORDED) == 0))
1486 wc_printf("CHECKED ");
1487 wc_printf(" OnChange=\""
1488 " if (this.form.type[3].checked == true) { "
1489 " this.form.er_floor.disabled = false; "
1492 wc_printf(_("Private - invitation only"));
1494 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1495 if (er_flags & QR_MAILBOX)
1496 wc_printf("CHECKED ");
1497 wc_printf (" OnChange=\""
1498 " if (this.form.type[4].checked == true) { "
1499 " this.form.er_floor.disabled = true; "
1502 wc_printf(_("Personal (mailbox for you only)"));
1504 wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1506 wc_printf(_("If private, cause current users to forget room"));
1508 wc_printf("\n</ul>\n");
1510 wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1511 if (er_flags & QR_PREFONLY)
1512 wc_printf("CHECKED ");
1514 wc_printf(_("Preferred users only"));
1516 wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1517 if (er_flags & QR_READONLY)
1518 wc_printf("CHECKED ");
1520 wc_printf(_("Read-only room"));
1522 wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1523 if (er_flags2 & QR2_COLLABDEL)
1524 wc_printf("CHECKED ");
1526 wc_printf(_("All users allowed to post may also delete messages"));
1528 /** directory stuff */
1529 wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1530 if (er_flags & QR_DIRECTORY)
1531 wc_printf("CHECKED ");
1533 wc_printf(_("File directory room"));
1535 wc_printf("\n<ul><li>");
1536 wc_printf(_("Directory name: "));
1537 wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1540 wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1541 if (er_flags & QR_UPLOAD)
1542 wc_printf("CHECKED ");
1544 wc_printf(_("Uploading allowed"));
1546 wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1547 if (er_flags & QR_DOWNLOAD)
1548 wc_printf("CHECKED ");
1550 wc_printf(_("Downloading allowed"));
1552 wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1553 if (er_flags & QR_VISDIR)
1554 wc_printf("CHECKED ");
1556 wc_printf(_("Visible directory"));
1557 wc_printf("</ul>\n");
1559 /** end of directory stuff */
1561 wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1562 if (er_flags & QR_NETWORK)
1563 wc_printf("CHECKED ");
1565 wc_printf(_("Network shared room"));
1567 wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1568 if (er_flags & QR_PERMANENT)
1569 wc_printf("CHECKED ");
1571 wc_printf(_("Permanent (does not auto-purge)"));
1573 wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1574 if (er_flags2 & QR2_SUBJECTREQ)
1575 wc_printf("CHECKED ");
1577 wc_printf(_("Subject Required (Force users to specify a message subject)"));
1579 /** start of anon options */
1581 wc_printf("\n<li>");
1582 wc_printf(_("Anonymous messages"));
1583 wc_printf("<ul>\n");
1585 wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1586 if (((er_flags & QR_ANONONLY) == 0)
1587 && ((er_flags & QR_ANONOPT) == 0))
1588 wc_printf("CHECKED ");
1590 wc_printf(_("No anonymous messages"));
1592 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1593 if (er_flags & QR_ANONONLY)
1594 wc_printf("CHECKED ");
1596 wc_printf(_("All messages are anonymous"));
1598 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1599 if (er_flags & QR_ANONOPT)
1600 wc_printf("CHECKED ");
1602 wc_printf(_("Prompt user when entering messages"));
1603 wc_printf("</ul>\n");
1605 /* end of anon options */
1608 wc_printf(_("Room aide: "));
1610 serv_getln(buf, sizeof buf);
1611 if (buf[0] != '2') {
1612 wc_printf("<em>%s</em>\n", &buf[4]);
1614 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1615 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1618 wc_printf("</ul><CENTER>\n");
1619 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1620 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1622 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1628 wc_printf("</div>");
1632 /* Sharing the room with other Citadel nodes... */
1633 if (!strcmp(tab, "sharing")) {
1634 wc_printf("<div class=\"tabcontent\">");
1636 shared_with = strdup("");
1637 not_shared_with = strdup("");
1639 /** Learn the current configuration */
1640 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1641 serv_getln(buf, sizeof buf);
1642 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1643 extract_token(node, buf, 0, '|', sizeof node);
1644 not_shared_with = realloc(not_shared_with,
1645 strlen(not_shared_with) + 32);
1646 strcat(not_shared_with, node);
1647 strcat(not_shared_with, "\n");
1651 serv_getln(buf, sizeof buf);
1652 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1653 extract_token(cmd, buf, 0, '|', sizeof cmd);
1654 extract_token(node, buf, 1, '|', sizeof node);
1655 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1656 if (!strcasecmp(cmd, "ignet_push_share")) {
1657 shared_with = realloc(shared_with,
1658 strlen(shared_with) + 32);
1659 strcat(shared_with, node);
1660 if (!IsEmptyStr(remote_room)) {
1661 strcat(shared_with, "|");
1662 strcat(shared_with, remote_room);
1664 strcat(shared_with, "\n");
1668 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1669 extract_token(buf, shared_with, i, '\n', sizeof buf);
1670 extract_token(node, buf, 0, '|', sizeof node);
1671 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1672 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1673 if (!strcasecmp(node, cmd)) {
1674 remove_token(not_shared_with, j, '\n');
1679 /* Display the stuff */
1680 wc_printf("<CENTER><br />"
1681 "<table border=1 cellpadding=5><tr>"
1683 wc_printf(_("Shared with"));
1684 wc_printf("</I></B></td>"
1686 wc_printf(_("Not shared with"));
1687 wc_printf("</I></B></td></tr>\n"
1688 "<tr><td VALIGN=TOP>\n");
1690 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1691 wc_printf(_("Remote node name"));
1692 wc_printf("</td><td>");
1693 wc_printf(_("Remote room name"));
1694 wc_printf("</td><td>");
1695 wc_printf(_("Actions"));
1696 wc_printf("</td></tr>\n");
1698 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1699 extract_token(buf, shared_with, i, '\n', sizeof buf);
1700 extract_token(node, buf, 0, '|', sizeof node);
1701 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1702 if (!IsEmptyStr(node)) {
1703 wc_printf("<form method=\"POST\" action=\"netedit\">");
1704 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1705 wc_printf("<tr><td>%s</td>\n", node);
1708 if (!IsEmptyStr(remote_room)) {
1709 escputs(remote_room);
1715 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1716 "VALUE=\"ignet_push_share|");
1718 if (!IsEmptyStr(remote_room)) {
1720 urlescputs(remote_room);
1723 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1724 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1725 wc_printf("<input type=\"submit\" "
1726 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1727 wc_printf("</td></tr></form>\n");
1731 wc_printf("</table>\n");
1732 wc_printf("</td><td VALIGN=TOP>\n");
1733 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1734 wc_printf(_("Remote node name"));
1735 wc_printf("</td><td>");
1736 wc_printf(_("Remote room name"));
1737 wc_printf("</td><td>");
1738 wc_printf(_("Actions"));
1739 wc_printf("</td></tr>\n");
1741 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1742 extract_token(node, not_shared_with, i, '\n', sizeof node);
1743 if (!IsEmptyStr(node)) {
1744 wc_printf("<form method=\"POST\" action=\"netedit\">");
1745 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1746 wc_printf("<tr><td>");
1748 wc_printf("</td><td>"
1749 "<input type=\"INPUT\" "
1753 wc_printf("<input type=\"hidden\" "
1755 "VALUE=\"ignet_push_share|");
1758 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1759 "VALUE=\"sharing\">\n");
1760 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1761 "VALUE=\"add\">\n");
1762 wc_printf("<input type=\"submit\" "
1763 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1764 wc_printf("</td></tr></form>\n");
1768 wc_printf("</table>\n");
1769 wc_printf("</td></tr>"
1770 "</table></CENTER><br />\n"
1771 "<I><B>%s</B><ul><li>", _("Notes:"));
1772 wc_printf(_("When sharing a room, "
1773 "it must be shared from both ends. Adding a node to "
1774 "the 'shared' list sends messages out, but in order to"
1775 " receive messages, the other nodes must be configured"
1776 " to send messages out to your system as well. "
1777 "<li>If the remote room name is blank, it is assumed "
1778 "that the room name is identical on the remote node."
1779 "<li>If the remote room name is different, the remote "
1780 "node must also configure the name of the room here."
1784 wc_printf("</div>");
1787 if (not_shared_with != NULL)
1788 free (not_shared_with);
1790 /* Mailing list management */
1791 if (!strcmp(tab, "listserv")) {
1792 room_states RoomFlags;
1793 wc_printf("<div class=\"tabcontent\">");
1795 wc_printf("<br /><center>"
1796 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1797 "<tr><td VALIGN=TOP>");
1799 wc_printf(_("<i>The contents of this room are being "
1800 "mailed <b>as individual messages</b> "
1801 "to the following list recipients:"
1802 "</i><br /><br />\n"));
1805 serv_getln(buf, sizeof buf);
1806 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1807 extract_token(cmd, buf, 0, '|', sizeof cmd);
1808 if (!strcasecmp(cmd, "listrecp")) {
1809 extract_token(recp, buf, 1, '|', sizeof recp);
1812 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1815 wc_printf(_("(remove)"));
1816 wc_printf("</A><br />");
1819 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1820 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1821 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1822 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1823 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1824 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1825 wc_printf("</form>\n");
1827 wc_printf("</td><td VALIGN=TOP>\n");
1829 wc_printf(_("<i>The contents of this room are being "
1830 "mailed <b>in digest form</b> "
1831 "to the following list recipients:"
1832 "</i><br /><br />\n"));
1835 serv_getln(buf, sizeof buf);
1836 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1837 extract_token(cmd, buf, 0, '|', sizeof cmd);
1838 if (!strcasecmp(cmd, "digestrecp")) {
1839 extract_token(recp, buf, 1, '|', sizeof recp);
1842 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1846 wc_printf(_("(remove)"));
1847 wc_printf("</A><br />");
1850 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1851 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1852 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1853 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1854 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1855 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1856 wc_printf("</form>\n");
1858 wc_printf("</td></tr></table>\n");
1860 /** Pop open an address book -- begin **/
1861 wc_printf("<div align=right>"
1862 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1864 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1869 _("Add recipients from Contacts or other address books"),
1870 _("Add recipients from Contacts or other address books")
1872 /* Pop open an address book -- end **/
1874 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1876 get_roomflags (&RoomFlags);
1878 /* Self Service subscription? */
1879 wc_printf("<table><tr><td>\n");
1880 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1881 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1882 " <tr><td colspan=\"2\">\n",
1883 (is_selflist(&RoomFlags))?"checked":"");
1884 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1885 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1886 (is_https ? "https" : "http"),
1887 ChrPtr(WC->Hdr->HR.http_host));
1888 /* Public posting? */
1889 wc_printf("<tr><td>");
1890 wc_printf(_("Allow non-subscribers to mail to this room."));
1891 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1892 (is_publiclist(&RoomFlags))?"checked":"");
1894 /* Moderated List? */
1895 wc_printf("<tr><td>");
1896 wc_printf(_("Room post publication needs Aide permission."));
1897 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1898 (is_moderatedlist(&RoomFlags))?"checked":"");
1901 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1902 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1903 wc_printf("</table></form>");
1906 wc_printf("</CENTER>\n");
1907 wc_printf("</div>");
1911 /* Configuration of The Dreaded Auto-Purger */
1912 if (!strcmp(tab, "expire")) {
1913 wc_printf("<div class=\"tabcontent\">");
1915 serv_puts("GPEX room");
1916 serv_getln(buf, sizeof buf);
1917 if (!strncmp(buf, "550", 3)) {
1918 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1919 _("Higher access is required to access this function.")
1922 else if (buf[0] != '2') {
1923 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1926 roompolicy = extract_int(&buf[4], 0);
1927 roomvalue = extract_int(&buf[4], 1);
1929 serv_puts("GPEX floor");
1930 serv_getln(buf, sizeof buf);
1931 if (buf[0] == '2') {
1932 floorpolicy = extract_int(&buf[4], 0);
1933 floorvalue = extract_int(&buf[4], 1);
1936 wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1937 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1938 wc_printf("<table border=0 cellspacing=5>\n");
1939 wc_printf("<tr><td>");
1940 wc_printf(_("Message expire policy for this room"));
1941 wc_printf("<br />(");
1942 escputs(ChrPtr(WC->CurRoom.name));
1943 wc_printf(")</td><td>");
1944 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1945 ((roompolicy == 0) ? "CHECKED" : "") );
1946 wc_printf(_("Use the default policy for this floor"));
1947 wc_printf("<br />\n");
1948 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1949 ((roompolicy == 1) ? "CHECKED" : "") );
1950 wc_printf(_("Never automatically expire messages"));
1951 wc_printf("<br />\n");
1952 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1953 ((roompolicy == 2) ? "CHECKED" : "") );
1954 wc_printf(_("Expire by message count"));
1955 wc_printf("<br />\n");
1956 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1957 ((roompolicy == 3) ? "CHECKED" : "") );
1958 wc_printf(_("Expire by message age"));
1959 wc_printf("<br />");
1960 wc_printf(_("Number of messages or days: "));
1961 wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1962 wc_printf("</td></tr>\n");
1964 if (WC->axlevel >= 6) {
1965 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1966 wc_printf("<tr><td>");
1967 wc_printf(_("Message expire policy for this floor"));
1968 wc_printf("<br />(");
1969 escputs(floorlist[WC->CurRoom.floorid]);
1970 wc_printf(")</td><td>");
1971 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1972 ((floorpolicy == 0) ? "CHECKED" : "") );
1973 wc_printf(_("Use the system default"));
1974 wc_printf("<br />\n");
1975 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1976 ((floorpolicy == 1) ? "CHECKED" : "") );
1977 wc_printf(_("Never automatically expire messages"));
1978 wc_printf("<br />\n");
1979 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1980 ((floorpolicy == 2) ? "CHECKED" : "") );
1981 wc_printf(_("Expire by message count"));
1982 wc_printf("<br />\n");
1983 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1984 ((floorpolicy == 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=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1992 wc_printf("<CENTER>\n");
1993 wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1994 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1995 wc_printf(" ");
1996 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1997 wc_printf("</CENTER></td><tr>\n");
1999 wc_printf("</table>\n"
2000 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
2005 wc_printf("</div>");
2008 /* Access controls */
2009 if (!strcmp(tab, "access")) {
2010 wc_printf("<div class=\"tabcontent\">");
2012 wc_printf("</div>");
2015 /* Fetch messages from remote locations */
2016 if (!strcmp(tab, "feeds")) {
2017 wc_printf("<div class=\"tabcontent\">");
2020 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
2021 wc_printf("</i><br />\n");
2023 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2024 "<tr class=\"even\"><th>");
2025 wc_printf(_("Remote host"));
2026 wc_printf("</th><th>");
2027 wc_printf(_("User name"));
2028 wc_printf("</th><th>");
2029 wc_printf(_("Password"));
2030 wc_printf("</th><th>");
2031 wc_printf(_("Keep messages on server?"));
2032 wc_printf("</th><th>");
2033 wc_printf(_("Interval"));
2034 wc_printf("</th><th> </th></tr>");
2037 serv_getln(buf, sizeof buf);
2039 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2040 extract_token(cmd, buf, 0, '|', sizeof cmd);
2041 if (!strcasecmp(cmd, "pop3client")) {
2042 safestrncpy(recp, &buf[11], sizeof recp);
2045 wc_printf("<tr class=\"%s\">",
2046 (bg ? "even" : "odd")
2050 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2055 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2059 wc_printf("<td>*****</td>"); /* Don't show the password */
2061 wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2063 wc_printf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2065 wc_printf("<td class=\"button_link\">");
2066 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2069 wc_printf(_("(remove)"));
2070 wc_printf("</a></td>");
2076 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2078 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2079 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2080 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2082 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2085 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2088 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2091 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2094 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2097 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2098 wc_printf("</td></tr>");
2099 wc_printf("</form></table>\n");
2101 wc_printf("<hr>\n");
2104 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2105 wc_printf("</i><br />\n");
2107 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2108 "<tr class=\"even\"><th>");
2109 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2110 wc_printf(_("Feed URL"));
2111 wc_printf("</th><th>");
2112 wc_printf("</th></tr>");
2115 serv_getln(buf, sizeof buf);
2117 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2118 extract_token(cmd, buf, 0, '|', sizeof cmd);
2119 if (!strcasecmp(cmd, "rssclient")) {
2120 safestrncpy(recp, &buf[10], sizeof recp);
2123 wc_printf("<tr class=\"%s\">",
2124 (bg ? "even" : "odd")
2128 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2132 wc_printf("<td class=\"button_link\">");
2133 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2136 wc_printf(_("(remove)"));
2137 wc_printf("</a></td>");
2143 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2145 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2146 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2147 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2149 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2150 "maxlength=\"256\" name=\"line_pop3host\">\n");
2153 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2154 wc_printf("</td></tr>");
2155 wc_printf("</form></table>\n");
2157 wc_printf("</div>");
2161 /* end content of whatever tab is open now */
2162 wc_printf("</div>\n");
2164 address_book_popup();
2170 * Toggle self-service list subscription
2172 void toggle_self_service(void) {
2173 room_states RoomFlags;
2175 get_roomflags (&RoomFlags);
2177 if (yesbstr("QR2_SelfList"))
2178 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2180 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2182 if (yesbstr("QR2_SMTP_PUBLIC"))
2183 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2185 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2187 if (yesbstr("QR2_Moderated"))
2188 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2190 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2191 if (yesbstr("QR2_SubsOnly"))
2192 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2194 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2196 set_roomflags (&RoomFlags);
2204 * save new parameters for a room
2211 StrBuf *er_password;
2213 StrBuf *er_roomaide;
2216 int er_listingorder;
2222 if (!havebstr("ok_button")) {
2223 strcpy(WC->ImportantMessage,
2224 _("Cancelled. Changes were not saved."));
2230 StrBuf_ServGetln(Buf);
2231 if (GetServerStatus(Buf, NULL) != 2) {
2232 StrBufCutLeft(Buf, 4);
2233 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2239 er_name = NewStrBuf();
2240 er_password = NewStrBuf();
2241 er_dirname = NewStrBuf();
2242 er_roomaide = NewStrBuf();
2244 StrBufCutLeft(Buf, 4);
2245 StrBufExtract_token(er_name, Buf, 0, '|');
2246 StrBufExtract_token(er_password, Buf, 1, '|');
2247 StrBufExtract_token(er_dirname, Buf, 2, '|');
2248 er_flags = StrBufExtract_int(Buf, 3, '|');
2249 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2250 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2251 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2253 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2254 if (StrLength(er_roomaide) == 0) {
2256 StrBuf_ServGetln(Buf);
2257 if (GetServerStatus(Buf, NULL) != 2) {
2258 FlushStrBuf(er_roomaide);
2260 StrBufCutLeft(Buf, 4);
2261 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2264 Ptr = sbstr("er_name");
2265 if (StrLength(Ptr) > 0) {
2266 FlushStrBuf(er_name);
2267 StrBufAppendBuf(er_name, Ptr, 0);
2270 Ptr = sbstr("er_password");
2271 if (StrLength(Ptr) > 0) {
2272 FlushStrBuf(er_password);
2273 StrBufAppendBuf(er_password, Ptr, 0);
2277 Ptr = sbstr("er_dirname");
2278 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2279 FlushStrBuf(er_dirname);
2280 StrBufAppendBuf(er_dirname, Ptr, 0);
2284 Ptr = sbstr("type");
2285 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2287 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2288 er_flags |= (QR_PRIVATE);
2290 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2291 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2293 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2294 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2296 if (!strcmp(ChrPtr(Ptr), "personal")) {
2297 er_flags |= QR_MAILBOX;
2299 er_flags &= ~QR_MAILBOX;
2302 if (yesbstr("prefonly")) {
2303 er_flags |= QR_PREFONLY;
2305 er_flags &= ~QR_PREFONLY;
2308 if (yesbstr("readonly")) {
2309 er_flags |= QR_READONLY;
2311 er_flags &= ~QR_READONLY;
2315 if (yesbstr("collabdel")) {
2316 er_flags2 |= QR2_COLLABDEL;
2318 er_flags2 &= ~QR2_COLLABDEL;
2321 if (yesbstr("permanent")) {
2322 er_flags |= QR_PERMANENT;
2324 er_flags &= ~QR_PERMANENT;
2327 if (yesbstr("subjectreq")) {
2328 er_flags2 |= QR2_SUBJECTREQ;
2330 er_flags2 &= ~QR2_SUBJECTREQ;
2333 if (yesbstr("network")) {
2334 er_flags |= QR_NETWORK;
2336 er_flags &= ~QR_NETWORK;
2339 if (yesbstr("directory")) {
2340 er_flags |= QR_DIRECTORY;
2342 er_flags &= ~QR_DIRECTORY;
2345 if (yesbstr("ulallowed")) {
2346 er_flags |= QR_UPLOAD;
2348 er_flags &= ~QR_UPLOAD;
2351 if (yesbstr("dlallowed")) {
2352 er_flags |= QR_DOWNLOAD;
2354 er_flags &= ~QR_DOWNLOAD;
2357 if (yesbstr("visdir")) {
2358 er_flags |= QR_VISDIR;
2360 er_flags &= ~QR_VISDIR;
2363 Ptr = sbstr("anon");
2365 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2366 if (!strcmp(ChrPtr(Ptr), "anononly"))
2367 er_flags |= QR_ANONONLY;
2368 if (!strcmp(ChrPtr(Ptr), "anon2"))
2369 er_flags |= QR_ANONOPT;
2371 bump = yesbstr("bump");
2373 er_floor = ibstr("er_floor");
2375 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2377 ChrPtr(er_password),
2386 StrBuf_ServGetln(Buf);
2387 if (GetServerStatus(Buf, NULL) != 2) {
2388 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2391 FreeStrBuf(&er_name);
2392 FreeStrBuf(&er_password);
2393 FreeStrBuf(&er_dirname);
2394 FreeStrBuf(&er_roomaide);
2399 if (StrLength(er_roomaide) > 0) {
2400 serv_printf("SETA %s", ChrPtr(er_roomaide));
2401 StrBuf_ServGetln(Buf);
2402 if (GetServerStatus(Buf, NULL) != 2) {
2403 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2404 display_main_menu();
2406 FreeStrBuf(&er_name);
2407 FreeStrBuf(&er_password);
2408 FreeStrBuf(&er_dirname);
2409 FreeStrBuf(&er_roomaide);
2414 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2417 FreeStrBuf(&er_name);
2418 FreeStrBuf(&er_password);
2419 FreeStrBuf(&er_dirname);
2420 FreeStrBuf(&er_roomaide);
2426 * Display form for Invite, Kick, and show Who Knows a room
2428 void do_invt_kick(void) {
2429 char buf[SIZ], room[SIZ], username[SIZ];
2432 serv_getln(buf, sizeof buf);
2434 if (buf[0] != '2') {
2438 extract_token(room, &buf[4], 0, '|', sizeof room);
2440 strcpy(username, bstr("username"));
2442 if (havebstr("kick_button")) {
2443 sprintf(buf, "KICK %s", username);
2445 serv_getln(buf, sizeof buf);
2447 if (buf[0] != '2') {
2448 strcpy(WC->ImportantMessage, &buf[4]);
2450 sprintf(WC->ImportantMessage,
2451 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2456 if (havebstr("invite_button")) {
2457 sprintf(buf, "INVT %s", username);
2459 serv_getln(buf, sizeof buf);
2461 if (buf[0] != '2') {
2462 strcpy(WC->ImportantMessage, &buf[4]);
2464 sprintf(WC->ImportantMessage,
2465 _("<B><I>User %s invited to room %s.</I></B>\n"),
2476 * Display form for Invite, Kick, and show Who Knows a room
2478 void display_whok(void)
2480 char buf[SIZ], room[SIZ], username[SIZ];
2483 serv_getln(buf, sizeof buf);
2485 if (buf[0] != '2') {
2489 extract_token(room, &buf[4], 0, '|', sizeof room);
2492 wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2493 wc_printf(_("The users listed below have access to this room. "
2494 "To remove a user from the access list, select the user "
2495 "name from the list and click 'Kick'."));
2496 wc_printf("<br /><br />");
2498 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2499 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2500 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2501 wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2503 serv_getln(buf, sizeof buf);
2504 if (buf[0] == '1') {
2505 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2506 extract_token(username, buf, 0, '|', sizeof username);
2507 wc_printf("<OPTION>");
2512 wc_printf("</select><br />\n");
2514 wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2515 wc_printf("</form></CENTER>\n");
2517 wc_printf("</td><td>");
2518 wc_printf(_("To grant another user access to this room, enter the "
2519 "user name in the box below and click 'Invite'."));
2520 wc_printf("<br /><br />");
2522 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2523 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2524 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2525 wc_printf(_("Invite:"));
2527 wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2528 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2529 "<input type=\"submit\" value=\"%s\">"
2530 "</form></CENTER>\n", _("Invite"));
2531 /* Pop open an address book -- begin **/
2533 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2535 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2538 _("Users"), _("Users")
2540 /* Pop open an address book -- end **/
2542 wc_printf("</td></tr></table>\n");
2543 address_book_popup();
2550 * display the form for entering a new room
2552 void display_entroom(void)
2559 serv_puts("CRE8 0");
2560 serv_getln(buf, sizeof buf);
2562 if (buf[0] != '2') {
2563 strcpy(WC->ImportantMessage, &buf[4]);
2564 display_main_menu();
2569 output_headers(1, 1, 1, 0, 0, 0);
2571 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2572 do_template("beginbox", NULL);
2574 wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2575 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2577 wc_printf("<table class=\"altern\"> ");
2579 wc_printf("<tr class=\"even\"><td>");
2580 wc_printf(_("Name of room: "));
2581 wc_printf("</td><td>");
2582 wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2583 wc_printf("</td></tr>");
2585 wc_printf("<tr class=\"odd\"><td>");
2586 wc_printf(_("Resides on floor: "));
2587 wc_printf("</td><td>");
2588 load_floorlist(Buf);
2589 wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2590 for (i = 0; i < 128; ++i)
2591 if (!IsEmptyStr(floorlist[i])) {
2592 wc_printf("<option ");
2593 wc_printf("value=\"%d\">", i);
2594 escputs(floorlist[i]);
2595 wc_printf("</option>\n");
2597 wc_printf("</select>\n");
2598 wc_printf("</td></tr>");
2601 * Our clever little snippet of JavaScript automatically selects
2602 * a public room if the view is set to Bulletin Board or wiki, and
2603 * it selects a mailbox room otherwise. The user can override this,
2604 * of course. We also disable the floor selector for mailboxes.
2606 wc_printf("<tr class=\"even\"><td>");
2607 wc_printf(_("Default view for room: "));
2608 wc_printf("</td><td>");
2609 wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2610 " if ( (this.form.er_view.value == 0) "
2611 " || (this.form.er_view.value == 6) ) { "
2612 " this.form.type[0].checked=true; "
2613 " this.form.er_floor.disabled = false; "
2616 " this.form.type[4].checked=true; "
2617 " this.form.er_floor.disabled = true; "
2620 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2621 if (is_view_allowed_as_default(i)) {
2622 wc_printf("<option %s value=\"%d\">",
2623 ((i == 0) ? "selected" : ""), i );
2624 escputs(viewdefs[i]);
2625 wc_printf("</option>\n");
2628 wc_printf("</select>\n");
2629 wc_printf("</td></tr>");
2631 wc_printf("<tr class=\"even\"><td>");
2632 wc_printf(_("Type of room:"));
2633 wc_printf("</td><td>");
2634 wc_printf("<ul class=\"adminlist\">\n");
2636 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2637 wc_printf("CHECKED OnChange=\""
2638 " if (this.form.type[0].checked == true) { "
2639 " this.form.er_floor.disabled = false; "
2642 wc_printf(_("Public (automatically appears to everyone)"));
2645 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2646 " if (this.form.type[1].checked == true) { "
2647 " this.form.er_floor.disabled = false; "
2650 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2653 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2654 " if (this.form.type[2].checked == true) { "
2655 " this.form.er_floor.disabled = false; "
2658 wc_printf(_("Private - require password: "));
2659 wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2662 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2663 " if (this.form.type[3].checked == true) { "
2664 " this.form.er_floor.disabled = false; "
2667 wc_printf(_("Private - invitation only"));
2670 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2672 " if (this.form.type[4].checked == true) { "
2673 " this.form.er_floor.disabled = true; "
2676 wc_printf(_("Personal (mailbox for you only)"));
2679 wc_printf("\n</ul>\n");
2680 wc_printf("</td></tr></table>\n");
2682 wc_printf("<div class=\"buttons\">\n");
2683 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2684 wc_printf(" ");
2685 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2686 wc_printf("</div>\n");
2687 wc_printf("</form>\n<hr />");
2688 serv_printf("MESG roomaccess");
2689 serv_getln(buf, sizeof buf);
2690 if (buf[0] == '1') {
2694 do_template("endbox", NULL);
2704 * support function for entroom() -- sets the default view
2706 void er_set_default_view(int newview) {
2719 serv_getln(buf, sizeof buf);
2720 if (buf[0] != '2') return;
2722 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2723 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2724 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2725 rm_bits1 = extract_int(&buf[4], 3);
2726 rm_floor = extract_int(&buf[4], 4);
2727 rm_listorder = extract_int(&buf[4], 5);
2728 rm_bits2 = extract_int(&buf[4], 7);
2730 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2731 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2732 rm_listorder, newview, rm_bits2
2734 serv_getln(buf, sizeof buf);
2745 const StrBuf *er_name;
2746 const StrBuf *er_type;
2747 const StrBuf *er_password;
2751 wcsession *WCC = WC;
2753 if (!havebstr("ok_button")) {
2754 strcpy(WC->ImportantMessage,
2755 _("Cancelled. No new room was created."));
2756 display_main_menu();
2759 er_name = sbstr("er_name");
2760 er_type = sbstr("type");
2761 er_password = sbstr("er_password");
2762 er_floor = ibstr("er_floor");
2763 er_view = ibstr("er_view");
2766 if (!strcmp(ChrPtr(er_type), "hidden"))
2768 else if (!strcmp(ChrPtr(er_type), "passworded"))
2770 else if (!strcmp(ChrPtr(er_type), "invonly"))
2772 else if (!strcmp(ChrPtr(er_type), "personal"))
2775 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2778 ChrPtr(er_password),
2783 serv_getln(buf, sizeof buf);
2784 if (buf[0] != '2') {
2785 strcpy(WCC->ImportantMessage, &buf[4]);
2786 display_main_menu();
2789 /** TODO: Room created, now update the left hand icon bar for this user */
2790 burn_folder_cache(0); /* burn the old folder cache */
2794 serv_printf("VIEW %d", er_view);
2795 serv_getln(buf, sizeof buf);
2796 WCC->CurRoom.view = er_view;
2798 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
2799 display_editroom ();
2801 do_change_view(er_view); /* Now go there */
2808 * \brief display the screen to enter a private room
2810 void display_private(char *rname, int req_pass)
2812 WCTemplputParams SubTP;
2814 output_headers(1, 1, 1, 0, 0, 0);
2816 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2817 memset(&SubTP, 0, sizeof(WCTemplputParams));
2818 SubTP.Filter.ContextType = CTX_STRBUF;
2819 SubTP.Context = Buf;
2820 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2825 wc_printf(_("If you know the name of a hidden (guess-name) or "
2826 "passworded room, you can enter that room by typing "
2827 "its name below. Once you gain access to a private "
2828 "room, it will appear in your regular room listings "
2829 "so you don't have to keep returning here."));
2832 wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2833 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2835 wc_printf("<table class=\"altern\"> "
2836 "<tr class=\"even\"><td>");
2837 wc_printf(_("Enter room name:"));
2838 wc_printf("</td><td>"
2839 "<input type=\"text\" name=\"gr_name\" "
2840 "value=\"%s\" maxlength=\"128\">\n", rname);
2843 wc_printf("</td></tr><tr class=\"odd\"><td>");
2844 wc_printf(_("Enter room password:"));
2845 wc_printf("</td><td>");
2846 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2848 wc_printf("</td></tr></table>\n");
2850 wc_printf("<div class=\"buttons\">\n");
2851 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2853 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2857 wc_printf("</div></form>\n");
2859 do_template("endbox", NULL);
2865 * \brief goto a private room
2867 void goto_private(void)
2872 if (!havebstr("ok_button")) {
2873 display_main_menu();
2876 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2877 serv_printf("GOTO %s|%s",
2880 serv_getln(buf, sizeof buf);
2882 if (buf[0] == '2') {
2883 smart_goto(sbstr("gr_name"));
2886 if (!strncmp(buf, "540", 3)) {
2887 display_private(bstr("gr_name"), 1);
2890 output_headers(1, 1, 1, 0, 0, 0);
2891 wc_printf("%s\n", &buf[4]);
2904 StrBuf *final_destination;
2907 * If the forget-room routine fails for any reason, we fall back
2908 * to the current room; otherwise, we go to the Lobby
2910 final_destination = NewStrBufDup(WC->CurRoom.name);
2912 if (havebstr("ok_button")) {
2913 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
2914 serv_getln(buf, sizeof buf);
2915 if (buf[0] == '2') {
2917 serv_getln(buf, sizeof buf);
2918 if (buf[0] == '2') {
2919 FlushStrBuf(final_destination);
2920 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2925 smart_goto(final_destination);
2926 FreeStrBuf(&final_destination);
2932 * \brief Delete the current room
2934 void delete_room(void)
2939 serv_puts("KILL 1");
2940 serv_getln(buf, sizeof buf);
2941 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2943 if (buf[0] != '2') {
2944 strcpy(WC->ImportantMessage, &buf[4]);
2945 display_main_menu();
2950 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2959 * \brief Perform changes to a room's network configuration
2961 void netedit(void) {
2970 /*/ TODO: do line dynamic! */
2971 if (havebstr("line_pop3host")) {
2972 strcpy(line, bstr("prefix"));
2973 strcat(line, bstr("line_pop3host"));
2975 strcat(line, bstr("line_pop3user"));
2977 strcat(line, bstr("line_pop3pass"));
2979 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2981 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2982 strcat(line, bstr("suffix"));
2984 else if (havebstr("line")) {
2985 strcpy(line, bstr("prefix"));
2986 strcat(line, bstr("line"));
2987 strcat(line, bstr("suffix"));
3002 serv_getln(buf, sizeof buf);
3003 if (buf[0] != '1') {
3009 /** This loop works for add *or* remove. Spiffy, eh? */
3010 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3011 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
3012 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
3013 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
3014 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
3015 if ( (strcasecmp(cmpa0, cmpb0))
3016 || (strcasecmp(cmpa1, cmpb1)) ) {
3017 fprintf(fp, "%s\n", buf);
3023 serv_getln(buf, sizeof buf);
3024 if (buf[0] != '4') {
3030 while (fgets(buf, sizeof buf, fp) != NULL) {
3031 buf[strlen(buf)-1] = 0;
3035 if (havebstr("add_button")) {
3036 num_addrs = num_tokens(bstr("line"), ',');
3037 if (num_addrs < 2) {
3038 /* just adding one node or address */
3042 /* adding multiple addresses separated by commas */
3043 for (i=0; i<num_addrs; ++i) {
3044 strcpy(line, bstr("prefix"));
3045 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3048 strcat(line, bstr("suffix"));
3062 * \brief Convert a room name to a folder-ish-looking name.
3063 * \param folder the folderish name
3064 * \param room the room name
3065 * \param floor the floor name
3066 * \param is_mailbox is it a mailbox?
3068 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3073 * For mailboxes, just do it straight...
3076 sprintf(folder, "My folders|%s", room);
3080 * Otherwise, prefix the floor name as a "public folders" moniker
3083 if (floor > MAX_FLOORS) {
3085 sprintf(folder, "%%%%%%|%s", room);
3088 sprintf(folder, "%s|%s", floorlist[floor], room);
3093 * Replace "\" characters with "|" for pseudo-folder-delimiting
3095 len = strlen (folder);
3096 for (i=0; i<len; ++i) {
3097 if (folder[i] == '\\') folder[i] = '|';
3105 * \brief Back end for change_view()
3106 * \param newview set newview???
3108 void do_change_view(int newview) {
3111 serv_printf("VIEW %d", newview);
3112 serv_getln(buf, sizeof buf);
3113 WC->CurRoom.view = newview;
3114 smart_goto(WC->CurRoom.name);
3120 * \brief Change the view for this room
3122 void change_view(void) {
3125 view = lbstr("view");
3126 do_change_view(view);
3130 * \brief Burn the cached folder list.
3131 * \param age How old the cahce needs to be before we burn it.
3134 void burn_folder_cache(time_t age)
3136 /** If our cached folder list is very old, burn it. */
3137 if (WC->cache_fold != NULL) {
3138 if ((time(NULL) - WC->cache_timestamp) > age) {
3139 free(WC->cache_fold);
3140 WC->cache_fold = NULL;
3148 * \brief Do either a known rooms list or a folders list, depending on the
3153 StrBuf *ListView = NULL;
3155 /** Determine whether the user is trying to change views */
3156 if (havebstr("view")) {
3157 ListView = NewStrBufDup(SBSTR("view"));
3158 set_preference("roomlistview", ListView, 1);
3160 /** Sanitize the input so its safe */
3161 if((get_preference("roomlistview", &ListView) != 0)||
3162 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3163 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3165 if (ListView == NULL) {
3166 ListView = NewStrBufPlain(HKEY("rooms"));
3167 set_preference("roomlistview", ListView, 0);
3171 ListView = NewStrBufPlain(HKEY("rooms"));
3172 set_preference("roomlistview", ListView, 0);
3176 FreeStrBuf(&ListView);
3183 * \brief Set the message expire policy for this room and/or floor
3185 void set_room_policy(void) {
3188 if (!havebstr("ok_button")) {
3189 strcpy(WC->ImportantMessage,
3190 _("Cancelled. Changes were not saved."));
3195 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3196 serv_getln(buf, sizeof buf);
3197 strcpy(WC->ImportantMessage, &buf[4]);
3199 if (WC->axlevel >= 6) {
3200 strcat(WC->ImportantMessage, "<br />\n");
3201 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3202 serv_getln(buf, sizeof buf);
3203 strcat(WC->ImportantMessage, &buf[4]);
3209 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3211 StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3215 void _display_private(void) {
3216 display_private("", 0);
3219 void dotgoto(void) {
3220 if (!havebstr("room")) {
3221 readloop(readnew, eUseDefault);
3224 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3227 smart_goto(sbstr("room"));
3232 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3234 wcsession *WCC = WC;
3237 StrBufAppendTemplate(Target, TP,
3242 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3244 wc_printf("<div id=\"banner\">\n");
3245 embed_room_banner();
3246 wc_printf("</div>\n");
3250 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3252 wcsession *WCC = WC;
3255 (!IsEmptyStr(WCC->ugname)))
3256 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3259 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3261 wcsession *WCC = WC;
3262 return (WCC != NULL)?
3263 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3266 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3268 wcsession *WCC = WC;
3269 return (WCC == NULL)? 0 :
3270 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3271 (WCC->CurRoom.is_inbox) ||
3272 (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3275 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3277 wcsession *WCC = WC;
3279 return ((WCC!=NULL) &&
3280 (!IsEmptyStr(WCC->ugname)) &&
3281 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3285 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
3287 folder *Folder = (folder *)(TP->Context);
3290 UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3291 if (UA_CheckFlag == 0)
3292 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3293 "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
3295 return ((Folder->RAFlags & UA_CheckFlag) != 0);
3300 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3303 wcsession *WCC = WC;
3305 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3306 if (QR_CheckFlag == 0)
3307 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3308 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3310 return ((WCC!=NULL) &&
3311 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3314 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3317 folder *Folder = (folder *)(TP->Context);
3319 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3320 if (QR_CheckFlag == 0)
3321 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3322 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3323 return ((Folder->QRFlags & QR_CheckFlag) != 0);
3327 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3330 wcsession *WCC = WC;
3332 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3333 if (QR2_CheckFlag == 0)
3334 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3335 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3337 return ((WCC!=NULL) &&
3338 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3341 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3344 folder *Folder = (folder *)(TP->Context);
3346 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3347 if (QR2_CheckFlag == 0)
3348 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3349 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3350 return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3354 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3356 wcsession *WCC = WC;
3358 return ( (WCC!= NULL) &&
3359 ((WCC->axlevel >= 6) ||
3360 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3361 (WCC->CurRoom.is_inbox) ));
3364 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3366 wcsession *WCC = WC;
3368 if ((WCC == NULL) ||
3369 (TP->Tokens->nParameters < 3))
3371 return ((WCC->CurRoom.view < VIEW_BBS) ||
3372 (WCC->CurRoom.view > VIEW_MAX));
3375 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3379 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
3381 wcsession *WCC = WC;
3385 HashList *Whok = NULL;
3391 StrBuf_ServGetln(Line);
3392 if (GetServerStatus(Line, &State) == 1)
3394 Whok = NewHash(1, Flathash);
3395 while(!Done && StrBuf_ServGetln(Line))
3396 if ( (StrLength(Line)==3) &&
3397 !strcmp(ChrPtr(Line), "000"))
3404 const char *Pos = NULL;
3405 Token = NewStrBufPlain (NULL, StrLength(Line));
3406 StrBufExtract_NextToken(Token, Line, &Pos, '|');
3414 else if (State == 550)
3415 StrBufAppendBufPlain(WCC->ImportantMsg,
3416 _("Higher access is required to access this function."), -1, 0);
3423 void FlushRoomlist(void)
3425 wcsession *WCC = WC;
3426 free_march_list(WCC);
3427 DeleteHash(&WCC->Floors);
3428 DeleteHash(&WCC->Rooms);
3429 DeleteHash(&WCC->FloorsByName);
3436 initialize_viewdefs();
3437 RegisterPreference("roomlistview",
3438 _("Room list view"),
3441 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3443 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3446 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3447 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3448 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3449 WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3450 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3451 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3452 WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3453 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3454 WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3455 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3456 WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3457 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3458 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3459 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3460 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3461 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3462 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3463 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3465 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3466 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3467 RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3469 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3470 RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3471 RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
3473 RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
3474 RegisterNamespace("THISROOM:MSGS:NEW", 0, 0, tmplput_CurrentRoom_nNewMessages, NULL, CTX_NONE);
3475 RegisterNamespace("THISROOM:MSGS:TOTAL", 0, 0, tmplput_CurrentRoom_nTotalMessages, NULL, CTX_NONE);
3477 RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
3478 RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3479 RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3480 RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3481 RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3482 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3483 RegisterConditional(HKEY("COND:THISROOM:HAVE_VIEW"), 0, ConditionalThisRoomHaveView, CTX_NONE);
3484 RegisterNamespace("THISROOM:VIEW_STRING", 0, 1, tmplput_CurrentRoomViewString, NULL, CTX_NONE);
3485 RegisterNamespace("ROOM:VIEW_STRING", 1, 2, tmplput_RoomViewString, NULL, CTX_NONE);
3487 RegisterNamespace("THISROOM:INFOTEXT", 1, 2, tmplput_CurrentRoomInfoText, NULL, CTX_NONE);
3488 RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3489 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3490 RegisterConditional(HKEY("COND:THISROOM:CURR_VIEW"), 0, ConditionalThisRoomCurrView, CTX_NONE);
3491 RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
3492 RegisterConditional(HKEY("COND:THISROOM:HAVE_INFOTEXT"), 0, ConditionalThisRoomXHaveInfoText, CTX_NONE);
3493 RegisterNamespace("THISROOM:FILES:N", 0, 1, tmplput_CurrentRoomXNFiles, NULL, CTX_NONE);
3494 RegisterNamespace("THISROOM:FILES:STR", 0, 1, tmplput_CurrentRoomX_FileString, NULL, CTX_NONE);
3496 REGISTERTokenParamDefine(QR_PERMANENT);
3497 REGISTERTokenParamDefine(QR_INUSE);
3498 REGISTERTokenParamDefine(QR_PRIVATE);
3499 REGISTERTokenParamDefine(QR_PASSWORDED);
3500 REGISTERTokenParamDefine(QR_GUESSNAME);
3501 REGISTERTokenParamDefine(QR_DIRECTORY);
3502 REGISTERTokenParamDefine(QR_UPLOAD);
3503 REGISTERTokenParamDefine(QR_DOWNLOAD);
3504 REGISTERTokenParamDefine(QR_VISDIR);
3505 REGISTERTokenParamDefine(QR_ANONONLY);
3506 REGISTERTokenParamDefine(QR_ANONOPT);
3507 REGISTERTokenParamDefine(QR_NETWORK);
3508 REGISTERTokenParamDefine(QR_PREFONLY);
3509 REGISTERTokenParamDefine(QR_READONLY);
3510 REGISTERTokenParamDefine(QR_MAILBOX);
3511 REGISTERTokenParamDefine(QR2_SYSTEM);
3512 REGISTERTokenParamDefine(QR2_SELFLIST);
3513 REGISTERTokenParamDefine(QR2_COLLABDEL);
3514 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3515 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3516 REGISTERTokenParamDefine(QR2_MODERATED);
3518 REGISTERTokenParamDefine(UA_KNOWN);
3519 REGISTERTokenParamDefine(UA_GOTOALLOWED);
3520 REGISTERTokenParamDefine(UA_HASNEWMSGS);
3521 REGISTERTokenParamDefine(UA_ZAPPED);
3522 REGISTERTokenParamDefine(UA_POSTALLOWED);
3523 REGISTERTokenParamDefine(UA_ADMINALLOWED);
3524 REGISTERTokenParamDefine(UA_DELETEALLOWED);
3525 REGISTERTokenParamDefine(UA_ISTRASH);
3527 REGISTERTokenParamDefine(US_NEEDVALID);
3528 REGISTERTokenParamDefine(US_PERM);
3529 REGISTERTokenParamDefine(US_LASTOLD);
3530 REGISTERTokenParamDefine(US_EXPERT);
3531 REGISTERTokenParamDefine(US_UNLISTED);
3532 REGISTERTokenParamDefine(US_NOPROMPT);
3533 REGISTERTokenParamDefine(US_PROMPTCTL);
3534 REGISTERTokenParamDefine(US_DISAPPEAR);
3535 REGISTERTokenParamDefine(US_REGIS);
3536 REGISTERTokenParamDefine(US_PAGINATOR);
3537 REGISTERTokenParamDefine(US_INTERNET);
3538 REGISTERTokenParamDefine(US_FLOORS);
3539 REGISTERTokenParamDefine(US_COLOR);
3540 REGISTERTokenParamDefine(US_USER_SET);
3542 REGISTERTokenParamDefine(VIEW_BBS);
3543 REGISTERTokenParamDefine(VIEW_MAILBOX);
3544 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3545 REGISTERTokenParamDefine(VIEW_CALENDAR);
3546 REGISTERTokenParamDefine(VIEW_TASKS);
3547 REGISTERTokenParamDefine(VIEW_NOTES);
3548 REGISTERTokenParamDefine(VIEW_WIKI);
3549 REGISTERTokenParamDefine(VIEW_CALBRIEF);
3550 REGISTERTokenParamDefine(VIEW_JOURNAL);
3551 REGISTERTokenParamDefine(VIEW_BLOG);
3554 REGISTERTokenParamDefine(ignet_push_share);
3555 { /* these are the parts of an IGNET push config */
3556 REGISTERTokenParamDefine(GNET_IGNET_NODE);
3557 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
3559 REGISTERTokenParamDefine(listrecp);
3560 REGISTERTokenParamDefine(digestrecp);
3561 REGISTERTokenParamDefine(pop3client);
3562 { /* These are the parts of a pop3 client line... */
3563 REGISTERTokenParamDefine(GNET_POP3_HOST);
3564 REGISTERTokenParamDefine(GNET_POP3_USER);
3565 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
3566 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
3568 REGISTERTokenParamDefine(rssclient);
3569 REGISTERTokenParamDefine(participate);
3571 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3572 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3574 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3575 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3577 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3578 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3579 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3586 SessionDestroyModule_ROOMOPS
3589 FlushFolder(&sess->CurRoom);
3590 if (sess->cache_fold != NULL) {
3591 free(sess->cache_fold);