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");
322 * Display a search box
324 void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP)
326 wc_printf("<form name=\"searchomatic\" action=\"do_search\">\n");
327 wc_printf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
328 wc_printf("<label for=\"srchquery\">");
329 wc_printf(_("Search: "));
330 wc_printf("</label><input ");
331 wc_printf("%s", WC->serv_info->serv_fulltext_enabled ? "" : "disabled ");
332 wc_printf("type=\"text\" name=\"query\" id=\"srchquery\" size=\"15\" maxlength=\"128\" class=\"inputbox\">\n"
334 wc_printf("</div></form>\n");
339 * Embed the room banner
341 * got The information returned from a GOTO server command
342 * navbar_style Determines which navigation buttons to display
346 void embed_room_banner(char *got, int navbar_style) {
350 char with_files[256];
354 * We need to have the information returned by a GOTO server command.
355 * If it isn't supplied, we fake it by issuing our own GOTO.
358 memset(buf, '0', 20);
360 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
361 serv_getln(buf, sizeof buf);
365 /* The browser needs some information for its own use */
366 wc_printf("<script type=\"text/javascript\"> \n"
367 " room_is_trash = %d; \n"
369 ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
373 * If the user happens to select the "make this my start page" link,
374 * we want it to remember the URL as a "/dotskip" one instead of
375 * a "skip" or "gotonext" or something like that.
377 if (WCC->Hdr->this_page == NULL) {
378 WCC->Hdr->this_page = NewStrBuf();
380 StrBufPrintf(WCC->Hdr->this_page,
382 ChrPtr(WC->CurRoom.name)
385 /* Check for new mail. */
386 WC->new_mail = extract_int(&got[4], 9);
387 WC->CurRoom.view = extract_int(&got[4], 11);
389 /* Is this a directory room and does it contain files and how many? */
390 if ((WC->CurRoom.QRFlags & QR_DIRECTORY) && (WC->CurRoom.QRFlags & QR_VISDIR))
393 serv_getln(buf2, sizeof buf2);
394 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
396 snprintf (with_files, sizeof with_files,
397 "; <a href=\"do_template?template=files\"> %d %s </a>",
399 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
402 strcpy (with_files, "");
404 svprintf(HKEY("NUMMSGS"), WCS_STRING,
405 _("%d new of %d messages%s"),
406 extract_int(&got[4], 1),
407 extract_int(&got[4], 2),
410 svcallback("ROOMINFO", readinfo);
411 svcallback("VIEWOMATIC", embed_view_o_matic);
412 svcallback("SEARCHOMATIC", embed_search_o_matic);
413 svcallback("START", offer_start_page);
415 do_template("roombanner", NULL);
416 /* roombanner contains this for mobile */
417 if (navbar_style != navbar_none && (WC->is_mobile < 1)) {
419 wc_printf("<div id=\"navbar\"><ul>");
421 if (navbar_style == navbar_default) wc_printf(
422 "<li class=\"ungoto\">"
423 "<a href=\"ungoto\">"
424 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
425 "<span class=\"navbar_link\">%s</span></A>"
426 "</li>\n", _("Ungoto")
429 if ( (navbar_style == navbar_default) && (WC->CurRoom.view == VIEW_BBS) ) {
431 "<li class=\"newmess\">"
432 "<a href=\"readnew\">"
433 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
434 "<span class=\"navbar_link\">%s</span></A>"
435 "</li>\n", _("Read new messages")
439 if (navbar_style == navbar_default) {
440 switch(WC->CurRoom.view) {
441 case VIEW_ADDRESSBOOK:
443 "<li class=\"viewcontacts\">"
444 "<a href=\"readfwd\">"
445 "<img src=\"static/viewcontacts_24x.gif\" "
446 "alt=\"\" width=\"24\" height=\"24\">"
447 "<span class=\"navbar_link\">"
449 "</span></a></li>\n", _("View contacts")
454 "<li class=\"staskday\">"
455 "<a href=\"readfwd?calview=day\">"
456 "<img src=\"static/taskday2_24x.gif\" "
457 "alt=\"\" width=\"24\" height=\"24\">"
458 "<span class=\"navbar_link\">"
460 "</span></a></li>\n", _("Day view")
463 "<li class=\"monthview\">"
464 "<a href=\"readfwd?calview=month\">"
465 "<img src=\"static/monthview2_24x.gif\" "
466 "alt=\"\" width=\"24\" height=\"24\">"
467 "<span class=\"navbar_link\">"
469 "</span></a></li>\n", _("Month view")
474 "<li class=\"monthview\">"
475 "<a href=\"readfwd?calview=month\">"
476 "<img src=\"static/monthview2_24x.gif\" "
477 "alt=\"\" width=\"24\" height=\"24\">"
478 "<span class=\"navbar_link\">"
480 "</span></a></li>\n", _("Calendar list")
485 "<li class=\"taskmanag\">"
486 "<a href=\"readfwd\">"
487 "<img src=\"static/taskmanag_24x.gif\" "
488 "alt=\"\" width=\"24\" height=\"24\">"
489 "<span class=\"navbar_link\">"
491 "</span></a></li>\n", _("View tasks")
496 "<li class=\"viewnotes\">"
497 "<a href=\"readfwd\">"
498 "<img src=\"static/viewnotes_24x.gif\" "
499 "alt=\"\" width=\"24\" height=\"24\">"
500 "<span class=\"navbar_link\">"
502 "</span></a></li>\n", _("View notes")
507 "<li class=\"readallmess\">"
508 "<a id=\"m_refresh\" href=\"readfwd\">"
509 "<img src=\"static/readallmess3_24x.gif\" "
510 "alt=\"\" width=\"24\" height=\"24\">"
511 "<span class=\"navbar_link\">"
513 "</span></a></li>\n", _("Refresh message list")
518 "<li class=\"readallmess\">"
519 "<a href=\"wiki?page=home\">"
520 "<img src=\"static/readallmess3_24x.gif\" "
521 "alt=\"\" width=\"24\" height=\"24\">"
522 "<span class=\"navbar_link\">"
524 "</span></a></li>\n", _("Wiki home")
529 "<li class=\"readallmess\">"
530 "<a href=\"readfwd\">"
531 "<img src=\"static/readallmess3_24x.gif\" "
532 "alt=\"\" width=\"24\" height=\"24\">"
533 "<span class=\"navbar_link\">"
535 "</span></a></li>\n", _("Read all messages")
541 if (navbar_style == navbar_default) {
542 switch(WC->CurRoom.view) {
543 case VIEW_ADDRESSBOOK:
545 "<li class=\"addnewcontact\">"
546 "<a href=\"display_enter\">"
547 "<img src=\"static/addnewcontact_24x.gif\" "
548 "alt=\"\" width=\"24\" height=\"24\">"
549 "<span class=\"navbar_link\">"
551 "</span></a></li>\n", _("Add new contact")
556 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
557 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
558 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
559 if (havebstr("day" )) wc_printf("?day=%s", bstr("day"));
561 "<img src=\"static/addevent_24x.gif\" "
562 "alt=\"\" width=\"24\" height=\"24\">"
563 "<span class=\"navbar_link\">"
565 "</span></a></li>\n", _("Add new event")
570 "<li class=\"newmess\">"
571 "<a href=\"display_enter\">"
572 "<img src=\"static/newmess3_24x.gif\" "
573 "alt=\"\" width=\"24\" height=\"24\">"
574 "<span class=\"navbar_link\">"
576 "</span></a></li>\n", _("Add new task")
581 "<li class=\"enternewnote\">"
582 "<a href=\"add_new_note\">"
583 "<img src=\"static/enternewnote_24x.gif\" "
584 "alt=\"\" width=\"24\" height=\"24\">"
585 "<span class=\"navbar_link\">"
587 "</span></a></li>\n", _("Add new note")
591 safestrncpy(buf, bstr("page"), sizeof buf);
592 if (IsEmptyStr(buf)) {
593 safestrncpy(buf, "home", sizeof buf);
597 "<li class=\"newmess\">"
598 "<a href=\"display_enter?page=%s\">"
599 "<img src=\"static/newmess3_24x.gif\" "
600 "alt=\"\" width=\"24\" height=\"24\">"
601 "<span class=\"navbar_link\">"
603 "</span></a></li>\n", buf, _("Edit this page")
606 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
607 /* already viewing history; display a link to the current page */
609 "<li class=\"newmess\">"
610 "<a href=\"wiki?page=%s\">"
611 "<img src=\"static/newmess3_24x.gif\" "
612 "alt=\"\" width=\"24\" height=\"24\">"
613 "<span class=\"navbar_link\">"
615 "</span></a></li>\n", buf, _("Current version")
619 /* display a link to the history */
621 "<li class=\"newmess\">"
622 "<a href=\"wiki_history?page=%s\">"
623 "<img src=\"static/newmess3_24x.gif\" "
624 "alt=\"\" width=\"24\" height=\"24\">"
625 "<span class=\"navbar_link\">"
627 "</span></a></li>\n", buf, _("History")
633 "<li class=\"newmess\">"
634 "<a href=\"display_enter\">"
635 "<img src=\"static/newmess3_24x.gif\" "
636 "alt=\"\" width=\"24\" height=\"24\">"
637 "<span class=\"navbar_link\">"
639 "</span></a></li>\n", _("Write mail")
642 "<li class=\"newmess\">"
643 "<a href=\"javascript:deleteAllSelectedMessages();\">"
644 "<img src=\"static/delete.gif\" "
645 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
647 "</span></a></li>\n", _("Delete")
652 "<li class=\"newmess\">"
653 "<a href=\"display_enter\">"
654 "<img src=\"static/newmess3_24x.gif\" "
655 "alt=\"\" width=\"24\" height=\"24\">"
656 "<span class=\"navbar_link\">"
658 "</span></a></li>\n", _("Enter a message")
664 if (navbar_style == navbar_default) wc_printf(
665 "<li class=\"skipthisroom\">"
668 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
669 "width=\"24\" height=\"24\">"
670 "<span class=\"navbar_link\">%s</span></a>"
672 _("Leave all messages marked as unread, go to next room with unread messages"),
676 if (navbar_style == navbar_default) wc_printf(
677 "<li class=\"markngo\">"
678 "<a href=\"gotonext\" "
680 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
681 "width=\"24\" height=\"24\">"
682 "<span class=\"navbar_link\">%s</span></a>"
684 _("Mark all messages as read, go to next room with unread messages"),
688 wc_printf("</ul></div>\n");
695 * back end routine to take the session to a new room
697 long gotoroom(const StrBuf *gname)
701 static long ls = (-1L);
704 /* store ungoto information */
705 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
709 /* move to the new room */
710 serv_printf("GOTO %s", ChrPtr(gname));
711 StrBuf_ServGetln(Buf);
712 if (GetServerStatus(Buf, &err) != 2) {
713 serv_puts("GOTO _BASEROOM_");
714 StrBuf_ServGetln(Buf);
716 * well, we know that this is the fallback case,
717 * but we're interested that the first command
718 * didn't work out in first place.
720 if (GetServerStatus(Buf, NULL) != 2) {
725 ParseGoto(&WCC->CurRoom, Buf);
727 remove_march(WCC->CurRoom.name);
728 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
736 void ParseGoto(folder *room, StrBuf *Line)
744 if (StrLength(Line) < 4) {
748 /* ignore the commandstate... */
749 Pos = ChrPtr(Line) + 4;
751 if (room->RoomNameParts != NULL)
754 for (i=0; i < room->nRoomNameParts; i++)
755 FreeStrBuf(&room->RoomNameParts[i]);
756 free(room->RoomNameParts);
757 room->RoomNameParts = NULL;
762 pBuf = NewStrBufPlain(NULL, StrLength(Line));
765 memset(room, 0, sizeof(folder));
768 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
770 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
771 if (room->nNewMessages > 0)
772 room->RAFlags |= UA_HASNEWMSGS;
774 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
776 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
778 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
780 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
781 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
783 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
785 flag = StrBufExtractNext_long(Line, &Pos, '|');
786 if (WCC->is_aide || flag) {
787 room->RAFlags |= UA_ADMINALLOWED;
790 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
792 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
794 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
796 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
798 flag = StrBufExtractNext_long(Line, &Pos, '|');
800 room->RAFlags |= UA_ISTRASH; // wc_is_trash
802 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
804 /* find out, whether we are in a sub-room */
805 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
806 if (room->nRoomNameParts > 1)
811 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
812 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
813 for (i=0; i < room->nRoomNameParts; i++)
815 room->RoomNameParts[i] = NewStrBuf();
816 StrBufExtract_NextToken(room->RoomNameParts[i],
817 room->name, &Pos, '\\');
821 /* Private mailboxes on the main floor get remapped to the personal folder */
822 if ((room->QRFlags & QR_MAILBOX) &&
823 (room->floorid == 0))
825 room->floorid = VIRTUAL_MY_FLOOR;
826 if ((room->nRoomNameParts == 1) &&
827 (StrLength(room->name) == 4) &&
828 (strcmp(ChrPtr(room->name), "Mail") == 0))
834 /* get a pointer to the floor we're on: */
835 if (WCC->Floors == NULL)
836 GetFloorListHash(NULL, NULL);
838 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
839 room->Floor = (const Floor*) vFloor;
842 void LoadRoomAide(void)
847 if (WCC->CurRoom.RoomAideLoaded)
850 WCC->CurRoom.RoomAideLoaded = 1;
853 StrBuf_ServGetln(Buf);
854 if (GetServerStatus(Buf, NULL) != 2) {
855 FlushStrBuf(WCC->CurRoom.RoomAide);
856 AppendImportantMessage (ChrPtr(Buf) + 4,
861 Pos = ChrPtr(Buf) + 4;
863 FreeStrBuf(&WCC->CurRoom.RoomAide);
864 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
866 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
870 void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
873 folder *Folder = &WCC->CurRoom;
874 const Floor *pFloor = Folder->Floor;
879 StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
882 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
888 StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
892 void LoadRoomXA (void)
897 if (WCC->CurRoom.XALoaded)
900 WCC->CurRoom.XALoaded = 1;
903 StrBuf_ServGetln(Buf);
904 if (GetServerStatus(Buf, NULL) != 2) {
905 FlushStrBuf(WCC->CurRoom.XAPass);
906 FlushStrBuf(WCC->CurRoom.Directory);
908 AppendImportantMessage (ChrPtr(Buf) + 4,
913 Pos = ChrPtr(Buf) + 4;
915 FreeStrBuf(&WCC->CurRoom.XAPass);
916 FreeStrBuf(&WCC->CurRoom.Directory);
918 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
919 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
921 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
922 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
923 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
924 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
925 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
926 WCC->CurRoom.DefView = StrBufExtractNext_long(Buf, &Pos, '|');
927 /* QR2Flags, we already know them... */
934 void LoadXRoomPic(void)
939 if (WCC->CurRoom.XHaveRoomPicLoaded)
942 WCC->CurRoom.XHaveRoomPicLoaded = 1;
944 serv_puts("OIMG _roompic_");
945 StrBuf_ServGetln(Buf);
946 if (GetServerStatus(Buf, NULL) != 2) {
947 WCC->CurRoom.XHaveRoomPic = 0;
949 WCC->CurRoom.XHaveRoomPic = 1;
952 StrBuf_ServGetln(Buf);
953 GetServerStatus(Buf, NULL);
957 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
965 return WCC->CurRoom.XHaveRoomPic == 1;
968 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
974 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
976 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
982 StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
984 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
990 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
992 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
998 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.DefView);
1002 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
1004 wcsession *WCC = WC;
1012 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1013 return CheckThis == WCC->CurRoom.Order;
1016 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1018 wcsession *WCC = WC;
1026 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1027 return CheckThis == WCC->CurRoom.DefView;
1037 void smart_goto(const StrBuf *next_room) {
1038 gotoroom(next_room);
1039 readloop(readnew, eUseDefault);
1045 * mark all messages in current room as having been read
1047 void slrp_highest(void)
1051 serv_puts("SLRP HIGHEST");
1052 serv_getln(buf, sizeof buf);
1056 typedef struct __room_states {
1071 * Set/clear/read the "self-service list subscribe" flag for a room
1073 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1074 * returns the new value.
1077 int self_service(int newval) {
1078 int current_value = 0;
1084 int flags, floor, order, view, flags2;
1087 serv_getln(buf, sizeof buf);
1088 if (buf[0] != '2') return(0);
1090 extract_token(name, &buf[4], 0, '|', sizeof name);
1091 extract_token(password, &buf[4], 1, '|', sizeof password);
1092 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1093 flags = extract_int(&buf[4], 3);
1094 floor = extract_int(&buf[4], 4);
1095 order = extract_int(&buf[4], 5);
1096 view = extract_int(&buf[4], 6);
1097 flags2 = extract_int(&buf[4], 7);
1099 if (flags2 & QR2_SELFLIST) {
1107 flags2 = flags2 | QR2_SELFLIST;
1109 else if (newval == 0) {
1110 flags2 = flags2 & ~QR2_SELFLIST;
1113 return(current_value);
1116 if (newval != current_value) {
1117 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1118 name, password, dirname, flags,
1119 floor, order, view, flags2);
1120 serv_getln(buf, sizeof buf);
1127 int is_selflist(room_states *RoomFlags)
1129 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1132 int is_publiclist(room_states *RoomFlags)
1134 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1137 int is_moderatedlist(room_states *RoomFlags)
1139 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1143 * Set/clear/read the "self-service list subscribe" flag for a room
1145 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1146 * returns the new value.
1149 int get_roomflags(room_states *RoomOps)
1154 serv_getln(buf, sizeof buf);
1155 if (buf[0] != '2') return(0);
1157 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1158 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1159 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1160 RoomOps->flags = extract_int(&buf[4], 3);
1161 RoomOps->floor = extract_int(&buf[4], 4);
1162 RoomOps->order = extract_int(&buf[4], 5);
1163 RoomOps->view = extract_int(&buf[4], 6);
1164 RoomOps->flags2 = extract_int(&buf[4], 7);
1168 int set_roomflags(room_states *RoomOps)
1172 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1181 serv_getln(buf, sizeof buf);
1191 * display the form for editing a room
1193 void display_editroom(void)
1199 char remote_room[128];
1202 char er_password[10];
1203 char er_dirname[15];
1204 char er_roomaide[26];
1211 char *not_shared_with = NULL;
1214 int floorpolicy = 0;
1216 char pop3_host[128];
1221 if (IsEmptyStr(tab)) tab = "admin";
1224 load_floorlist(Buf);
1226 output_headers(1, 1, 1, 0, 0, 0);
1228 wc_printf("<div class=\"fix_scrollbar_bug\">");
1230 wc_printf("<br />\n");
1232 /* print the tabbed dialog */
1233 wc_printf("<div align=\"center\">");
1234 wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1235 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1238 wc_printf("<td class=\"");
1239 if (!strcmp(tab, "admin")) {
1240 wc_printf(" tab_cell_label\">");
1241 wc_printf(_("Administration"));
1244 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1245 wc_printf(_("Administration"));
1248 wc_printf("</td>\n");
1249 wc_printf("<td> </td>\n");
1251 if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1253 wc_printf("<td class=\"");
1254 if (!strcmp(tab, "config")) {
1255 wc_printf(" tab_cell_label\">");
1256 wc_printf(_("Configuration"));
1259 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1260 wc_printf(_("Configuration"));
1263 wc_printf("</td>\n");
1264 wc_printf("<td> </td>\n");
1266 wc_printf("<td class=\"");
1267 if (!strcmp(tab, "expire")) {
1268 wc_printf(" tab_cell_label\">");
1269 wc_printf(_("Message expire policy"));
1272 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1273 wc_printf(_("Message expire policy"));
1276 wc_printf("</td>\n");
1277 wc_printf("<td> </td>\n");
1279 wc_printf("<td class=\"");
1280 if (!strcmp(tab, "access")) {
1281 wc_printf(" tab_cell_label\">");
1282 wc_printf(_("Access controls"));
1285 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1286 wc_printf(_("Access controls"));
1289 wc_printf("</td>\n");
1290 wc_printf("<td> </td>\n");
1292 wc_printf("<td class=\"");
1293 if (!strcmp(tab, "sharing")) {
1294 wc_printf(" tab_cell_label\">");
1295 wc_printf(_("Sharing"));
1298 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1299 wc_printf(_("Sharing"));
1302 wc_printf("</td>\n");
1303 wc_printf("<td> </td>\n");
1305 wc_printf("<td class=\"");
1306 if (!strcmp(tab, "listserv")) {
1307 wc_printf(" tab_cell_label\">");
1308 wc_printf(_("Mailing list service"));
1311 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1312 wc_printf(_("Mailing list service"));
1315 wc_printf("</td>\n");
1316 wc_printf("<td> </td>\n");
1320 wc_printf("<td class=\"");
1321 if (!strcmp(tab, "feeds")) {
1322 wc_printf(" tab_cell_label\">");
1323 wc_printf(_("Remote retrieval"));
1326 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1327 wc_printf(_("Remote retrieval"));
1330 wc_printf("</td>\n");
1331 wc_printf("<td> </td>\n");
1333 wc_printf("</tr></table>\n");
1334 wc_printf("</div>\n");
1335 /* end tabbed dialog */
1337 wc_printf("<script type=\"text/javascript\">"
1338 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1342 /* begin content of whatever tab is open now */
1344 if (!strcmp(tab, "admin")) {
1345 wc_printf("<div class=\"tabcontent\">");
1347 "<li><a href=\"delete_room\" "
1348 "onClick=\"return confirm('");
1349 wc_printf(_("Are you sure you want to delete this room?"));
1350 wc_printf("');\">\n");
1351 wc_printf(_("Delete this room"));
1353 "<li><a href=\"display_editroompic?which_room=");
1354 urlescputs(ChrPtr(WC->CurRoom.name));
1356 wc_printf(_("Set or change the icon for this room's banner"));
1358 "<li><a href=\"display_editinfo\">\n");
1359 wc_printf(_("Edit this room's Info file"));
1362 wc_printf("</div>");
1365 if (!strcmp(tab, "config")) {
1366 wc_printf("<div class=\"tabcontent\">");
1368 serv_getln(buf, sizeof buf);
1370 if (!strncmp(buf, "550", 3)) {
1371 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1372 _("Higher access is required to access this function.")
1375 else if (buf[0] != '2') {
1376 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1379 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1380 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1381 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1382 er_flags = extract_int(&buf[4], 3);
1383 er_floor = extract_int(&buf[4], 4);
1384 er_flags2 = extract_int(&buf[4], 7);
1386 wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1387 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1389 wc_printf("<ul><li>");
1390 wc_printf(_("Name of room: "));
1391 wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1397 wc_printf(_("Resides on floor: "));
1398 wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1399 if (er_flags & QR_MAILBOX)
1400 wc_printf("disabled >\n");
1401 for (i = 0; i < 128; ++i)
1402 if (!IsEmptyStr(floorlist[i])) {
1403 wc_printf("<OPTION ");
1405 wc_printf("SELECTED ");
1406 wc_printf("VALUE=\"%d\">", i);
1407 escputs(floorlist[i]);
1408 wc_printf("</OPTION>\n");
1410 wc_printf("</select>\n");
1413 wc_printf(_("Type of room:"));
1414 wc_printf("<ul>\n");
1416 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1417 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1418 wc_printf("CHECKED ");
1419 wc_printf("OnChange=\""
1420 " if (this.form.type[0].checked == true) { "
1421 " this.form.er_floor.disabled = false; "
1424 wc_printf(_("Public (automatically appears to everyone)"));
1427 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1428 if ((er_flags & QR_PRIVATE) &&
1429 (er_flags & QR_GUESSNAME))
1430 wc_printf("CHECKED ");
1431 wc_printf(" OnChange=\""
1432 " if (this.form.type[1].checked == true) { "
1433 " this.form.er_floor.disabled = false; "
1436 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1438 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1439 if ((er_flags & QR_PRIVATE) &&
1440 (er_flags & QR_PASSWORDED))
1441 wc_printf("CHECKED ");
1442 wc_printf(" OnChange=\""
1443 " if (this.form.type[2].checked == true) { "
1444 " this.form.er_floor.disabled = false; "
1447 wc_printf(_("Private - require password: "));
1448 wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1451 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1452 if ((er_flags & QR_PRIVATE)
1453 && ((er_flags & QR_GUESSNAME) == 0)
1454 && ((er_flags & QR_PASSWORDED) == 0))
1455 wc_printf("CHECKED ");
1456 wc_printf(" OnChange=\""
1457 " if (this.form.type[3].checked == true) { "
1458 " this.form.er_floor.disabled = false; "
1461 wc_printf(_("Private - invitation only"));
1463 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1464 if (er_flags & QR_MAILBOX)
1465 wc_printf("CHECKED ");
1466 wc_printf (" OnChange=\""
1467 " if (this.form.type[4].checked == true) { "
1468 " this.form.er_floor.disabled = true; "
1471 wc_printf(_("Personal (mailbox for you only)"));
1473 wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1475 wc_printf(_("If private, cause current users to forget room"));
1477 wc_printf("\n</ul>\n");
1479 wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1480 if (er_flags & QR_PREFONLY)
1481 wc_printf("CHECKED ");
1483 wc_printf(_("Preferred users only"));
1485 wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1486 if (er_flags & QR_READONLY)
1487 wc_printf("CHECKED ");
1489 wc_printf(_("Read-only room"));
1491 wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1492 if (er_flags2 & QR2_COLLABDEL)
1493 wc_printf("CHECKED ");
1495 wc_printf(_("All users allowed to post may also delete messages"));
1497 /** directory stuff */
1498 wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1499 if (er_flags & QR_DIRECTORY)
1500 wc_printf("CHECKED ");
1502 wc_printf(_("File directory room"));
1504 wc_printf("\n<ul><li>");
1505 wc_printf(_("Directory name: "));
1506 wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1509 wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1510 if (er_flags & QR_UPLOAD)
1511 wc_printf("CHECKED ");
1513 wc_printf(_("Uploading allowed"));
1515 wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1516 if (er_flags & QR_DOWNLOAD)
1517 wc_printf("CHECKED ");
1519 wc_printf(_("Downloading allowed"));
1521 wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1522 if (er_flags & QR_VISDIR)
1523 wc_printf("CHECKED ");
1525 wc_printf(_("Visible directory"));
1526 wc_printf("</ul>\n");
1528 /** end of directory stuff */
1530 wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1531 if (er_flags & QR_NETWORK)
1532 wc_printf("CHECKED ");
1534 wc_printf(_("Network shared room"));
1536 wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1537 if (er_flags & QR_PERMANENT)
1538 wc_printf("CHECKED ");
1540 wc_printf(_("Permanent (does not auto-purge)"));
1542 wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1543 if (er_flags2 & QR2_SUBJECTREQ)
1544 wc_printf("CHECKED ");
1546 wc_printf(_("Subject Required (Force users to specify a message subject)"));
1548 /** start of anon options */
1550 wc_printf("\n<li>");
1551 wc_printf(_("Anonymous messages"));
1552 wc_printf("<ul>\n");
1554 wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1555 if (((er_flags & QR_ANONONLY) == 0)
1556 && ((er_flags & QR_ANONOPT) == 0))
1557 wc_printf("CHECKED ");
1559 wc_printf(_("No anonymous messages"));
1561 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1562 if (er_flags & QR_ANONONLY)
1563 wc_printf("CHECKED ");
1565 wc_printf(_("All messages are anonymous"));
1567 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1568 if (er_flags & QR_ANONOPT)
1569 wc_printf("CHECKED ");
1571 wc_printf(_("Prompt user when entering messages"));
1572 wc_printf("</ul>\n");
1574 /* end of anon options */
1577 wc_printf(_("Room aide: "));
1579 serv_getln(buf, sizeof buf);
1580 if (buf[0] != '2') {
1581 wc_printf("<em>%s</em>\n", &buf[4]);
1583 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1584 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1587 wc_printf("</ul><CENTER>\n");
1588 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1589 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1591 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1597 wc_printf("</div>");
1601 /* Sharing the room with other Citadel nodes... */
1602 if (!strcmp(tab, "sharing")) {
1603 wc_printf("<div class=\"tabcontent\">");
1605 shared_with = strdup("");
1606 not_shared_with = strdup("");
1608 /** Learn the current configuration */
1609 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1610 serv_getln(buf, sizeof buf);
1611 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1612 extract_token(node, buf, 0, '|', sizeof node);
1613 not_shared_with = realloc(not_shared_with,
1614 strlen(not_shared_with) + 32);
1615 strcat(not_shared_with, node);
1616 strcat(not_shared_with, "\n");
1620 serv_getln(buf, sizeof buf);
1621 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1622 extract_token(cmd, buf, 0, '|', sizeof cmd);
1623 extract_token(node, buf, 1, '|', sizeof node);
1624 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1625 if (!strcasecmp(cmd, "ignet_push_share")) {
1626 shared_with = realloc(shared_with,
1627 strlen(shared_with) + 32);
1628 strcat(shared_with, node);
1629 if (!IsEmptyStr(remote_room)) {
1630 strcat(shared_with, "|");
1631 strcat(shared_with, remote_room);
1633 strcat(shared_with, "\n");
1637 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1638 extract_token(buf, shared_with, i, '\n', sizeof buf);
1639 extract_token(node, buf, 0, '|', sizeof node);
1640 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1641 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1642 if (!strcasecmp(node, cmd)) {
1643 remove_token(not_shared_with, j, '\n');
1648 /* Display the stuff */
1649 wc_printf("<CENTER><br />"
1650 "<table border=1 cellpadding=5><tr>"
1652 wc_printf(_("Shared with"));
1653 wc_printf("</I></B></td>"
1655 wc_printf(_("Not shared with"));
1656 wc_printf("</I></B></td></tr>\n"
1657 "<tr><td VALIGN=TOP>\n");
1659 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1660 wc_printf(_("Remote node name"));
1661 wc_printf("</td><td>");
1662 wc_printf(_("Remote room name"));
1663 wc_printf("</td><td>");
1664 wc_printf(_("Actions"));
1665 wc_printf("</td></tr>\n");
1667 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1668 extract_token(buf, shared_with, i, '\n', sizeof buf);
1669 extract_token(node, buf, 0, '|', sizeof node);
1670 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1671 if (!IsEmptyStr(node)) {
1672 wc_printf("<form method=\"POST\" action=\"netedit\">");
1673 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1674 wc_printf("<tr><td>%s</td>\n", node);
1677 if (!IsEmptyStr(remote_room)) {
1678 escputs(remote_room);
1684 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1685 "VALUE=\"ignet_push_share|");
1687 if (!IsEmptyStr(remote_room)) {
1689 urlescputs(remote_room);
1692 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1693 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1694 wc_printf("<input type=\"submit\" "
1695 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1696 wc_printf("</td></tr></form>\n");
1700 wc_printf("</table>\n");
1701 wc_printf("</td><td VALIGN=TOP>\n");
1702 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1703 wc_printf(_("Remote node name"));
1704 wc_printf("</td><td>");
1705 wc_printf(_("Remote room name"));
1706 wc_printf("</td><td>");
1707 wc_printf(_("Actions"));
1708 wc_printf("</td></tr>\n");
1710 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1711 extract_token(node, not_shared_with, i, '\n', sizeof node);
1712 if (!IsEmptyStr(node)) {
1713 wc_printf("<form method=\"POST\" action=\"netedit\">");
1714 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1715 wc_printf("<tr><td>");
1717 wc_printf("</td><td>"
1718 "<input type=\"INPUT\" "
1722 wc_printf("<input type=\"hidden\" "
1724 "VALUE=\"ignet_push_share|");
1727 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1728 "VALUE=\"sharing\">\n");
1729 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1730 "VALUE=\"add\">\n");
1731 wc_printf("<input type=\"submit\" "
1732 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1733 wc_printf("</td></tr></form>\n");
1737 wc_printf("</table>\n");
1738 wc_printf("</td></tr>"
1739 "</table></CENTER><br />\n"
1740 "<I><B>%s</B><ul><li>", _("Notes:"));
1741 wc_printf(_("When sharing a room, "
1742 "it must be shared from both ends. Adding a node to "
1743 "the 'shared' list sends messages out, but in order to"
1744 " receive messages, the other nodes must be configured"
1745 " to send messages out to your system as well. "
1746 "<li>If the remote room name is blank, it is assumed "
1747 "that the room name is identical on the remote node."
1748 "<li>If the remote room name is different, the remote "
1749 "node must also configure the name of the room here."
1753 wc_printf("</div>");
1756 if (not_shared_with != NULL)
1757 free (not_shared_with);
1759 /* Mailing list management */
1760 if (!strcmp(tab, "listserv")) {
1761 room_states RoomFlags;
1762 wc_printf("<div class=\"tabcontent\">");
1764 wc_printf("<br /><center>"
1765 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1766 "<tr><td VALIGN=TOP>");
1768 wc_printf(_("<i>The contents of this room are being "
1769 "mailed <b>as individual messages</b> "
1770 "to the following list recipients:"
1771 "</i><br /><br />\n"));
1774 serv_getln(buf, sizeof buf);
1775 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1776 extract_token(cmd, buf, 0, '|', sizeof cmd);
1777 if (!strcasecmp(cmd, "listrecp")) {
1778 extract_token(recp, buf, 1, '|', sizeof recp);
1781 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1784 wc_printf(_("(remove)"));
1785 wc_printf("</A><br />");
1788 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1789 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1790 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1791 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1792 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1793 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1794 wc_printf("</form>\n");
1796 wc_printf("</td><td VALIGN=TOP>\n");
1798 wc_printf(_("<i>The contents of this room are being "
1799 "mailed <b>in digest form</b> "
1800 "to the following list recipients:"
1801 "</i><br /><br />\n"));
1804 serv_getln(buf, sizeof buf);
1805 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1806 extract_token(cmd, buf, 0, '|', sizeof cmd);
1807 if (!strcasecmp(cmd, "digestrecp")) {
1808 extract_token(recp, buf, 1, '|', sizeof recp);
1811 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1815 wc_printf(_("(remove)"));
1816 wc_printf("</A><br />");
1819 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1820 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1821 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1822 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1823 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1824 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1825 wc_printf("</form>\n");
1827 wc_printf("</td></tr></table>\n");
1829 /** Pop open an address book -- begin **/
1830 wc_printf("<div align=right>"
1831 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1833 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1838 _("Add recipients from Contacts or other address books"),
1839 _("Add recipients from Contacts or other address books")
1841 /* Pop open an address book -- end **/
1843 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1845 get_roomflags (&RoomFlags);
1847 /* Self Service subscription? */
1848 wc_printf("<table><tr><td>\n");
1849 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1850 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1851 " <tr><td colspan=\"2\">\n",
1852 (is_selflist(&RoomFlags))?"checked":"");
1853 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1854 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1855 (is_https ? "https" : "http"),
1856 ChrPtr(WC->Hdr->HR.http_host));
1857 /* Public posting? */
1858 wc_printf("<tr><td>");
1859 wc_printf(_("Allow non-subscribers to mail to this room."));
1860 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1861 (is_publiclist(&RoomFlags))?"checked":"");
1863 /* Moderated List? */
1864 wc_printf("<tr><td>");
1865 wc_printf(_("Room post publication needs Aide permission."));
1866 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1867 (is_moderatedlist(&RoomFlags))?"checked":"");
1870 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1871 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1872 wc_printf("</table></form>");
1875 wc_printf("</CENTER>\n");
1876 wc_printf("</div>");
1880 /* Configuration of The Dreaded Auto-Purger */
1881 if (!strcmp(tab, "expire")) {
1882 wc_printf("<div class=\"tabcontent\">");
1884 serv_puts("GPEX room");
1885 serv_getln(buf, sizeof buf);
1886 if (!strncmp(buf, "550", 3)) {
1887 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1888 _("Higher access is required to access this function.")
1891 else if (buf[0] != '2') {
1892 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1895 roompolicy = extract_int(&buf[4], 0);
1896 roomvalue = extract_int(&buf[4], 1);
1898 serv_puts("GPEX floor");
1899 serv_getln(buf, sizeof buf);
1900 if (buf[0] == '2') {
1901 floorpolicy = extract_int(&buf[4], 0);
1902 floorvalue = extract_int(&buf[4], 1);
1905 wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1906 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1907 wc_printf("<table border=0 cellspacing=5>\n");
1908 wc_printf("<tr><td>");
1909 wc_printf(_("Message expire policy for this room"));
1910 wc_printf("<br />(");
1911 escputs(ChrPtr(WC->CurRoom.name));
1912 wc_printf(")</td><td>");
1913 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1914 ((roompolicy == 0) ? "CHECKED" : "") );
1915 wc_printf(_("Use the default policy for this floor"));
1916 wc_printf("<br />\n");
1917 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1918 ((roompolicy == 1) ? "CHECKED" : "") );
1919 wc_printf(_("Never automatically expire messages"));
1920 wc_printf("<br />\n");
1921 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1922 ((roompolicy == 2) ? "CHECKED" : "") );
1923 wc_printf(_("Expire by message count"));
1924 wc_printf("<br />\n");
1925 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1926 ((roompolicy == 3) ? "CHECKED" : "") );
1927 wc_printf(_("Expire by message age"));
1928 wc_printf("<br />");
1929 wc_printf(_("Number of messages or days: "));
1930 wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1931 wc_printf("</td></tr>\n");
1933 if (WC->axlevel >= 6) {
1934 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1935 wc_printf("<tr><td>");
1936 wc_printf(_("Message expire policy for this floor"));
1937 wc_printf("<br />(");
1938 escputs(floorlist[WC->CurRoom.floorid]);
1939 wc_printf(")</td><td>");
1940 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1941 ((floorpolicy == 0) ? "CHECKED" : "") );
1942 wc_printf(_("Use the system default"));
1943 wc_printf("<br />\n");
1944 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1945 ((floorpolicy == 1) ? "CHECKED" : "") );
1946 wc_printf(_("Never automatically expire messages"));
1947 wc_printf("<br />\n");
1948 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1949 ((floorpolicy == 2) ? "CHECKED" : "") );
1950 wc_printf(_("Expire by message count"));
1951 wc_printf("<br />\n");
1952 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1953 ((floorpolicy == 3) ? "CHECKED" : "") );
1954 wc_printf(_("Expire by message age"));
1955 wc_printf("<br />");
1956 wc_printf(_("Number of messages or days: "));
1957 wc_printf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1961 wc_printf("<CENTER>\n");
1962 wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1963 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1964 wc_printf(" ");
1965 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1966 wc_printf("</CENTER></td><tr>\n");
1968 wc_printf("</table>\n"
1969 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1974 wc_printf("</div>");
1977 /* Access controls */
1978 if (!strcmp(tab, "access")) {
1979 wc_printf("<div class=\"tabcontent\">");
1981 wc_printf("</div>");
1984 /* Fetch messages from remote locations */
1985 if (!strcmp(tab, "feeds")) {
1986 wc_printf("<div class=\"tabcontent\">");
1989 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1990 wc_printf("</i><br />\n");
1992 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
1993 "<tr class=\"even\"><th>");
1994 wc_printf(_("Remote host"));
1995 wc_printf("</th><th>");
1996 wc_printf(_("User name"));
1997 wc_printf("</th><th>");
1998 wc_printf(_("Password"));
1999 wc_printf("</th><th>");
2000 wc_printf(_("Keep messages on server?"));
2001 wc_printf("</th><th>");
2002 wc_printf(_("Interval"));
2003 wc_printf("</th><th> </th></tr>");
2006 serv_getln(buf, sizeof buf);
2008 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2009 extract_token(cmd, buf, 0, '|', sizeof cmd);
2010 if (!strcasecmp(cmd, "pop3client")) {
2011 safestrncpy(recp, &buf[11], sizeof recp);
2014 wc_printf("<tr class=\"%s\">",
2015 (bg ? "even" : "odd")
2019 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2024 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2028 wc_printf("<td>*****</td>"); /* Don't show the password */
2030 wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2032 wc_printf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2034 wc_printf("<td class=\"button_link\">");
2035 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2038 wc_printf(_("(remove)"));
2039 wc_printf("</a></td>");
2045 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2047 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2048 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2049 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2051 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2054 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2057 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2060 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2063 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2066 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2067 wc_printf("</td></tr>");
2068 wc_printf("</form></table>\n");
2070 wc_printf("<hr>\n");
2073 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2074 wc_printf("</i><br />\n");
2076 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2077 "<tr class=\"even\"><th>");
2078 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2079 wc_printf(_("Feed URL"));
2080 wc_printf("</th><th>");
2081 wc_printf("</th></tr>");
2084 serv_getln(buf, sizeof buf);
2086 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2087 extract_token(cmd, buf, 0, '|', sizeof cmd);
2088 if (!strcasecmp(cmd, "rssclient")) {
2089 safestrncpy(recp, &buf[10], sizeof recp);
2092 wc_printf("<tr class=\"%s\">",
2093 (bg ? "even" : "odd")
2097 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2101 wc_printf("<td class=\"button_link\">");
2102 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2105 wc_printf(_("(remove)"));
2106 wc_printf("</a></td>");
2112 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2114 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2115 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2116 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2118 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2119 "maxlength=\"256\" name=\"line_pop3host\">\n");
2122 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2123 wc_printf("</td></tr>");
2124 wc_printf("</form></table>\n");
2126 wc_printf("</div>");
2130 /* end content of whatever tab is open now */
2131 wc_printf("</div>\n");
2133 address_book_popup();
2139 * Toggle self-service list subscription
2141 void toggle_self_service(void) {
2142 room_states RoomFlags;
2144 get_roomflags (&RoomFlags);
2146 if (yesbstr("QR2_SelfList"))
2147 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2149 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2151 if (yesbstr("QR2_SMTP_PUBLIC"))
2152 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2154 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2156 if (yesbstr("QR2_Moderated"))
2157 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2159 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2160 if (yesbstr("QR2_SubsOnly"))
2161 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2163 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2165 set_roomflags (&RoomFlags);
2173 * save new parameters for a room
2180 StrBuf *er_password;
2182 StrBuf *er_roomaide;
2185 int er_listingorder;
2191 if (!havebstr("ok_button")) {
2192 strcpy(WC->ImportantMessage,
2193 _("Cancelled. Changes were not saved."));
2199 StrBuf_ServGetln(Buf);
2200 if (GetServerStatus(Buf, NULL) != 2) {
2201 StrBufCutLeft(Buf, 4);
2202 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2208 er_name = NewStrBuf();
2209 er_password = NewStrBuf();
2210 er_dirname = NewStrBuf();
2211 er_roomaide = NewStrBuf();
2213 StrBufCutLeft(Buf, 4);
2214 StrBufExtract_token(er_name, Buf, 0, '|');
2215 StrBufExtract_token(er_password, Buf, 1, '|');
2216 StrBufExtract_token(er_dirname, Buf, 2, '|');
2217 er_flags = StrBufExtract_int(Buf, 3, '|');
2218 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2219 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2220 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2222 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2223 if (StrLength(er_roomaide) == 0) {
2225 StrBuf_ServGetln(Buf);
2226 if (GetServerStatus(Buf, NULL) != 2) {
2227 FlushStrBuf(er_roomaide);
2229 StrBufCutLeft(Buf, 4);
2230 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2233 Ptr = sbstr("er_name");
2234 if (StrLength(Ptr) > 0) {
2235 FlushStrBuf(er_name);
2236 StrBufAppendBuf(er_name, Ptr, 0);
2239 Ptr = sbstr("er_password");
2240 if (StrLength(Ptr) > 0) {
2241 FlushStrBuf(er_password);
2242 StrBufAppendBuf(er_password, Ptr, 0);
2246 Ptr = sbstr("er_dirname");
2247 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2248 FlushStrBuf(er_dirname);
2249 StrBufAppendBuf(er_dirname, Ptr, 0);
2253 Ptr = sbstr("type");
2254 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2256 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2257 er_flags |= (QR_PRIVATE);
2259 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2260 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2262 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2263 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2265 if (!strcmp(ChrPtr(Ptr), "personal")) {
2266 er_flags |= QR_MAILBOX;
2268 er_flags &= ~QR_MAILBOX;
2271 if (yesbstr("prefonly")) {
2272 er_flags |= QR_PREFONLY;
2274 er_flags &= ~QR_PREFONLY;
2277 if (yesbstr("readonly")) {
2278 er_flags |= QR_READONLY;
2280 er_flags &= ~QR_READONLY;
2284 if (yesbstr("collabdel")) {
2285 er_flags2 |= QR2_COLLABDEL;
2287 er_flags2 &= ~QR2_COLLABDEL;
2290 if (yesbstr("permanent")) {
2291 er_flags |= QR_PERMANENT;
2293 er_flags &= ~QR_PERMANENT;
2296 if (yesbstr("subjectreq")) {
2297 er_flags2 |= QR2_SUBJECTREQ;
2299 er_flags2 &= ~QR2_SUBJECTREQ;
2302 if (yesbstr("network")) {
2303 er_flags |= QR_NETWORK;
2305 er_flags &= ~QR_NETWORK;
2308 if (yesbstr("directory")) {
2309 er_flags |= QR_DIRECTORY;
2311 er_flags &= ~QR_DIRECTORY;
2314 if (yesbstr("ulallowed")) {
2315 er_flags |= QR_UPLOAD;
2317 er_flags &= ~QR_UPLOAD;
2320 if (yesbstr("dlallowed")) {
2321 er_flags |= QR_DOWNLOAD;
2323 er_flags &= ~QR_DOWNLOAD;
2326 if (yesbstr("visdir")) {
2327 er_flags |= QR_VISDIR;
2329 er_flags &= ~QR_VISDIR;
2332 Ptr = sbstr("anon");
2334 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2335 if (!strcmp(ChrPtr(Ptr), "anononly"))
2336 er_flags |= QR_ANONONLY;
2337 if (!strcmp(ChrPtr(Ptr), "anon2"))
2338 er_flags |= QR_ANONOPT;
2340 bump = yesbstr("bump");
2342 er_floor = ibstr("er_floor");
2344 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2346 ChrPtr(er_password),
2355 StrBuf_ServGetln(Buf);
2356 if (GetServerStatus(Buf, NULL) != 2) {
2357 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2360 FreeStrBuf(&er_name);
2361 FreeStrBuf(&er_password);
2362 FreeStrBuf(&er_dirname);
2363 FreeStrBuf(&er_roomaide);
2368 if (StrLength(er_roomaide) > 0) {
2369 serv_printf("SETA %s", ChrPtr(er_roomaide));
2370 StrBuf_ServGetln(Buf);
2371 if (GetServerStatus(Buf, NULL) != 2) {
2372 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2373 display_main_menu();
2375 FreeStrBuf(&er_name);
2376 FreeStrBuf(&er_password);
2377 FreeStrBuf(&er_dirname);
2378 FreeStrBuf(&er_roomaide);
2383 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2386 FreeStrBuf(&er_name);
2387 FreeStrBuf(&er_password);
2388 FreeStrBuf(&er_dirname);
2389 FreeStrBuf(&er_roomaide);
2395 * Display form for Invite, Kick, and show Who Knows a room
2397 void do_invt_kick(void) {
2398 char buf[SIZ], room[SIZ], username[SIZ];
2401 serv_getln(buf, sizeof buf);
2403 if (buf[0] != '2') {
2407 extract_token(room, &buf[4], 0, '|', sizeof room);
2409 strcpy(username, bstr("username"));
2411 if (havebstr("kick_button")) {
2412 sprintf(buf, "KICK %s", username);
2414 serv_getln(buf, sizeof buf);
2416 if (buf[0] != '2') {
2417 strcpy(WC->ImportantMessage, &buf[4]);
2419 sprintf(WC->ImportantMessage,
2420 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2425 if (havebstr("invite_button")) {
2426 sprintf(buf, "INVT %s", username);
2428 serv_getln(buf, sizeof buf);
2430 if (buf[0] != '2') {
2431 strcpy(WC->ImportantMessage, &buf[4]);
2433 sprintf(WC->ImportantMessage,
2434 _("<B><I>User %s invited to room %s.</I></B>\n"),
2445 * Display form for Invite, Kick, and show Who Knows a room
2447 void display_whok(void)
2449 char buf[SIZ], room[SIZ], username[SIZ];
2452 serv_getln(buf, sizeof buf);
2454 if (buf[0] != '2') {
2458 extract_token(room, &buf[4], 0, '|', sizeof room);
2461 wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2462 wc_printf(_("The users listed below have access to this room. "
2463 "To remove a user from the access list, select the user "
2464 "name from the list and click 'Kick'."));
2465 wc_printf("<br /><br />");
2467 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2468 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2469 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2470 wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2472 serv_getln(buf, sizeof buf);
2473 if (buf[0] == '1') {
2474 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2475 extract_token(username, buf, 0, '|', sizeof username);
2476 wc_printf("<OPTION>");
2481 wc_printf("</select><br />\n");
2483 wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2484 wc_printf("</form></CENTER>\n");
2486 wc_printf("</td><td>");
2487 wc_printf(_("To grant another user access to this room, enter the "
2488 "user name in the box below and click 'Invite'."));
2489 wc_printf("<br /><br />");
2491 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2492 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2493 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2494 wc_printf(_("Invite:"));
2496 wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2497 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2498 "<input type=\"submit\" value=\"%s\">"
2499 "</form></CENTER>\n", _("Invite"));
2500 /* Pop open an address book -- begin **/
2502 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2504 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2507 _("Users"), _("Users")
2509 /* Pop open an address book -- end **/
2511 wc_printf("</td></tr></table>\n");
2512 address_book_popup();
2519 * display the form for entering a new room
2521 void display_entroom(void)
2528 serv_puts("CRE8 0");
2529 serv_getln(buf, sizeof buf);
2531 if (buf[0] != '2') {
2532 strcpy(WC->ImportantMessage, &buf[4]);
2533 display_main_menu();
2538 output_headers(1, 1, 1, 0, 0, 0);
2540 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2541 do_template("beginbox", NULL);
2543 wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2544 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2546 wc_printf("<table class=\"altern\"> ");
2548 wc_printf("<tr class=\"even\"><td>");
2549 wc_printf(_("Name of room: "));
2550 wc_printf("</td><td>");
2551 wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2552 wc_printf("</td></tr>");
2554 wc_printf("<tr class=\"odd\"><td>");
2555 wc_printf(_("Resides on floor: "));
2556 wc_printf("</td><td>");
2557 load_floorlist(Buf);
2558 wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2559 for (i = 0; i < 128; ++i)
2560 if (!IsEmptyStr(floorlist[i])) {
2561 wc_printf("<option ");
2562 wc_printf("value=\"%d\">", i);
2563 escputs(floorlist[i]);
2564 wc_printf("</option>\n");
2566 wc_printf("</select>\n");
2567 wc_printf("</td></tr>");
2570 * Our clever little snippet of JavaScript automatically selects
2571 * a public room if the view is set to Bulletin Board or wiki, and
2572 * it selects a mailbox room otherwise. The user can override this,
2573 * of course. We also disable the floor selector for mailboxes.
2575 wc_printf("<tr class=\"even\"><td>");
2576 wc_printf(_("Default view for room: "));
2577 wc_printf("</td><td>");
2578 wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2579 " if ( (this.form.er_view.value == 0) "
2580 " || (this.form.er_view.value == 6) ) { "
2581 " this.form.type[0].checked=true; "
2582 " this.form.er_floor.disabled = false; "
2585 " this.form.type[4].checked=true; "
2586 " this.form.er_floor.disabled = true; "
2589 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2590 if (is_view_allowed_as_default(i)) {
2591 wc_printf("<option %s value=\"%d\">",
2592 ((i == 0) ? "selected" : ""), i );
2593 escputs(viewdefs[i]);
2594 wc_printf("</option>\n");
2597 wc_printf("</select>\n");
2598 wc_printf("</td></tr>");
2600 wc_printf("<tr class=\"even\"><td>");
2601 wc_printf(_("Type of room:"));
2602 wc_printf("</td><td>");
2603 wc_printf("<ul class=\"adminlist\">\n");
2605 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2606 wc_printf("CHECKED OnChange=\""
2607 " if (this.form.type[0].checked == true) { "
2608 " this.form.er_floor.disabled = false; "
2611 wc_printf(_("Public (automatically appears to everyone)"));
2614 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2615 " if (this.form.type[1].checked == true) { "
2616 " this.form.er_floor.disabled = false; "
2619 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2622 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2623 " if (this.form.type[2].checked == true) { "
2624 " this.form.er_floor.disabled = false; "
2627 wc_printf(_("Private - require password: "));
2628 wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2631 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2632 " if (this.form.type[3].checked == true) { "
2633 " this.form.er_floor.disabled = false; "
2636 wc_printf(_("Private - invitation only"));
2639 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2641 " if (this.form.type[4].checked == true) { "
2642 " this.form.er_floor.disabled = true; "
2645 wc_printf(_("Personal (mailbox for you only)"));
2648 wc_printf("\n</ul>\n");
2649 wc_printf("</td></tr></table>\n");
2651 wc_printf("<div class=\"buttons\">\n");
2652 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2653 wc_printf(" ");
2654 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2655 wc_printf("</div>\n");
2656 wc_printf("</form>\n<hr />");
2657 serv_printf("MESG roomaccess");
2658 serv_getln(buf, sizeof buf);
2659 if (buf[0] == '1') {
2663 do_template("endbox", NULL);
2673 * support function for entroom() -- sets the default view
2675 void er_set_default_view(int newview) {
2688 serv_getln(buf, sizeof buf);
2689 if (buf[0] != '2') return;
2691 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2692 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2693 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2694 rm_bits1 = extract_int(&buf[4], 3);
2695 rm_floor = extract_int(&buf[4], 4);
2696 rm_listorder = extract_int(&buf[4], 5);
2697 rm_bits2 = extract_int(&buf[4], 7);
2699 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2700 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2701 rm_listorder, newview, rm_bits2
2703 serv_getln(buf, sizeof buf);
2714 const StrBuf *er_name;
2715 const StrBuf *er_type;
2716 const StrBuf *er_password;
2720 wcsession *WCC = WC;
2722 if (!havebstr("ok_button")) {
2723 strcpy(WC->ImportantMessage,
2724 _("Cancelled. No new room was created."));
2725 display_main_menu();
2728 er_name = sbstr("er_name");
2729 er_type = sbstr("type");
2730 er_password = sbstr("er_password");
2731 er_floor = ibstr("er_floor");
2732 er_view = ibstr("er_view");
2735 if (!strcmp(ChrPtr(er_type), "hidden"))
2737 else if (!strcmp(ChrPtr(er_type), "passworded"))
2739 else if (!strcmp(ChrPtr(er_type), "invonly"))
2741 else if (!strcmp(ChrPtr(er_type), "personal"))
2744 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2747 ChrPtr(er_password),
2752 serv_getln(buf, sizeof buf);
2753 if (buf[0] != '2') {
2754 strcpy(WCC->ImportantMessage, &buf[4]);
2755 display_main_menu();
2758 /** TODO: Room created, now update the left hand icon bar for this user */
2759 burn_folder_cache(0); /* burn the old folder cache */
2763 serv_printf("VIEW %d", er_view);
2764 serv_getln(buf, sizeof buf);
2765 WCC->CurRoom.view = er_view;
2767 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
2768 display_editroom ();
2770 do_change_view(er_view); /* Now go there */
2777 * \brief display the screen to enter a private room
2779 void display_private(char *rname, int req_pass)
2781 WCTemplputParams SubTP;
2783 output_headers(1, 1, 1, 0, 0, 0);
2785 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2786 memset(&SubTP, 0, sizeof(WCTemplputParams));
2787 SubTP.Filter.ContextType = CTX_STRBUF;
2788 SubTP.Context = Buf;
2789 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2794 wc_printf(_("If you know the name of a hidden (guess-name) or "
2795 "passworded room, you can enter that room by typing "
2796 "its name below. Once you gain access to a private "
2797 "room, it will appear in your regular room listings "
2798 "so you don't have to keep returning here."));
2801 wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2802 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2804 wc_printf("<table class=\"altern\"> "
2805 "<tr class=\"even\"><td>");
2806 wc_printf(_("Enter room name:"));
2807 wc_printf("</td><td>"
2808 "<input type=\"text\" name=\"gr_name\" "
2809 "value=\"%s\" maxlength=\"128\">\n", rname);
2812 wc_printf("</td></tr><tr class=\"odd\"><td>");
2813 wc_printf(_("Enter room password:"));
2814 wc_printf("</td><td>");
2815 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2817 wc_printf("</td></tr></table>\n");
2819 wc_printf("<div class=\"buttons\">\n");
2820 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2822 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2826 wc_printf("</div></form>\n");
2828 do_template("endbox", NULL);
2834 * \brief goto a private room
2836 void goto_private(void)
2841 if (!havebstr("ok_button")) {
2842 display_main_menu();
2845 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2846 serv_printf("GOTO %s|%s",
2849 serv_getln(buf, sizeof buf);
2851 if (buf[0] == '2') {
2852 smart_goto(sbstr("gr_name"));
2855 if (!strncmp(buf, "540", 3)) {
2856 display_private(bstr("gr_name"), 1);
2859 output_headers(1, 1, 1, 0, 0, 0);
2860 wc_printf("%s\n", &buf[4]);
2867 * \brief display the screen to zap a room
2869 void display_zap(void)
2871 output_headers(1, 1, 2, 0, 0, 0);
2873 wc_printf("<div id=\"banner\">\n");
2875 wc_printf(_("Zap (forget/unsubscribe) the current room"));
2876 wc_printf("</h1>\n");
2877 wc_printf("</div>\n");
2879 wc_printf("<div id=\"content\" class=\"service\">\n");
2881 wc_printf(_("If you select this option, <em>%s</em> will "
2882 "disappear from your room list. Is this what you wish "
2883 "to do?<br />\n"), ChrPtr(WC->CurRoom.name));
2885 wc_printf("<form method=\"POST\" action=\"zap\">\n");
2886 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2887 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2888 wc_printf(" ");
2889 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2890 wc_printf("</form>\n");
2901 StrBuf *final_destination;
2904 * If the forget-room routine fails for any reason, we fall back
2905 * to the current room; otherwise, we go to the Lobby
2907 final_destination = NewStrBufDup(WC->CurRoom.name);
2909 if (havebstr("ok_button")) {
2910 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
2911 serv_getln(buf, sizeof buf);
2912 if (buf[0] == '2') {
2914 serv_getln(buf, sizeof buf);
2915 if (buf[0] == '2') {
2916 FlushStrBuf(final_destination);
2917 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2921 smart_goto(final_destination);
2922 FreeStrBuf(&final_destination);
2928 * \brief Delete the current room
2930 void delete_room(void)
2935 serv_puts("KILL 1");
2936 serv_getln(buf, sizeof buf);
2937 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2938 if (buf[0] != '2') {
2939 strcpy(WC->ImportantMessage, &buf[4]);
2940 display_main_menu();
2945 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2954 * \brief Perform changes to a room's network configuration
2956 void netedit(void) {
2965 /*/ TODO: do line dynamic! */
2966 if (havebstr("line_pop3host")) {
2967 strcpy(line, bstr("prefix"));
2968 strcat(line, bstr("line_pop3host"));
2970 strcat(line, bstr("line_pop3user"));
2972 strcat(line, bstr("line_pop3pass"));
2974 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2976 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2977 strcat(line, bstr("suffix"));
2979 else if (havebstr("line")) {
2980 strcpy(line, bstr("prefix"));
2981 strcat(line, bstr("line"));
2982 strcat(line, bstr("suffix"));
2997 serv_getln(buf, sizeof buf);
2998 if (buf[0] != '1') {
3004 /** This loop works for add *or* remove. Spiffy, eh? */
3005 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3006 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
3007 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
3008 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
3009 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
3010 if ( (strcasecmp(cmpa0, cmpb0))
3011 || (strcasecmp(cmpa1, cmpb1)) ) {
3012 fprintf(fp, "%s\n", buf);
3018 serv_getln(buf, sizeof buf);
3019 if (buf[0] != '4') {
3025 while (fgets(buf, sizeof buf, fp) != NULL) {
3026 buf[strlen(buf)-1] = 0;
3030 if (havebstr("add_button")) {
3031 num_addrs = num_tokens(bstr("line"), ',');
3032 if (num_addrs < 2) {
3033 /* just adding one node or address */
3037 /* adding multiple addresses separated by commas */
3038 for (i=0; i<num_addrs; ++i) {
3039 strcpy(line, bstr("prefix"));
3040 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3043 strcat(line, bstr("suffix"));
3057 * \brief Convert a room name to a folder-ish-looking name.
3058 * \param folder the folderish name
3059 * \param room the room name
3060 * \param floor the floor name
3061 * \param is_mailbox is it a mailbox?
3063 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3068 * For mailboxes, just do it straight...
3071 sprintf(folder, "My folders|%s", room);
3075 * Otherwise, prefix the floor name as a "public folders" moniker
3078 if (floor > MAX_FLOORS) {
3080 sprintf(folder, "%%%%%%|%s", room);
3083 sprintf(folder, "%s|%s", floorlist[floor], room);
3088 * Replace "\" characters with "|" for pseudo-folder-delimiting
3090 len = strlen (folder);
3091 for (i=0; i<len; ++i) {
3092 if (folder[i] == '\\') folder[i] = '|';
3100 * \brief Back end for change_view()
3101 * \param newview set newview???
3103 void do_change_view(int newview) {
3106 serv_printf("VIEW %d", newview);
3107 serv_getln(buf, sizeof buf);
3108 WC->CurRoom.view = newview;
3109 smart_goto(WC->CurRoom.name);
3115 * \brief Change the view for this room
3117 void change_view(void) {
3120 view = lbstr("view");
3121 do_change_view(view);
3125 * \brief Burn the cached folder list.
3126 * \param age How old the cahce needs to be before we burn it.
3129 void burn_folder_cache(time_t age)
3131 /** If our cached folder list is very old, burn it. */
3132 if (WC->cache_fold != NULL) {
3133 if ((time(NULL) - WC->cache_timestamp) > age) {
3134 free(WC->cache_fold);
3135 WC->cache_fold = NULL;
3143 * \brief Do either a known rooms list or a folders list, depending on the
3148 StrBuf *ListView = NULL;
3150 /** Determine whether the user is trying to change views */
3151 if (havebstr("view")) {
3152 ListView = NewStrBufDup(SBSTR("view"));
3153 set_preference("roomlistview", ListView, 1);
3155 /** Sanitize the input so its safe */
3156 if((get_preference("roomlistview", &ListView) != 0)||
3157 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3158 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3160 if (ListView == NULL) {
3161 ListView = NewStrBufPlain(HKEY("rooms"));
3162 set_preference("roomlistview", ListView, 0);
3166 ListView = NewStrBufPlain(HKEY("rooms"));
3167 set_preference("roomlistview", ListView, 0);
3171 FreeStrBuf(&ListView);
3178 * \brief Set the message expire policy for this room and/or floor
3180 void set_room_policy(void) {
3183 if (!havebstr("ok_button")) {
3184 strcpy(WC->ImportantMessage,
3185 _("Cancelled. Changes were not saved."));
3190 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3191 serv_getln(buf, sizeof buf);
3192 strcpy(WC->ImportantMessage, &buf[4]);
3194 if (WC->axlevel >= 6) {
3195 strcat(WC->ImportantMessage, "<br />\n");
3196 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3197 serv_getln(buf, sizeof buf);
3198 strcat(WC->ImportantMessage, &buf[4]);
3204 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3206 StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3210 void _display_private(void) {
3211 display_private("", 0);
3214 void dotgoto(void) {
3215 if (!havebstr("room")) {
3216 readloop(readnew, eUseDefault);
3219 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3222 smart_goto(sbstr("room"));
3227 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3229 wcsession *WCC = WC;
3232 StrBufAppendTemplate(Target, TP,
3237 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3239 wc_printf("<div id=\"banner\">\n");
3240 embed_room_banner(NULL, navbar_default);
3241 wc_printf("</div>\n");
3245 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3247 wcsession *WCC = WC;
3250 (!IsEmptyStr(WCC->ugname)))
3251 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3254 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3256 wcsession *WCC = WC;
3257 return (WCC != NULL)?
3258 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3261 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3263 wcsession *WCC = WC;
3264 return (WCC == NULL)? 0 :
3265 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3266 (WCC->CurRoom.is_inbox) ||
3267 (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3270 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3272 wcsession *WCC = WC;
3274 return ((WCC!=NULL) &&
3275 (!IsEmptyStr(WCC->ugname)) &&
3276 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3280 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
3282 folder *Folder = (folder *)(TP->Context);
3285 UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3286 if (UA_CheckFlag == 0)
3287 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3288 "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
3290 return ((Folder->RAFlags & UA_CheckFlag) != 0);
3295 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3298 wcsession *WCC = WC;
3300 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3301 if (QR_CheckFlag == 0)
3302 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3303 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3305 return ((WCC!=NULL) &&
3306 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3309 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3312 folder *Folder = (folder *)(TP->Context);
3314 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3315 if (QR_CheckFlag == 0)
3316 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3317 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3318 return ((Folder->QRFlags & QR_CheckFlag) != 0);
3322 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3325 wcsession *WCC = WC;
3327 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3328 if (QR2_CheckFlag == 0)
3329 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3330 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3332 return ((WCC!=NULL) &&
3333 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3336 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3339 folder *Folder = (folder *)(TP->Context);
3341 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3342 if (QR2_CheckFlag == 0)
3343 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3344 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3345 return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3349 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3351 wcsession *WCC = WC;
3353 return ( (WCC!= NULL) &&
3354 ((WCC->axlevel >= 6) ||
3355 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3356 (WCC->CurRoom.is_inbox) ));
3359 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3361 wcsession *WCC = WC;
3363 if ((WCC == NULL) ||
3364 (TP->Tokens->nParameters < 3))
3366 return ((WCC->CurRoom.view < VIEW_BBS) ||
3367 (WCC->CurRoom.view > VIEW_MAX));
3370 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3374 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
3376 wcsession *WCC = WC;
3380 HashList *Whok = NULL;
3386 Token = NewStrBuf();
3387 StrBuf_ServGetln(Line);
3388 if (GetServerStatus(Line, &State) == 1)
3390 Whok = NewHash(1, Flathash);
3391 while(!Done && StrBuf_ServGetln(Line))
3392 if ( (StrLength(Line)==3) &&
3393 !strcmp(ChrPtr(Line), "000"))
3400 const char *Pos = NULL;
3401 Token = NewStrBufPlain (NULL, StrLength(Line));
3402 StrBufExtract_NextToken(Token, Line, &Pos, '|');
3410 else if (State == 550)
3411 StrBufAppendBufPlain(WCC->ImportantMsg,
3412 _("Higher access is required to access this function."), -1, 0);
3422 initialize_viewdefs();
3423 RegisterPreference("roomlistview",
3424 _("Room list view"),
3427 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3429 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3432 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3433 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3434 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3435 WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3436 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3437 WebcitAddUrlHandler(HKEY("zapped_list"), "", 0, zapped_list, 0);
3438 WebcitAddUrlHandler(HKEY("display_zap"), "", 0, display_zap, 0);
3439 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3440 WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3441 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3442 WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3443 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3444 WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3445 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3446 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3447 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3448 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3449 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3450 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3451 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3453 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3454 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3455 RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3457 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3458 RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3459 RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
3461 RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
3462 RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
3463 RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3464 RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3465 RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3466 RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3467 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3468 RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3469 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3470 RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
3472 REGISTERTokenParamDefine(QR_PERMANENT);
3473 REGISTERTokenParamDefine(QR_INUSE);
3474 REGISTERTokenParamDefine(QR_PRIVATE);
3475 REGISTERTokenParamDefine(QR_PASSWORDED);
3476 REGISTERTokenParamDefine(QR_GUESSNAME);
3477 REGISTERTokenParamDefine(QR_DIRECTORY);
3478 REGISTERTokenParamDefine(QR_UPLOAD);
3479 REGISTERTokenParamDefine(QR_DOWNLOAD);
3480 REGISTERTokenParamDefine(QR_VISDIR);
3481 REGISTERTokenParamDefine(QR_ANONONLY);
3482 REGISTERTokenParamDefine(QR_ANONOPT);
3483 REGISTERTokenParamDefine(QR_NETWORK);
3484 REGISTERTokenParamDefine(QR_PREFONLY);
3485 REGISTERTokenParamDefine(QR_READONLY);
3486 REGISTERTokenParamDefine(QR_MAILBOX);
3487 REGISTERTokenParamDefine(QR2_SYSTEM);
3488 REGISTERTokenParamDefine(QR2_SELFLIST);
3489 REGISTERTokenParamDefine(QR2_COLLABDEL);
3490 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3491 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3492 REGISTERTokenParamDefine(QR2_MODERATED);
3494 REGISTERTokenParamDefine(UA_KNOWN);
3495 REGISTERTokenParamDefine(UA_GOTOALLOWED);
3496 REGISTERTokenParamDefine(UA_HASNEWMSGS);
3497 REGISTERTokenParamDefine(UA_ZAPPED);
3498 REGISTERTokenParamDefine(UA_POSTALLOWED);
3499 REGISTERTokenParamDefine(UA_ADMINALLOWED);
3500 REGISTERTokenParamDefine(UA_DELETEALLOWED);
3501 REGISTERTokenParamDefine(UA_ISTRASH);
3503 REGISTERTokenParamDefine(US_NEEDVALID);
3504 REGISTERTokenParamDefine(US_PERM);
3505 REGISTERTokenParamDefine(US_LASTOLD);
3506 REGISTERTokenParamDefine(US_EXPERT);
3507 REGISTERTokenParamDefine(US_UNLISTED);
3508 REGISTERTokenParamDefine(US_NOPROMPT);
3509 REGISTERTokenParamDefine(US_PROMPTCTL);
3510 REGISTERTokenParamDefine(US_DISAPPEAR);
3511 REGISTERTokenParamDefine(US_REGIS);
3512 REGISTERTokenParamDefine(US_PAGINATOR);
3513 REGISTERTokenParamDefine(US_INTERNET);
3514 REGISTERTokenParamDefine(US_FLOORS);
3515 REGISTERTokenParamDefine(US_COLOR);
3516 REGISTERTokenParamDefine(US_USER_SET);
3518 REGISTERTokenParamDefine(VIEW_BBS);
3519 REGISTERTokenParamDefine(VIEW_MAILBOX);
3520 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3521 REGISTERTokenParamDefine(VIEW_CALENDAR);
3522 REGISTERTokenParamDefine(VIEW_TASKS);
3523 REGISTERTokenParamDefine(VIEW_NOTES);
3524 REGISTERTokenParamDefine(VIEW_WIKI);
3525 REGISTERTokenParamDefine(VIEW_CALBRIEF);
3526 REGISTERTokenParamDefine(VIEW_JOURNAL);
3527 REGISTERTokenParamDefine(VIEW_BLOG);
3530 REGISTERTokenParamDefine(ignet_push_share);
3531 { /* these are the parts of an IGNET push config */
3532 REGISTERTokenParamDefine(GNET_IGNET_NODE);
3533 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
3535 REGISTERTokenParamDefine(listrecp);
3536 REGISTERTokenParamDefine(digestrecp);
3537 REGISTERTokenParamDefine(pop3client);
3538 { /* These are the parts of a pop3 client line... */
3539 REGISTERTokenParamDefine(GNET_POP3_HOST);
3540 REGISTERTokenParamDefine(GNET_POP3_USER);
3541 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
3542 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
3544 REGISTERTokenParamDefine(rssclient);
3545 REGISTERTokenParamDefine(participate);
3547 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3548 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3550 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3551 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3553 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3554 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3555 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3562 SessionDestroyModule_ROOMOPS
3565 FlushFolder(&sess->CurRoom);
3566 if (sess->cache_fold != NULL) {
3567 free(sess->cache_fold);
3570 free_march_list(sess);
3571 DeleteHash(&sess->Floors);
3572 DeleteHash(&sess->Rooms);
3573 DeleteHash(&sess->FloorsByName);