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);
351 do_template("roombanner", NULL);
352 /* roombanner contains this for mobile */
353 if (navbar_style != navbar_none && (WC->is_mobile < 1)) {
355 wc_printf("<div id=\"navbar\"><ul>");
357 if (navbar_style == navbar_default) wc_printf(
358 "<li class=\"ungoto\">"
359 "<a href=\"ungoto\">"
360 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
361 "<span class=\"navbar_link\">%s</span></A>"
362 "</li>\n", _("Ungoto")
365 if ( (navbar_style == navbar_default) && (WC->CurRoom.view == VIEW_BBS) ) {
367 "<li class=\"newmess\">"
368 "<a href=\"readnew\">"
369 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
370 "<span class=\"navbar_link\">%s</span></A>"
371 "</li>\n", _("Read new messages")
375 if (navbar_style == navbar_default) {
376 switch(WC->CurRoom.view) {
377 case VIEW_ADDRESSBOOK:
379 "<li class=\"viewcontacts\">"
380 "<a href=\"readfwd\">"
381 "<img src=\"static/viewcontacts_24x.gif\" "
382 "alt=\"\" width=\"24\" height=\"24\">"
383 "<span class=\"navbar_link\">"
385 "</span></a></li>\n", _("View contacts")
390 "<li class=\"staskday\">"
391 "<a href=\"readfwd?calview=day\">"
392 "<img src=\"static/taskday2_24x.gif\" "
393 "alt=\"\" width=\"24\" height=\"24\">"
394 "<span class=\"navbar_link\">"
396 "</span></a></li>\n", _("Day view")
399 "<li class=\"monthview\">"
400 "<a href=\"readfwd?calview=month\">"
401 "<img src=\"static/monthview2_24x.gif\" "
402 "alt=\"\" width=\"24\" height=\"24\">"
403 "<span class=\"navbar_link\">"
405 "</span></a></li>\n", _("Month view")
410 "<li class=\"monthview\">"
411 "<a href=\"readfwd?calview=month\">"
412 "<img src=\"static/monthview2_24x.gif\" "
413 "alt=\"\" width=\"24\" height=\"24\">"
414 "<span class=\"navbar_link\">"
416 "</span></a></li>\n", _("Calendar list")
421 "<li class=\"taskmanag\">"
422 "<a href=\"readfwd\">"
423 "<img src=\"static/taskmanag_24x.gif\" "
424 "alt=\"\" width=\"24\" height=\"24\">"
425 "<span class=\"navbar_link\">"
427 "</span></a></li>\n", _("View tasks")
432 "<li class=\"viewnotes\">"
433 "<a href=\"readfwd\">"
434 "<img src=\"static/viewnotes_24x.gif\" "
435 "alt=\"\" width=\"24\" height=\"24\">"
436 "<span class=\"navbar_link\">"
438 "</span></a></li>\n", _("View notes")
443 "<li class=\"readallmess\">"
444 "<a id=\"m_refresh\" href=\"readfwd\">"
445 "<img src=\"static/readallmess3_24x.gif\" "
446 "alt=\"\" width=\"24\" height=\"24\">"
447 "<span class=\"navbar_link\">"
449 "</span></a></li>\n", _("Refresh message list")
454 "<li class=\"readallmess\">"
455 "<a href=\"wiki?page=home\">"
456 "<img src=\"static/readallmess3_24x.gif\" "
457 "alt=\"\" width=\"24\" height=\"24\">"
458 "<span class=\"navbar_link\">"
460 "</span></a></li>\n", _("Wiki home")
465 "<li class=\"readallmess\">"
466 "<a href=\"readfwd\">"
467 "<img src=\"static/readallmess3_24x.gif\" "
468 "alt=\"\" width=\"24\" height=\"24\">"
469 "<span class=\"navbar_link\">"
471 "</span></a></li>\n", _("Read all messages")
477 if (navbar_style == navbar_default) {
478 switch(WC->CurRoom.view) {
479 case VIEW_ADDRESSBOOK:
481 "<li class=\"addnewcontact\">"
482 "<a href=\"display_enter\">"
483 "<img src=\"static/addnewcontact_24x.gif\" "
484 "alt=\"\" width=\"24\" height=\"24\">"
485 "<span class=\"navbar_link\">"
487 "</span></a></li>\n", _("Add new contact")
492 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
493 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
494 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
495 if (havebstr("day" )) wc_printf("?day=%s", bstr("day"));
497 "<img src=\"static/addevent_24x.gif\" "
498 "alt=\"\" width=\"24\" height=\"24\">"
499 "<span class=\"navbar_link\">"
501 "</span></a></li>\n", _("Add new event")
506 "<li class=\"newmess\">"
507 "<a href=\"display_enter\">"
508 "<img src=\"static/newmess3_24x.gif\" "
509 "alt=\"\" width=\"24\" height=\"24\">"
510 "<span class=\"navbar_link\">"
512 "</span></a></li>\n", _("Add new task")
517 "<li class=\"enternewnote\">"
518 "<a href=\"add_new_note\">"
519 "<img src=\"static/enternewnote_24x.gif\" "
520 "alt=\"\" width=\"24\" height=\"24\">"
521 "<span class=\"navbar_link\">"
523 "</span></a></li>\n", _("Add new note")
527 safestrncpy(buf, bstr("page"), sizeof buf);
528 if (IsEmptyStr(buf)) {
529 safestrncpy(buf, "home", sizeof buf);
533 "<li class=\"newmess\">"
534 "<a href=\"display_enter?page=%s\">"
535 "<img src=\"static/newmess3_24x.gif\" "
536 "alt=\"\" width=\"24\" height=\"24\">"
537 "<span class=\"navbar_link\">"
539 "</span></a></li>\n", buf, _("Edit this page")
542 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
543 /* already viewing history; display a link to the current page */
545 "<li class=\"newmess\">"
546 "<a href=\"wiki?page=%s\">"
547 "<img src=\"static/newmess3_24x.gif\" "
548 "alt=\"\" width=\"24\" height=\"24\">"
549 "<span class=\"navbar_link\">"
551 "</span></a></li>\n", buf, _("Current version")
555 /* display a link to the history */
557 "<li class=\"newmess\">"
558 "<a href=\"wiki_history?page=%s\">"
559 "<img src=\"static/newmess3_24x.gif\" "
560 "alt=\"\" width=\"24\" height=\"24\">"
561 "<span class=\"navbar_link\">"
563 "</span></a></li>\n", buf, _("History")
569 "<li class=\"newmess\">"
570 "<a href=\"display_enter\">"
571 "<img src=\"static/newmess3_24x.gif\" "
572 "alt=\"\" width=\"24\" height=\"24\">"
573 "<span class=\"navbar_link\">"
575 "</span></a></li>\n", _("Write mail")
578 "<li class=\"newmess\">"
579 "<a href=\"javascript:deleteAllSelectedMessages();\">"
580 "<img src=\"static/delete.gif\" "
581 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
583 "</span></a></li>\n", _("Delete")
588 "<li class=\"newmess\">"
589 "<a href=\"display_enter\">"
590 "<img src=\"static/newmess3_24x.gif\" "
591 "alt=\"\" width=\"24\" height=\"24\">"
592 "<span class=\"navbar_link\">"
594 "</span></a></li>\n", _("Enter a message")
600 if (navbar_style == navbar_default) wc_printf(
601 "<li class=\"skipthisroom\">"
604 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
605 "width=\"24\" height=\"24\">"
606 "<span class=\"navbar_link\">%s</span></a>"
608 _("Leave all messages marked as unread, go to next room with unread messages"),
612 if (navbar_style == navbar_default) wc_printf(
613 "<li class=\"markngo\">"
614 "<a href=\"gotonext\" "
616 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
617 "width=\"24\" height=\"24\">"
618 "<span class=\"navbar_link\">%s</span></a>"
620 _("Mark all messages as read, go to next room with unread messages"),
624 wc_printf("</ul></div>\n");
631 * back end routine to take the session to a new room
633 long gotoroom(const StrBuf *gname)
637 static long ls = (-1L);
640 /* store ungoto information */
641 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
645 /* move to the new room */
646 serv_printf("GOTO %s", ChrPtr(gname));
647 StrBuf_ServGetln(Buf);
648 if (GetServerStatus(Buf, &err) != 2) {
649 serv_puts("GOTO _BASEROOM_");
650 StrBuf_ServGetln(Buf);
652 * well, we know that this is the fallback case,
653 * but we're interested that the first command
654 * didn't work out in first place.
656 if (GetServerStatus(Buf, NULL) != 2) {
661 ParseGoto(&WCC->CurRoom, Buf);
663 remove_march(WCC->CurRoom.name);
664 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
672 void ParseGoto(folder *room, StrBuf *Line)
680 if (StrLength(Line) < 4) {
684 /* ignore the commandstate... */
685 Pos = ChrPtr(Line) + 4;
687 if (room->RoomNameParts != NULL)
690 for (i=0; i < room->nRoomNameParts; i++)
691 FreeStrBuf(&room->RoomNameParts[i]);
692 free(room->RoomNameParts);
693 room->RoomNameParts = NULL;
698 pBuf = NewStrBufPlain(NULL, StrLength(Line));
701 memset(room, 0, sizeof(folder));
704 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
706 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
707 if (room->nNewMessages > 0)
708 room->RAFlags |= UA_HASNEWMSGS;
710 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
712 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
714 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
716 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
717 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
719 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
721 flag = StrBufExtractNext_long(Line, &Pos, '|');
722 if (WCC->is_aide || flag) {
723 room->RAFlags |= UA_ADMINALLOWED;
726 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
728 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
730 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
732 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
734 flag = StrBufExtractNext_long(Line, &Pos, '|');
736 room->RAFlags |= UA_ISTRASH; // wc_is_trash
738 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
740 /* find out, whether we are in a sub-room */
741 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
742 if (room->nRoomNameParts > 1)
747 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
748 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
749 for (i=0; i < room->nRoomNameParts; i++)
751 room->RoomNameParts[i] = NewStrBuf();
752 StrBufExtract_NextToken(room->RoomNameParts[i],
753 room->name, &Pos, '\\');
757 /* Private mailboxes on the main floor get remapped to the personal folder */
758 if ((room->QRFlags & QR_MAILBOX) &&
759 (room->floorid == 0))
761 room->floorid = VIRTUAL_MY_FLOOR;
762 if ((room->nRoomNameParts == 1) &&
763 (StrLength(room->name) == 4) &&
764 (strcmp(ChrPtr(room->name), "Mail") == 0))
770 /* get a pointer to the floor we're on: */
771 if (WCC->Floors == NULL)
772 GetFloorListHash(NULL, NULL);
774 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
775 room->Floor = (const Floor*) vFloor;
778 void LoadRoomAide(void)
783 if (WCC->CurRoom.RoomAideLoaded)
786 WCC->CurRoom.RoomAideLoaded = 1;
789 StrBuf_ServGetln(Buf);
790 if (GetServerStatus(Buf, NULL) != 2) {
791 FlushStrBuf(WCC->CurRoom.RoomAide);
792 AppendImportantMessage (ChrPtr(Buf) + 4,
797 Pos = ChrPtr(Buf) + 4;
799 FreeStrBuf(&WCC->CurRoom.RoomAide);
800 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
802 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
806 void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
809 folder *Folder = &WCC->CurRoom;
810 const Floor *pFloor = Folder->Floor;
815 StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
818 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
824 StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
828 void LoadRoomXA (void)
833 if (WCC->CurRoom.XALoaded)
836 WCC->CurRoom.XALoaded = 1;
839 StrBuf_ServGetln(Buf);
840 if (GetServerStatus(Buf, NULL) != 2) {
841 FlushStrBuf(WCC->CurRoom.XAPass);
842 FlushStrBuf(WCC->CurRoom.Directory);
844 AppendImportantMessage (ChrPtr(Buf) + 4,
849 Pos = ChrPtr(Buf) + 4;
851 FreeStrBuf(&WCC->CurRoom.XAPass);
852 FreeStrBuf(&WCC->CurRoom.Directory);
854 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
855 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
857 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
858 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
859 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
860 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
861 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
862 WCC->CurRoom.DefView = StrBufExtractNext_long(Buf, &Pos, '|');
863 /* QR2Flags, we already know them... */
870 void LoadXRoomPic(void)
875 if (WCC->CurRoom.XHaveRoomPicLoaded)
878 WCC->CurRoom.XHaveRoomPicLoaded = 1;
880 serv_puts("OIMG _roompic_");
881 StrBuf_ServGetln(Buf);
882 if (GetServerStatus(Buf, NULL) != 2) {
883 WCC->CurRoom.XHaveRoomPic = 0;
885 WCC->CurRoom.XHaveRoomPic = 1;
888 StrBuf_ServGetln(Buf);
889 GetServerStatus(Buf, NULL);
893 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
901 return WCC->CurRoom.XHaveRoomPic == 1;
904 void LoadXRoomInfoText(void)
910 if (WCC->CurRoom.XHaveInfoTextLoaded)
913 WCC->CurRoom.XHaveInfoTextLoaded = 1;
918 StrBuf_ServGetln(Buf);
919 if (GetServerStatus(Buf, NULL) == 1) {
920 WCC->CurRoom.XInfoText = NewStrBuf ();
922 while (!Done && StrBuf_ServGetln(Buf)>=0) {
923 if ( (StrLength(Buf)==3) &&
924 !strcmp(ChrPtr(Buf), "000"))
927 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
934 int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
942 return (StrLength(WCC->CurRoom.XInfoText)>0);
945 void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
951 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1);
954 void LoadXRoomXCountFiles(void)
960 if (WCC->CurRoom.XHaveDownloadCount)
963 WCC->CurRoom.XHaveDownloadCount = 1;
967 StrBuf_ServGetln(Buf);
968 if (GetServerStatus(Buf, NULL) == 1) {
970 while (!Done && StrBuf_ServGetln(Buf)>=0) {
971 if ( (StrLength(Buf)==3) &&
972 !strcmp(ChrPtr(Buf), "000"))
975 WCC->CurRoom.XDownloadCount++;
982 void tmplput_CurrentRoomXNFiles(StrBuf *Target, WCTemplputParams *TP)
986 LoadXRoomXCountFiles();
988 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.XDownloadCount);
991 void tmplput_CurrentRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
995 LoadXRoomXCountFiles();
997 if (WCC->CurRoom.XDownloadCount == 1)
998 StrBufAppendBufPlain(Target, _("file"), -1, 0);
1000 StrBufAppendBufPlain(Target, _("files"), -1, 0);
1003 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
1005 wcsession *WCC = WC;
1009 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
1011 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
1013 wcsession *WCC = WC;
1017 StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
1019 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
1021 wcsession *WCC = WC;
1025 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
1027 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1029 wcsession *WCC = WC;
1033 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.DefView);
1036 void tmplput_CurrentRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP)
1038 wcsession *WCC = WC;
1042 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
1045 void tmplput_CurrentRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP)
1047 wcsession *WCC = WC;
1051 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nTotalMessages);
1054 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
1056 wcsession *WCC = WC;
1064 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1065 return CheckThis == WCC->CurRoom.Order;
1068 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1070 wcsession *WCC = WC;
1078 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1079 return CheckThis == WCC->CurRoom.DefView;
1089 void smart_goto(const StrBuf *next_room) {
1090 gotoroom(next_room);
1091 readloop(readnew, eUseDefault);
1097 * mark all messages in current room as having been read
1099 void slrp_highest(void)
1103 serv_puts("SLRP HIGHEST");
1104 serv_getln(buf, sizeof buf);
1108 typedef struct __room_states {
1123 * Set/clear/read the "self-service list subscribe" flag for a room
1125 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1126 * returns the new value.
1129 int self_service(int newval) {
1130 int current_value = 0;
1136 int flags, floor, order, view, flags2;
1139 serv_getln(buf, sizeof buf);
1140 if (buf[0] != '2') return(0);
1142 extract_token(name, &buf[4], 0, '|', sizeof name);
1143 extract_token(password, &buf[4], 1, '|', sizeof password);
1144 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1145 flags = extract_int(&buf[4], 3);
1146 floor = extract_int(&buf[4], 4);
1147 order = extract_int(&buf[4], 5);
1148 view = extract_int(&buf[4], 6);
1149 flags2 = extract_int(&buf[4], 7);
1151 if (flags2 & QR2_SELFLIST) {
1159 flags2 = flags2 | QR2_SELFLIST;
1161 else if (newval == 0) {
1162 flags2 = flags2 & ~QR2_SELFLIST;
1165 return(current_value);
1168 if (newval != current_value) {
1169 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1170 name, password, dirname, flags,
1171 floor, order, view, flags2);
1172 serv_getln(buf, sizeof buf);
1179 int is_selflist(room_states *RoomFlags)
1181 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1184 int is_publiclist(room_states *RoomFlags)
1186 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1189 int is_moderatedlist(room_states *RoomFlags)
1191 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1195 * Set/clear/read the "self-service list subscribe" flag for a room
1197 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1198 * returns the new value.
1201 int get_roomflags(room_states *RoomOps)
1206 serv_getln(buf, sizeof buf);
1207 if (buf[0] != '2') return(0);
1209 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1210 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1211 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1212 RoomOps->flags = extract_int(&buf[4], 3);
1213 RoomOps->floor = extract_int(&buf[4], 4);
1214 RoomOps->order = extract_int(&buf[4], 5);
1215 RoomOps->view = extract_int(&buf[4], 6);
1216 RoomOps->flags2 = extract_int(&buf[4], 7);
1220 int set_roomflags(room_states *RoomOps)
1224 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1233 serv_getln(buf, sizeof buf);
1243 * display the form for editing a room
1245 void display_editroom(void)
1251 char remote_room[128];
1254 char er_password[10];
1255 char er_dirname[15];
1256 char er_roomaide[26];
1263 char *not_shared_with = NULL;
1266 int floorpolicy = 0;
1268 char pop3_host[128];
1273 if (IsEmptyStr(tab)) tab = "admin";
1276 load_floorlist(Buf);
1278 output_headers(1, 1, 1, 0, 0, 0);
1280 wc_printf("<div class=\"fix_scrollbar_bug\">");
1282 wc_printf("<br />\n");
1284 /* print the tabbed dialog */
1285 wc_printf("<div align=\"center\">");
1286 wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1287 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1290 wc_printf("<td class=\"");
1291 if (!strcmp(tab, "admin")) {
1292 wc_printf(" tab_cell_label\">");
1293 wc_printf(_("Administration"));
1296 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1297 wc_printf(_("Administration"));
1300 wc_printf("</td>\n");
1301 wc_printf("<td> </td>\n");
1303 if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1305 wc_printf("<td class=\"");
1306 if (!strcmp(tab, "config")) {
1307 wc_printf(" tab_cell_label\">");
1308 wc_printf(_("Configuration"));
1311 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1312 wc_printf(_("Configuration"));
1315 wc_printf("</td>\n");
1316 wc_printf("<td> </td>\n");
1318 wc_printf("<td class=\"");
1319 if (!strcmp(tab, "expire")) {
1320 wc_printf(" tab_cell_label\">");
1321 wc_printf(_("Message expire policy"));
1324 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1325 wc_printf(_("Message expire policy"));
1328 wc_printf("</td>\n");
1329 wc_printf("<td> </td>\n");
1331 wc_printf("<td class=\"");
1332 if (!strcmp(tab, "access")) {
1333 wc_printf(" tab_cell_label\">");
1334 wc_printf(_("Access controls"));
1337 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1338 wc_printf(_("Access controls"));
1341 wc_printf("</td>\n");
1342 wc_printf("<td> </td>\n");
1344 wc_printf("<td class=\"");
1345 if (!strcmp(tab, "sharing")) {
1346 wc_printf(" tab_cell_label\">");
1347 wc_printf(_("Sharing"));
1350 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1351 wc_printf(_("Sharing"));
1354 wc_printf("</td>\n");
1355 wc_printf("<td> </td>\n");
1357 wc_printf("<td class=\"");
1358 if (!strcmp(tab, "listserv")) {
1359 wc_printf(" tab_cell_label\">");
1360 wc_printf(_("Mailing list service"));
1363 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1364 wc_printf(_("Mailing list service"));
1367 wc_printf("</td>\n");
1368 wc_printf("<td> </td>\n");
1372 wc_printf("<td class=\"");
1373 if (!strcmp(tab, "feeds")) {
1374 wc_printf(" tab_cell_label\">");
1375 wc_printf(_("Remote retrieval"));
1378 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1379 wc_printf(_("Remote retrieval"));
1382 wc_printf("</td>\n");
1383 wc_printf("<td> </td>\n");
1385 wc_printf("</tr></table>\n");
1386 wc_printf("</div>\n");
1387 /* end tabbed dialog */
1389 wc_printf("<script type=\"text/javascript\">"
1390 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1394 /* begin content of whatever tab is open now */
1396 if (!strcmp(tab, "admin")) {
1397 wc_printf("<div class=\"tabcontent\">");
1399 "<li><a href=\"delete_room\" "
1400 "onClick=\"return confirm('");
1401 wc_printf(_("Are you sure you want to delete this room?"));
1402 wc_printf("');\">\n");
1403 wc_printf(_("Delete this room"));
1405 "<li><a href=\"display_editroompic?which_room=");
1406 urlescputs(ChrPtr(WC->CurRoom.name));
1408 wc_printf(_("Set or change the icon for this room's banner"));
1410 "<li><a href=\"display_editinfo\">\n");
1411 wc_printf(_("Edit this room's Info file"));
1414 wc_printf("</div>");
1417 if (!strcmp(tab, "config")) {
1418 wc_printf("<div class=\"tabcontent\">");
1420 serv_getln(buf, sizeof buf);
1422 if (!strncmp(buf, "550", 3)) {
1423 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1424 _("Higher access is required to access this function.")
1427 else if (buf[0] != '2') {
1428 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1431 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1432 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1433 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1434 er_flags = extract_int(&buf[4], 3);
1435 er_floor = extract_int(&buf[4], 4);
1436 er_flags2 = extract_int(&buf[4], 7);
1438 wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1439 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1441 wc_printf("<ul><li>");
1442 wc_printf(_("Name of room: "));
1443 wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1449 wc_printf(_("Resides on floor: "));
1450 wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1451 if (er_flags & QR_MAILBOX)
1452 wc_printf("disabled >\n");
1453 for (i = 0; i < 128; ++i)
1454 if (!IsEmptyStr(floorlist[i])) {
1455 wc_printf("<OPTION ");
1457 wc_printf("SELECTED ");
1458 wc_printf("VALUE=\"%d\">", i);
1459 escputs(floorlist[i]);
1460 wc_printf("</OPTION>\n");
1462 wc_printf("</select>\n");
1465 wc_printf(_("Type of room:"));
1466 wc_printf("<ul>\n");
1468 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1469 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1470 wc_printf("CHECKED ");
1471 wc_printf("OnChange=\""
1472 " if (this.form.type[0].checked == true) { "
1473 " this.form.er_floor.disabled = false; "
1476 wc_printf(_("Public (automatically appears to everyone)"));
1479 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1480 if ((er_flags & QR_PRIVATE) &&
1481 (er_flags & QR_GUESSNAME))
1482 wc_printf("CHECKED ");
1483 wc_printf(" OnChange=\""
1484 " if (this.form.type[1].checked == true) { "
1485 " this.form.er_floor.disabled = false; "
1488 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1490 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1491 if ((er_flags & QR_PRIVATE) &&
1492 (er_flags & QR_PASSWORDED))
1493 wc_printf("CHECKED ");
1494 wc_printf(" OnChange=\""
1495 " if (this.form.type[2].checked == true) { "
1496 " this.form.er_floor.disabled = false; "
1499 wc_printf(_("Private - require password: "));
1500 wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1503 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1504 if ((er_flags & QR_PRIVATE)
1505 && ((er_flags & QR_GUESSNAME) == 0)
1506 && ((er_flags & QR_PASSWORDED) == 0))
1507 wc_printf("CHECKED ");
1508 wc_printf(" OnChange=\""
1509 " if (this.form.type[3].checked == true) { "
1510 " this.form.er_floor.disabled = false; "
1513 wc_printf(_("Private - invitation only"));
1515 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1516 if (er_flags & QR_MAILBOX)
1517 wc_printf("CHECKED ");
1518 wc_printf (" OnChange=\""
1519 " if (this.form.type[4].checked == true) { "
1520 " this.form.er_floor.disabled = true; "
1523 wc_printf(_("Personal (mailbox for you only)"));
1525 wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1527 wc_printf(_("If private, cause current users to forget room"));
1529 wc_printf("\n</ul>\n");
1531 wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1532 if (er_flags & QR_PREFONLY)
1533 wc_printf("CHECKED ");
1535 wc_printf(_("Preferred users only"));
1537 wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1538 if (er_flags & QR_READONLY)
1539 wc_printf("CHECKED ");
1541 wc_printf(_("Read-only room"));
1543 wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1544 if (er_flags2 & QR2_COLLABDEL)
1545 wc_printf("CHECKED ");
1547 wc_printf(_("All users allowed to post may also delete messages"));
1549 /** directory stuff */
1550 wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1551 if (er_flags & QR_DIRECTORY)
1552 wc_printf("CHECKED ");
1554 wc_printf(_("File directory room"));
1556 wc_printf("\n<ul><li>");
1557 wc_printf(_("Directory name: "));
1558 wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1561 wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1562 if (er_flags & QR_UPLOAD)
1563 wc_printf("CHECKED ");
1565 wc_printf(_("Uploading allowed"));
1567 wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1568 if (er_flags & QR_DOWNLOAD)
1569 wc_printf("CHECKED ");
1571 wc_printf(_("Downloading allowed"));
1573 wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1574 if (er_flags & QR_VISDIR)
1575 wc_printf("CHECKED ");
1577 wc_printf(_("Visible directory"));
1578 wc_printf("</ul>\n");
1580 /** end of directory stuff */
1582 wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1583 if (er_flags & QR_NETWORK)
1584 wc_printf("CHECKED ");
1586 wc_printf(_("Network shared room"));
1588 wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1589 if (er_flags & QR_PERMANENT)
1590 wc_printf("CHECKED ");
1592 wc_printf(_("Permanent (does not auto-purge)"));
1594 wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1595 if (er_flags2 & QR2_SUBJECTREQ)
1596 wc_printf("CHECKED ");
1598 wc_printf(_("Subject Required (Force users to specify a message subject)"));
1600 /** start of anon options */
1602 wc_printf("\n<li>");
1603 wc_printf(_("Anonymous messages"));
1604 wc_printf("<ul>\n");
1606 wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1607 if (((er_flags & QR_ANONONLY) == 0)
1608 && ((er_flags & QR_ANONOPT) == 0))
1609 wc_printf("CHECKED ");
1611 wc_printf(_("No anonymous messages"));
1613 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1614 if (er_flags & QR_ANONONLY)
1615 wc_printf("CHECKED ");
1617 wc_printf(_("All messages are anonymous"));
1619 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1620 if (er_flags & QR_ANONOPT)
1621 wc_printf("CHECKED ");
1623 wc_printf(_("Prompt user when entering messages"));
1624 wc_printf("</ul>\n");
1626 /* end of anon options */
1629 wc_printf(_("Room aide: "));
1631 serv_getln(buf, sizeof buf);
1632 if (buf[0] != '2') {
1633 wc_printf("<em>%s</em>\n", &buf[4]);
1635 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1636 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1639 wc_printf("</ul><CENTER>\n");
1640 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1641 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1643 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1649 wc_printf("</div>");
1653 /* Sharing the room with other Citadel nodes... */
1654 if (!strcmp(tab, "sharing")) {
1655 wc_printf("<div class=\"tabcontent\">");
1657 shared_with = strdup("");
1658 not_shared_with = strdup("");
1660 /** Learn the current configuration */
1661 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1662 serv_getln(buf, sizeof buf);
1663 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1664 extract_token(node, buf, 0, '|', sizeof node);
1665 not_shared_with = realloc(not_shared_with,
1666 strlen(not_shared_with) + 32);
1667 strcat(not_shared_with, node);
1668 strcat(not_shared_with, "\n");
1672 serv_getln(buf, sizeof buf);
1673 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1674 extract_token(cmd, buf, 0, '|', sizeof cmd);
1675 extract_token(node, buf, 1, '|', sizeof node);
1676 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1677 if (!strcasecmp(cmd, "ignet_push_share")) {
1678 shared_with = realloc(shared_with,
1679 strlen(shared_with) + 32);
1680 strcat(shared_with, node);
1681 if (!IsEmptyStr(remote_room)) {
1682 strcat(shared_with, "|");
1683 strcat(shared_with, remote_room);
1685 strcat(shared_with, "\n");
1689 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1690 extract_token(buf, shared_with, i, '\n', sizeof buf);
1691 extract_token(node, buf, 0, '|', sizeof node);
1692 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1693 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1694 if (!strcasecmp(node, cmd)) {
1695 remove_token(not_shared_with, j, '\n');
1700 /* Display the stuff */
1701 wc_printf("<CENTER><br />"
1702 "<table border=1 cellpadding=5><tr>"
1704 wc_printf(_("Shared with"));
1705 wc_printf("</I></B></td>"
1707 wc_printf(_("Not shared with"));
1708 wc_printf("</I></B></td></tr>\n"
1709 "<tr><td VALIGN=TOP>\n");
1711 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1712 wc_printf(_("Remote node name"));
1713 wc_printf("</td><td>");
1714 wc_printf(_("Remote room name"));
1715 wc_printf("</td><td>");
1716 wc_printf(_("Actions"));
1717 wc_printf("</td></tr>\n");
1719 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1720 extract_token(buf, shared_with, i, '\n', sizeof buf);
1721 extract_token(node, buf, 0, '|', sizeof node);
1722 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1723 if (!IsEmptyStr(node)) {
1724 wc_printf("<form method=\"POST\" action=\"netedit\">");
1725 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1726 wc_printf("<tr><td>%s</td>\n", node);
1729 if (!IsEmptyStr(remote_room)) {
1730 escputs(remote_room);
1736 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1737 "VALUE=\"ignet_push_share|");
1739 if (!IsEmptyStr(remote_room)) {
1741 urlescputs(remote_room);
1744 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1745 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1746 wc_printf("<input type=\"submit\" "
1747 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1748 wc_printf("</td></tr></form>\n");
1752 wc_printf("</table>\n");
1753 wc_printf("</td><td VALIGN=TOP>\n");
1754 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1755 wc_printf(_("Remote node name"));
1756 wc_printf("</td><td>");
1757 wc_printf(_("Remote room name"));
1758 wc_printf("</td><td>");
1759 wc_printf(_("Actions"));
1760 wc_printf("</td></tr>\n");
1762 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1763 extract_token(node, not_shared_with, i, '\n', sizeof node);
1764 if (!IsEmptyStr(node)) {
1765 wc_printf("<form method=\"POST\" action=\"netedit\">");
1766 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1767 wc_printf("<tr><td>");
1769 wc_printf("</td><td>"
1770 "<input type=\"INPUT\" "
1774 wc_printf("<input type=\"hidden\" "
1776 "VALUE=\"ignet_push_share|");
1779 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1780 "VALUE=\"sharing\">\n");
1781 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1782 "VALUE=\"add\">\n");
1783 wc_printf("<input type=\"submit\" "
1784 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1785 wc_printf("</td></tr></form>\n");
1789 wc_printf("</table>\n");
1790 wc_printf("</td></tr>"
1791 "</table></CENTER><br />\n"
1792 "<I><B>%s</B><ul><li>", _("Notes:"));
1793 wc_printf(_("When sharing a room, "
1794 "it must be shared from both ends. Adding a node to "
1795 "the 'shared' list sends messages out, but in order to"
1796 " receive messages, the other nodes must be configured"
1797 " to send messages out to your system as well. "
1798 "<li>If the remote room name is blank, it is assumed "
1799 "that the room name is identical on the remote node."
1800 "<li>If the remote room name is different, the remote "
1801 "node must also configure the name of the room here."
1805 wc_printf("</div>");
1808 if (not_shared_with != NULL)
1809 free (not_shared_with);
1811 /* Mailing list management */
1812 if (!strcmp(tab, "listserv")) {
1813 room_states RoomFlags;
1814 wc_printf("<div class=\"tabcontent\">");
1816 wc_printf("<br /><center>"
1817 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1818 "<tr><td VALIGN=TOP>");
1820 wc_printf(_("<i>The contents of this room are being "
1821 "mailed <b>as individual messages</b> "
1822 "to the following list recipients:"
1823 "</i><br /><br />\n"));
1826 serv_getln(buf, sizeof buf);
1827 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1828 extract_token(cmd, buf, 0, '|', sizeof cmd);
1829 if (!strcasecmp(cmd, "listrecp")) {
1830 extract_token(recp, buf, 1, '|', sizeof recp);
1833 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1836 wc_printf(_("(remove)"));
1837 wc_printf("</A><br />");
1840 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1841 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1842 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1843 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1844 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1845 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1846 wc_printf("</form>\n");
1848 wc_printf("</td><td VALIGN=TOP>\n");
1850 wc_printf(_("<i>The contents of this room are being "
1851 "mailed <b>in digest form</b> "
1852 "to the following list recipients:"
1853 "</i><br /><br />\n"));
1856 serv_getln(buf, sizeof buf);
1857 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1858 extract_token(cmd, buf, 0, '|', sizeof cmd);
1859 if (!strcasecmp(cmd, "digestrecp")) {
1860 extract_token(recp, buf, 1, '|', sizeof recp);
1863 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1867 wc_printf(_("(remove)"));
1868 wc_printf("</A><br />");
1871 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1872 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1873 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1874 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1875 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1876 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1877 wc_printf("</form>\n");
1879 wc_printf("</td></tr></table>\n");
1881 /** Pop open an address book -- begin **/
1882 wc_printf("<div align=right>"
1883 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1885 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1890 _("Add recipients from Contacts or other address books"),
1891 _("Add recipients from Contacts or other address books")
1893 /* Pop open an address book -- end **/
1895 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1897 get_roomflags (&RoomFlags);
1899 /* Self Service subscription? */
1900 wc_printf("<table><tr><td>\n");
1901 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1902 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1903 " <tr><td colspan=\"2\">\n",
1904 (is_selflist(&RoomFlags))?"checked":"");
1905 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1906 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1907 (is_https ? "https" : "http"),
1908 ChrPtr(WC->Hdr->HR.http_host));
1909 /* Public posting? */
1910 wc_printf("<tr><td>");
1911 wc_printf(_("Allow non-subscribers to mail to this room."));
1912 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1913 (is_publiclist(&RoomFlags))?"checked":"");
1915 /* Moderated List? */
1916 wc_printf("<tr><td>");
1917 wc_printf(_("Room post publication needs Aide permission."));
1918 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1919 (is_moderatedlist(&RoomFlags))?"checked":"");
1922 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1923 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1924 wc_printf("</table></form>");
1927 wc_printf("</CENTER>\n");
1928 wc_printf("</div>");
1932 /* Configuration of The Dreaded Auto-Purger */
1933 if (!strcmp(tab, "expire")) {
1934 wc_printf("<div class=\"tabcontent\">");
1936 serv_puts("GPEX room");
1937 serv_getln(buf, sizeof buf);
1938 if (!strncmp(buf, "550", 3)) {
1939 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1940 _("Higher access is required to access this function.")
1943 else if (buf[0] != '2') {
1944 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1947 roompolicy = extract_int(&buf[4], 0);
1948 roomvalue = extract_int(&buf[4], 1);
1950 serv_puts("GPEX floor");
1951 serv_getln(buf, sizeof buf);
1952 if (buf[0] == '2') {
1953 floorpolicy = extract_int(&buf[4], 0);
1954 floorvalue = extract_int(&buf[4], 1);
1957 wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1958 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1959 wc_printf("<table border=0 cellspacing=5>\n");
1960 wc_printf("<tr><td>");
1961 wc_printf(_("Message expire policy for this room"));
1962 wc_printf("<br />(");
1963 escputs(ChrPtr(WC->CurRoom.name));
1964 wc_printf(")</td><td>");
1965 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1966 ((roompolicy == 0) ? "CHECKED" : "") );
1967 wc_printf(_("Use the default policy for this floor"));
1968 wc_printf("<br />\n");
1969 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1970 ((roompolicy == 1) ? "CHECKED" : "") );
1971 wc_printf(_("Never automatically expire messages"));
1972 wc_printf("<br />\n");
1973 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1974 ((roompolicy == 2) ? "CHECKED" : "") );
1975 wc_printf(_("Expire by message count"));
1976 wc_printf("<br />\n");
1977 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1978 ((roompolicy == 3) ? "CHECKED" : "") );
1979 wc_printf(_("Expire by message age"));
1980 wc_printf("<br />");
1981 wc_printf(_("Number of messages or days: "));
1982 wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1983 wc_printf("</td></tr>\n");
1985 if (WC->axlevel >= 6) {
1986 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1987 wc_printf("<tr><td>");
1988 wc_printf(_("Message expire policy for this floor"));
1989 wc_printf("<br />(");
1990 escputs(floorlist[WC->CurRoom.floorid]);
1991 wc_printf(")</td><td>");
1992 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1993 ((floorpolicy == 0) ? "CHECKED" : "") );
1994 wc_printf(_("Use the system default"));
1995 wc_printf("<br />\n");
1996 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1997 ((floorpolicy == 1) ? "CHECKED" : "") );
1998 wc_printf(_("Never automatically expire messages"));
1999 wc_printf("<br />\n");
2000 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
2001 ((floorpolicy == 2) ? "CHECKED" : "") );
2002 wc_printf(_("Expire by message count"));
2003 wc_printf("<br />\n");
2004 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
2005 ((floorpolicy == 3) ? "CHECKED" : "") );
2006 wc_printf(_("Expire by message age"));
2007 wc_printf("<br />");
2008 wc_printf(_("Number of messages or days: "));
2009 wc_printf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
2013 wc_printf("<CENTER>\n");
2014 wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
2015 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
2016 wc_printf(" ");
2017 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2018 wc_printf("</CENTER></td><tr>\n");
2020 wc_printf("</table>\n"
2021 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
2026 wc_printf("</div>");
2029 /* Access controls */
2030 if (!strcmp(tab, "access")) {
2031 wc_printf("<div class=\"tabcontent\">");
2033 wc_printf("</div>");
2036 /* Fetch messages from remote locations */
2037 if (!strcmp(tab, "feeds")) {
2038 wc_printf("<div class=\"tabcontent\">");
2041 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
2042 wc_printf("</i><br />\n");
2044 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2045 "<tr class=\"even\"><th>");
2046 wc_printf(_("Remote host"));
2047 wc_printf("</th><th>");
2048 wc_printf(_("User name"));
2049 wc_printf("</th><th>");
2050 wc_printf(_("Password"));
2051 wc_printf("</th><th>");
2052 wc_printf(_("Keep messages on server?"));
2053 wc_printf("</th><th>");
2054 wc_printf(_("Interval"));
2055 wc_printf("</th><th> </th></tr>");
2058 serv_getln(buf, sizeof buf);
2060 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2061 extract_token(cmd, buf, 0, '|', sizeof cmd);
2062 if (!strcasecmp(cmd, "pop3client")) {
2063 safestrncpy(recp, &buf[11], sizeof recp);
2066 wc_printf("<tr class=\"%s\">",
2067 (bg ? "even" : "odd")
2071 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2076 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2080 wc_printf("<td>*****</td>"); /* Don't show the password */
2082 wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2084 wc_printf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2086 wc_printf("<td class=\"button_link\">");
2087 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2090 wc_printf(_("(remove)"));
2091 wc_printf("</a></td>");
2097 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2099 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2100 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2101 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2103 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2106 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2109 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2112 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2115 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2118 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2119 wc_printf("</td></tr>");
2120 wc_printf("</form></table>\n");
2122 wc_printf("<hr>\n");
2125 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2126 wc_printf("</i><br />\n");
2128 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2129 "<tr class=\"even\"><th>");
2130 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2131 wc_printf(_("Feed URL"));
2132 wc_printf("</th><th>");
2133 wc_printf("</th></tr>");
2136 serv_getln(buf, sizeof buf);
2138 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2139 extract_token(cmd, buf, 0, '|', sizeof cmd);
2140 if (!strcasecmp(cmd, "rssclient")) {
2141 safestrncpy(recp, &buf[10], sizeof recp);
2144 wc_printf("<tr class=\"%s\">",
2145 (bg ? "even" : "odd")
2149 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2153 wc_printf("<td class=\"button_link\">");
2154 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2157 wc_printf(_("(remove)"));
2158 wc_printf("</a></td>");
2164 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2166 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2167 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2168 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2170 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2171 "maxlength=\"256\" name=\"line_pop3host\">\n");
2174 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2175 wc_printf("</td></tr>");
2176 wc_printf("</form></table>\n");
2178 wc_printf("</div>");
2182 /* end content of whatever tab is open now */
2183 wc_printf("</div>\n");
2185 address_book_popup();
2191 * Toggle self-service list subscription
2193 void toggle_self_service(void) {
2194 room_states RoomFlags;
2196 get_roomflags (&RoomFlags);
2198 if (yesbstr("QR2_SelfList"))
2199 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2201 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2203 if (yesbstr("QR2_SMTP_PUBLIC"))
2204 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2206 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2208 if (yesbstr("QR2_Moderated"))
2209 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2211 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2212 if (yesbstr("QR2_SubsOnly"))
2213 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2215 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2217 set_roomflags (&RoomFlags);
2225 * save new parameters for a room
2232 StrBuf *er_password;
2234 StrBuf *er_roomaide;
2237 int er_listingorder;
2243 if (!havebstr("ok_button")) {
2244 strcpy(WC->ImportantMessage,
2245 _("Cancelled. Changes were not saved."));
2251 StrBuf_ServGetln(Buf);
2252 if (GetServerStatus(Buf, NULL) != 2) {
2253 StrBufCutLeft(Buf, 4);
2254 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2260 er_name = NewStrBuf();
2261 er_password = NewStrBuf();
2262 er_dirname = NewStrBuf();
2263 er_roomaide = NewStrBuf();
2265 StrBufCutLeft(Buf, 4);
2266 StrBufExtract_token(er_name, Buf, 0, '|');
2267 StrBufExtract_token(er_password, Buf, 1, '|');
2268 StrBufExtract_token(er_dirname, Buf, 2, '|');
2269 er_flags = StrBufExtract_int(Buf, 3, '|');
2270 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2271 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2272 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2274 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2275 if (StrLength(er_roomaide) == 0) {
2277 StrBuf_ServGetln(Buf);
2278 if (GetServerStatus(Buf, NULL) != 2) {
2279 FlushStrBuf(er_roomaide);
2281 StrBufCutLeft(Buf, 4);
2282 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2285 Ptr = sbstr("er_name");
2286 if (StrLength(Ptr) > 0) {
2287 FlushStrBuf(er_name);
2288 StrBufAppendBuf(er_name, Ptr, 0);
2291 Ptr = sbstr("er_password");
2292 if (StrLength(Ptr) > 0) {
2293 FlushStrBuf(er_password);
2294 StrBufAppendBuf(er_password, Ptr, 0);
2298 Ptr = sbstr("er_dirname");
2299 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2300 FlushStrBuf(er_dirname);
2301 StrBufAppendBuf(er_dirname, Ptr, 0);
2305 Ptr = sbstr("type");
2306 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2308 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2309 er_flags |= (QR_PRIVATE);
2311 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2312 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2314 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2315 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2317 if (!strcmp(ChrPtr(Ptr), "personal")) {
2318 er_flags |= QR_MAILBOX;
2320 er_flags &= ~QR_MAILBOX;
2323 if (yesbstr("prefonly")) {
2324 er_flags |= QR_PREFONLY;
2326 er_flags &= ~QR_PREFONLY;
2329 if (yesbstr("readonly")) {
2330 er_flags |= QR_READONLY;
2332 er_flags &= ~QR_READONLY;
2336 if (yesbstr("collabdel")) {
2337 er_flags2 |= QR2_COLLABDEL;
2339 er_flags2 &= ~QR2_COLLABDEL;
2342 if (yesbstr("permanent")) {
2343 er_flags |= QR_PERMANENT;
2345 er_flags &= ~QR_PERMANENT;
2348 if (yesbstr("subjectreq")) {
2349 er_flags2 |= QR2_SUBJECTREQ;
2351 er_flags2 &= ~QR2_SUBJECTREQ;
2354 if (yesbstr("network")) {
2355 er_flags |= QR_NETWORK;
2357 er_flags &= ~QR_NETWORK;
2360 if (yesbstr("directory")) {
2361 er_flags |= QR_DIRECTORY;
2363 er_flags &= ~QR_DIRECTORY;
2366 if (yesbstr("ulallowed")) {
2367 er_flags |= QR_UPLOAD;
2369 er_flags &= ~QR_UPLOAD;
2372 if (yesbstr("dlallowed")) {
2373 er_flags |= QR_DOWNLOAD;
2375 er_flags &= ~QR_DOWNLOAD;
2378 if (yesbstr("visdir")) {
2379 er_flags |= QR_VISDIR;
2381 er_flags &= ~QR_VISDIR;
2384 Ptr = sbstr("anon");
2386 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2387 if (!strcmp(ChrPtr(Ptr), "anononly"))
2388 er_flags |= QR_ANONONLY;
2389 if (!strcmp(ChrPtr(Ptr), "anon2"))
2390 er_flags |= QR_ANONOPT;
2392 bump = yesbstr("bump");
2394 er_floor = ibstr("er_floor");
2396 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2398 ChrPtr(er_password),
2407 StrBuf_ServGetln(Buf);
2408 if (GetServerStatus(Buf, NULL) != 2) {
2409 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2412 FreeStrBuf(&er_name);
2413 FreeStrBuf(&er_password);
2414 FreeStrBuf(&er_dirname);
2415 FreeStrBuf(&er_roomaide);
2420 if (StrLength(er_roomaide) > 0) {
2421 serv_printf("SETA %s", ChrPtr(er_roomaide));
2422 StrBuf_ServGetln(Buf);
2423 if (GetServerStatus(Buf, NULL) != 2) {
2424 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2425 display_main_menu();
2427 FreeStrBuf(&er_name);
2428 FreeStrBuf(&er_password);
2429 FreeStrBuf(&er_dirname);
2430 FreeStrBuf(&er_roomaide);
2435 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2438 FreeStrBuf(&er_name);
2439 FreeStrBuf(&er_password);
2440 FreeStrBuf(&er_dirname);
2441 FreeStrBuf(&er_roomaide);
2447 * Display form for Invite, Kick, and show Who Knows a room
2449 void do_invt_kick(void) {
2450 char buf[SIZ], room[SIZ], username[SIZ];
2453 serv_getln(buf, sizeof buf);
2455 if (buf[0] != '2') {
2459 extract_token(room, &buf[4], 0, '|', sizeof room);
2461 strcpy(username, bstr("username"));
2463 if (havebstr("kick_button")) {
2464 sprintf(buf, "KICK %s", username);
2466 serv_getln(buf, sizeof buf);
2468 if (buf[0] != '2') {
2469 strcpy(WC->ImportantMessage, &buf[4]);
2471 sprintf(WC->ImportantMessage,
2472 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2477 if (havebstr("invite_button")) {
2478 sprintf(buf, "INVT %s", username);
2480 serv_getln(buf, sizeof buf);
2482 if (buf[0] != '2') {
2483 strcpy(WC->ImportantMessage, &buf[4]);
2485 sprintf(WC->ImportantMessage,
2486 _("<B><I>User %s invited to room %s.</I></B>\n"),
2497 * Display form for Invite, Kick, and show Who Knows a room
2499 void display_whok(void)
2501 char buf[SIZ], room[SIZ], username[SIZ];
2504 serv_getln(buf, sizeof buf);
2506 if (buf[0] != '2') {
2510 extract_token(room, &buf[4], 0, '|', sizeof room);
2513 wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2514 wc_printf(_("The users listed below have access to this room. "
2515 "To remove a user from the access list, select the user "
2516 "name from the list and click 'Kick'."));
2517 wc_printf("<br /><br />");
2519 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2520 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2521 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2522 wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2524 serv_getln(buf, sizeof buf);
2525 if (buf[0] == '1') {
2526 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2527 extract_token(username, buf, 0, '|', sizeof username);
2528 wc_printf("<OPTION>");
2533 wc_printf("</select><br />\n");
2535 wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2536 wc_printf("</form></CENTER>\n");
2538 wc_printf("</td><td>");
2539 wc_printf(_("To grant another user access to this room, enter the "
2540 "user name in the box below and click 'Invite'."));
2541 wc_printf("<br /><br />");
2543 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2544 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2545 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2546 wc_printf(_("Invite:"));
2548 wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2549 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2550 "<input type=\"submit\" value=\"%s\">"
2551 "</form></CENTER>\n", _("Invite"));
2552 /* Pop open an address book -- begin **/
2554 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2556 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2559 _("Users"), _("Users")
2561 /* Pop open an address book -- end **/
2563 wc_printf("</td></tr></table>\n");
2564 address_book_popup();
2571 * display the form for entering a new room
2573 void display_entroom(void)
2580 serv_puts("CRE8 0");
2581 serv_getln(buf, sizeof buf);
2583 if (buf[0] != '2') {
2584 strcpy(WC->ImportantMessage, &buf[4]);
2585 display_main_menu();
2590 output_headers(1, 1, 1, 0, 0, 0);
2592 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2593 do_template("beginbox", NULL);
2595 wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2596 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2598 wc_printf("<table class=\"altern\"> ");
2600 wc_printf("<tr class=\"even\"><td>");
2601 wc_printf(_("Name of room: "));
2602 wc_printf("</td><td>");
2603 wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2604 wc_printf("</td></tr>");
2606 wc_printf("<tr class=\"odd\"><td>");
2607 wc_printf(_("Resides on floor: "));
2608 wc_printf("</td><td>");
2609 load_floorlist(Buf);
2610 wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2611 for (i = 0; i < 128; ++i)
2612 if (!IsEmptyStr(floorlist[i])) {
2613 wc_printf("<option ");
2614 wc_printf("value=\"%d\">", i);
2615 escputs(floorlist[i]);
2616 wc_printf("</option>\n");
2618 wc_printf("</select>\n");
2619 wc_printf("</td></tr>");
2622 * Our clever little snippet of JavaScript automatically selects
2623 * a public room if the view is set to Bulletin Board or wiki, and
2624 * it selects a mailbox room otherwise. The user can override this,
2625 * of course. We also disable the floor selector for mailboxes.
2627 wc_printf("<tr class=\"even\"><td>");
2628 wc_printf(_("Default view for room: "));
2629 wc_printf("</td><td>");
2630 wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2631 " if ( (this.form.er_view.value == 0) "
2632 " || (this.form.er_view.value == 6) ) { "
2633 " this.form.type[0].checked=true; "
2634 " this.form.er_floor.disabled = false; "
2637 " this.form.type[4].checked=true; "
2638 " this.form.er_floor.disabled = true; "
2641 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2642 if (is_view_allowed_as_default(i)) {
2643 wc_printf("<option %s value=\"%d\">",
2644 ((i == 0) ? "selected" : ""), i );
2645 escputs(viewdefs[i]);
2646 wc_printf("</option>\n");
2649 wc_printf("</select>\n");
2650 wc_printf("</td></tr>");
2652 wc_printf("<tr class=\"even\"><td>");
2653 wc_printf(_("Type of room:"));
2654 wc_printf("</td><td>");
2655 wc_printf("<ul class=\"adminlist\">\n");
2657 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2658 wc_printf("CHECKED OnChange=\""
2659 " if (this.form.type[0].checked == true) { "
2660 " this.form.er_floor.disabled = false; "
2663 wc_printf(_("Public (automatically appears to everyone)"));
2666 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2667 " if (this.form.type[1].checked == true) { "
2668 " this.form.er_floor.disabled = false; "
2671 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2674 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2675 " if (this.form.type[2].checked == true) { "
2676 " this.form.er_floor.disabled = false; "
2679 wc_printf(_("Private - require password: "));
2680 wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2683 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2684 " if (this.form.type[3].checked == true) { "
2685 " this.form.er_floor.disabled = false; "
2688 wc_printf(_("Private - invitation only"));
2691 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2693 " if (this.form.type[4].checked == true) { "
2694 " this.form.er_floor.disabled = true; "
2697 wc_printf(_("Personal (mailbox for you only)"));
2700 wc_printf("\n</ul>\n");
2701 wc_printf("</td></tr></table>\n");
2703 wc_printf("<div class=\"buttons\">\n");
2704 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2705 wc_printf(" ");
2706 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2707 wc_printf("</div>\n");
2708 wc_printf("</form>\n<hr />");
2709 serv_printf("MESG roomaccess");
2710 serv_getln(buf, sizeof buf);
2711 if (buf[0] == '1') {
2715 do_template("endbox", NULL);
2725 * support function for entroom() -- sets the default view
2727 void er_set_default_view(int newview) {
2740 serv_getln(buf, sizeof buf);
2741 if (buf[0] != '2') return;
2743 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2744 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2745 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2746 rm_bits1 = extract_int(&buf[4], 3);
2747 rm_floor = extract_int(&buf[4], 4);
2748 rm_listorder = extract_int(&buf[4], 5);
2749 rm_bits2 = extract_int(&buf[4], 7);
2751 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2752 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2753 rm_listorder, newview, rm_bits2
2755 serv_getln(buf, sizeof buf);
2766 const StrBuf *er_name;
2767 const StrBuf *er_type;
2768 const StrBuf *er_password;
2772 wcsession *WCC = WC;
2774 if (!havebstr("ok_button")) {
2775 strcpy(WC->ImportantMessage,
2776 _("Cancelled. No new room was created."));
2777 display_main_menu();
2780 er_name = sbstr("er_name");
2781 er_type = sbstr("type");
2782 er_password = sbstr("er_password");
2783 er_floor = ibstr("er_floor");
2784 er_view = ibstr("er_view");
2787 if (!strcmp(ChrPtr(er_type), "hidden"))
2789 else if (!strcmp(ChrPtr(er_type), "passworded"))
2791 else if (!strcmp(ChrPtr(er_type), "invonly"))
2793 else if (!strcmp(ChrPtr(er_type), "personal"))
2796 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2799 ChrPtr(er_password),
2804 serv_getln(buf, sizeof buf);
2805 if (buf[0] != '2') {
2806 strcpy(WCC->ImportantMessage, &buf[4]);
2807 display_main_menu();
2810 /** TODO: Room created, now update the left hand icon bar for this user */
2811 burn_folder_cache(0); /* burn the old folder cache */
2815 serv_printf("VIEW %d", er_view);
2816 serv_getln(buf, sizeof buf);
2817 WCC->CurRoom.view = er_view;
2819 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
2820 display_editroom ();
2822 do_change_view(er_view); /* Now go there */
2829 * \brief display the screen to enter a private room
2831 void display_private(char *rname, int req_pass)
2833 WCTemplputParams SubTP;
2835 output_headers(1, 1, 1, 0, 0, 0);
2837 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2838 memset(&SubTP, 0, sizeof(WCTemplputParams));
2839 SubTP.Filter.ContextType = CTX_STRBUF;
2840 SubTP.Context = Buf;
2841 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2846 wc_printf(_("If you know the name of a hidden (guess-name) or "
2847 "passworded room, you can enter that room by typing "
2848 "its name below. Once you gain access to a private "
2849 "room, it will appear in your regular room listings "
2850 "so you don't have to keep returning here."));
2853 wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2854 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2856 wc_printf("<table class=\"altern\"> "
2857 "<tr class=\"even\"><td>");
2858 wc_printf(_("Enter room name:"));
2859 wc_printf("</td><td>"
2860 "<input type=\"text\" name=\"gr_name\" "
2861 "value=\"%s\" maxlength=\"128\">\n", rname);
2864 wc_printf("</td></tr><tr class=\"odd\"><td>");
2865 wc_printf(_("Enter room password:"));
2866 wc_printf("</td><td>");
2867 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2869 wc_printf("</td></tr></table>\n");
2871 wc_printf("<div class=\"buttons\">\n");
2872 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2874 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2878 wc_printf("</div></form>\n");
2880 do_template("endbox", NULL);
2886 * \brief goto a private room
2888 void goto_private(void)
2893 if (!havebstr("ok_button")) {
2894 display_main_menu();
2897 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2898 serv_printf("GOTO %s|%s",
2901 serv_getln(buf, sizeof buf);
2903 if (buf[0] == '2') {
2904 smart_goto(sbstr("gr_name"));
2907 if (!strncmp(buf, "540", 3)) {
2908 display_private(bstr("gr_name"), 1);
2911 output_headers(1, 1, 1, 0, 0, 0);
2912 wc_printf("%s\n", &buf[4]);
2919 * \brief display the screen to zap a room
2921 void display_zap(void)
2923 output_headers(1, 1, 2, 0, 0, 0);
2925 wc_printf("<div id=\"banner\">\n");
2927 wc_printf(_("Zap (forget/unsubscribe) the current room"));
2928 wc_printf("</h1>\n");
2929 wc_printf("</div>\n");
2931 wc_printf("<div id=\"content\" class=\"service\">\n");
2933 wc_printf(_("If you select this option, <em>%s</em> will "
2934 "disappear from your room list. Is this what you wish "
2935 "to do?<br />\n"), ChrPtr(WC->CurRoom.name));
2937 wc_printf("<form method=\"POST\" action=\"zap\">\n");
2938 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2939 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2940 wc_printf(" ");
2941 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2942 wc_printf("</form>\n");
2953 StrBuf *final_destination;
2956 * If the forget-room routine fails for any reason, we fall back
2957 * to the current room; otherwise, we go to the Lobby
2959 final_destination = NewStrBufDup(WC->CurRoom.name);
2961 if (havebstr("ok_button")) {
2962 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
2963 serv_getln(buf, sizeof buf);
2964 if (buf[0] == '2') {
2966 serv_getln(buf, sizeof buf);
2967 if (buf[0] == '2') {
2968 FlushStrBuf(final_destination);
2969 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2973 smart_goto(final_destination);
2974 FreeStrBuf(&final_destination);
2980 * \brief Delete the current room
2982 void delete_room(void)
2987 serv_puts("KILL 1");
2988 serv_getln(buf, sizeof buf);
2989 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2990 if (buf[0] != '2') {
2991 strcpy(WC->ImportantMessage, &buf[4]);
2992 display_main_menu();
2997 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
3006 * \brief Perform changes to a room's network configuration
3008 void netedit(void) {
3017 /*/ TODO: do line dynamic! */
3018 if (havebstr("line_pop3host")) {
3019 strcpy(line, bstr("prefix"));
3020 strcat(line, bstr("line_pop3host"));
3022 strcat(line, bstr("line_pop3user"));
3024 strcat(line, bstr("line_pop3pass"));
3026 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
3028 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
3029 strcat(line, bstr("suffix"));
3031 else if (havebstr("line")) {
3032 strcpy(line, bstr("prefix"));
3033 strcat(line, bstr("line"));
3034 strcat(line, bstr("suffix"));
3049 serv_getln(buf, sizeof buf);
3050 if (buf[0] != '1') {
3056 /** This loop works for add *or* remove. Spiffy, eh? */
3057 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3058 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
3059 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
3060 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
3061 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
3062 if ( (strcasecmp(cmpa0, cmpb0))
3063 || (strcasecmp(cmpa1, cmpb1)) ) {
3064 fprintf(fp, "%s\n", buf);
3070 serv_getln(buf, sizeof buf);
3071 if (buf[0] != '4') {
3077 while (fgets(buf, sizeof buf, fp) != NULL) {
3078 buf[strlen(buf)-1] = 0;
3082 if (havebstr("add_button")) {
3083 num_addrs = num_tokens(bstr("line"), ',');
3084 if (num_addrs < 2) {
3085 /* just adding one node or address */
3089 /* adding multiple addresses separated by commas */
3090 for (i=0; i<num_addrs; ++i) {
3091 strcpy(line, bstr("prefix"));
3092 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3095 strcat(line, bstr("suffix"));
3109 * \brief Convert a room name to a folder-ish-looking name.
3110 * \param folder the folderish name
3111 * \param room the room name
3112 * \param floor the floor name
3113 * \param is_mailbox is it a mailbox?
3115 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3120 * For mailboxes, just do it straight...
3123 sprintf(folder, "My folders|%s", room);
3127 * Otherwise, prefix the floor name as a "public folders" moniker
3130 if (floor > MAX_FLOORS) {
3132 sprintf(folder, "%%%%%%|%s", room);
3135 sprintf(folder, "%s|%s", floorlist[floor], room);
3140 * Replace "\" characters with "|" for pseudo-folder-delimiting
3142 len = strlen (folder);
3143 for (i=0; i<len; ++i) {
3144 if (folder[i] == '\\') folder[i] = '|';
3152 * \brief Back end for change_view()
3153 * \param newview set newview???
3155 void do_change_view(int newview) {
3158 serv_printf("VIEW %d", newview);
3159 serv_getln(buf, sizeof buf);
3160 WC->CurRoom.view = newview;
3161 smart_goto(WC->CurRoom.name);
3167 * \brief Change the view for this room
3169 void change_view(void) {
3172 view = lbstr("view");
3173 do_change_view(view);
3177 * \brief Burn the cached folder list.
3178 * \param age How old the cahce needs to be before we burn it.
3181 void burn_folder_cache(time_t age)
3183 /** If our cached folder list is very old, burn it. */
3184 if (WC->cache_fold != NULL) {
3185 if ((time(NULL) - WC->cache_timestamp) > age) {
3186 free(WC->cache_fold);
3187 WC->cache_fold = NULL;
3195 * \brief Do either a known rooms list or a folders list, depending on the
3200 StrBuf *ListView = NULL;
3202 /** Determine whether the user is trying to change views */
3203 if (havebstr("view")) {
3204 ListView = NewStrBufDup(SBSTR("view"));
3205 set_preference("roomlistview", ListView, 1);
3207 /** Sanitize the input so its safe */
3208 if((get_preference("roomlistview", &ListView) != 0)||
3209 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3210 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3212 if (ListView == NULL) {
3213 ListView = NewStrBufPlain(HKEY("rooms"));
3214 set_preference("roomlistview", ListView, 0);
3218 ListView = NewStrBufPlain(HKEY("rooms"));
3219 set_preference("roomlistview", ListView, 0);
3223 FreeStrBuf(&ListView);
3230 * \brief Set the message expire policy for this room and/or floor
3232 void set_room_policy(void) {
3235 if (!havebstr("ok_button")) {
3236 strcpy(WC->ImportantMessage,
3237 _("Cancelled. Changes were not saved."));
3242 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3243 serv_getln(buf, sizeof buf);
3244 strcpy(WC->ImportantMessage, &buf[4]);
3246 if (WC->axlevel >= 6) {
3247 strcat(WC->ImportantMessage, "<br />\n");
3248 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3249 serv_getln(buf, sizeof buf);
3250 strcat(WC->ImportantMessage, &buf[4]);
3256 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3258 StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3262 void _display_private(void) {
3263 display_private("", 0);
3266 void dotgoto(void) {
3267 if (!havebstr("room")) {
3268 readloop(readnew, eUseDefault);
3271 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3274 smart_goto(sbstr("room"));
3279 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3281 wcsession *WCC = WC;
3284 StrBufAppendTemplate(Target, TP,
3289 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3291 wc_printf("<div id=\"banner\">\n");
3292 embed_room_banner(NULL, navbar_default);
3293 wc_printf("</div>\n");
3297 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3299 wcsession *WCC = WC;
3302 (!IsEmptyStr(WCC->ugname)))
3303 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3306 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3308 wcsession *WCC = WC;
3309 return (WCC != NULL)?
3310 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3313 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3315 wcsession *WCC = WC;
3316 return (WCC == NULL)? 0 :
3317 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3318 (WCC->CurRoom.is_inbox) ||
3319 (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3322 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3324 wcsession *WCC = WC;
3326 return ((WCC!=NULL) &&
3327 (!IsEmptyStr(WCC->ugname)) &&
3328 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3332 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
3334 folder *Folder = (folder *)(TP->Context);
3337 UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3338 if (UA_CheckFlag == 0)
3339 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3340 "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
3342 return ((Folder->RAFlags & UA_CheckFlag) != 0);
3347 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3350 wcsession *WCC = WC;
3352 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3353 if (QR_CheckFlag == 0)
3354 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3355 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3357 return ((WCC!=NULL) &&
3358 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3361 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3364 folder *Folder = (folder *)(TP->Context);
3366 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3367 if (QR_CheckFlag == 0)
3368 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3369 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3370 return ((Folder->QRFlags & QR_CheckFlag) != 0);
3374 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3377 wcsession *WCC = WC;
3379 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3380 if (QR2_CheckFlag == 0)
3381 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3382 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3384 return ((WCC!=NULL) &&
3385 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3388 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3391 folder *Folder = (folder *)(TP->Context);
3393 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3394 if (QR2_CheckFlag == 0)
3395 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3396 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3397 return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3401 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3403 wcsession *WCC = WC;
3405 return ( (WCC!= NULL) &&
3406 ((WCC->axlevel >= 6) ||
3407 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3408 (WCC->CurRoom.is_inbox) ));
3411 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3413 wcsession *WCC = WC;
3415 if ((WCC == NULL) ||
3416 (TP->Tokens->nParameters < 3))
3418 return ((WCC->CurRoom.view < VIEW_BBS) ||
3419 (WCC->CurRoom.view > VIEW_MAX));
3422 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3426 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
3428 wcsession *WCC = WC;
3432 HashList *Whok = NULL;
3438 Token = NewStrBuf();
3439 StrBuf_ServGetln(Line);
3440 if (GetServerStatus(Line, &State) == 1)
3442 Whok = NewHash(1, Flathash);
3443 while(!Done && StrBuf_ServGetln(Line))
3444 if ( (StrLength(Line)==3) &&
3445 !strcmp(ChrPtr(Line), "000"))
3452 const char *Pos = NULL;
3453 Token = NewStrBufPlain (NULL, StrLength(Line));
3454 StrBufExtract_NextToken(Token, Line, &Pos, '|');
3462 else if (State == 550)
3463 StrBufAppendBufPlain(WCC->ImportantMsg,
3464 _("Higher access is required to access this function."), -1, 0);
3474 initialize_viewdefs();
3475 RegisterPreference("roomlistview",
3476 _("Room list view"),
3479 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3481 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3484 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3485 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3486 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3487 WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3488 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3489 WebcitAddUrlHandler(HKEY("zapped_list"), "", 0, zapped_list, 0);
3490 WebcitAddUrlHandler(HKEY("display_zap"), "", 0, display_zap, 0);
3491 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3492 WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3493 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3494 WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3495 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3496 WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3497 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3498 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3499 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3500 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3501 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3502 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3503 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3505 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3506 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3507 RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3509 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3510 RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3511 RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
3513 RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
3514 RegisterNamespace("THISROOM:MSGS:NEW", 0, 0, tmplput_CurrentRoom_nNewMessages, NULL, CTX_NONE);
3515 RegisterNamespace("THISROOM:MSGS:TOTAL", 0, 0, tmplput_CurrentRoom_nTotalMessages, NULL, CTX_NONE);
3517 RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
3518 RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3519 RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3520 RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3521 RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3522 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3523 RegisterNamespace("THISROOM:INFOTEXT", 1, 2, tmplput_CurrentRoomInfoText, NULL, CTX_NONE);
3524 RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3525 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3526 RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
3527 RegisterConditional(HKEY("COND:THISROOM:HAVE_INFOTEXT"), 0, ConditionalThisRoomXHaveInfoText, CTX_NONE);
3528 RegisterNamespace("THISROOM:FILES:N", 0, 1, tmplput_CurrentRoomXNFiles, NULL, CTX_NONE);
3529 RegisterNamespace("THISROOM:FILES:STR", 0, 1, tmplput_CurrentRoomX_FileString, NULL, CTX_NONE);
3531 REGISTERTokenParamDefine(QR_PERMANENT);
3532 REGISTERTokenParamDefine(QR_INUSE);
3533 REGISTERTokenParamDefine(QR_PRIVATE);
3534 REGISTERTokenParamDefine(QR_PASSWORDED);
3535 REGISTERTokenParamDefine(QR_GUESSNAME);
3536 REGISTERTokenParamDefine(QR_DIRECTORY);
3537 REGISTERTokenParamDefine(QR_UPLOAD);
3538 REGISTERTokenParamDefine(QR_DOWNLOAD);
3539 REGISTERTokenParamDefine(QR_VISDIR);
3540 REGISTERTokenParamDefine(QR_ANONONLY);
3541 REGISTERTokenParamDefine(QR_ANONOPT);
3542 REGISTERTokenParamDefine(QR_NETWORK);
3543 REGISTERTokenParamDefine(QR_PREFONLY);
3544 REGISTERTokenParamDefine(QR_READONLY);
3545 REGISTERTokenParamDefine(QR_MAILBOX);
3546 REGISTERTokenParamDefine(QR2_SYSTEM);
3547 REGISTERTokenParamDefine(QR2_SELFLIST);
3548 REGISTERTokenParamDefine(QR2_COLLABDEL);
3549 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3550 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3551 REGISTERTokenParamDefine(QR2_MODERATED);
3553 REGISTERTokenParamDefine(UA_KNOWN);
3554 REGISTERTokenParamDefine(UA_GOTOALLOWED);
3555 REGISTERTokenParamDefine(UA_HASNEWMSGS);
3556 REGISTERTokenParamDefine(UA_ZAPPED);
3557 REGISTERTokenParamDefine(UA_POSTALLOWED);
3558 REGISTERTokenParamDefine(UA_ADMINALLOWED);
3559 REGISTERTokenParamDefine(UA_DELETEALLOWED);
3560 REGISTERTokenParamDefine(UA_ISTRASH);
3562 REGISTERTokenParamDefine(US_NEEDVALID);
3563 REGISTERTokenParamDefine(US_PERM);
3564 REGISTERTokenParamDefine(US_LASTOLD);
3565 REGISTERTokenParamDefine(US_EXPERT);
3566 REGISTERTokenParamDefine(US_UNLISTED);
3567 REGISTERTokenParamDefine(US_NOPROMPT);
3568 REGISTERTokenParamDefine(US_PROMPTCTL);
3569 REGISTERTokenParamDefine(US_DISAPPEAR);
3570 REGISTERTokenParamDefine(US_REGIS);
3571 REGISTERTokenParamDefine(US_PAGINATOR);
3572 REGISTERTokenParamDefine(US_INTERNET);
3573 REGISTERTokenParamDefine(US_FLOORS);
3574 REGISTERTokenParamDefine(US_COLOR);
3575 REGISTERTokenParamDefine(US_USER_SET);
3577 REGISTERTokenParamDefine(VIEW_BBS);
3578 REGISTERTokenParamDefine(VIEW_MAILBOX);
3579 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3580 REGISTERTokenParamDefine(VIEW_CALENDAR);
3581 REGISTERTokenParamDefine(VIEW_TASKS);
3582 REGISTERTokenParamDefine(VIEW_NOTES);
3583 REGISTERTokenParamDefine(VIEW_WIKI);
3584 REGISTERTokenParamDefine(VIEW_CALBRIEF);
3585 REGISTERTokenParamDefine(VIEW_JOURNAL);
3586 REGISTERTokenParamDefine(VIEW_BLOG);
3589 REGISTERTokenParamDefine(ignet_push_share);
3590 { /* these are the parts of an IGNET push config */
3591 REGISTERTokenParamDefine(GNET_IGNET_NODE);
3592 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
3594 REGISTERTokenParamDefine(listrecp);
3595 REGISTERTokenParamDefine(digestrecp);
3596 REGISTERTokenParamDefine(pop3client);
3597 { /* These are the parts of a pop3 client line... */
3598 REGISTERTokenParamDefine(GNET_POP3_HOST);
3599 REGISTERTokenParamDefine(GNET_POP3_USER);
3600 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
3601 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
3603 REGISTERTokenParamDefine(rssclient);
3604 REGISTERTokenParamDefine(participate);
3606 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3607 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3609 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3610 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3612 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3613 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3614 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3621 SessionDestroyModule_ROOMOPS
3624 FlushFolder(&sess->CurRoom);
3625 if (sess->cache_fold != NULL) {
3626 free(sess->cache_fold);
3629 free_march_list(sess);
3630 DeleteHash(&sess->Floors);
3631 DeleteHash(&sess->Rooms);
3632 DeleteHash(&sess->FloorsByName);