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);
236 * read this room's info file (set v to 1 for verbose mode)
238 void readinfo(StrBuf *Target, WCTemplputParams *TP)
243 int fullinfo_len = 0;
246 serv_getln(buf, sizeof buf);
249 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
250 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
251 strcpy(&fullinfo[fullinfo_len], buf);
252 fullinfo_len += strlen(buf);
256 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
257 strcpy(&briefinfo[50], "...");
259 wc_printf("<div class=\"infos\" "
260 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
264 wc_printf("</div><div id=\"room_infos\" style=\"display:none;\">");
265 wc_printf("<img class=\"close_infos\" "
266 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
267 "src=\"static/closewindow.gif\" alt=\"%s\" width=\"16\" height=\"16\">",
280 * Display the current view and offer an option to change it
282 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
286 wc_printf("<form name=\"viewomatic\" action=\"changeview\">\n");
287 wc_printf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
288 wc_printf("<label for=\"view_name\">");
289 wc_printf(_("View as:"));
290 wc_printf("</label> "
291 "<select name=\"newview\" size=\"1\" "
292 "id=\"view_name\" class=\"selectbox\" "
293 "OnChange=\"location.href=viewomatic.newview.options"
294 "[selectedIndex].value\">\n");
296 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
298 * Only offer the views that make sense, given the default
299 * view for the room. For example, don't offer a Calendar
300 * view in a non-Calendar room.
303 (i == WC->CurRoom.view)
304 || (i == WC->CurRoom.defview) /* default */
305 || ( (i == 0) && (WC->CurRoom.defview == 1) ) /* mail or bulletin */
306 || ( (i == 1) && (WC->CurRoom.defview == 0) ) /* mail or bulletin */
307 /* || ( (i == 7) && (WC->CurRoom.defview == 3) ) (calendar list temporarily disabled) */
310 wc_printf("<option %s value=\"changeview?view=%d\">",
311 ((i == WC->CurRoom.view) ? "selected" : ""),
313 escputs(viewdefs[i]);
314 wc_printf("</option>\n");
317 wc_printf("</select></div></form>\n");
323 * Embed the room banner
325 * got The information returned from a GOTO server command
326 * navbar_style Determines which navigation buttons to display
330 void embed_room_banner(char *got, int navbar_style) {
334 char with_files[256];
338 * We need to have the information returned by a GOTO server command.
339 * If it isn't supplied, we fake it by issuing our own GOTO.
342 memset(buf, '0', 20);
344 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
345 serv_getln(buf, sizeof buf);
349 /* The browser needs some information for its own use */
350 wc_printf("<script type=\"text/javascript\"> \n"
351 " room_is_trash = %d; \n"
353 ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
357 * If the user happens to select the "make this my start page" link,
358 * we want it to remember the URL as a "/dotskip" one instead of
359 * a "skip" or "gotonext" or something like that.
361 if (WCC->Hdr->this_page == NULL) {
362 WCC->Hdr->this_page = NewStrBuf();
364 StrBufPrintf(WCC->Hdr->this_page,
366 ChrPtr(WC->CurRoom.name)
369 /* Check for new mail. */
370 WC->new_mail = extract_int(&got[4], 9);
371 WC->CurRoom.view = extract_int(&got[4], 11);
373 /* Is this a directory room and does it contain files and how many? */
374 if ((WC->CurRoom.QRFlags & QR_DIRECTORY) && (WC->CurRoom.QRFlags & QR_VISDIR))
377 serv_getln(buf2, sizeof buf2);
378 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
380 snprintf (with_files, sizeof with_files,
381 "; <a href=\"do_template?template=files\"> %d %s </a>",
383 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
386 strcpy (with_files, "");
388 svprintf(HKEY("NUMMSGS"), WCS_STRING,
389 _("%d new of %d messages%s"),
390 extract_int(&got[4], 1),
391 extract_int(&got[4], 2),
394 svcallback("ROOMINFO", readinfo);
395 svcallback("VIEWOMATIC", embed_view_o_matic);
396 svcallback("START", offer_start_page);
398 do_template("roombanner", NULL);
399 /* roombanner contains this for mobile */
400 if (navbar_style != navbar_none && (WC->is_mobile < 1)) {
402 wc_printf("<div id=\"navbar\"><ul>");
404 if (navbar_style == navbar_default) wc_printf(
405 "<li class=\"ungoto\">"
406 "<a href=\"ungoto\">"
407 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
408 "<span class=\"navbar_link\">%s</span></A>"
409 "</li>\n", _("Ungoto")
412 if ( (navbar_style == navbar_default) && (WC->CurRoom.view == VIEW_BBS) ) {
414 "<li class=\"newmess\">"
415 "<a href=\"readnew\">"
416 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
417 "<span class=\"navbar_link\">%s</span></A>"
418 "</li>\n", _("Read new messages")
422 if (navbar_style == navbar_default) {
423 switch(WC->CurRoom.view) {
424 case VIEW_ADDRESSBOOK:
426 "<li class=\"viewcontacts\">"
427 "<a href=\"readfwd\">"
428 "<img src=\"static/viewcontacts_24x.gif\" "
429 "alt=\"\" width=\"24\" height=\"24\">"
430 "<span class=\"navbar_link\">"
432 "</span></a></li>\n", _("View contacts")
437 "<li class=\"staskday\">"
438 "<a href=\"readfwd?calview=day\">"
439 "<img src=\"static/taskday2_24x.gif\" "
440 "alt=\"\" width=\"24\" height=\"24\">"
441 "<span class=\"navbar_link\">"
443 "</span></a></li>\n", _("Day view")
446 "<li class=\"monthview\">"
447 "<a href=\"readfwd?calview=month\">"
448 "<img src=\"static/monthview2_24x.gif\" "
449 "alt=\"\" width=\"24\" height=\"24\">"
450 "<span class=\"navbar_link\">"
452 "</span></a></li>\n", _("Month view")
457 "<li class=\"monthview\">"
458 "<a href=\"readfwd?calview=month\">"
459 "<img src=\"static/monthview2_24x.gif\" "
460 "alt=\"\" width=\"24\" height=\"24\">"
461 "<span class=\"navbar_link\">"
463 "</span></a></li>\n", _("Calendar list")
468 "<li class=\"taskmanag\">"
469 "<a href=\"readfwd\">"
470 "<img src=\"static/taskmanag_24x.gif\" "
471 "alt=\"\" width=\"24\" height=\"24\">"
472 "<span class=\"navbar_link\">"
474 "</span></a></li>\n", _("View tasks")
479 "<li class=\"viewnotes\">"
480 "<a href=\"readfwd\">"
481 "<img src=\"static/viewnotes_24x.gif\" "
482 "alt=\"\" width=\"24\" height=\"24\">"
483 "<span class=\"navbar_link\">"
485 "</span></a></li>\n", _("View notes")
490 "<li class=\"readallmess\">"
491 "<a id=\"m_refresh\" href=\"readfwd\">"
492 "<img src=\"static/readallmess3_24x.gif\" "
493 "alt=\"\" width=\"24\" height=\"24\">"
494 "<span class=\"navbar_link\">"
496 "</span></a></li>\n", _("Refresh message list")
501 "<li class=\"readallmess\">"
502 "<a href=\"wiki?page=home\">"
503 "<img src=\"static/readallmess3_24x.gif\" "
504 "alt=\"\" width=\"24\" height=\"24\">"
505 "<span class=\"navbar_link\">"
507 "</span></a></li>\n", _("Wiki home")
512 "<li class=\"readallmess\">"
513 "<a href=\"readfwd\">"
514 "<img src=\"static/readallmess3_24x.gif\" "
515 "alt=\"\" width=\"24\" height=\"24\">"
516 "<span class=\"navbar_link\">"
518 "</span></a></li>\n", _("Read all messages")
524 if (navbar_style == navbar_default) {
525 switch(WC->CurRoom.view) {
526 case VIEW_ADDRESSBOOK:
528 "<li class=\"addnewcontact\">"
529 "<a href=\"display_enter\">"
530 "<img src=\"static/addnewcontact_24x.gif\" "
531 "alt=\"\" width=\"24\" height=\"24\">"
532 "<span class=\"navbar_link\">"
534 "</span></a></li>\n", _("Add new contact")
539 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
540 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
541 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
542 if (havebstr("day" )) wc_printf("?day=%s", bstr("day"));
544 "<img src=\"static/addevent_24x.gif\" "
545 "alt=\"\" width=\"24\" height=\"24\">"
546 "<span class=\"navbar_link\">"
548 "</span></a></li>\n", _("Add new event")
553 "<li class=\"newmess\">"
554 "<a href=\"display_enter\">"
555 "<img src=\"static/newmess3_24x.gif\" "
556 "alt=\"\" width=\"24\" height=\"24\">"
557 "<span class=\"navbar_link\">"
559 "</span></a></li>\n", _("Add new task")
564 "<li class=\"enternewnote\">"
565 "<a href=\"add_new_note\">"
566 "<img src=\"static/enternewnote_24x.gif\" "
567 "alt=\"\" width=\"24\" height=\"24\">"
568 "<span class=\"navbar_link\">"
570 "</span></a></li>\n", _("Add new note")
574 safestrncpy(buf, bstr("page"), sizeof buf);
575 if (IsEmptyStr(buf)) {
576 safestrncpy(buf, "home", sizeof buf);
580 "<li class=\"newmess\">"
581 "<a href=\"display_enter?page=%s\">"
582 "<img src=\"static/newmess3_24x.gif\" "
583 "alt=\"\" width=\"24\" height=\"24\">"
584 "<span class=\"navbar_link\">"
586 "</span></a></li>\n", buf, _("Edit this page")
589 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
590 /* already viewing history; display a link to the current page */
592 "<li class=\"newmess\">"
593 "<a href=\"wiki?page=%s\">"
594 "<img src=\"static/newmess3_24x.gif\" "
595 "alt=\"\" width=\"24\" height=\"24\">"
596 "<span class=\"navbar_link\">"
598 "</span></a></li>\n", buf, _("Current version")
602 /* display a link to the history */
604 "<li class=\"newmess\">"
605 "<a href=\"wiki_history?page=%s\">"
606 "<img src=\"static/newmess3_24x.gif\" "
607 "alt=\"\" width=\"24\" height=\"24\">"
608 "<span class=\"navbar_link\">"
610 "</span></a></li>\n", buf, _("History")
616 "<li class=\"newmess\">"
617 "<a href=\"display_enter\">"
618 "<img src=\"static/newmess3_24x.gif\" "
619 "alt=\"\" width=\"24\" height=\"24\">"
620 "<span class=\"navbar_link\">"
622 "</span></a></li>\n", _("Write mail")
625 "<li class=\"newmess\">"
626 "<a href=\"javascript:deleteAllSelectedMessages();\">"
627 "<img src=\"static/delete.gif\" "
628 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
630 "</span></a></li>\n", _("Delete")
635 "<li class=\"newmess\">"
636 "<a href=\"display_enter\">"
637 "<img src=\"static/newmess3_24x.gif\" "
638 "alt=\"\" width=\"24\" height=\"24\">"
639 "<span class=\"navbar_link\">"
641 "</span></a></li>\n", _("Enter a message")
647 if (navbar_style == navbar_default) wc_printf(
648 "<li class=\"skipthisroom\">"
651 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
652 "width=\"24\" height=\"24\">"
653 "<span class=\"navbar_link\">%s</span></a>"
655 _("Leave all messages marked as unread, go to next room with unread messages"),
659 if (navbar_style == navbar_default) wc_printf(
660 "<li class=\"markngo\">"
661 "<a href=\"gotonext\" "
663 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
664 "width=\"24\" height=\"24\">"
665 "<span class=\"navbar_link\">%s</span></a>"
667 _("Mark all messages as read, go to next room with unread messages"),
671 wc_printf("</ul></div>\n");
678 * back end routine to take the session to a new room
680 long gotoroom(const StrBuf *gname)
684 static long ls = (-1L);
687 /* store ungoto information */
688 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
692 /* move to the new room */
693 serv_printf("GOTO %s", ChrPtr(gname));
694 StrBuf_ServGetln(Buf);
695 if (GetServerStatus(Buf, &err) != 2) {
696 serv_puts("GOTO _BASEROOM_");
697 StrBuf_ServGetln(Buf);
699 * well, we know that this is the fallback case,
700 * but we're interested that the first command
701 * didn't work out in first place.
703 if (GetServerStatus(Buf, NULL) != 2) {
708 ParseGoto(&WCC->CurRoom, Buf);
710 remove_march(WCC->CurRoom.name);
711 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
719 void ParseGoto(folder *room, StrBuf *Line)
727 if (StrLength(Line) < 4) {
731 /* ignore the commandstate... */
732 Pos = ChrPtr(Line) + 4;
734 if (room->RoomNameParts != NULL)
737 for (i=0; i < room->nRoomNameParts; i++)
738 FreeStrBuf(&room->RoomNameParts[i]);
739 free(room->RoomNameParts);
740 room->RoomNameParts = NULL;
745 pBuf = NewStrBufPlain(NULL, StrLength(Line));
748 memset(room, 0, sizeof(folder));
751 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
753 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
754 if (room->nNewMessages > 0)
755 room->RAFlags |= UA_HASNEWMSGS;
757 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
759 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
761 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
763 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
764 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
766 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
768 flag = StrBufExtractNext_long(Line, &Pos, '|');
769 if (WCC->is_aide || flag) {
770 room->RAFlags |= UA_ADMINALLOWED;
773 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
775 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
777 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
779 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
781 flag = StrBufExtractNext_long(Line, &Pos, '|');
783 room->RAFlags |= UA_ISTRASH; // wc_is_trash
785 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
787 /* find out, whether we are in a sub-room */
788 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
789 if (room->nRoomNameParts > 1)
794 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
795 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
796 for (i=0; i < room->nRoomNameParts; i++)
798 room->RoomNameParts[i] = NewStrBuf();
799 StrBufExtract_NextToken(room->RoomNameParts[i],
800 room->name, &Pos, '\\');
804 /* Private mailboxes on the main floor get remapped to the personal folder */
805 if ((room->QRFlags & QR_MAILBOX) &&
806 (room->floorid == 0))
808 room->floorid = VIRTUAL_MY_FLOOR;
809 if ((room->nRoomNameParts == 1) &&
810 (StrLength(room->name) == 4) &&
811 (strcmp(ChrPtr(room->name), "Mail") == 0))
817 /* get a pointer to the floor we're on: */
818 if (WCC->Floors == NULL)
819 GetFloorListHash(NULL, NULL);
821 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
822 room->Floor = (const Floor*) vFloor;
825 void LoadRoomAide(void)
830 if (WCC->CurRoom.RoomAideLoaded)
833 WCC->CurRoom.RoomAideLoaded = 1;
836 StrBuf_ServGetln(Buf);
837 if (GetServerStatus(Buf, NULL) != 2) {
838 FlushStrBuf(WCC->CurRoom.RoomAide);
839 AppendImportantMessage (ChrPtr(Buf) + 4,
844 Pos = ChrPtr(Buf) + 4;
846 FreeStrBuf(&WCC->CurRoom.RoomAide);
847 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
849 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
853 void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
856 folder *Folder = &WCC->CurRoom;
857 const Floor *pFloor = Folder->Floor;
862 StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
865 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
871 StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
875 void LoadRoomXA (void)
880 if (WCC->CurRoom.XALoaded)
883 WCC->CurRoom.XALoaded = 1;
886 StrBuf_ServGetln(Buf);
887 if (GetServerStatus(Buf, NULL) != 2) {
888 FlushStrBuf(WCC->CurRoom.XAPass);
889 FlushStrBuf(WCC->CurRoom.Directory);
891 AppendImportantMessage (ChrPtr(Buf) + 4,
896 Pos = ChrPtr(Buf) + 4;
898 FreeStrBuf(&WCC->CurRoom.XAPass);
899 FreeStrBuf(&WCC->CurRoom.Directory);
901 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
902 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
904 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
905 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
906 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
907 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
908 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
909 WCC->CurRoom.DefView = StrBufExtractNext_long(Buf, &Pos, '|');
910 /* QR2Flags, we already know them... */
917 void LoadXRoomPic(void)
922 if (WCC->CurRoom.XHaveRoomPicLoaded)
925 WCC->CurRoom.XHaveRoomPicLoaded = 1;
927 serv_puts("OIMG _roompic_");
928 StrBuf_ServGetln(Buf);
929 if (GetServerStatus(Buf, NULL) != 2) {
930 WCC->CurRoom.XHaveRoomPic = 0;
932 WCC->CurRoom.XHaveRoomPic = 1;
935 StrBuf_ServGetln(Buf);
936 GetServerStatus(Buf, NULL);
940 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
948 return WCC->CurRoom.XHaveRoomPic == 1;
951 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
957 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
959 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
965 StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
967 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
973 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
975 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
981 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.DefView);
985 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
995 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
996 return CheckThis == WCC->CurRoom.Order;
999 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1001 wcsession *WCC = WC;
1009 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1010 return CheckThis == WCC->CurRoom.DefView;
1020 void smart_goto(const StrBuf *next_room) {
1021 gotoroom(next_room);
1022 readloop(readnew, eUseDefault);
1028 * mark all messages in current room as having been read
1030 void slrp_highest(void)
1034 serv_puts("SLRP HIGHEST");
1035 serv_getln(buf, sizeof buf);
1039 typedef struct __room_states {
1054 * Set/clear/read the "self-service list subscribe" flag for a room
1056 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1057 * returns the new value.
1060 int self_service(int newval) {
1061 int current_value = 0;
1067 int flags, floor, order, view, flags2;
1070 serv_getln(buf, sizeof buf);
1071 if (buf[0] != '2') return(0);
1073 extract_token(name, &buf[4], 0, '|', sizeof name);
1074 extract_token(password, &buf[4], 1, '|', sizeof password);
1075 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1076 flags = extract_int(&buf[4], 3);
1077 floor = extract_int(&buf[4], 4);
1078 order = extract_int(&buf[4], 5);
1079 view = extract_int(&buf[4], 6);
1080 flags2 = extract_int(&buf[4], 7);
1082 if (flags2 & QR2_SELFLIST) {
1090 flags2 = flags2 | QR2_SELFLIST;
1092 else if (newval == 0) {
1093 flags2 = flags2 & ~QR2_SELFLIST;
1096 return(current_value);
1099 if (newval != current_value) {
1100 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1101 name, password, dirname, flags,
1102 floor, order, view, flags2);
1103 serv_getln(buf, sizeof buf);
1110 int is_selflist(room_states *RoomFlags)
1112 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1115 int is_publiclist(room_states *RoomFlags)
1117 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1120 int is_moderatedlist(room_states *RoomFlags)
1122 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1126 * Set/clear/read the "self-service list subscribe" flag for a room
1128 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1129 * returns the new value.
1132 int get_roomflags(room_states *RoomOps)
1137 serv_getln(buf, sizeof buf);
1138 if (buf[0] != '2') return(0);
1140 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1141 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1142 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1143 RoomOps->flags = extract_int(&buf[4], 3);
1144 RoomOps->floor = extract_int(&buf[4], 4);
1145 RoomOps->order = extract_int(&buf[4], 5);
1146 RoomOps->view = extract_int(&buf[4], 6);
1147 RoomOps->flags2 = extract_int(&buf[4], 7);
1151 int set_roomflags(room_states *RoomOps)
1155 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1164 serv_getln(buf, sizeof buf);
1174 * display the form for editing a room
1176 void display_editroom(void)
1182 char remote_room[128];
1185 char er_password[10];
1186 char er_dirname[15];
1187 char er_roomaide[26];
1194 char *not_shared_with = NULL;
1197 int floorpolicy = 0;
1199 char pop3_host[128];
1204 if (IsEmptyStr(tab)) tab = "admin";
1207 load_floorlist(Buf);
1209 output_headers(1, 1, 1, 0, 0, 0);
1211 wc_printf("<div class=\"fix_scrollbar_bug\">");
1213 wc_printf("<br />\n");
1215 /* print the tabbed dialog */
1216 wc_printf("<div align=\"center\">");
1217 wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1218 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1221 wc_printf("<td class=\"");
1222 if (!strcmp(tab, "admin")) {
1223 wc_printf(" tab_cell_label\">");
1224 wc_printf(_("Administration"));
1227 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1228 wc_printf(_("Administration"));
1231 wc_printf("</td>\n");
1232 wc_printf("<td> </td>\n");
1234 if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1236 wc_printf("<td class=\"");
1237 if (!strcmp(tab, "config")) {
1238 wc_printf(" tab_cell_label\">");
1239 wc_printf(_("Configuration"));
1242 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1243 wc_printf(_("Configuration"));
1246 wc_printf("</td>\n");
1247 wc_printf("<td> </td>\n");
1249 wc_printf("<td class=\"");
1250 if (!strcmp(tab, "expire")) {
1251 wc_printf(" tab_cell_label\">");
1252 wc_printf(_("Message expire policy"));
1255 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1256 wc_printf(_("Message expire policy"));
1259 wc_printf("</td>\n");
1260 wc_printf("<td> </td>\n");
1262 wc_printf("<td class=\"");
1263 if (!strcmp(tab, "access")) {
1264 wc_printf(" tab_cell_label\">");
1265 wc_printf(_("Access controls"));
1268 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1269 wc_printf(_("Access controls"));
1272 wc_printf("</td>\n");
1273 wc_printf("<td> </td>\n");
1275 wc_printf("<td class=\"");
1276 if (!strcmp(tab, "sharing")) {
1277 wc_printf(" tab_cell_label\">");
1278 wc_printf(_("Sharing"));
1281 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1282 wc_printf(_("Sharing"));
1285 wc_printf("</td>\n");
1286 wc_printf("<td> </td>\n");
1288 wc_printf("<td class=\"");
1289 if (!strcmp(tab, "listserv")) {
1290 wc_printf(" tab_cell_label\">");
1291 wc_printf(_("Mailing list service"));
1294 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1295 wc_printf(_("Mailing list service"));
1298 wc_printf("</td>\n");
1299 wc_printf("<td> </td>\n");
1303 wc_printf("<td class=\"");
1304 if (!strcmp(tab, "feeds")) {
1305 wc_printf(" tab_cell_label\">");
1306 wc_printf(_("Remote retrieval"));
1309 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1310 wc_printf(_("Remote retrieval"));
1313 wc_printf("</td>\n");
1314 wc_printf("<td> </td>\n");
1316 wc_printf("</tr></table>\n");
1317 wc_printf("</div>\n");
1318 /* end tabbed dialog */
1320 wc_printf("<script type=\"text/javascript\">"
1321 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1325 /* begin content of whatever tab is open now */
1327 if (!strcmp(tab, "admin")) {
1328 wc_printf("<div class=\"tabcontent\">");
1330 "<li><a href=\"delete_room\" "
1331 "onClick=\"return confirm('");
1332 wc_printf(_("Are you sure you want to delete this room?"));
1333 wc_printf("');\">\n");
1334 wc_printf(_("Delete this room"));
1336 "<li><a href=\"display_editroompic?which_room=");
1337 urlescputs(ChrPtr(WC->CurRoom.name));
1339 wc_printf(_("Set or change the icon for this room's banner"));
1341 "<li><a href=\"display_editinfo\">\n");
1342 wc_printf(_("Edit this room's Info file"));
1345 wc_printf("</div>");
1348 if (!strcmp(tab, "config")) {
1349 wc_printf("<div class=\"tabcontent\">");
1351 serv_getln(buf, sizeof buf);
1353 if (!strncmp(buf, "550", 3)) {
1354 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1355 _("Higher access is required to access this function.")
1358 else if (buf[0] != '2') {
1359 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1362 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1363 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1364 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1365 er_flags = extract_int(&buf[4], 3);
1366 er_floor = extract_int(&buf[4], 4);
1367 er_flags2 = extract_int(&buf[4], 7);
1369 wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1370 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1372 wc_printf("<ul><li>");
1373 wc_printf(_("Name of room: "));
1374 wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1380 wc_printf(_("Resides on floor: "));
1381 wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1382 if (er_flags & QR_MAILBOX)
1383 wc_printf("disabled >\n");
1384 for (i = 0; i < 128; ++i)
1385 if (!IsEmptyStr(floorlist[i])) {
1386 wc_printf("<OPTION ");
1388 wc_printf("SELECTED ");
1389 wc_printf("VALUE=\"%d\">", i);
1390 escputs(floorlist[i]);
1391 wc_printf("</OPTION>\n");
1393 wc_printf("</select>\n");
1396 wc_printf(_("Type of room:"));
1397 wc_printf("<ul>\n");
1399 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1400 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1401 wc_printf("CHECKED ");
1402 wc_printf("OnChange=\""
1403 " if (this.form.type[0].checked == true) { "
1404 " this.form.er_floor.disabled = false; "
1407 wc_printf(_("Public (automatically appears to everyone)"));
1410 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1411 if ((er_flags & QR_PRIVATE) &&
1412 (er_flags & QR_GUESSNAME))
1413 wc_printf("CHECKED ");
1414 wc_printf(" OnChange=\""
1415 " if (this.form.type[1].checked == true) { "
1416 " this.form.er_floor.disabled = false; "
1419 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1421 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1422 if ((er_flags & QR_PRIVATE) &&
1423 (er_flags & QR_PASSWORDED))
1424 wc_printf("CHECKED ");
1425 wc_printf(" OnChange=\""
1426 " if (this.form.type[2].checked == true) { "
1427 " this.form.er_floor.disabled = false; "
1430 wc_printf(_("Private - require password: "));
1431 wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1434 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1435 if ((er_flags & QR_PRIVATE)
1436 && ((er_flags & QR_GUESSNAME) == 0)
1437 && ((er_flags & QR_PASSWORDED) == 0))
1438 wc_printf("CHECKED ");
1439 wc_printf(" OnChange=\""
1440 " if (this.form.type[3].checked == true) { "
1441 " this.form.er_floor.disabled = false; "
1444 wc_printf(_("Private - invitation only"));
1446 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1447 if (er_flags & QR_MAILBOX)
1448 wc_printf("CHECKED ");
1449 wc_printf (" OnChange=\""
1450 " if (this.form.type[4].checked == true) { "
1451 " this.form.er_floor.disabled = true; "
1454 wc_printf(_("Personal (mailbox for you only)"));
1456 wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1458 wc_printf(_("If private, cause current users to forget room"));
1460 wc_printf("\n</ul>\n");
1462 wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1463 if (er_flags & QR_PREFONLY)
1464 wc_printf("CHECKED ");
1466 wc_printf(_("Preferred users only"));
1468 wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1469 if (er_flags & QR_READONLY)
1470 wc_printf("CHECKED ");
1472 wc_printf(_("Read-only room"));
1474 wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1475 if (er_flags2 & QR2_COLLABDEL)
1476 wc_printf("CHECKED ");
1478 wc_printf(_("All users allowed to post may also delete messages"));
1480 /** directory stuff */
1481 wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1482 if (er_flags & QR_DIRECTORY)
1483 wc_printf("CHECKED ");
1485 wc_printf(_("File directory room"));
1487 wc_printf("\n<ul><li>");
1488 wc_printf(_("Directory name: "));
1489 wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1492 wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1493 if (er_flags & QR_UPLOAD)
1494 wc_printf("CHECKED ");
1496 wc_printf(_("Uploading allowed"));
1498 wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1499 if (er_flags & QR_DOWNLOAD)
1500 wc_printf("CHECKED ");
1502 wc_printf(_("Downloading allowed"));
1504 wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1505 if (er_flags & QR_VISDIR)
1506 wc_printf("CHECKED ");
1508 wc_printf(_("Visible directory"));
1509 wc_printf("</ul>\n");
1511 /** end of directory stuff */
1513 wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1514 if (er_flags & QR_NETWORK)
1515 wc_printf("CHECKED ");
1517 wc_printf(_("Network shared room"));
1519 wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1520 if (er_flags & QR_PERMANENT)
1521 wc_printf("CHECKED ");
1523 wc_printf(_("Permanent (does not auto-purge)"));
1525 wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1526 if (er_flags2 & QR2_SUBJECTREQ)
1527 wc_printf("CHECKED ");
1529 wc_printf(_("Subject Required (Force users to specify a message subject)"));
1531 /** start of anon options */
1533 wc_printf("\n<li>");
1534 wc_printf(_("Anonymous messages"));
1535 wc_printf("<ul>\n");
1537 wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1538 if (((er_flags & QR_ANONONLY) == 0)
1539 && ((er_flags & QR_ANONOPT) == 0))
1540 wc_printf("CHECKED ");
1542 wc_printf(_("No anonymous messages"));
1544 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1545 if (er_flags & QR_ANONONLY)
1546 wc_printf("CHECKED ");
1548 wc_printf(_("All messages are anonymous"));
1550 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1551 if (er_flags & QR_ANONOPT)
1552 wc_printf("CHECKED ");
1554 wc_printf(_("Prompt user when entering messages"));
1555 wc_printf("</ul>\n");
1557 /* end of anon options */
1560 wc_printf(_("Room aide: "));
1562 serv_getln(buf, sizeof buf);
1563 if (buf[0] != '2') {
1564 wc_printf("<em>%s</em>\n", &buf[4]);
1566 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1567 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1570 wc_printf("</ul><CENTER>\n");
1571 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1572 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1574 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1580 wc_printf("</div>");
1584 /* Sharing the room with other Citadel nodes... */
1585 if (!strcmp(tab, "sharing")) {
1586 wc_printf("<div class=\"tabcontent\">");
1588 shared_with = strdup("");
1589 not_shared_with = strdup("");
1591 /** Learn the current configuration */
1592 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1593 serv_getln(buf, sizeof buf);
1594 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1595 extract_token(node, buf, 0, '|', sizeof node);
1596 not_shared_with = realloc(not_shared_with,
1597 strlen(not_shared_with) + 32);
1598 strcat(not_shared_with, node);
1599 strcat(not_shared_with, "\n");
1603 serv_getln(buf, sizeof buf);
1604 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1605 extract_token(cmd, buf, 0, '|', sizeof cmd);
1606 extract_token(node, buf, 1, '|', sizeof node);
1607 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1608 if (!strcasecmp(cmd, "ignet_push_share")) {
1609 shared_with = realloc(shared_with,
1610 strlen(shared_with) + 32);
1611 strcat(shared_with, node);
1612 if (!IsEmptyStr(remote_room)) {
1613 strcat(shared_with, "|");
1614 strcat(shared_with, remote_room);
1616 strcat(shared_with, "\n");
1620 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1621 extract_token(buf, shared_with, i, '\n', sizeof buf);
1622 extract_token(node, buf, 0, '|', sizeof node);
1623 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1624 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1625 if (!strcasecmp(node, cmd)) {
1626 remove_token(not_shared_with, j, '\n');
1631 /* Display the stuff */
1632 wc_printf("<CENTER><br />"
1633 "<table border=1 cellpadding=5><tr>"
1635 wc_printf(_("Shared with"));
1636 wc_printf("</I></B></td>"
1638 wc_printf(_("Not shared with"));
1639 wc_printf("</I></B></td></tr>\n"
1640 "<tr><td VALIGN=TOP>\n");
1642 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1643 wc_printf(_("Remote node name"));
1644 wc_printf("</td><td>");
1645 wc_printf(_("Remote room name"));
1646 wc_printf("</td><td>");
1647 wc_printf(_("Actions"));
1648 wc_printf("</td></tr>\n");
1650 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1651 extract_token(buf, shared_with, i, '\n', sizeof buf);
1652 extract_token(node, buf, 0, '|', sizeof node);
1653 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1654 if (!IsEmptyStr(node)) {
1655 wc_printf("<form method=\"POST\" action=\"netedit\">");
1656 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1657 wc_printf("<tr><td>%s</td>\n", node);
1660 if (!IsEmptyStr(remote_room)) {
1661 escputs(remote_room);
1667 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1668 "VALUE=\"ignet_push_share|");
1670 if (!IsEmptyStr(remote_room)) {
1672 urlescputs(remote_room);
1675 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1676 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1677 wc_printf("<input type=\"submit\" "
1678 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1679 wc_printf("</td></tr></form>\n");
1683 wc_printf("</table>\n");
1684 wc_printf("</td><td VALIGN=TOP>\n");
1685 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1686 wc_printf(_("Remote node name"));
1687 wc_printf("</td><td>");
1688 wc_printf(_("Remote room name"));
1689 wc_printf("</td><td>");
1690 wc_printf(_("Actions"));
1691 wc_printf("</td></tr>\n");
1693 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1694 extract_token(node, not_shared_with, i, '\n', sizeof node);
1695 if (!IsEmptyStr(node)) {
1696 wc_printf("<form method=\"POST\" action=\"netedit\">");
1697 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1698 wc_printf("<tr><td>");
1700 wc_printf("</td><td>"
1701 "<input type=\"INPUT\" "
1705 wc_printf("<input type=\"hidden\" "
1707 "VALUE=\"ignet_push_share|");
1710 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1711 "VALUE=\"sharing\">\n");
1712 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1713 "VALUE=\"add\">\n");
1714 wc_printf("<input type=\"submit\" "
1715 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1716 wc_printf("</td></tr></form>\n");
1720 wc_printf("</table>\n");
1721 wc_printf("</td></tr>"
1722 "</table></CENTER><br />\n"
1723 "<I><B>%s</B><ul><li>", _("Notes:"));
1724 wc_printf(_("When sharing a room, "
1725 "it must be shared from both ends. Adding a node to "
1726 "the 'shared' list sends messages out, but in order to"
1727 " receive messages, the other nodes must be configured"
1728 " to send messages out to your system as well. "
1729 "<li>If the remote room name is blank, it is assumed "
1730 "that the room name is identical on the remote node."
1731 "<li>If the remote room name is different, the remote "
1732 "node must also configure the name of the room here."
1736 wc_printf("</div>");
1739 if (not_shared_with != NULL)
1740 free (not_shared_with);
1742 /* Mailing list management */
1743 if (!strcmp(tab, "listserv")) {
1744 room_states RoomFlags;
1745 wc_printf("<div class=\"tabcontent\">");
1747 wc_printf("<br /><center>"
1748 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1749 "<tr><td VALIGN=TOP>");
1751 wc_printf(_("<i>The contents of this room are being "
1752 "mailed <b>as individual messages</b> "
1753 "to the following list recipients:"
1754 "</i><br /><br />\n"));
1757 serv_getln(buf, sizeof buf);
1758 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1759 extract_token(cmd, buf, 0, '|', sizeof cmd);
1760 if (!strcasecmp(cmd, "listrecp")) {
1761 extract_token(recp, buf, 1, '|', sizeof recp);
1764 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1767 wc_printf(_("(remove)"));
1768 wc_printf("</A><br />");
1771 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1772 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1773 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1774 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1775 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1776 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1777 wc_printf("</form>\n");
1779 wc_printf("</td><td VALIGN=TOP>\n");
1781 wc_printf(_("<i>The contents of this room are being "
1782 "mailed <b>in digest form</b> "
1783 "to the following list recipients:"
1784 "</i><br /><br />\n"));
1787 serv_getln(buf, sizeof buf);
1788 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1789 extract_token(cmd, buf, 0, '|', sizeof cmd);
1790 if (!strcasecmp(cmd, "digestrecp")) {
1791 extract_token(recp, buf, 1, '|', sizeof recp);
1794 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1798 wc_printf(_("(remove)"));
1799 wc_printf("</A><br />");
1802 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1803 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1804 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1805 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1806 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1807 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1808 wc_printf("</form>\n");
1810 wc_printf("</td></tr></table>\n");
1812 /** Pop open an address book -- begin **/
1813 wc_printf("<div align=right>"
1814 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1816 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1821 _("Add recipients from Contacts or other address books"),
1822 _("Add recipients from Contacts or other address books")
1824 /* Pop open an address book -- end **/
1826 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1828 get_roomflags (&RoomFlags);
1830 /* Self Service subscription? */
1831 wc_printf("<table><tr><td>\n");
1832 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1833 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1834 " <tr><td colspan=\"2\">\n",
1835 (is_selflist(&RoomFlags))?"checked":"");
1836 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1837 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1838 (is_https ? "https" : "http"),
1839 ChrPtr(WC->Hdr->HR.http_host));
1840 /* Public posting? */
1841 wc_printf("<tr><td>");
1842 wc_printf(_("Allow non-subscribers to mail to this room."));
1843 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1844 (is_publiclist(&RoomFlags))?"checked":"");
1846 /* Moderated List? */
1847 wc_printf("<tr><td>");
1848 wc_printf(_("Room post publication needs Aide permission."));
1849 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1850 (is_moderatedlist(&RoomFlags))?"checked":"");
1853 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1854 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1855 wc_printf("</table></form>");
1858 wc_printf("</CENTER>\n");
1859 wc_printf("</div>");
1863 /* Configuration of The Dreaded Auto-Purger */
1864 if (!strcmp(tab, "expire")) {
1865 wc_printf("<div class=\"tabcontent\">");
1867 serv_puts("GPEX room");
1868 serv_getln(buf, sizeof buf);
1869 if (!strncmp(buf, "550", 3)) {
1870 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1871 _("Higher access is required to access this function.")
1874 else if (buf[0] != '2') {
1875 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1878 roompolicy = extract_int(&buf[4], 0);
1879 roomvalue = extract_int(&buf[4], 1);
1881 serv_puts("GPEX floor");
1882 serv_getln(buf, sizeof buf);
1883 if (buf[0] == '2') {
1884 floorpolicy = extract_int(&buf[4], 0);
1885 floorvalue = extract_int(&buf[4], 1);
1888 wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1889 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1890 wc_printf("<table border=0 cellspacing=5>\n");
1891 wc_printf("<tr><td>");
1892 wc_printf(_("Message expire policy for this room"));
1893 wc_printf("<br />(");
1894 escputs(ChrPtr(WC->CurRoom.name));
1895 wc_printf(")</td><td>");
1896 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1897 ((roompolicy == 0) ? "CHECKED" : "") );
1898 wc_printf(_("Use the default policy for this floor"));
1899 wc_printf("<br />\n");
1900 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1901 ((roompolicy == 1) ? "CHECKED" : "") );
1902 wc_printf(_("Never automatically expire messages"));
1903 wc_printf("<br />\n");
1904 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1905 ((roompolicy == 2) ? "CHECKED" : "") );
1906 wc_printf(_("Expire by message count"));
1907 wc_printf("<br />\n");
1908 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1909 ((roompolicy == 3) ? "CHECKED" : "") );
1910 wc_printf(_("Expire by message age"));
1911 wc_printf("<br />");
1912 wc_printf(_("Number of messages or days: "));
1913 wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1914 wc_printf("</td></tr>\n");
1916 if (WC->axlevel >= 6) {
1917 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1918 wc_printf("<tr><td>");
1919 wc_printf(_("Message expire policy for this floor"));
1920 wc_printf("<br />(");
1921 escputs(floorlist[WC->CurRoom.floorid]);
1922 wc_printf(")</td><td>");
1923 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1924 ((floorpolicy == 0) ? "CHECKED" : "") );
1925 wc_printf(_("Use the system default"));
1926 wc_printf("<br />\n");
1927 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1928 ((floorpolicy == 1) ? "CHECKED" : "") );
1929 wc_printf(_("Never automatically expire messages"));
1930 wc_printf("<br />\n");
1931 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1932 ((floorpolicy == 2) ? "CHECKED" : "") );
1933 wc_printf(_("Expire by message count"));
1934 wc_printf("<br />\n");
1935 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1936 ((floorpolicy == 3) ? "CHECKED" : "") );
1937 wc_printf(_("Expire by message age"));
1938 wc_printf("<br />");
1939 wc_printf(_("Number of messages or days: "));
1940 wc_printf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1944 wc_printf("<CENTER>\n");
1945 wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1946 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1947 wc_printf(" ");
1948 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1949 wc_printf("</CENTER></td><tr>\n");
1951 wc_printf("</table>\n"
1952 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1957 wc_printf("</div>");
1960 /* Access controls */
1961 if (!strcmp(tab, "access")) {
1962 wc_printf("<div class=\"tabcontent\">");
1964 wc_printf("</div>");
1967 /* Fetch messages from remote locations */
1968 if (!strcmp(tab, "feeds")) {
1969 wc_printf("<div class=\"tabcontent\">");
1972 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1973 wc_printf("</i><br />\n");
1975 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
1976 "<tr class=\"even\"><th>");
1977 wc_printf(_("Remote host"));
1978 wc_printf("</th><th>");
1979 wc_printf(_("User name"));
1980 wc_printf("</th><th>");
1981 wc_printf(_("Password"));
1982 wc_printf("</th><th>");
1983 wc_printf(_("Keep messages on server?"));
1984 wc_printf("</th><th>");
1985 wc_printf(_("Interval"));
1986 wc_printf("</th><th> </th></tr>");
1989 serv_getln(buf, sizeof buf);
1991 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1992 extract_token(cmd, buf, 0, '|', sizeof cmd);
1993 if (!strcasecmp(cmd, "pop3client")) {
1994 safestrncpy(recp, &buf[11], sizeof recp);
1997 wc_printf("<tr class=\"%s\">",
1998 (bg ? "even" : "odd")
2002 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2007 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2011 wc_printf("<td>*****</td>"); /* Don't show the password */
2013 wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2015 wc_printf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2017 wc_printf("<td class=\"button_link\">");
2018 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2021 wc_printf(_("(remove)"));
2022 wc_printf("</a></td>");
2028 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2030 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2031 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2032 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2034 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2037 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2040 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2043 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2046 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2049 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2050 wc_printf("</td></tr>");
2051 wc_printf("</form></table>\n");
2053 wc_printf("<hr>\n");
2056 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2057 wc_printf("</i><br />\n");
2059 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2060 "<tr class=\"even\"><th>");
2061 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2062 wc_printf(_("Feed URL"));
2063 wc_printf("</th><th>");
2064 wc_printf("</th></tr>");
2067 serv_getln(buf, sizeof buf);
2069 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2070 extract_token(cmd, buf, 0, '|', sizeof cmd);
2071 if (!strcasecmp(cmd, "rssclient")) {
2072 safestrncpy(recp, &buf[10], sizeof recp);
2075 wc_printf("<tr class=\"%s\">",
2076 (bg ? "even" : "odd")
2080 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2084 wc_printf("<td class=\"button_link\">");
2085 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2088 wc_printf(_("(remove)"));
2089 wc_printf("</a></td>");
2095 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2097 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2098 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2099 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2101 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2102 "maxlength=\"256\" name=\"line_pop3host\">\n");
2105 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2106 wc_printf("</td></tr>");
2107 wc_printf("</form></table>\n");
2109 wc_printf("</div>");
2113 /* end content of whatever tab is open now */
2114 wc_printf("</div>\n");
2116 address_book_popup();
2122 * Toggle self-service list subscription
2124 void toggle_self_service(void) {
2125 room_states RoomFlags;
2127 get_roomflags (&RoomFlags);
2129 if (yesbstr("QR2_SelfList"))
2130 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2132 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2134 if (yesbstr("QR2_SMTP_PUBLIC"))
2135 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2137 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2139 if (yesbstr("QR2_Moderated"))
2140 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2142 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2143 if (yesbstr("QR2_SubsOnly"))
2144 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2146 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2148 set_roomflags (&RoomFlags);
2156 * save new parameters for a room
2163 StrBuf *er_password;
2165 StrBuf *er_roomaide;
2168 int er_listingorder;
2174 if (!havebstr("ok_button")) {
2175 strcpy(WC->ImportantMessage,
2176 _("Cancelled. Changes were not saved."));
2182 StrBuf_ServGetln(Buf);
2183 if (GetServerStatus(Buf, NULL) != 2) {
2184 StrBufCutLeft(Buf, 4);
2185 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2191 er_name = NewStrBuf();
2192 er_password = NewStrBuf();
2193 er_dirname = NewStrBuf();
2194 er_roomaide = NewStrBuf();
2196 StrBufCutLeft(Buf, 4);
2197 StrBufExtract_token(er_name, Buf, 0, '|');
2198 StrBufExtract_token(er_password, Buf, 1, '|');
2199 StrBufExtract_token(er_dirname, Buf, 2, '|');
2200 er_flags = StrBufExtract_int(Buf, 3, '|');
2201 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2202 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2203 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2205 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2206 if (StrLength(er_roomaide) == 0) {
2208 StrBuf_ServGetln(Buf);
2209 if (GetServerStatus(Buf, NULL) != 2) {
2210 FlushStrBuf(er_roomaide);
2212 StrBufCutLeft(Buf, 4);
2213 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2216 Ptr = sbstr("er_name");
2217 if (StrLength(Ptr) > 0) {
2218 FlushStrBuf(er_name);
2219 StrBufAppendBuf(er_name, Ptr, 0);
2222 Ptr = sbstr("er_password");
2223 if (StrLength(Ptr) > 0) {
2224 FlushStrBuf(er_password);
2225 StrBufAppendBuf(er_password, Ptr, 0);
2229 Ptr = sbstr("er_dirname");
2230 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2231 FlushStrBuf(er_dirname);
2232 StrBufAppendBuf(er_dirname, Ptr, 0);
2236 Ptr = sbstr("type");
2237 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2239 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2240 er_flags |= (QR_PRIVATE);
2242 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2243 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2245 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2246 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2248 if (!strcmp(ChrPtr(Ptr), "personal")) {
2249 er_flags |= QR_MAILBOX;
2251 er_flags &= ~QR_MAILBOX;
2254 if (yesbstr("prefonly")) {
2255 er_flags |= QR_PREFONLY;
2257 er_flags &= ~QR_PREFONLY;
2260 if (yesbstr("readonly")) {
2261 er_flags |= QR_READONLY;
2263 er_flags &= ~QR_READONLY;
2267 if (yesbstr("collabdel")) {
2268 er_flags2 |= QR2_COLLABDEL;
2270 er_flags2 &= ~QR2_COLLABDEL;
2273 if (yesbstr("permanent")) {
2274 er_flags |= QR_PERMANENT;
2276 er_flags &= ~QR_PERMANENT;
2279 if (yesbstr("subjectreq")) {
2280 er_flags2 |= QR2_SUBJECTREQ;
2282 er_flags2 &= ~QR2_SUBJECTREQ;
2285 if (yesbstr("network")) {
2286 er_flags |= QR_NETWORK;
2288 er_flags &= ~QR_NETWORK;
2291 if (yesbstr("directory")) {
2292 er_flags |= QR_DIRECTORY;
2294 er_flags &= ~QR_DIRECTORY;
2297 if (yesbstr("ulallowed")) {
2298 er_flags |= QR_UPLOAD;
2300 er_flags &= ~QR_UPLOAD;
2303 if (yesbstr("dlallowed")) {
2304 er_flags |= QR_DOWNLOAD;
2306 er_flags &= ~QR_DOWNLOAD;
2309 if (yesbstr("visdir")) {
2310 er_flags |= QR_VISDIR;
2312 er_flags &= ~QR_VISDIR;
2315 Ptr = sbstr("anon");
2317 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2318 if (!strcmp(ChrPtr(Ptr), "anononly"))
2319 er_flags |= QR_ANONONLY;
2320 if (!strcmp(ChrPtr(Ptr), "anon2"))
2321 er_flags |= QR_ANONOPT;
2323 bump = yesbstr("bump");
2325 er_floor = ibstr("er_floor");
2327 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2329 ChrPtr(er_password),
2338 StrBuf_ServGetln(Buf);
2339 if (GetServerStatus(Buf, NULL) != 2) {
2340 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2343 FreeStrBuf(&er_name);
2344 FreeStrBuf(&er_password);
2345 FreeStrBuf(&er_dirname);
2346 FreeStrBuf(&er_roomaide);
2351 if (StrLength(er_roomaide) > 0) {
2352 serv_printf("SETA %s", ChrPtr(er_roomaide));
2353 StrBuf_ServGetln(Buf);
2354 if (GetServerStatus(Buf, NULL) != 2) {
2355 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2356 display_main_menu();
2358 FreeStrBuf(&er_name);
2359 FreeStrBuf(&er_password);
2360 FreeStrBuf(&er_dirname);
2361 FreeStrBuf(&er_roomaide);
2366 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2369 FreeStrBuf(&er_name);
2370 FreeStrBuf(&er_password);
2371 FreeStrBuf(&er_dirname);
2372 FreeStrBuf(&er_roomaide);
2378 * Display form for Invite, Kick, and show Who Knows a room
2380 void do_invt_kick(void) {
2381 char buf[SIZ], room[SIZ], username[SIZ];
2384 serv_getln(buf, sizeof buf);
2386 if (buf[0] != '2') {
2390 extract_token(room, &buf[4], 0, '|', sizeof room);
2392 strcpy(username, bstr("username"));
2394 if (havebstr("kick_button")) {
2395 sprintf(buf, "KICK %s", username);
2397 serv_getln(buf, sizeof buf);
2399 if (buf[0] != '2') {
2400 strcpy(WC->ImportantMessage, &buf[4]);
2402 sprintf(WC->ImportantMessage,
2403 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2408 if (havebstr("invite_button")) {
2409 sprintf(buf, "INVT %s", username);
2411 serv_getln(buf, sizeof buf);
2413 if (buf[0] != '2') {
2414 strcpy(WC->ImportantMessage, &buf[4]);
2416 sprintf(WC->ImportantMessage,
2417 _("<B><I>User %s invited to room %s.</I></B>\n"),
2428 * Display form for Invite, Kick, and show Who Knows a room
2430 void display_whok(void)
2432 char buf[SIZ], room[SIZ], username[SIZ];
2435 serv_getln(buf, sizeof buf);
2437 if (buf[0] != '2') {
2441 extract_token(room, &buf[4], 0, '|', sizeof room);
2444 wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2445 wc_printf(_("The users listed below have access to this room. "
2446 "To remove a user from the access list, select the user "
2447 "name from the list and click 'Kick'."));
2448 wc_printf("<br /><br />");
2450 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2451 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2452 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2453 wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2455 serv_getln(buf, sizeof buf);
2456 if (buf[0] == '1') {
2457 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2458 extract_token(username, buf, 0, '|', sizeof username);
2459 wc_printf("<OPTION>");
2464 wc_printf("</select><br />\n");
2466 wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2467 wc_printf("</form></CENTER>\n");
2469 wc_printf("</td><td>");
2470 wc_printf(_("To grant another user access to this room, enter the "
2471 "user name in the box below and click 'Invite'."));
2472 wc_printf("<br /><br />");
2474 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2475 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2476 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2477 wc_printf(_("Invite:"));
2479 wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2480 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2481 "<input type=\"submit\" value=\"%s\">"
2482 "</form></CENTER>\n", _("Invite"));
2483 /* Pop open an address book -- begin **/
2485 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2487 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2490 _("Users"), _("Users")
2492 /* Pop open an address book -- end **/
2494 wc_printf("</td></tr></table>\n");
2495 address_book_popup();
2502 * display the form for entering a new room
2504 void display_entroom(void)
2511 serv_puts("CRE8 0");
2512 serv_getln(buf, sizeof buf);
2514 if (buf[0] != '2') {
2515 strcpy(WC->ImportantMessage, &buf[4]);
2516 display_main_menu();
2521 output_headers(1, 1, 1, 0, 0, 0);
2523 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2524 do_template("beginbox", NULL);
2526 wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2527 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2529 wc_printf("<table class=\"altern\"> ");
2531 wc_printf("<tr class=\"even\"><td>");
2532 wc_printf(_("Name of room: "));
2533 wc_printf("</td><td>");
2534 wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2535 wc_printf("</td></tr>");
2537 wc_printf("<tr class=\"odd\"><td>");
2538 wc_printf(_("Resides on floor: "));
2539 wc_printf("</td><td>");
2540 load_floorlist(Buf);
2541 wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2542 for (i = 0; i < 128; ++i)
2543 if (!IsEmptyStr(floorlist[i])) {
2544 wc_printf("<option ");
2545 wc_printf("value=\"%d\">", i);
2546 escputs(floorlist[i]);
2547 wc_printf("</option>\n");
2549 wc_printf("</select>\n");
2550 wc_printf("</td></tr>");
2553 * Our clever little snippet of JavaScript automatically selects
2554 * a public room if the view is set to Bulletin Board or wiki, and
2555 * it selects a mailbox room otherwise. The user can override this,
2556 * of course. We also disable the floor selector for mailboxes.
2558 wc_printf("<tr class=\"even\"><td>");
2559 wc_printf(_("Default view for room: "));
2560 wc_printf("</td><td>");
2561 wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2562 " if ( (this.form.er_view.value == 0) "
2563 " || (this.form.er_view.value == 6) ) { "
2564 " this.form.type[0].checked=true; "
2565 " this.form.er_floor.disabled = false; "
2568 " this.form.type[4].checked=true; "
2569 " this.form.er_floor.disabled = true; "
2572 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2573 if (is_view_allowed_as_default(i)) {
2574 wc_printf("<option %s value=\"%d\">",
2575 ((i == 0) ? "selected" : ""), i );
2576 escputs(viewdefs[i]);
2577 wc_printf("</option>\n");
2580 wc_printf("</select>\n");
2581 wc_printf("</td></tr>");
2583 wc_printf("<tr class=\"even\"><td>");
2584 wc_printf(_("Type of room:"));
2585 wc_printf("</td><td>");
2586 wc_printf("<ul class=\"adminlist\">\n");
2588 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2589 wc_printf("CHECKED OnChange=\""
2590 " if (this.form.type[0].checked == true) { "
2591 " this.form.er_floor.disabled = false; "
2594 wc_printf(_("Public (automatically appears to everyone)"));
2597 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2598 " if (this.form.type[1].checked == true) { "
2599 " this.form.er_floor.disabled = false; "
2602 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2605 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2606 " if (this.form.type[2].checked == true) { "
2607 " this.form.er_floor.disabled = false; "
2610 wc_printf(_("Private - require password: "));
2611 wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2614 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2615 " if (this.form.type[3].checked == true) { "
2616 " this.form.er_floor.disabled = false; "
2619 wc_printf(_("Private - invitation only"));
2622 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2624 " if (this.form.type[4].checked == true) { "
2625 " this.form.er_floor.disabled = true; "
2628 wc_printf(_("Personal (mailbox for you only)"));
2631 wc_printf("\n</ul>\n");
2632 wc_printf("</td></tr></table>\n");
2634 wc_printf("<div class=\"buttons\">\n");
2635 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2636 wc_printf(" ");
2637 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2638 wc_printf("</div>\n");
2639 wc_printf("</form>\n<hr />");
2640 serv_printf("MESG roomaccess");
2641 serv_getln(buf, sizeof buf);
2642 if (buf[0] == '1') {
2646 do_template("endbox", NULL);
2656 * support function for entroom() -- sets the default view
2658 void er_set_default_view(int newview) {
2671 serv_getln(buf, sizeof buf);
2672 if (buf[0] != '2') return;
2674 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2675 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2676 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2677 rm_bits1 = extract_int(&buf[4], 3);
2678 rm_floor = extract_int(&buf[4], 4);
2679 rm_listorder = extract_int(&buf[4], 5);
2680 rm_bits2 = extract_int(&buf[4], 7);
2682 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2683 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2684 rm_listorder, newview, rm_bits2
2686 serv_getln(buf, sizeof buf);
2697 const StrBuf *er_name;
2698 const StrBuf *er_type;
2699 const StrBuf *er_password;
2703 wcsession *WCC = WC;
2705 if (!havebstr("ok_button")) {
2706 strcpy(WC->ImportantMessage,
2707 _("Cancelled. No new room was created."));
2708 display_main_menu();
2711 er_name = sbstr("er_name");
2712 er_type = sbstr("type");
2713 er_password = sbstr("er_password");
2714 er_floor = ibstr("er_floor");
2715 er_view = ibstr("er_view");
2718 if (!strcmp(ChrPtr(er_type), "hidden"))
2720 else if (!strcmp(ChrPtr(er_type), "passworded"))
2722 else if (!strcmp(ChrPtr(er_type), "invonly"))
2724 else if (!strcmp(ChrPtr(er_type), "personal"))
2727 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2730 ChrPtr(er_password),
2735 serv_getln(buf, sizeof buf);
2736 if (buf[0] != '2') {
2737 strcpy(WCC->ImportantMessage, &buf[4]);
2738 display_main_menu();
2741 /** TODO: Room created, now update the left hand icon bar for this user */
2742 burn_folder_cache(0); /* burn the old folder cache */
2746 serv_printf("VIEW %d", er_view);
2747 serv_getln(buf, sizeof buf);
2748 WCC->CurRoom.view = er_view;
2750 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
2751 display_editroom ();
2753 do_change_view(er_view); /* Now go there */
2760 * \brief display the screen to enter a private room
2762 void display_private(char *rname, int req_pass)
2764 WCTemplputParams SubTP;
2766 output_headers(1, 1, 1, 0, 0, 0);
2768 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2769 memset(&SubTP, 0, sizeof(WCTemplputParams));
2770 SubTP.Filter.ContextType = CTX_STRBUF;
2771 SubTP.Context = Buf;
2772 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2777 wc_printf(_("If you know the name of a hidden (guess-name) or "
2778 "passworded room, you can enter that room by typing "
2779 "its name below. Once you gain access to a private "
2780 "room, it will appear in your regular room listings "
2781 "so you don't have to keep returning here."));
2784 wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2785 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2787 wc_printf("<table class=\"altern\"> "
2788 "<tr class=\"even\"><td>");
2789 wc_printf(_("Enter room name:"));
2790 wc_printf("</td><td>"
2791 "<input type=\"text\" name=\"gr_name\" "
2792 "value=\"%s\" maxlength=\"128\">\n", rname);
2795 wc_printf("</td></tr><tr class=\"odd\"><td>");
2796 wc_printf(_("Enter room password:"));
2797 wc_printf("</td><td>");
2798 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2800 wc_printf("</td></tr></table>\n");
2802 wc_printf("<div class=\"buttons\">\n");
2803 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2805 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2809 wc_printf("</div></form>\n");
2811 do_template("endbox", NULL);
2817 * \brief goto a private room
2819 void goto_private(void)
2824 if (!havebstr("ok_button")) {
2825 display_main_menu();
2828 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2829 serv_printf("GOTO %s|%s",
2832 serv_getln(buf, sizeof buf);
2834 if (buf[0] == '2') {
2835 smart_goto(sbstr("gr_name"));
2838 if (!strncmp(buf, "540", 3)) {
2839 display_private(bstr("gr_name"), 1);
2842 output_headers(1, 1, 1, 0, 0, 0);
2843 wc_printf("%s\n", &buf[4]);
2850 * \brief display the screen to zap a room
2852 void display_zap(void)
2854 output_headers(1, 1, 2, 0, 0, 0);
2856 wc_printf("<div id=\"banner\">\n");
2858 wc_printf(_("Zap (forget/unsubscribe) the current room"));
2859 wc_printf("</h1>\n");
2860 wc_printf("</div>\n");
2862 wc_printf("<div id=\"content\" class=\"service\">\n");
2864 wc_printf(_("If you select this option, <em>%s</em> will "
2865 "disappear from your room list. Is this what you wish "
2866 "to do?<br />\n"), ChrPtr(WC->CurRoom.name));
2868 wc_printf("<form method=\"POST\" action=\"zap\">\n");
2869 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2870 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2871 wc_printf(" ");
2872 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2873 wc_printf("</form>\n");
2884 StrBuf *final_destination;
2887 * If the forget-room routine fails for any reason, we fall back
2888 * to the current room; otherwise, we go to the Lobby
2890 final_destination = NewStrBufDup(WC->CurRoom.name);
2892 if (havebstr("ok_button")) {
2893 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
2894 serv_getln(buf, sizeof buf);
2895 if (buf[0] == '2') {
2897 serv_getln(buf, sizeof buf);
2898 if (buf[0] == '2') {
2899 FlushStrBuf(final_destination);
2900 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2904 smart_goto(final_destination);
2905 FreeStrBuf(&final_destination);
2911 * \brief Delete the current room
2913 void delete_room(void)
2918 serv_puts("KILL 1");
2919 serv_getln(buf, sizeof buf);
2920 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2921 if (buf[0] != '2') {
2922 strcpy(WC->ImportantMessage, &buf[4]);
2923 display_main_menu();
2928 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2937 * \brief Perform changes to a room's network configuration
2939 void netedit(void) {
2948 /*/ TODO: do line dynamic! */
2949 if (havebstr("line_pop3host")) {
2950 strcpy(line, bstr("prefix"));
2951 strcat(line, bstr("line_pop3host"));
2953 strcat(line, bstr("line_pop3user"));
2955 strcat(line, bstr("line_pop3pass"));
2957 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2959 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2960 strcat(line, bstr("suffix"));
2962 else if (havebstr("line")) {
2963 strcpy(line, bstr("prefix"));
2964 strcat(line, bstr("line"));
2965 strcat(line, bstr("suffix"));
2980 serv_getln(buf, sizeof buf);
2981 if (buf[0] != '1') {
2987 /** This loop works for add *or* remove. Spiffy, eh? */
2988 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2989 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2990 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2991 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2992 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2993 if ( (strcasecmp(cmpa0, cmpb0))
2994 || (strcasecmp(cmpa1, cmpb1)) ) {
2995 fprintf(fp, "%s\n", buf);
3001 serv_getln(buf, sizeof buf);
3002 if (buf[0] != '4') {
3008 while (fgets(buf, sizeof buf, fp) != NULL) {
3009 buf[strlen(buf)-1] = 0;
3013 if (havebstr("add_button")) {
3014 num_addrs = num_tokens(bstr("line"), ',');
3015 if (num_addrs < 2) {
3016 /* just adding one node or address */
3020 /* adding multiple addresses separated by commas */
3021 for (i=0; i<num_addrs; ++i) {
3022 strcpy(line, bstr("prefix"));
3023 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3026 strcat(line, bstr("suffix"));
3040 * \brief Convert a room name to a folder-ish-looking name.
3041 * \param folder the folderish name
3042 * \param room the room name
3043 * \param floor the floor name
3044 * \param is_mailbox is it a mailbox?
3046 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3051 * For mailboxes, just do it straight...
3054 sprintf(folder, "My folders|%s", room);
3058 * Otherwise, prefix the floor name as a "public folders" moniker
3061 if (floor > MAX_FLOORS) {
3063 sprintf(folder, "%%%%%%|%s", room);
3066 sprintf(folder, "%s|%s", floorlist[floor], room);
3071 * Replace "\" characters with "|" for pseudo-folder-delimiting
3073 len = strlen (folder);
3074 for (i=0; i<len; ++i) {
3075 if (folder[i] == '\\') folder[i] = '|';
3083 * \brief Back end for change_view()
3084 * \param newview set newview???
3086 void do_change_view(int newview) {
3089 serv_printf("VIEW %d", newview);
3090 serv_getln(buf, sizeof buf);
3091 WC->CurRoom.view = newview;
3092 smart_goto(WC->CurRoom.name);
3098 * \brief Change the view for this room
3100 void change_view(void) {
3103 view = lbstr("view");
3104 do_change_view(view);
3108 * \brief Burn the cached folder list.
3109 * \param age How old the cahce needs to be before we burn it.
3112 void burn_folder_cache(time_t age)
3114 /** If our cached folder list is very old, burn it. */
3115 if (WC->cache_fold != NULL) {
3116 if ((time(NULL) - WC->cache_timestamp) > age) {
3117 free(WC->cache_fold);
3118 WC->cache_fold = NULL;
3126 * \brief Do either a known rooms list or a folders list, depending on the
3131 StrBuf *ListView = NULL;
3133 /** Determine whether the user is trying to change views */
3134 if (havebstr("view")) {
3135 ListView = NewStrBufDup(SBSTR("view"));
3136 set_preference("roomlistview", ListView, 1);
3138 /** Sanitize the input so its safe */
3139 if((get_preference("roomlistview", &ListView) != 0)||
3140 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3141 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3143 if (ListView == NULL) {
3144 ListView = NewStrBufPlain(HKEY("rooms"));
3145 set_preference("roomlistview", ListView, 0);
3149 ListView = NewStrBufPlain(HKEY("rooms"));
3150 set_preference("roomlistview", ListView, 0);
3154 FreeStrBuf(&ListView);
3161 * \brief Set the message expire policy for this room and/or floor
3163 void set_room_policy(void) {
3166 if (!havebstr("ok_button")) {
3167 strcpy(WC->ImportantMessage,
3168 _("Cancelled. Changes were not saved."));
3173 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3174 serv_getln(buf, sizeof buf);
3175 strcpy(WC->ImportantMessage, &buf[4]);
3177 if (WC->axlevel >= 6) {
3178 strcat(WC->ImportantMessage, "<br />\n");
3179 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3180 serv_getln(buf, sizeof buf);
3181 strcat(WC->ImportantMessage, &buf[4]);
3187 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3189 StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3193 void _display_private(void) {
3194 display_private("", 0);
3197 void dotgoto(void) {
3198 if (!havebstr("room")) {
3199 readloop(readnew, eUseDefault);
3202 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3205 smart_goto(sbstr("room"));
3210 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3212 wcsession *WCC = WC;
3215 StrBufAppendTemplate(Target, TP,
3220 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3222 wc_printf("<div id=\"banner\">\n");
3223 embed_room_banner(NULL, navbar_default);
3224 wc_printf("</div>\n");
3228 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3230 wcsession *WCC = WC;
3233 (!IsEmptyStr(WCC->ugname)))
3234 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3237 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3239 wcsession *WCC = WC;
3240 return (WCC != NULL)?
3241 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3244 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3246 wcsession *WCC = WC;
3247 return (WCC == NULL)? 0 :
3248 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3249 (WCC->CurRoom.is_inbox) ||
3250 (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3253 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3255 wcsession *WCC = WC;
3257 return ((WCC!=NULL) &&
3258 (!IsEmptyStr(WCC->ugname)) &&
3259 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3263 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
3265 folder *Folder = (folder *)(TP->Context);
3268 UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3269 if (UA_CheckFlag == 0)
3270 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3271 "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
3273 return ((Folder->RAFlags & UA_CheckFlag) != 0);
3278 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3281 wcsession *WCC = WC;
3283 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3284 if (QR_CheckFlag == 0)
3285 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3286 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3288 return ((WCC!=NULL) &&
3289 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3292 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3295 folder *Folder = (folder *)(TP->Context);
3297 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3298 if (QR_CheckFlag == 0)
3299 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3300 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3301 return ((Folder->QRFlags & QR_CheckFlag) != 0);
3305 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3308 wcsession *WCC = WC;
3310 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3311 if (QR2_CheckFlag == 0)
3312 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3313 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3315 return ((WCC!=NULL) &&
3316 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3319 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3322 folder *Folder = (folder *)(TP->Context);
3324 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3325 if (QR2_CheckFlag == 0)
3326 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3327 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3328 return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3332 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3334 wcsession *WCC = WC;
3336 return ( (WCC!= NULL) &&
3337 ((WCC->axlevel >= 6) ||
3338 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3339 (WCC->CurRoom.is_inbox) ));
3342 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3344 wcsession *WCC = WC;
3346 if ((WCC == NULL) ||
3347 (TP->Tokens->nParameters < 3))
3349 return ((WCC->CurRoom.view < VIEW_BBS) ||
3350 (WCC->CurRoom.view > VIEW_MAX));
3353 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3357 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
3359 wcsession *WCC = WC;
3363 HashList *Whok = NULL;
3369 Token = NewStrBuf();
3370 StrBuf_ServGetln(Line);
3371 if (GetServerStatus(Line, &State) == 1)
3373 Whok = NewHash(1, Flathash);
3374 while(!Done && StrBuf_ServGetln(Line))
3375 if ( (StrLength(Line)==3) &&
3376 !strcmp(ChrPtr(Line), "000"))
3383 const char *Pos = NULL;
3384 Token = NewStrBufPlain (NULL, StrLength(Line));
3385 StrBufExtract_NextToken(Token, Line, &Pos, '|');
3393 else if (State == 550)
3394 StrBufAppendBufPlain(WCC->ImportantMsg,
3395 _("Higher access is required to access this function."), -1, 0);
3405 initialize_viewdefs();
3406 RegisterPreference("roomlistview",
3407 _("Room list view"),
3410 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3412 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3415 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3416 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3417 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3418 WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3419 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3420 WebcitAddUrlHandler(HKEY("zapped_list"), "", 0, zapped_list, 0);
3421 WebcitAddUrlHandler(HKEY("display_zap"), "", 0, display_zap, 0);
3422 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3423 WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3424 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3425 WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3426 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3427 WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3428 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3429 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3430 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3431 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3432 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3433 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3434 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3436 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3437 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3438 RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3440 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3441 RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3442 RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
3444 RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
3445 RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
3446 RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3447 RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3448 RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3449 RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3450 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3451 RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3452 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3453 RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
3455 REGISTERTokenParamDefine(QR_PERMANENT);
3456 REGISTERTokenParamDefine(QR_INUSE);
3457 REGISTERTokenParamDefine(QR_PRIVATE);
3458 REGISTERTokenParamDefine(QR_PASSWORDED);
3459 REGISTERTokenParamDefine(QR_GUESSNAME);
3460 REGISTERTokenParamDefine(QR_DIRECTORY);
3461 REGISTERTokenParamDefine(QR_UPLOAD);
3462 REGISTERTokenParamDefine(QR_DOWNLOAD);
3463 REGISTERTokenParamDefine(QR_VISDIR);
3464 REGISTERTokenParamDefine(QR_ANONONLY);
3465 REGISTERTokenParamDefine(QR_ANONOPT);
3466 REGISTERTokenParamDefine(QR_NETWORK);
3467 REGISTERTokenParamDefine(QR_PREFONLY);
3468 REGISTERTokenParamDefine(QR_READONLY);
3469 REGISTERTokenParamDefine(QR_MAILBOX);
3470 REGISTERTokenParamDefine(QR2_SYSTEM);
3471 REGISTERTokenParamDefine(QR2_SELFLIST);
3472 REGISTERTokenParamDefine(QR2_COLLABDEL);
3473 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3474 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3475 REGISTERTokenParamDefine(QR2_MODERATED);
3477 REGISTERTokenParamDefine(UA_KNOWN);
3478 REGISTERTokenParamDefine(UA_GOTOALLOWED);
3479 REGISTERTokenParamDefine(UA_HASNEWMSGS);
3480 REGISTERTokenParamDefine(UA_ZAPPED);
3481 REGISTERTokenParamDefine(UA_POSTALLOWED);
3482 REGISTERTokenParamDefine(UA_ADMINALLOWED);
3483 REGISTERTokenParamDefine(UA_DELETEALLOWED);
3484 REGISTERTokenParamDefine(UA_ISTRASH);
3486 REGISTERTokenParamDefine(US_NEEDVALID);
3487 REGISTERTokenParamDefine(US_PERM);
3488 REGISTERTokenParamDefine(US_LASTOLD);
3489 REGISTERTokenParamDefine(US_EXPERT);
3490 REGISTERTokenParamDefine(US_UNLISTED);
3491 REGISTERTokenParamDefine(US_NOPROMPT);
3492 REGISTERTokenParamDefine(US_PROMPTCTL);
3493 REGISTERTokenParamDefine(US_DISAPPEAR);
3494 REGISTERTokenParamDefine(US_REGIS);
3495 REGISTERTokenParamDefine(US_PAGINATOR);
3496 REGISTERTokenParamDefine(US_INTERNET);
3497 REGISTERTokenParamDefine(US_FLOORS);
3498 REGISTERTokenParamDefine(US_COLOR);
3499 REGISTERTokenParamDefine(US_USER_SET);
3501 REGISTERTokenParamDefine(VIEW_BBS);
3502 REGISTERTokenParamDefine(VIEW_MAILBOX);
3503 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3504 REGISTERTokenParamDefine(VIEW_CALENDAR);
3505 REGISTERTokenParamDefine(VIEW_TASKS);
3506 REGISTERTokenParamDefine(VIEW_NOTES);
3507 REGISTERTokenParamDefine(VIEW_WIKI);
3508 REGISTERTokenParamDefine(VIEW_CALBRIEF);
3509 REGISTERTokenParamDefine(VIEW_JOURNAL);
3510 REGISTERTokenParamDefine(VIEW_BLOG);
3513 REGISTERTokenParamDefine(ignet_push_share);
3514 { /* these are the parts of an IGNET push config */
3515 REGISTERTokenParamDefine(GNET_IGNET_NODE);
3516 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
3518 REGISTERTokenParamDefine(listrecp);
3519 REGISTERTokenParamDefine(digestrecp);
3520 REGISTERTokenParamDefine(pop3client);
3521 { /* These are the parts of a pop3 client line... */
3522 REGISTERTokenParamDefine(GNET_POP3_HOST);
3523 REGISTERTokenParamDefine(GNET_POP3_USER);
3524 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
3525 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
3527 REGISTERTokenParamDefine(rssclient);
3528 REGISTERTokenParamDefine(participate);
3530 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3531 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3533 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3534 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3536 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3537 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3538 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3545 SessionDestroyModule_ROOMOPS
3548 FlushFolder(&sess->CurRoom);
3549 if (sess->cache_fold != NULL) {
3550 free(sess->cache_fold);
3553 free_march_list(sess);
3554 DeleteHash(&sess->Floors);
3555 DeleteHash(&sess->Rooms);
3556 DeleteHash(&sess->FloorsByName);