3 * Lots of different room-related operations.
10 char floorlist[MAX_FLOORS][SIZ]; /* list of our floor names */
12 char *viewdefs[9]; /* the different kinds of available views */
14 /* See GetFloorListHash and GetRoomListHash for info on these.
15 * Basically we pull LFLR/LKRA etc. and set up a room HashList with these keys.
18 void display_whok(void);
19 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP);
22 * Initialize the viewdefs with localized strings
24 void initialize_viewdefs(void) {
25 viewdefs[0] = _("Bulletin Board");
26 viewdefs[1] = _("Mail Folder");
27 viewdefs[2] = _("Address Book");
28 viewdefs[3] = _("Calendar");
29 viewdefs[4] = _("Task List");
30 viewdefs[5] = _("Notes List");
31 viewdefs[6] = _("Wiki");
32 viewdefs[7] = _("Calendar List");
33 viewdefs[8] = _("Journal");
37 * Determine which views are allowed as the default for creating a new room.
39 int is_view_allowed_as_default(int which_view)
42 case VIEW_BBS: return(1);
43 case VIEW_MAILBOX: return(1);
44 case VIEW_ADDRESSBOOK: return(1);
45 case VIEW_CALENDAR: return(1);
46 case VIEW_TASKS: return(1);
47 case VIEW_NOTES: return(1);
48 case VIEW_WIKI: return(1);
49 case VIEW_CALBRIEF: return(0);
50 case VIEW_JOURNAL: return(0);
51 default: return(0); /* should never get here */
57 * load the list of floors
59 void load_floorlist(StrBuf *Buf)
64 for (a = 0; a < MAX_FLOORS; ++a)
68 StrBuf_ServGetln(Buf);
69 if (GetServerStatus(Buf, NULL) != 1) {
70 strcpy(floorlist[0], "Main Floor");
73 while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
74 if ( (StrLength(Buf)==3) &&
75 !strcmp(ChrPtr(Buf), "000")) {
79 extract_token(floorlist[StrBufExtract_int(Buf, 0, '|')], ChrPtr(Buf), 1, '|', sizeof floorlist[0]);
87 * display rooms in tree structure
89 void room_tree_list(struct roomlisting *rp)
98 room_tree_list(rp->lnext);
100 strcpy(rmname, rp->rlname);
103 wc_printf("<a href=\"dotgoto?room=");
107 escputs1(rmname, 1, 1);
108 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
110 else if (f & QR_DIRECTORY)
112 else if (f & QR_NETWORK)
116 wc_printf("</a><tt> </tt>\n");
118 room_tree_list(rp->rnext);
124 * Room ordering stuff (compare first by floor, then by order)
126 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
128 if ((r1 == NULL) && (r2 == NULL))
134 if (r1->rlfloor < r2->rlfloor)
136 if (r1->rlfloor > r2->rlfloor)
138 if (r1->rlorder < r2->rlorder)
140 if (r1->rlorder > r2->rlorder)
147 * Common code for all room listings
149 void listrms(char *variety)
154 struct roomlisting *rl = NULL;
155 struct roomlisting *rp;
156 struct roomlisting *rs;
158 /* Ask the server for a room list */
160 serv_getln(buf, sizeof buf);
166 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
168 rp = malloc(sizeof(struct roomlisting));
169 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
170 rp->rlflags = extract_int(buf, 1);
171 rp->rlfloor = extract_int(buf, 2);
172 rp->rlorder = extract_int(buf, 3);
181 if (rordercmp(rp, rs) < 0) {
182 if (rs->lnext == NULL) {
189 if (rs->rnext == NULL) {
202 * If no rooms were listed, print an nbsp to make the cell
203 * borders show up anyway.
205 if (num_rooms == 0) wc_printf(" ");
210 * list all forgotten rooms
212 void zapped_list(void)
214 WCTemplputParams SubTP;
217 output_headers(1, 1, 1, 0, 0, 0);
218 memset(&SubTP, 0, sizeof(WCTemplputParams));
219 Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
220 SubTP.Filter.ContextType = CTX_STRBUF;
222 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
228 wc_printf("<br /><br />\n");
229 wc_printf(_("Click on any room to un-zap it and goto that room.\n"));
230 do_template("endbox", NULL);
235 * Display the current view and offer an option to change it
237 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
241 wc_printf("<form name=\"viewomatic\" action=\"changeview\">\n");
242 wc_printf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
243 wc_printf("<label for=\"view_name\">");
244 wc_printf(_("View as:"));
245 wc_printf("</label> "
246 "<select name=\"newview\" size=\"1\" "
247 "id=\"view_name\" class=\"selectbox\" "
248 "OnChange=\"location.href=viewomatic.newview.options"
249 "[selectedIndex].value\">\n");
251 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
253 * Only offer the views that make sense, given the default
254 * view for the room. For example, don't offer a Calendar
255 * view in a non-Calendar room.
258 (i == WC->CurRoom.view)
259 || (i == WC->CurRoom.defview) /* default */
260 || ( (i == 0) && (WC->CurRoom.defview == 1) ) /* mail or bulletin */
261 || ( (i == 1) && (WC->CurRoom.defview == 0) ) /* mail or bulletin */
262 /* || ( (i == 7) && (WC->CurRoom.defview == 3) ) (calendar list temporarily disabled) */
265 wc_printf("<option %s value=\"changeview?view=%d\">",
266 ((i == WC->CurRoom.view) ? "selected" : ""),
268 escputs(viewdefs[i]);
269 wc_printf("</option>\n");
272 wc_printf("</select></div></form>\n");
278 * Embed the room banner
280 * got The information returned from a GOTO server command
281 * navbar_style Determines which navigation buttons to display
285 void embed_room_banner(char *got, int navbar_style) {
289 char with_files[256];
293 * We need to have the information returned by a GOTO server command.
294 * If it isn't supplied, we fake it by issuing our own GOTO.
297 memset(buf, '0', 20);
299 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
300 serv_getln(buf, sizeof buf);
304 /* The browser needs some information for its own use */
305 wc_printf("<script type=\"text/javascript\"> \n"
306 " room_is_trash = %d; \n"
308 ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
312 * If the user happens to select the "make this my start page" link,
313 * we want it to remember the URL as a "/dotskip" one instead of
314 * a "skip" or "gotonext" or something like that.
316 if (WCC->Hdr->this_page == NULL) {
317 WCC->Hdr->this_page = NewStrBuf();
319 StrBufPrintf(WCC->Hdr->this_page,
321 ChrPtr(WC->CurRoom.name)
324 /* Check for new mail. */
325 WC->new_mail = extract_int(&got[4], 9);
326 WC->CurRoom.view = extract_int(&got[4], 11);
328 /* Is this a directory room and does it contain files and how many? */
329 if ((WC->CurRoom.QRFlags & QR_DIRECTORY) && (WC->CurRoom.QRFlags & QR_VISDIR))
332 serv_getln(buf2, sizeof buf2);
333 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
335 snprintf (with_files, sizeof with_files,
336 "; <a href=\"do_template?template=files\"> %d %s </a>",
338 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
341 strcpy (with_files, "");
343 svprintf(HKEY("NUMMSGS"), WCS_STRING,
344 _("%d new of %d messages%s"),
345 extract_int(&got[4], 1),
346 extract_int(&got[4], 2),
349 svcallback("VIEWOMATIC", embed_view_o_matic);
350 svcallback("START", offer_start_page);
352 do_template("roombanner", NULL);
353 /* roombanner contains this for mobile */
354 if (navbar_style != navbar_none && (WC->is_mobile < 1)) {
356 wc_printf("<div id=\"navbar\"><ul>");
358 if (navbar_style == navbar_default) wc_printf(
359 "<li class=\"ungoto\">"
360 "<a href=\"ungoto\">"
361 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
362 "<span class=\"navbar_link\">%s</span></A>"
363 "</li>\n", _("Ungoto")
366 if ( (navbar_style == navbar_default) && (WC->CurRoom.view == VIEW_BBS) ) {
368 "<li class=\"newmess\">"
369 "<a href=\"readnew\">"
370 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
371 "<span class=\"navbar_link\">%s</span></A>"
372 "</li>\n", _("Read new messages")
376 if (navbar_style == navbar_default) {
377 switch(WC->CurRoom.view) {
378 case VIEW_ADDRESSBOOK:
380 "<li class=\"viewcontacts\">"
381 "<a href=\"readfwd\">"
382 "<img src=\"static/viewcontacts_24x.gif\" "
383 "alt=\"\" width=\"24\" height=\"24\">"
384 "<span class=\"navbar_link\">"
386 "</span></a></li>\n", _("View contacts")
391 "<li class=\"staskday\">"
392 "<a href=\"readfwd?calview=day\">"
393 "<img src=\"static/taskday2_24x.gif\" "
394 "alt=\"\" width=\"24\" height=\"24\">"
395 "<span class=\"navbar_link\">"
397 "</span></a></li>\n", _("Day view")
400 "<li class=\"monthview\">"
401 "<a href=\"readfwd?calview=month\">"
402 "<img src=\"static/monthview2_24x.gif\" "
403 "alt=\"\" width=\"24\" height=\"24\">"
404 "<span class=\"navbar_link\">"
406 "</span></a></li>\n", _("Month view")
411 "<li class=\"monthview\">"
412 "<a href=\"readfwd?calview=month\">"
413 "<img src=\"static/monthview2_24x.gif\" "
414 "alt=\"\" width=\"24\" height=\"24\">"
415 "<span class=\"navbar_link\">"
417 "</span></a></li>\n", _("Calendar list")
422 "<li class=\"taskmanag\">"
423 "<a href=\"readfwd\">"
424 "<img src=\"static/taskmanag_24x.gif\" "
425 "alt=\"\" width=\"24\" height=\"24\">"
426 "<span class=\"navbar_link\">"
428 "</span></a></li>\n", _("View tasks")
433 "<li class=\"viewnotes\">"
434 "<a href=\"readfwd\">"
435 "<img src=\"static/viewnotes_24x.gif\" "
436 "alt=\"\" width=\"24\" height=\"24\">"
437 "<span class=\"navbar_link\">"
439 "</span></a></li>\n", _("View notes")
444 "<li class=\"readallmess\">"
445 "<a id=\"m_refresh\" href=\"readfwd\">"
446 "<img src=\"static/readallmess3_24x.gif\" "
447 "alt=\"\" width=\"24\" height=\"24\">"
448 "<span class=\"navbar_link\">"
450 "</span></a></li>\n", _("Refresh message list")
455 "<li class=\"readallmess\">"
456 "<a href=\"wiki?page=home\">"
457 "<img src=\"static/readallmess3_24x.gif\" "
458 "alt=\"\" width=\"24\" height=\"24\">"
459 "<span class=\"navbar_link\">"
461 "</span></a></li>\n", _("Wiki home")
466 "<li class=\"readallmess\">"
467 "<a href=\"readfwd\">"
468 "<img src=\"static/readallmess3_24x.gif\" "
469 "alt=\"\" width=\"24\" height=\"24\">"
470 "<span class=\"navbar_link\">"
472 "</span></a></li>\n", _("Read all messages")
478 if (navbar_style == navbar_default) {
479 switch(WC->CurRoom.view) {
480 case VIEW_ADDRESSBOOK:
482 "<li class=\"addnewcontact\">"
483 "<a href=\"display_enter\">"
484 "<img src=\"static/addnewcontact_24x.gif\" "
485 "alt=\"\" width=\"24\" height=\"24\">"
486 "<span class=\"navbar_link\">"
488 "</span></a></li>\n", _("Add new contact")
493 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
494 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
495 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
496 if (havebstr("day" )) wc_printf("?day=%s", bstr("day"));
498 "<img src=\"static/addevent_24x.gif\" "
499 "alt=\"\" width=\"24\" height=\"24\">"
500 "<span class=\"navbar_link\">"
502 "</span></a></li>\n", _("Add new event")
507 "<li class=\"newmess\">"
508 "<a href=\"display_enter\">"
509 "<img src=\"static/newmess3_24x.gif\" "
510 "alt=\"\" width=\"24\" height=\"24\">"
511 "<span class=\"navbar_link\">"
513 "</span></a></li>\n", _("Add new task")
518 "<li class=\"enternewnote\">"
519 "<a href=\"add_new_note\">"
520 "<img src=\"static/enternewnote_24x.gif\" "
521 "alt=\"\" width=\"24\" height=\"24\">"
522 "<span class=\"navbar_link\">"
524 "</span></a></li>\n", _("Add new note")
528 safestrncpy(buf, bstr("page"), sizeof buf);
529 if (IsEmptyStr(buf)) {
530 safestrncpy(buf, "home", sizeof buf);
534 "<li class=\"newmess\">"
535 "<a href=\"display_enter?page=%s\">"
536 "<img src=\"static/newmess3_24x.gif\" "
537 "alt=\"\" width=\"24\" height=\"24\">"
538 "<span class=\"navbar_link\">"
540 "</span></a></li>\n", buf, _("Edit this page")
543 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
544 /* already viewing history; display a link to the current page */
546 "<li class=\"newmess\">"
547 "<a href=\"wiki?page=%s\">"
548 "<img src=\"static/newmess3_24x.gif\" "
549 "alt=\"\" width=\"24\" height=\"24\">"
550 "<span class=\"navbar_link\">"
552 "</span></a></li>\n", buf, _("Current version")
556 /* display a link to the history */
558 "<li class=\"newmess\">"
559 "<a href=\"wiki_history?page=%s\">"
560 "<img src=\"static/newmess3_24x.gif\" "
561 "alt=\"\" width=\"24\" height=\"24\">"
562 "<span class=\"navbar_link\">"
564 "</span></a></li>\n", buf, _("History")
570 "<li class=\"newmess\">"
571 "<a href=\"display_enter\">"
572 "<img src=\"static/newmess3_24x.gif\" "
573 "alt=\"\" width=\"24\" height=\"24\">"
574 "<span class=\"navbar_link\">"
576 "</span></a></li>\n", _("Write mail")
579 "<li class=\"newmess\">"
580 "<a href=\"javascript:deleteAllSelectedMessages();\">"
581 "<img src=\"static/delete.gif\" "
582 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
584 "</span></a></li>\n", _("Delete")
589 "<li class=\"newmess\">"
590 "<a href=\"display_enter\">"
591 "<img src=\"static/newmess3_24x.gif\" "
592 "alt=\"\" width=\"24\" height=\"24\">"
593 "<span class=\"navbar_link\">"
595 "</span></a></li>\n", _("Enter a message")
601 if (navbar_style == navbar_default) wc_printf(
602 "<li class=\"skipthisroom\">"
605 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
606 "width=\"24\" height=\"24\">"
607 "<span class=\"navbar_link\">%s</span></a>"
609 _("Leave all messages marked as unread, go to next room with unread messages"),
613 if (navbar_style == navbar_default) wc_printf(
614 "<li class=\"markngo\">"
615 "<a href=\"gotonext\" "
617 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
618 "width=\"24\" height=\"24\">"
619 "<span class=\"navbar_link\">%s</span></a>"
621 _("Mark all messages as read, go to next room with unread messages"),
625 wc_printf("</ul></div>\n");
632 * back end routine to take the session to a new room
634 long gotoroom(const StrBuf *gname)
638 static long ls = (-1L);
641 /* store ungoto information */
642 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
646 /* move to the new room */
647 serv_printf("GOTO %s", ChrPtr(gname));
648 StrBuf_ServGetln(Buf);
649 if (GetServerStatus(Buf, &err) != 2) {
650 serv_puts("GOTO _BASEROOM_");
651 StrBuf_ServGetln(Buf);
653 * well, we know that this is the fallback case,
654 * but we're interested that the first command
655 * didn't work out in first place.
657 if (GetServerStatus(Buf, NULL) != 2) {
662 ParseGoto(&WCC->CurRoom, Buf);
664 remove_march(WCC->CurRoom.name);
665 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
673 void ParseGoto(folder *room, StrBuf *Line)
681 if (StrLength(Line) < 4) {
685 /* ignore the commandstate... */
686 Pos = ChrPtr(Line) + 4;
688 if (room->RoomNameParts != NULL)
691 for (i=0; i < room->nRoomNameParts; i++)
692 FreeStrBuf(&room->RoomNameParts[i]);
693 free(room->RoomNameParts);
694 room->RoomNameParts = NULL;
699 pBuf = NewStrBufPlain(NULL, StrLength(Line));
702 memset(room, 0, sizeof(folder));
705 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
707 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
708 if (room->nNewMessages > 0)
709 room->RAFlags |= UA_HASNEWMSGS;
711 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
713 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
715 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
717 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
718 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
720 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
722 flag = StrBufExtractNext_long(Line, &Pos, '|');
723 if (WCC->is_aide || flag) {
724 room->RAFlags |= UA_ADMINALLOWED;
727 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
729 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
731 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
733 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
735 flag = StrBufExtractNext_long(Line, &Pos, '|');
737 room->RAFlags |= UA_ISTRASH; // wc_is_trash
739 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
741 /* find out, whether we are in a sub-room */
742 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
743 if (room->nRoomNameParts > 1)
748 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
749 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
750 for (i=0; i < room->nRoomNameParts; i++)
752 room->RoomNameParts[i] = NewStrBuf();
753 StrBufExtract_NextToken(room->RoomNameParts[i],
754 room->name, &Pos, '\\');
758 /* Private mailboxes on the main floor get remapped to the personal folder */
759 if ((room->QRFlags & QR_MAILBOX) &&
760 (room->floorid == 0))
762 room->floorid = VIRTUAL_MY_FLOOR;
763 if ((room->nRoomNameParts == 1) &&
764 (StrLength(room->name) == 4) &&
765 (strcmp(ChrPtr(room->name), "Mail") == 0))
771 /* get a pointer to the floor we're on: */
772 if (WCC->Floors == NULL)
773 GetFloorListHash(NULL, NULL);
775 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
776 room->Floor = (const Floor*) vFloor;
779 void LoadRoomAide(void)
784 if (WCC->CurRoom.RoomAideLoaded)
787 WCC->CurRoom.RoomAideLoaded = 1;
790 StrBuf_ServGetln(Buf);
791 if (GetServerStatus(Buf, NULL) != 2) {
792 FlushStrBuf(WCC->CurRoom.RoomAide);
793 AppendImportantMessage (ChrPtr(Buf) + 4,
798 Pos = ChrPtr(Buf) + 4;
800 FreeStrBuf(&WCC->CurRoom.RoomAide);
801 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
803 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
807 void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
810 folder *Folder = &WCC->CurRoom;
811 const Floor *pFloor = Folder->Floor;
816 StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
819 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
825 StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
829 void LoadRoomXA (void)
834 if (WCC->CurRoom.XALoaded)
837 WCC->CurRoom.XALoaded = 1;
840 StrBuf_ServGetln(Buf);
841 if (GetServerStatus(Buf, NULL) != 2) {
842 FlushStrBuf(WCC->CurRoom.XAPass);
843 FlushStrBuf(WCC->CurRoom.Directory);
845 AppendImportantMessage (ChrPtr(Buf) + 4,
850 Pos = ChrPtr(Buf) + 4;
852 FreeStrBuf(&WCC->CurRoom.XAPass);
853 FreeStrBuf(&WCC->CurRoom.Directory);
855 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
856 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
858 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
859 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
860 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
861 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
862 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
863 WCC->CurRoom.DefView = StrBufExtractNext_long(Buf, &Pos, '|');
864 /* QR2Flags, we already know them... */
871 void LoadXRoomPic(void)
876 if (WCC->CurRoom.XHaveRoomPicLoaded)
879 WCC->CurRoom.XHaveRoomPicLoaded = 1;
881 serv_puts("OIMG _roompic_");
882 StrBuf_ServGetln(Buf);
883 if (GetServerStatus(Buf, NULL) != 2) {
884 WCC->CurRoom.XHaveRoomPic = 0;
886 WCC->CurRoom.XHaveRoomPic = 1;
889 StrBuf_ServGetln(Buf);
890 GetServerStatus(Buf, NULL);
894 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
902 return WCC->CurRoom.XHaveRoomPic == 1;
905 void LoadXRoomInfoText(void)
911 if (WCC->CurRoom.XHaveInfoTextLoaded)
914 WCC->CurRoom.XHaveInfoTextLoaded = 1;
919 StrBuf_ServGetln(Buf);
920 if (GetServerStatus(Buf, NULL) == 1) {
921 WCC->CurRoom.XInfoText = NewStrBuf ();
923 while (!Done && StrBuf_ServGetln(Buf)>=0) {
924 if ( (StrLength(Buf)==3) &&
925 !strcmp(ChrPtr(Buf), "000"))
928 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
935 int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
943 return (StrLength(WCC->CurRoom.XInfoText)>0);
946 void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
952 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1);
955 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
961 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
963 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
969 StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
971 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
977 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
979 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
985 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.DefView);
989 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
999 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1000 return CheckThis == WCC->CurRoom.Order;
1003 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1005 wcsession *WCC = WC;
1013 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1014 return CheckThis == WCC->CurRoom.DefView;
1024 void smart_goto(const StrBuf *next_room) {
1025 gotoroom(next_room);
1026 readloop(readnew, eUseDefault);
1032 * mark all messages in current room as having been read
1034 void slrp_highest(void)
1038 serv_puts("SLRP HIGHEST");
1039 serv_getln(buf, sizeof buf);
1043 typedef struct __room_states {
1058 * Set/clear/read the "self-service list subscribe" flag for a room
1060 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1061 * returns the new value.
1064 int self_service(int newval) {
1065 int current_value = 0;
1071 int flags, floor, order, view, flags2;
1074 serv_getln(buf, sizeof buf);
1075 if (buf[0] != '2') return(0);
1077 extract_token(name, &buf[4], 0, '|', sizeof name);
1078 extract_token(password, &buf[4], 1, '|', sizeof password);
1079 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1080 flags = extract_int(&buf[4], 3);
1081 floor = extract_int(&buf[4], 4);
1082 order = extract_int(&buf[4], 5);
1083 view = extract_int(&buf[4], 6);
1084 flags2 = extract_int(&buf[4], 7);
1086 if (flags2 & QR2_SELFLIST) {
1094 flags2 = flags2 | QR2_SELFLIST;
1096 else if (newval == 0) {
1097 flags2 = flags2 & ~QR2_SELFLIST;
1100 return(current_value);
1103 if (newval != current_value) {
1104 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1105 name, password, dirname, flags,
1106 floor, order, view, flags2);
1107 serv_getln(buf, sizeof buf);
1114 int is_selflist(room_states *RoomFlags)
1116 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1119 int is_publiclist(room_states *RoomFlags)
1121 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1124 int is_moderatedlist(room_states *RoomFlags)
1126 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1130 * Set/clear/read the "self-service list subscribe" flag for a room
1132 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1133 * returns the new value.
1136 int get_roomflags(room_states *RoomOps)
1141 serv_getln(buf, sizeof buf);
1142 if (buf[0] != '2') return(0);
1144 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1145 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1146 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1147 RoomOps->flags = extract_int(&buf[4], 3);
1148 RoomOps->floor = extract_int(&buf[4], 4);
1149 RoomOps->order = extract_int(&buf[4], 5);
1150 RoomOps->view = extract_int(&buf[4], 6);
1151 RoomOps->flags2 = extract_int(&buf[4], 7);
1155 int set_roomflags(room_states *RoomOps)
1159 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1168 serv_getln(buf, sizeof buf);
1178 * display the form for editing a room
1180 void display_editroom(void)
1186 char remote_room[128];
1189 char er_password[10];
1190 char er_dirname[15];
1191 char er_roomaide[26];
1198 char *not_shared_with = NULL;
1201 int floorpolicy = 0;
1203 char pop3_host[128];
1208 if (IsEmptyStr(tab)) tab = "admin";
1211 load_floorlist(Buf);
1213 output_headers(1, 1, 1, 0, 0, 0);
1215 wc_printf("<div class=\"fix_scrollbar_bug\">");
1217 wc_printf("<br />\n");
1219 /* print the tabbed dialog */
1220 wc_printf("<div align=\"center\">");
1221 wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1222 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1225 wc_printf("<td class=\"");
1226 if (!strcmp(tab, "admin")) {
1227 wc_printf(" tab_cell_label\">");
1228 wc_printf(_("Administration"));
1231 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1232 wc_printf(_("Administration"));
1235 wc_printf("</td>\n");
1236 wc_printf("<td> </td>\n");
1238 if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1240 wc_printf("<td class=\"");
1241 if (!strcmp(tab, "config")) {
1242 wc_printf(" tab_cell_label\">");
1243 wc_printf(_("Configuration"));
1246 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1247 wc_printf(_("Configuration"));
1250 wc_printf("</td>\n");
1251 wc_printf("<td> </td>\n");
1253 wc_printf("<td class=\"");
1254 if (!strcmp(tab, "expire")) {
1255 wc_printf(" tab_cell_label\">");
1256 wc_printf(_("Message expire policy"));
1259 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1260 wc_printf(_("Message expire policy"));
1263 wc_printf("</td>\n");
1264 wc_printf("<td> </td>\n");
1266 wc_printf("<td class=\"");
1267 if (!strcmp(tab, "access")) {
1268 wc_printf(" tab_cell_label\">");
1269 wc_printf(_("Access controls"));
1272 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1273 wc_printf(_("Access controls"));
1276 wc_printf("</td>\n");
1277 wc_printf("<td> </td>\n");
1279 wc_printf("<td class=\"");
1280 if (!strcmp(tab, "sharing")) {
1281 wc_printf(" tab_cell_label\">");
1282 wc_printf(_("Sharing"));
1285 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1286 wc_printf(_("Sharing"));
1289 wc_printf("</td>\n");
1290 wc_printf("<td> </td>\n");
1292 wc_printf("<td class=\"");
1293 if (!strcmp(tab, "listserv")) {
1294 wc_printf(" tab_cell_label\">");
1295 wc_printf(_("Mailing list service"));
1298 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1299 wc_printf(_("Mailing list service"));
1302 wc_printf("</td>\n");
1303 wc_printf("<td> </td>\n");
1307 wc_printf("<td class=\"");
1308 if (!strcmp(tab, "feeds")) {
1309 wc_printf(" tab_cell_label\">");
1310 wc_printf(_("Remote retrieval"));
1313 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1314 wc_printf(_("Remote retrieval"));
1317 wc_printf("</td>\n");
1318 wc_printf("<td> </td>\n");
1320 wc_printf("</tr></table>\n");
1321 wc_printf("</div>\n");
1322 /* end tabbed dialog */
1324 wc_printf("<script type=\"text/javascript\">"
1325 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1329 /* begin content of whatever tab is open now */
1331 if (!strcmp(tab, "admin")) {
1332 wc_printf("<div class=\"tabcontent\">");
1334 "<li><a href=\"delete_room\" "
1335 "onClick=\"return confirm('");
1336 wc_printf(_("Are you sure you want to delete this room?"));
1337 wc_printf("');\">\n");
1338 wc_printf(_("Delete this room"));
1340 "<li><a href=\"display_editroompic?which_room=");
1341 urlescputs(ChrPtr(WC->CurRoom.name));
1343 wc_printf(_("Set or change the icon for this room's banner"));
1345 "<li><a href=\"display_editinfo\">\n");
1346 wc_printf(_("Edit this room's Info file"));
1349 wc_printf("</div>");
1352 if (!strcmp(tab, "config")) {
1353 wc_printf("<div class=\"tabcontent\">");
1355 serv_getln(buf, sizeof buf);
1357 if (!strncmp(buf, "550", 3)) {
1358 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1359 _("Higher access is required to access this function.")
1362 else if (buf[0] != '2') {
1363 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1366 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1367 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1368 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1369 er_flags = extract_int(&buf[4], 3);
1370 er_floor = extract_int(&buf[4], 4);
1371 er_flags2 = extract_int(&buf[4], 7);
1373 wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1374 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1376 wc_printf("<ul><li>");
1377 wc_printf(_("Name of room: "));
1378 wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1384 wc_printf(_("Resides on floor: "));
1385 wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1386 if (er_flags & QR_MAILBOX)
1387 wc_printf("disabled >\n");
1388 for (i = 0; i < 128; ++i)
1389 if (!IsEmptyStr(floorlist[i])) {
1390 wc_printf("<OPTION ");
1392 wc_printf("SELECTED ");
1393 wc_printf("VALUE=\"%d\">", i);
1394 escputs(floorlist[i]);
1395 wc_printf("</OPTION>\n");
1397 wc_printf("</select>\n");
1400 wc_printf(_("Type of room:"));
1401 wc_printf("<ul>\n");
1403 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1404 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1405 wc_printf("CHECKED ");
1406 wc_printf("OnChange=\""
1407 " if (this.form.type[0].checked == true) { "
1408 " this.form.er_floor.disabled = false; "
1411 wc_printf(_("Public (automatically appears to everyone)"));
1414 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1415 if ((er_flags & QR_PRIVATE) &&
1416 (er_flags & QR_GUESSNAME))
1417 wc_printf("CHECKED ");
1418 wc_printf(" OnChange=\""
1419 " if (this.form.type[1].checked == true) { "
1420 " this.form.er_floor.disabled = false; "
1423 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1425 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1426 if ((er_flags & QR_PRIVATE) &&
1427 (er_flags & QR_PASSWORDED))
1428 wc_printf("CHECKED ");
1429 wc_printf(" OnChange=\""
1430 " if (this.form.type[2].checked == true) { "
1431 " this.form.er_floor.disabled = false; "
1434 wc_printf(_("Private - require password: "));
1435 wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1438 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1439 if ((er_flags & QR_PRIVATE)
1440 && ((er_flags & QR_GUESSNAME) == 0)
1441 && ((er_flags & QR_PASSWORDED) == 0))
1442 wc_printf("CHECKED ");
1443 wc_printf(" OnChange=\""
1444 " if (this.form.type[3].checked == true) { "
1445 " this.form.er_floor.disabled = false; "
1448 wc_printf(_("Private - invitation only"));
1450 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1451 if (er_flags & QR_MAILBOX)
1452 wc_printf("CHECKED ");
1453 wc_printf (" OnChange=\""
1454 " if (this.form.type[4].checked == true) { "
1455 " this.form.er_floor.disabled = true; "
1458 wc_printf(_("Personal (mailbox for you only)"));
1460 wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1462 wc_printf(_("If private, cause current users to forget room"));
1464 wc_printf("\n</ul>\n");
1466 wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1467 if (er_flags & QR_PREFONLY)
1468 wc_printf("CHECKED ");
1470 wc_printf(_("Preferred users only"));
1472 wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1473 if (er_flags & QR_READONLY)
1474 wc_printf("CHECKED ");
1476 wc_printf(_("Read-only room"));
1478 wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1479 if (er_flags2 & QR2_COLLABDEL)
1480 wc_printf("CHECKED ");
1482 wc_printf(_("All users allowed to post may also delete messages"));
1484 /** directory stuff */
1485 wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1486 if (er_flags & QR_DIRECTORY)
1487 wc_printf("CHECKED ");
1489 wc_printf(_("File directory room"));
1491 wc_printf("\n<ul><li>");
1492 wc_printf(_("Directory name: "));
1493 wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1496 wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1497 if (er_flags & QR_UPLOAD)
1498 wc_printf("CHECKED ");
1500 wc_printf(_("Uploading allowed"));
1502 wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1503 if (er_flags & QR_DOWNLOAD)
1504 wc_printf("CHECKED ");
1506 wc_printf(_("Downloading allowed"));
1508 wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1509 if (er_flags & QR_VISDIR)
1510 wc_printf("CHECKED ");
1512 wc_printf(_("Visible directory"));
1513 wc_printf("</ul>\n");
1515 /** end of directory stuff */
1517 wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1518 if (er_flags & QR_NETWORK)
1519 wc_printf("CHECKED ");
1521 wc_printf(_("Network shared room"));
1523 wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1524 if (er_flags & QR_PERMANENT)
1525 wc_printf("CHECKED ");
1527 wc_printf(_("Permanent (does not auto-purge)"));
1529 wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1530 if (er_flags2 & QR2_SUBJECTREQ)
1531 wc_printf("CHECKED ");
1533 wc_printf(_("Subject Required (Force users to specify a message subject)"));
1535 /** start of anon options */
1537 wc_printf("\n<li>");
1538 wc_printf(_("Anonymous messages"));
1539 wc_printf("<ul>\n");
1541 wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1542 if (((er_flags & QR_ANONONLY) == 0)
1543 && ((er_flags & QR_ANONOPT) == 0))
1544 wc_printf("CHECKED ");
1546 wc_printf(_("No anonymous messages"));
1548 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1549 if (er_flags & QR_ANONONLY)
1550 wc_printf("CHECKED ");
1552 wc_printf(_("All messages are anonymous"));
1554 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1555 if (er_flags & QR_ANONOPT)
1556 wc_printf("CHECKED ");
1558 wc_printf(_("Prompt user when entering messages"));
1559 wc_printf("</ul>\n");
1561 /* end of anon options */
1564 wc_printf(_("Room aide: "));
1566 serv_getln(buf, sizeof buf);
1567 if (buf[0] != '2') {
1568 wc_printf("<em>%s</em>\n", &buf[4]);
1570 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1571 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1574 wc_printf("</ul><CENTER>\n");
1575 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1576 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1578 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1584 wc_printf("</div>");
1588 /* Sharing the room with other Citadel nodes... */
1589 if (!strcmp(tab, "sharing")) {
1590 wc_printf("<div class=\"tabcontent\">");
1592 shared_with = strdup("");
1593 not_shared_with = strdup("");
1595 /** Learn the current configuration */
1596 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1597 serv_getln(buf, sizeof buf);
1598 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1599 extract_token(node, buf, 0, '|', sizeof node);
1600 not_shared_with = realloc(not_shared_with,
1601 strlen(not_shared_with) + 32);
1602 strcat(not_shared_with, node);
1603 strcat(not_shared_with, "\n");
1607 serv_getln(buf, sizeof buf);
1608 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1609 extract_token(cmd, buf, 0, '|', sizeof cmd);
1610 extract_token(node, buf, 1, '|', sizeof node);
1611 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1612 if (!strcasecmp(cmd, "ignet_push_share")) {
1613 shared_with = realloc(shared_with,
1614 strlen(shared_with) + 32);
1615 strcat(shared_with, node);
1616 if (!IsEmptyStr(remote_room)) {
1617 strcat(shared_with, "|");
1618 strcat(shared_with, remote_room);
1620 strcat(shared_with, "\n");
1624 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1625 extract_token(buf, shared_with, i, '\n', sizeof buf);
1626 extract_token(node, buf, 0, '|', sizeof node);
1627 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1628 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1629 if (!strcasecmp(node, cmd)) {
1630 remove_token(not_shared_with, j, '\n');
1635 /* Display the stuff */
1636 wc_printf("<CENTER><br />"
1637 "<table border=1 cellpadding=5><tr>"
1639 wc_printf(_("Shared with"));
1640 wc_printf("</I></B></td>"
1642 wc_printf(_("Not shared with"));
1643 wc_printf("</I></B></td></tr>\n"
1644 "<tr><td VALIGN=TOP>\n");
1646 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1647 wc_printf(_("Remote node name"));
1648 wc_printf("</td><td>");
1649 wc_printf(_("Remote room name"));
1650 wc_printf("</td><td>");
1651 wc_printf(_("Actions"));
1652 wc_printf("</td></tr>\n");
1654 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1655 extract_token(buf, shared_with, i, '\n', sizeof buf);
1656 extract_token(node, buf, 0, '|', sizeof node);
1657 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1658 if (!IsEmptyStr(node)) {
1659 wc_printf("<form method=\"POST\" action=\"netedit\">");
1660 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1661 wc_printf("<tr><td>%s</td>\n", node);
1664 if (!IsEmptyStr(remote_room)) {
1665 escputs(remote_room);
1671 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1672 "VALUE=\"ignet_push_share|");
1674 if (!IsEmptyStr(remote_room)) {
1676 urlescputs(remote_room);
1679 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1680 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1681 wc_printf("<input type=\"submit\" "
1682 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1683 wc_printf("</td></tr></form>\n");
1687 wc_printf("</table>\n");
1688 wc_printf("</td><td VALIGN=TOP>\n");
1689 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1690 wc_printf(_("Remote node name"));
1691 wc_printf("</td><td>");
1692 wc_printf(_("Remote room name"));
1693 wc_printf("</td><td>");
1694 wc_printf(_("Actions"));
1695 wc_printf("</td></tr>\n");
1697 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1698 extract_token(node, not_shared_with, i, '\n', sizeof node);
1699 if (!IsEmptyStr(node)) {
1700 wc_printf("<form method=\"POST\" action=\"netedit\">");
1701 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1702 wc_printf("<tr><td>");
1704 wc_printf("</td><td>"
1705 "<input type=\"INPUT\" "
1709 wc_printf("<input type=\"hidden\" "
1711 "VALUE=\"ignet_push_share|");
1714 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1715 "VALUE=\"sharing\">\n");
1716 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1717 "VALUE=\"add\">\n");
1718 wc_printf("<input type=\"submit\" "
1719 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1720 wc_printf("</td></tr></form>\n");
1724 wc_printf("</table>\n");
1725 wc_printf("</td></tr>"
1726 "</table></CENTER><br />\n"
1727 "<I><B>%s</B><ul><li>", _("Notes:"));
1728 wc_printf(_("When sharing a room, "
1729 "it must be shared from both ends. Adding a node to "
1730 "the 'shared' list sends messages out, but in order to"
1731 " receive messages, the other nodes must be configured"
1732 " to send messages out to your system as well. "
1733 "<li>If the remote room name is blank, it is assumed "
1734 "that the room name is identical on the remote node."
1735 "<li>If the remote room name is different, the remote "
1736 "node must also configure the name of the room here."
1740 wc_printf("</div>");
1743 if (not_shared_with != NULL)
1744 free (not_shared_with);
1746 /* Mailing list management */
1747 if (!strcmp(tab, "listserv")) {
1748 room_states RoomFlags;
1749 wc_printf("<div class=\"tabcontent\">");
1751 wc_printf("<br /><center>"
1752 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1753 "<tr><td VALIGN=TOP>");
1755 wc_printf(_("<i>The contents of this room are being "
1756 "mailed <b>as individual messages</b> "
1757 "to the following list recipients:"
1758 "</i><br /><br />\n"));
1761 serv_getln(buf, sizeof buf);
1762 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1763 extract_token(cmd, buf, 0, '|', sizeof cmd);
1764 if (!strcasecmp(cmd, "listrecp")) {
1765 extract_token(recp, buf, 1, '|', sizeof recp);
1768 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1771 wc_printf(_("(remove)"));
1772 wc_printf("</A><br />");
1775 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1776 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1777 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1778 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1779 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1780 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1781 wc_printf("</form>\n");
1783 wc_printf("</td><td VALIGN=TOP>\n");
1785 wc_printf(_("<i>The contents of this room are being "
1786 "mailed <b>in digest form</b> "
1787 "to the following list recipients:"
1788 "</i><br /><br />\n"));
1791 serv_getln(buf, sizeof buf);
1792 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1793 extract_token(cmd, buf, 0, '|', sizeof cmd);
1794 if (!strcasecmp(cmd, "digestrecp")) {
1795 extract_token(recp, buf, 1, '|', sizeof recp);
1798 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1802 wc_printf(_("(remove)"));
1803 wc_printf("</A><br />");
1806 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1807 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1808 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1809 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1810 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1811 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1812 wc_printf("</form>\n");
1814 wc_printf("</td></tr></table>\n");
1816 /** Pop open an address book -- begin **/
1817 wc_printf("<div align=right>"
1818 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1820 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1825 _("Add recipients from Contacts or other address books"),
1826 _("Add recipients from Contacts or other address books")
1828 /* Pop open an address book -- end **/
1830 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1832 get_roomflags (&RoomFlags);
1834 /* Self Service subscription? */
1835 wc_printf("<table><tr><td>\n");
1836 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1837 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1838 " <tr><td colspan=\"2\">\n",
1839 (is_selflist(&RoomFlags))?"checked":"");
1840 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1841 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1842 (is_https ? "https" : "http"),
1843 ChrPtr(WC->Hdr->HR.http_host));
1844 /* Public posting? */
1845 wc_printf("<tr><td>");
1846 wc_printf(_("Allow non-subscribers to mail to this room."));
1847 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1848 (is_publiclist(&RoomFlags))?"checked":"");
1850 /* Moderated List? */
1851 wc_printf("<tr><td>");
1852 wc_printf(_("Room post publication needs Aide permission."));
1853 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1854 (is_moderatedlist(&RoomFlags))?"checked":"");
1857 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1858 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1859 wc_printf("</table></form>");
1862 wc_printf("</CENTER>\n");
1863 wc_printf("</div>");
1867 /* Configuration of The Dreaded Auto-Purger */
1868 if (!strcmp(tab, "expire")) {
1869 wc_printf("<div class=\"tabcontent\">");
1871 serv_puts("GPEX room");
1872 serv_getln(buf, sizeof buf);
1873 if (!strncmp(buf, "550", 3)) {
1874 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1875 _("Higher access is required to access this function.")
1878 else if (buf[0] != '2') {
1879 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1882 roompolicy = extract_int(&buf[4], 0);
1883 roomvalue = extract_int(&buf[4], 1);
1885 serv_puts("GPEX floor");
1886 serv_getln(buf, sizeof buf);
1887 if (buf[0] == '2') {
1888 floorpolicy = extract_int(&buf[4], 0);
1889 floorvalue = extract_int(&buf[4], 1);
1892 wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1893 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1894 wc_printf("<table border=0 cellspacing=5>\n");
1895 wc_printf("<tr><td>");
1896 wc_printf(_("Message expire policy for this room"));
1897 wc_printf("<br />(");
1898 escputs(ChrPtr(WC->CurRoom.name));
1899 wc_printf(")</td><td>");
1900 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1901 ((roompolicy == 0) ? "CHECKED" : "") );
1902 wc_printf(_("Use the default policy for this floor"));
1903 wc_printf("<br />\n");
1904 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1905 ((roompolicy == 1) ? "CHECKED" : "") );
1906 wc_printf(_("Never automatically expire messages"));
1907 wc_printf("<br />\n");
1908 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1909 ((roompolicy == 2) ? "CHECKED" : "") );
1910 wc_printf(_("Expire by message count"));
1911 wc_printf("<br />\n");
1912 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1913 ((roompolicy == 3) ? "CHECKED" : "") );
1914 wc_printf(_("Expire by message age"));
1915 wc_printf("<br />");
1916 wc_printf(_("Number of messages or days: "));
1917 wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1918 wc_printf("</td></tr>\n");
1920 if (WC->axlevel >= 6) {
1921 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1922 wc_printf("<tr><td>");
1923 wc_printf(_("Message expire policy for this floor"));
1924 wc_printf("<br />(");
1925 escputs(floorlist[WC->CurRoom.floorid]);
1926 wc_printf(")</td><td>");
1927 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1928 ((floorpolicy == 0) ? "CHECKED" : "") );
1929 wc_printf(_("Use the system default"));
1930 wc_printf("<br />\n");
1931 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1932 ((floorpolicy == 1) ? "CHECKED" : "") );
1933 wc_printf(_("Never automatically expire messages"));
1934 wc_printf("<br />\n");
1935 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1936 ((floorpolicy == 2) ? "CHECKED" : "") );
1937 wc_printf(_("Expire by message count"));
1938 wc_printf("<br />\n");
1939 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1940 ((floorpolicy == 3) ? "CHECKED" : "") );
1941 wc_printf(_("Expire by message age"));
1942 wc_printf("<br />");
1943 wc_printf(_("Number of messages or days: "));
1944 wc_printf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1948 wc_printf("<CENTER>\n");
1949 wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1950 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1951 wc_printf(" ");
1952 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1953 wc_printf("</CENTER></td><tr>\n");
1955 wc_printf("</table>\n"
1956 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1961 wc_printf("</div>");
1964 /* Access controls */
1965 if (!strcmp(tab, "access")) {
1966 wc_printf("<div class=\"tabcontent\">");
1968 wc_printf("</div>");
1971 /* Fetch messages from remote locations */
1972 if (!strcmp(tab, "feeds")) {
1973 wc_printf("<div class=\"tabcontent\">");
1976 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1977 wc_printf("</i><br />\n");
1979 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
1980 "<tr class=\"even\"><th>");
1981 wc_printf(_("Remote host"));
1982 wc_printf("</th><th>");
1983 wc_printf(_("User name"));
1984 wc_printf("</th><th>");
1985 wc_printf(_("Password"));
1986 wc_printf("</th><th>");
1987 wc_printf(_("Keep messages on server?"));
1988 wc_printf("</th><th>");
1989 wc_printf(_("Interval"));
1990 wc_printf("</th><th> </th></tr>");
1993 serv_getln(buf, sizeof buf);
1995 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1996 extract_token(cmd, buf, 0, '|', sizeof cmd);
1997 if (!strcasecmp(cmd, "pop3client")) {
1998 safestrncpy(recp, &buf[11], sizeof recp);
2001 wc_printf("<tr class=\"%s\">",
2002 (bg ? "even" : "odd")
2006 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2011 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2015 wc_printf("<td>*****</td>"); /* Don't show the password */
2017 wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2019 wc_printf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2021 wc_printf("<td class=\"button_link\">");
2022 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2025 wc_printf(_("(remove)"));
2026 wc_printf("</a></td>");
2032 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2034 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2035 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2036 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2038 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2041 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2044 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2047 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2050 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2053 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2054 wc_printf("</td></tr>");
2055 wc_printf("</form></table>\n");
2057 wc_printf("<hr>\n");
2060 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2061 wc_printf("</i><br />\n");
2063 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2064 "<tr class=\"even\"><th>");
2065 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2066 wc_printf(_("Feed URL"));
2067 wc_printf("</th><th>");
2068 wc_printf("</th></tr>");
2071 serv_getln(buf, sizeof buf);
2073 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2074 extract_token(cmd, buf, 0, '|', sizeof cmd);
2075 if (!strcasecmp(cmd, "rssclient")) {
2076 safestrncpy(recp, &buf[10], sizeof recp);
2079 wc_printf("<tr class=\"%s\">",
2080 (bg ? "even" : "odd")
2084 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2088 wc_printf("<td class=\"button_link\">");
2089 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2092 wc_printf(_("(remove)"));
2093 wc_printf("</a></td>");
2099 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2101 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2102 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2103 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2105 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2106 "maxlength=\"256\" name=\"line_pop3host\">\n");
2109 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2110 wc_printf("</td></tr>");
2111 wc_printf("</form></table>\n");
2113 wc_printf("</div>");
2117 /* end content of whatever tab is open now */
2118 wc_printf("</div>\n");
2120 address_book_popup();
2126 * Toggle self-service list subscription
2128 void toggle_self_service(void) {
2129 room_states RoomFlags;
2131 get_roomflags (&RoomFlags);
2133 if (yesbstr("QR2_SelfList"))
2134 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2136 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2138 if (yesbstr("QR2_SMTP_PUBLIC"))
2139 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2141 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2143 if (yesbstr("QR2_Moderated"))
2144 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2146 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2147 if (yesbstr("QR2_SubsOnly"))
2148 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2150 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2152 set_roomflags (&RoomFlags);
2160 * save new parameters for a room
2167 StrBuf *er_password;
2169 StrBuf *er_roomaide;
2172 int er_listingorder;
2178 if (!havebstr("ok_button")) {
2179 strcpy(WC->ImportantMessage,
2180 _("Cancelled. Changes were not saved."));
2186 StrBuf_ServGetln(Buf);
2187 if (GetServerStatus(Buf, NULL) != 2) {
2188 StrBufCutLeft(Buf, 4);
2189 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2195 er_name = NewStrBuf();
2196 er_password = NewStrBuf();
2197 er_dirname = NewStrBuf();
2198 er_roomaide = NewStrBuf();
2200 StrBufCutLeft(Buf, 4);
2201 StrBufExtract_token(er_name, Buf, 0, '|');
2202 StrBufExtract_token(er_password, Buf, 1, '|');
2203 StrBufExtract_token(er_dirname, Buf, 2, '|');
2204 er_flags = StrBufExtract_int(Buf, 3, '|');
2205 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2206 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2207 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2209 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2210 if (StrLength(er_roomaide) == 0) {
2212 StrBuf_ServGetln(Buf);
2213 if (GetServerStatus(Buf, NULL) != 2) {
2214 FlushStrBuf(er_roomaide);
2216 StrBufCutLeft(Buf, 4);
2217 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2220 Ptr = sbstr("er_name");
2221 if (StrLength(Ptr) > 0) {
2222 FlushStrBuf(er_name);
2223 StrBufAppendBuf(er_name, Ptr, 0);
2226 Ptr = sbstr("er_password");
2227 if (StrLength(Ptr) > 0) {
2228 FlushStrBuf(er_password);
2229 StrBufAppendBuf(er_password, Ptr, 0);
2233 Ptr = sbstr("er_dirname");
2234 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2235 FlushStrBuf(er_dirname);
2236 StrBufAppendBuf(er_dirname, Ptr, 0);
2240 Ptr = sbstr("type");
2241 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2243 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2244 er_flags |= (QR_PRIVATE);
2246 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2247 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2249 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2250 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2252 if (!strcmp(ChrPtr(Ptr), "personal")) {
2253 er_flags |= QR_MAILBOX;
2255 er_flags &= ~QR_MAILBOX;
2258 if (yesbstr("prefonly")) {
2259 er_flags |= QR_PREFONLY;
2261 er_flags &= ~QR_PREFONLY;
2264 if (yesbstr("readonly")) {
2265 er_flags |= QR_READONLY;
2267 er_flags &= ~QR_READONLY;
2271 if (yesbstr("collabdel")) {
2272 er_flags2 |= QR2_COLLABDEL;
2274 er_flags2 &= ~QR2_COLLABDEL;
2277 if (yesbstr("permanent")) {
2278 er_flags |= QR_PERMANENT;
2280 er_flags &= ~QR_PERMANENT;
2283 if (yesbstr("subjectreq")) {
2284 er_flags2 |= QR2_SUBJECTREQ;
2286 er_flags2 &= ~QR2_SUBJECTREQ;
2289 if (yesbstr("network")) {
2290 er_flags |= QR_NETWORK;
2292 er_flags &= ~QR_NETWORK;
2295 if (yesbstr("directory")) {
2296 er_flags |= QR_DIRECTORY;
2298 er_flags &= ~QR_DIRECTORY;
2301 if (yesbstr("ulallowed")) {
2302 er_flags |= QR_UPLOAD;
2304 er_flags &= ~QR_UPLOAD;
2307 if (yesbstr("dlallowed")) {
2308 er_flags |= QR_DOWNLOAD;
2310 er_flags &= ~QR_DOWNLOAD;
2313 if (yesbstr("visdir")) {
2314 er_flags |= QR_VISDIR;
2316 er_flags &= ~QR_VISDIR;
2319 Ptr = sbstr("anon");
2321 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2322 if (!strcmp(ChrPtr(Ptr), "anononly"))
2323 er_flags |= QR_ANONONLY;
2324 if (!strcmp(ChrPtr(Ptr), "anon2"))
2325 er_flags |= QR_ANONOPT;
2327 bump = yesbstr("bump");
2329 er_floor = ibstr("er_floor");
2331 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2333 ChrPtr(er_password),
2342 StrBuf_ServGetln(Buf);
2343 if (GetServerStatus(Buf, NULL) != 2) {
2344 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2347 FreeStrBuf(&er_name);
2348 FreeStrBuf(&er_password);
2349 FreeStrBuf(&er_dirname);
2350 FreeStrBuf(&er_roomaide);
2355 if (StrLength(er_roomaide) > 0) {
2356 serv_printf("SETA %s", ChrPtr(er_roomaide));
2357 StrBuf_ServGetln(Buf);
2358 if (GetServerStatus(Buf, NULL) != 2) {
2359 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2360 display_main_menu();
2362 FreeStrBuf(&er_name);
2363 FreeStrBuf(&er_password);
2364 FreeStrBuf(&er_dirname);
2365 FreeStrBuf(&er_roomaide);
2370 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2373 FreeStrBuf(&er_name);
2374 FreeStrBuf(&er_password);
2375 FreeStrBuf(&er_dirname);
2376 FreeStrBuf(&er_roomaide);
2382 * Display form for Invite, Kick, and show Who Knows a room
2384 void do_invt_kick(void) {
2385 char buf[SIZ], room[SIZ], username[SIZ];
2388 serv_getln(buf, sizeof buf);
2390 if (buf[0] != '2') {
2394 extract_token(room, &buf[4], 0, '|', sizeof room);
2396 strcpy(username, bstr("username"));
2398 if (havebstr("kick_button")) {
2399 sprintf(buf, "KICK %s", username);
2401 serv_getln(buf, sizeof buf);
2403 if (buf[0] != '2') {
2404 strcpy(WC->ImportantMessage, &buf[4]);
2406 sprintf(WC->ImportantMessage,
2407 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2412 if (havebstr("invite_button")) {
2413 sprintf(buf, "INVT %s", username);
2415 serv_getln(buf, sizeof buf);
2417 if (buf[0] != '2') {
2418 strcpy(WC->ImportantMessage, &buf[4]);
2420 sprintf(WC->ImportantMessage,
2421 _("<B><I>User %s invited to room %s.</I></B>\n"),
2432 * Display form for Invite, Kick, and show Who Knows a room
2434 void display_whok(void)
2436 char buf[SIZ], room[SIZ], username[SIZ];
2439 serv_getln(buf, sizeof buf);
2441 if (buf[0] != '2') {
2445 extract_token(room, &buf[4], 0, '|', sizeof room);
2448 wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2449 wc_printf(_("The users listed below have access to this room. "
2450 "To remove a user from the access list, select the user "
2451 "name from the list and click 'Kick'."));
2452 wc_printf("<br /><br />");
2454 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2455 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2456 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2457 wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2459 serv_getln(buf, sizeof buf);
2460 if (buf[0] == '1') {
2461 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2462 extract_token(username, buf, 0, '|', sizeof username);
2463 wc_printf("<OPTION>");
2468 wc_printf("</select><br />\n");
2470 wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2471 wc_printf("</form></CENTER>\n");
2473 wc_printf("</td><td>");
2474 wc_printf(_("To grant another user access to this room, enter the "
2475 "user name in the box below and click 'Invite'."));
2476 wc_printf("<br /><br />");
2478 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2479 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2480 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2481 wc_printf(_("Invite:"));
2483 wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2484 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2485 "<input type=\"submit\" value=\"%s\">"
2486 "</form></CENTER>\n", _("Invite"));
2487 /* Pop open an address book -- begin **/
2489 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2491 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2494 _("Users"), _("Users")
2496 /* Pop open an address book -- end **/
2498 wc_printf("</td></tr></table>\n");
2499 address_book_popup();
2506 * display the form for entering a new room
2508 void display_entroom(void)
2515 serv_puts("CRE8 0");
2516 serv_getln(buf, sizeof buf);
2518 if (buf[0] != '2') {
2519 strcpy(WC->ImportantMessage, &buf[4]);
2520 display_main_menu();
2525 output_headers(1, 1, 1, 0, 0, 0);
2527 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2528 do_template("beginbox", NULL);
2530 wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2531 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2533 wc_printf("<table class=\"altern\"> ");
2535 wc_printf("<tr class=\"even\"><td>");
2536 wc_printf(_("Name of room: "));
2537 wc_printf("</td><td>");
2538 wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2539 wc_printf("</td></tr>");
2541 wc_printf("<tr class=\"odd\"><td>");
2542 wc_printf(_("Resides on floor: "));
2543 wc_printf("</td><td>");
2544 load_floorlist(Buf);
2545 wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2546 for (i = 0; i < 128; ++i)
2547 if (!IsEmptyStr(floorlist[i])) {
2548 wc_printf("<option ");
2549 wc_printf("value=\"%d\">", i);
2550 escputs(floorlist[i]);
2551 wc_printf("</option>\n");
2553 wc_printf("</select>\n");
2554 wc_printf("</td></tr>");
2557 * Our clever little snippet of JavaScript automatically selects
2558 * a public room if the view is set to Bulletin Board or wiki, and
2559 * it selects a mailbox room otherwise. The user can override this,
2560 * of course. We also disable the floor selector for mailboxes.
2562 wc_printf("<tr class=\"even\"><td>");
2563 wc_printf(_("Default view for room: "));
2564 wc_printf("</td><td>");
2565 wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2566 " if ( (this.form.er_view.value == 0) "
2567 " || (this.form.er_view.value == 6) ) { "
2568 " this.form.type[0].checked=true; "
2569 " this.form.er_floor.disabled = false; "
2572 " this.form.type[4].checked=true; "
2573 " this.form.er_floor.disabled = true; "
2576 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2577 if (is_view_allowed_as_default(i)) {
2578 wc_printf("<option %s value=\"%d\">",
2579 ((i == 0) ? "selected" : ""), i );
2580 escputs(viewdefs[i]);
2581 wc_printf("</option>\n");
2584 wc_printf("</select>\n");
2585 wc_printf("</td></tr>");
2587 wc_printf("<tr class=\"even\"><td>");
2588 wc_printf(_("Type of room:"));
2589 wc_printf("</td><td>");
2590 wc_printf("<ul class=\"adminlist\">\n");
2592 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2593 wc_printf("CHECKED OnChange=\""
2594 " if (this.form.type[0].checked == true) { "
2595 " this.form.er_floor.disabled = false; "
2598 wc_printf(_("Public (automatically appears to everyone)"));
2601 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2602 " if (this.form.type[1].checked == true) { "
2603 " this.form.er_floor.disabled = false; "
2606 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2609 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2610 " if (this.form.type[2].checked == true) { "
2611 " this.form.er_floor.disabled = false; "
2614 wc_printf(_("Private - require password: "));
2615 wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2618 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2619 " if (this.form.type[3].checked == true) { "
2620 " this.form.er_floor.disabled = false; "
2623 wc_printf(_("Private - invitation only"));
2626 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2628 " if (this.form.type[4].checked == true) { "
2629 " this.form.er_floor.disabled = true; "
2632 wc_printf(_("Personal (mailbox for you only)"));
2635 wc_printf("\n</ul>\n");
2636 wc_printf("</td></tr></table>\n");
2638 wc_printf("<div class=\"buttons\">\n");
2639 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2640 wc_printf(" ");
2641 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2642 wc_printf("</div>\n");
2643 wc_printf("</form>\n<hr />");
2644 serv_printf("MESG roomaccess");
2645 serv_getln(buf, sizeof buf);
2646 if (buf[0] == '1') {
2650 do_template("endbox", NULL);
2660 * support function for entroom() -- sets the default view
2662 void er_set_default_view(int newview) {
2675 serv_getln(buf, sizeof buf);
2676 if (buf[0] != '2') return;
2678 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2679 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2680 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2681 rm_bits1 = extract_int(&buf[4], 3);
2682 rm_floor = extract_int(&buf[4], 4);
2683 rm_listorder = extract_int(&buf[4], 5);
2684 rm_bits2 = extract_int(&buf[4], 7);
2686 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2687 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2688 rm_listorder, newview, rm_bits2
2690 serv_getln(buf, sizeof buf);
2701 const StrBuf *er_name;
2702 const StrBuf *er_type;
2703 const StrBuf *er_password;
2707 wcsession *WCC = WC;
2709 if (!havebstr("ok_button")) {
2710 strcpy(WC->ImportantMessage,
2711 _("Cancelled. No new room was created."));
2712 display_main_menu();
2715 er_name = sbstr("er_name");
2716 er_type = sbstr("type");
2717 er_password = sbstr("er_password");
2718 er_floor = ibstr("er_floor");
2719 er_view = ibstr("er_view");
2722 if (!strcmp(ChrPtr(er_type), "hidden"))
2724 else if (!strcmp(ChrPtr(er_type), "passworded"))
2726 else if (!strcmp(ChrPtr(er_type), "invonly"))
2728 else if (!strcmp(ChrPtr(er_type), "personal"))
2731 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2734 ChrPtr(er_password),
2739 serv_getln(buf, sizeof buf);
2740 if (buf[0] != '2') {
2741 strcpy(WCC->ImportantMessage, &buf[4]);
2742 display_main_menu();
2745 /** TODO: Room created, now update the left hand icon bar for this user */
2746 burn_folder_cache(0); /* burn the old folder cache */
2750 serv_printf("VIEW %d", er_view);
2751 serv_getln(buf, sizeof buf);
2752 WCC->CurRoom.view = er_view;
2754 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
2755 display_editroom ();
2757 do_change_view(er_view); /* Now go there */
2764 * \brief display the screen to enter a private room
2766 void display_private(char *rname, int req_pass)
2768 WCTemplputParams SubTP;
2770 output_headers(1, 1, 1, 0, 0, 0);
2772 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2773 memset(&SubTP, 0, sizeof(WCTemplputParams));
2774 SubTP.Filter.ContextType = CTX_STRBUF;
2775 SubTP.Context = Buf;
2776 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2781 wc_printf(_("If you know the name of a hidden (guess-name) or "
2782 "passworded room, you can enter that room by typing "
2783 "its name below. Once you gain access to a private "
2784 "room, it will appear in your regular room listings "
2785 "so you don't have to keep returning here."));
2788 wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2789 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2791 wc_printf("<table class=\"altern\"> "
2792 "<tr class=\"even\"><td>");
2793 wc_printf(_("Enter room name:"));
2794 wc_printf("</td><td>"
2795 "<input type=\"text\" name=\"gr_name\" "
2796 "value=\"%s\" maxlength=\"128\">\n", rname);
2799 wc_printf("</td></tr><tr class=\"odd\"><td>");
2800 wc_printf(_("Enter room password:"));
2801 wc_printf("</td><td>");
2802 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2804 wc_printf("</td></tr></table>\n");
2806 wc_printf("<div class=\"buttons\">\n");
2807 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2809 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2813 wc_printf("</div></form>\n");
2815 do_template("endbox", NULL);
2821 * \brief goto a private room
2823 void goto_private(void)
2828 if (!havebstr("ok_button")) {
2829 display_main_menu();
2832 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2833 serv_printf("GOTO %s|%s",
2836 serv_getln(buf, sizeof buf);
2838 if (buf[0] == '2') {
2839 smart_goto(sbstr("gr_name"));
2842 if (!strncmp(buf, "540", 3)) {
2843 display_private(bstr("gr_name"), 1);
2846 output_headers(1, 1, 1, 0, 0, 0);
2847 wc_printf("%s\n", &buf[4]);
2854 * \brief display the screen to zap a room
2856 void display_zap(void)
2858 output_headers(1, 1, 2, 0, 0, 0);
2860 wc_printf("<div id=\"banner\">\n");
2862 wc_printf(_("Zap (forget/unsubscribe) the current room"));
2863 wc_printf("</h1>\n");
2864 wc_printf("</div>\n");
2866 wc_printf("<div id=\"content\" class=\"service\">\n");
2868 wc_printf(_("If you select this option, <em>%s</em> will "
2869 "disappear from your room list. Is this what you wish "
2870 "to do?<br />\n"), ChrPtr(WC->CurRoom.name));
2872 wc_printf("<form method=\"POST\" action=\"zap\">\n");
2873 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2874 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2875 wc_printf(" ");
2876 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2877 wc_printf("</form>\n");
2888 StrBuf *final_destination;
2891 * If the forget-room routine fails for any reason, we fall back
2892 * to the current room; otherwise, we go to the Lobby
2894 final_destination = NewStrBufDup(WC->CurRoom.name);
2896 if (havebstr("ok_button")) {
2897 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
2898 serv_getln(buf, sizeof buf);
2899 if (buf[0] == '2') {
2901 serv_getln(buf, sizeof buf);
2902 if (buf[0] == '2') {
2903 FlushStrBuf(final_destination);
2904 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2908 smart_goto(final_destination);
2909 FreeStrBuf(&final_destination);
2915 * \brief Delete the current room
2917 void delete_room(void)
2922 serv_puts("KILL 1");
2923 serv_getln(buf, sizeof buf);
2924 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2925 if (buf[0] != '2') {
2926 strcpy(WC->ImportantMessage, &buf[4]);
2927 display_main_menu();
2932 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2941 * \brief Perform changes to a room's network configuration
2943 void netedit(void) {
2952 /*/ TODO: do line dynamic! */
2953 if (havebstr("line_pop3host")) {
2954 strcpy(line, bstr("prefix"));
2955 strcat(line, bstr("line_pop3host"));
2957 strcat(line, bstr("line_pop3user"));
2959 strcat(line, bstr("line_pop3pass"));
2961 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2963 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2964 strcat(line, bstr("suffix"));
2966 else if (havebstr("line")) {
2967 strcpy(line, bstr("prefix"));
2968 strcat(line, bstr("line"));
2969 strcat(line, bstr("suffix"));
2984 serv_getln(buf, sizeof buf);
2985 if (buf[0] != '1') {
2991 /** This loop works for add *or* remove. Spiffy, eh? */
2992 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2993 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2994 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2995 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2996 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2997 if ( (strcasecmp(cmpa0, cmpb0))
2998 || (strcasecmp(cmpa1, cmpb1)) ) {
2999 fprintf(fp, "%s\n", buf);
3005 serv_getln(buf, sizeof buf);
3006 if (buf[0] != '4') {
3012 while (fgets(buf, sizeof buf, fp) != NULL) {
3013 buf[strlen(buf)-1] = 0;
3017 if (havebstr("add_button")) {
3018 num_addrs = num_tokens(bstr("line"), ',');
3019 if (num_addrs < 2) {
3020 /* just adding one node or address */
3024 /* adding multiple addresses separated by commas */
3025 for (i=0; i<num_addrs; ++i) {
3026 strcpy(line, bstr("prefix"));
3027 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3030 strcat(line, bstr("suffix"));
3044 * \brief Convert a room name to a folder-ish-looking name.
3045 * \param folder the folderish name
3046 * \param room the room name
3047 * \param floor the floor name
3048 * \param is_mailbox is it a mailbox?
3050 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3055 * For mailboxes, just do it straight...
3058 sprintf(folder, "My folders|%s", room);
3062 * Otherwise, prefix the floor name as a "public folders" moniker
3065 if (floor > MAX_FLOORS) {
3067 sprintf(folder, "%%%%%%|%s", room);
3070 sprintf(folder, "%s|%s", floorlist[floor], room);
3075 * Replace "\" characters with "|" for pseudo-folder-delimiting
3077 len = strlen (folder);
3078 for (i=0; i<len; ++i) {
3079 if (folder[i] == '\\') folder[i] = '|';
3087 * \brief Back end for change_view()
3088 * \param newview set newview???
3090 void do_change_view(int newview) {
3093 serv_printf("VIEW %d", newview);
3094 serv_getln(buf, sizeof buf);
3095 WC->CurRoom.view = newview;
3096 smart_goto(WC->CurRoom.name);
3102 * \brief Change the view for this room
3104 void change_view(void) {
3107 view = lbstr("view");
3108 do_change_view(view);
3112 * \brief Burn the cached folder list.
3113 * \param age How old the cahce needs to be before we burn it.
3116 void burn_folder_cache(time_t age)
3118 /** If our cached folder list is very old, burn it. */
3119 if (WC->cache_fold != NULL) {
3120 if ((time(NULL) - WC->cache_timestamp) > age) {
3121 free(WC->cache_fold);
3122 WC->cache_fold = NULL;
3130 * \brief Do either a known rooms list or a folders list, depending on the
3135 StrBuf *ListView = NULL;
3137 /** Determine whether the user is trying to change views */
3138 if (havebstr("view")) {
3139 ListView = NewStrBufDup(SBSTR("view"));
3140 set_preference("roomlistview", ListView, 1);
3142 /** Sanitize the input so its safe */
3143 if((get_preference("roomlistview", &ListView) != 0)||
3144 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3145 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3147 if (ListView == NULL) {
3148 ListView = NewStrBufPlain(HKEY("rooms"));
3149 set_preference("roomlistview", ListView, 0);
3153 ListView = NewStrBufPlain(HKEY("rooms"));
3154 set_preference("roomlistview", ListView, 0);
3158 FreeStrBuf(&ListView);
3165 * \brief Set the message expire policy for this room and/or floor
3167 void set_room_policy(void) {
3170 if (!havebstr("ok_button")) {
3171 strcpy(WC->ImportantMessage,
3172 _("Cancelled. Changes were not saved."));
3177 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3178 serv_getln(buf, sizeof buf);
3179 strcpy(WC->ImportantMessage, &buf[4]);
3181 if (WC->axlevel >= 6) {
3182 strcat(WC->ImportantMessage, "<br />\n");
3183 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3184 serv_getln(buf, sizeof buf);
3185 strcat(WC->ImportantMessage, &buf[4]);
3191 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3193 StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3197 void _display_private(void) {
3198 display_private("", 0);
3201 void dotgoto(void) {
3202 if (!havebstr("room")) {
3203 readloop(readnew, eUseDefault);
3206 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3209 smart_goto(sbstr("room"));
3214 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3216 wcsession *WCC = WC;
3219 StrBufAppendTemplate(Target, TP,
3224 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3226 wc_printf("<div id=\"banner\">\n");
3227 embed_room_banner(NULL, navbar_default);
3228 wc_printf("</div>\n");
3232 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3234 wcsession *WCC = WC;
3237 (!IsEmptyStr(WCC->ugname)))
3238 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3241 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3243 wcsession *WCC = WC;
3244 return (WCC != NULL)?
3245 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3248 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3250 wcsession *WCC = WC;
3251 return (WCC == NULL)? 0 :
3252 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3253 (WCC->CurRoom.is_inbox) ||
3254 (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3257 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3259 wcsession *WCC = WC;
3261 return ((WCC!=NULL) &&
3262 (!IsEmptyStr(WCC->ugname)) &&
3263 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3267 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
3269 folder *Folder = (folder *)(TP->Context);
3272 UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3273 if (UA_CheckFlag == 0)
3274 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3275 "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
3277 return ((Folder->RAFlags & UA_CheckFlag) != 0);
3282 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3285 wcsession *WCC = WC;
3287 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3288 if (QR_CheckFlag == 0)
3289 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3290 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3292 return ((WCC!=NULL) &&
3293 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3296 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3299 folder *Folder = (folder *)(TP->Context);
3301 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3302 if (QR_CheckFlag == 0)
3303 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3304 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3305 return ((Folder->QRFlags & QR_CheckFlag) != 0);
3309 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3312 wcsession *WCC = WC;
3314 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3315 if (QR2_CheckFlag == 0)
3316 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3317 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3319 return ((WCC!=NULL) &&
3320 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3323 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3326 folder *Folder = (folder *)(TP->Context);
3328 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3329 if (QR2_CheckFlag == 0)
3330 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3331 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3332 return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3336 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3338 wcsession *WCC = WC;
3340 return ( (WCC!= NULL) &&
3341 ((WCC->axlevel >= 6) ||
3342 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3343 (WCC->CurRoom.is_inbox) ));
3346 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3348 wcsession *WCC = WC;
3350 if ((WCC == NULL) ||
3351 (TP->Tokens->nParameters < 3))
3353 return ((WCC->CurRoom.view < VIEW_BBS) ||
3354 (WCC->CurRoom.view > VIEW_MAX));
3357 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3361 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
3363 wcsession *WCC = WC;
3367 HashList *Whok = NULL;
3373 Token = NewStrBuf();
3374 StrBuf_ServGetln(Line);
3375 if (GetServerStatus(Line, &State) == 1)
3377 Whok = NewHash(1, Flathash);
3378 while(!Done && StrBuf_ServGetln(Line))
3379 if ( (StrLength(Line)==3) &&
3380 !strcmp(ChrPtr(Line), "000"))
3387 const char *Pos = NULL;
3388 Token = NewStrBufPlain (NULL, StrLength(Line));
3389 StrBufExtract_NextToken(Token, Line, &Pos, '|');
3397 else if (State == 550)
3398 StrBufAppendBufPlain(WCC->ImportantMsg,
3399 _("Higher access is required to access this function."), -1, 0);
3409 initialize_viewdefs();
3410 RegisterPreference("roomlistview",
3411 _("Room list view"),
3414 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3416 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3419 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3420 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3421 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3422 WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3423 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3424 WebcitAddUrlHandler(HKEY("zapped_list"), "", 0, zapped_list, 0);
3425 WebcitAddUrlHandler(HKEY("display_zap"), "", 0, display_zap, 0);
3426 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3427 WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3428 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3429 WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3430 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3431 WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3432 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3433 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3434 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3435 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3436 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3437 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3438 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3440 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3441 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3442 RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3444 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3445 RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3446 RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
3448 RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
3449 RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
3450 RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3451 RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3452 RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3453 RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3454 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3455 RegisterNamespace("THISROOM:INFOTEXT", 1, 2, tmplput_CurrentRoomInfoText, NULL, CTX_NONE);
3456 RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3457 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3458 RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
3459 RegisterConditional(HKEY("COND:THISROOM:HAVE_INFOTEXT"), 0, ConditionalThisRoomXHaveInfoText, CTX_NONE);
3462 REGISTERTokenParamDefine(QR_PERMANENT);
3463 REGISTERTokenParamDefine(QR_INUSE);
3464 REGISTERTokenParamDefine(QR_PRIVATE);
3465 REGISTERTokenParamDefine(QR_PASSWORDED);
3466 REGISTERTokenParamDefine(QR_GUESSNAME);
3467 REGISTERTokenParamDefine(QR_DIRECTORY);
3468 REGISTERTokenParamDefine(QR_UPLOAD);
3469 REGISTERTokenParamDefine(QR_DOWNLOAD);
3470 REGISTERTokenParamDefine(QR_VISDIR);
3471 REGISTERTokenParamDefine(QR_ANONONLY);
3472 REGISTERTokenParamDefine(QR_ANONOPT);
3473 REGISTERTokenParamDefine(QR_NETWORK);
3474 REGISTERTokenParamDefine(QR_PREFONLY);
3475 REGISTERTokenParamDefine(QR_READONLY);
3476 REGISTERTokenParamDefine(QR_MAILBOX);
3477 REGISTERTokenParamDefine(QR2_SYSTEM);
3478 REGISTERTokenParamDefine(QR2_SELFLIST);
3479 REGISTERTokenParamDefine(QR2_COLLABDEL);
3480 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3481 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3482 REGISTERTokenParamDefine(QR2_MODERATED);
3484 REGISTERTokenParamDefine(UA_KNOWN);
3485 REGISTERTokenParamDefine(UA_GOTOALLOWED);
3486 REGISTERTokenParamDefine(UA_HASNEWMSGS);
3487 REGISTERTokenParamDefine(UA_ZAPPED);
3488 REGISTERTokenParamDefine(UA_POSTALLOWED);
3489 REGISTERTokenParamDefine(UA_ADMINALLOWED);
3490 REGISTERTokenParamDefine(UA_DELETEALLOWED);
3491 REGISTERTokenParamDefine(UA_ISTRASH);
3493 REGISTERTokenParamDefine(US_NEEDVALID);
3494 REGISTERTokenParamDefine(US_PERM);
3495 REGISTERTokenParamDefine(US_LASTOLD);
3496 REGISTERTokenParamDefine(US_EXPERT);
3497 REGISTERTokenParamDefine(US_UNLISTED);
3498 REGISTERTokenParamDefine(US_NOPROMPT);
3499 REGISTERTokenParamDefine(US_PROMPTCTL);
3500 REGISTERTokenParamDefine(US_DISAPPEAR);
3501 REGISTERTokenParamDefine(US_REGIS);
3502 REGISTERTokenParamDefine(US_PAGINATOR);
3503 REGISTERTokenParamDefine(US_INTERNET);
3504 REGISTERTokenParamDefine(US_FLOORS);
3505 REGISTERTokenParamDefine(US_COLOR);
3506 REGISTERTokenParamDefine(US_USER_SET);
3508 REGISTERTokenParamDefine(VIEW_BBS);
3509 REGISTERTokenParamDefine(VIEW_MAILBOX);
3510 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3511 REGISTERTokenParamDefine(VIEW_CALENDAR);
3512 REGISTERTokenParamDefine(VIEW_TASKS);
3513 REGISTERTokenParamDefine(VIEW_NOTES);
3514 REGISTERTokenParamDefine(VIEW_WIKI);
3515 REGISTERTokenParamDefine(VIEW_CALBRIEF);
3516 REGISTERTokenParamDefine(VIEW_JOURNAL);
3517 REGISTERTokenParamDefine(VIEW_BLOG);
3520 REGISTERTokenParamDefine(ignet_push_share);
3521 { /* these are the parts of an IGNET push config */
3522 REGISTERTokenParamDefine(GNET_IGNET_NODE);
3523 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
3525 REGISTERTokenParamDefine(listrecp);
3526 REGISTERTokenParamDefine(digestrecp);
3527 REGISTERTokenParamDefine(pop3client);
3528 { /* These are the parts of a pop3 client line... */
3529 REGISTERTokenParamDefine(GNET_POP3_HOST);
3530 REGISTERTokenParamDefine(GNET_POP3_USER);
3531 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
3532 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
3534 REGISTERTokenParamDefine(rssclient);
3535 REGISTERTokenParamDefine(participate);
3537 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3538 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3540 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3541 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3543 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3544 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3545 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3552 SessionDestroyModule_ROOMOPS
3555 FlushFolder(&sess->CurRoom);
3556 if (sess->cache_fold != NULL) {
3557 free(sess->cache_fold);
3560 free_march_list(sess);
3561 DeleteHash(&sess->Floors);
3562 DeleteHash(&sess->Rooms);
3563 DeleteHash(&sess->FloorsByName);