4 * Lots of different room-related operations.
9 char floorlist[128][SIZ];
13 void initialize_viewdefs(void) {
14 viewdefs[0] = _("Bulletin Board");
15 viewdefs[1] = _("Mail Folder");
16 viewdefs[2] = _("Address Book");
17 viewdefs[3] = _("Calendar");
18 viewdefs[4] = _("Task List");
19 viewdefs[5] = _("Notes List");
24 * load the list of floors
26 void load_floorlist(void)
31 for (a = 0; a < 128; ++a)
35 serv_getln(buf, sizeof buf);
37 strcpy(floorlist[0], "Main Floor");
40 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
41 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
47 * remove a room from the march list
49 void remove_march(char *aaa)
51 struct march *mptr, *mptr2;
53 if (WC->march == NULL)
56 if (!strcasecmp(WC->march->march_name, aaa)) {
57 mptr = WC->march->next;
63 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
64 if (!strcasecmp(mptr->march_name, aaa)) {
65 mptr2->next = mptr->next;
78 void room_tree_list(struct roomlisting *rp)
87 room_tree_list(rp->lnext);
89 strcpy(rmname, rp->rlname);
92 wprintf("<a href=\"dotgoto&room=");
96 escputs1(rmname, 1, 1);
97 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
99 else if (f & QR_DIRECTORY)
101 else if (f & QR_NETWORK)
105 wprintf("</A><TT> </TT>\n");
107 room_tree_list(rp->rnext);
113 * Room ordering stuff (compare first by floor, then by order)
115 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
117 if ((r1 == NULL) && (r2 == NULL))
123 if (r1->rlfloor < r2->rlfloor)
125 if (r1->rlfloor > r2->rlfloor)
127 if (r1->rlorder < r2->rlorder)
129 if (r1->rlorder > r2->rlorder)
136 * Common code for all room listings
138 void listrms(char *variety)
143 struct roomlisting *rl = NULL;
144 struct roomlisting *rp;
145 struct roomlisting *rs;
148 /* Ask the server for a room list */
150 serv_getln(buf, sizeof buf);
155 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
157 rp = malloc(sizeof(struct roomlisting));
158 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
159 rp->rlflags = extract_int(buf, 1);
160 rp->rlfloor = extract_int(buf, 2);
161 rp->rlorder = extract_int(buf, 3);
170 if (rordercmp(rp, rs) < 0) {
171 if (rs->lnext == NULL) {
178 if (rs->rnext == NULL) {
190 /* If no rooms were listed, print an nbsp to make the cell
191 * borders show up anyway.
193 if (num_rooms == 0) wprintf(" ");
198 * list all forgotten rooms
200 void zapped_list(void)
202 output_headers(1, 1, 0, 0, 0, 0);
204 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
205 do_template("beginbox");
209 wprintf("<br /><br />\n");
210 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
211 do_template("endbox");
217 * read this room's info file (set v to 1 for verbose mode)
224 serv_getln(buf, sizeof buf);
233 /* Display room banner icon. The server doesn't actually
234 * need the room name, but we supply it in order to
235 * keep the browser from using a cached icon from
238 void embed_room_graphic(void) {
241 serv_puts("OIMG _roompic_");
242 serv_getln(buf, sizeof buf);
244 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
245 urlescputs(WC->wc_roomname);
248 serv_getln(buf, sizeof buf);
250 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
251 wprintf("<img height=48 width=48 src=\""
252 "static/viewcontacts_48x.gif"
256 else if (WC->wc_view == VIEW_CALENDAR) {
257 wprintf("<img height=48 width=48 src=\""
258 "static/calarea_48x.gif"
262 else if (WC->wc_view == VIEW_TASKS) {
263 wprintf("<img height=48 width=48 src=\""
264 "static/taskmanag_48x.gif"
268 else if (WC->wc_view == VIEW_NOTES) {
269 wprintf("<img height=48 width=48 src=\""
270 "static/storenotes_48x.gif"
274 else if (WC->wc_view == VIEW_MAILBOX) {
275 wprintf("<img height=48 width=48 src=\""
276 "static/privatemess_48x.gif"
281 wprintf("<img height=48 width=48 src=\""
282 "static/chatrooms_48x.gif"
292 * Display the current view and offer an option to change it
294 void embed_view_o_matic(void) {
297 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
298 "<span class=\"room_banner_new_messages\">");
299 wprintf(_("View as:"));
301 "<SELECT NAME=\"newview\" SIZE=\"1\" "
302 "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif;"
303 " font-size: 7pt; background: #444455; color: #ddddcc;\" "
304 "OnChange=\"location.href=viewomatic.newview.options"
305 "[selectedIndex].value\">\n");
307 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
309 * Only offer the views that make sense, given the default
310 * view for the room. For example, don't offer a Calendar
311 * view in a non-Calendar room.
315 || (i == WC->wc_default_view)
316 || ( (i == 0) && (WC->wc_default_view == 1) )
317 || ( (i == 1) && (WC->wc_default_view == 0) )
320 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
321 ((i == WC->wc_view) ? "SELECTED" : ""),
323 escputs(viewdefs[i]);
324 wprintf("</OPTION>\n");
327 wprintf("</select></span></form>\n");
332 void embed_room_banner(char *got, int navbar_style) {
335 /* We need to have the information returned by a GOTO server command.
336 * If it isn't supplied, we fake it by issuing our own GOTO.
339 serv_printf("GOTO %s", WC->wc_roomname);
340 serv_getln(fakegot, sizeof fakegot);
344 /* If the user happens to select the "make this my start page" link,
345 * we want it to remember the URL as a "/dotskip" one instead of
346 * a "skip" or "gotonext" or something like that.
348 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
351 /* Check for new mail. */
352 WC->new_mail = extract_int(&got[4], 9);
353 WC->wc_view = extract_int(&got[4], 11);
355 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
356 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
357 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
358 svcallback("ROOMPIC", embed_room_graphic);
359 svcallback("ROOMINFO", readinfo);
360 svcallback("VIEWOMATIC", embed_view_o_matic);
361 svcallback("START", offer_start_page);
363 do_template("roombanner");
364 if (navbar_style != navbar_none) {
366 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
367 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
370 if (navbar_style == navbar_default) wprintf(
372 "<a href=\"ungoto\">"
373 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
374 "<span class=\"navbar_link\">%s</span></A>"
375 "</td>\n", _("Ungoto")
378 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
381 "<a href=\"readnew\">"
382 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
383 "<span class=\"navbar_link\">%s</span></A>"
384 "</td>\n", _("Read new messages")
388 if (navbar_style == navbar_default) {
389 switch(WC->wc_view) {
390 case VIEW_ADDRESSBOOK:
393 "<a href=\"readfwd\">"
394 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
396 "<span class=\"navbar_link\">"
398 "</span></a></td>\n", _("View contacts")
404 "<a href=\"readfwd?calview=day\">"
405 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
407 "<span class=\"navbar_link\">"
409 "</span></a></td>\n", _("Day view")
413 "<a href=\"readfwd?calview=month\">"
414 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
416 "<span class=\"navbar_link\">"
418 "</span></a></td>\n", _("Month view")
424 "<a href=\"readfwd\">"
425 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
427 "<span class=\"navbar_link\">"
429 "</span></a></td>\n", _("View tasks")
435 "<a href=\"readfwd\">"
436 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
438 "<span class=\"navbar_link\">"
440 "</span></a></td>\n", _("View notes")
446 "<a href=\"readfwd\">"
447 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
449 "<span class=\"navbar_link\">"
451 "</span></a></td>\n", _("View message list")
457 "<a href=\"readfwd\">"
458 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
460 "<span class=\"navbar_link\">"
462 "</span></a></td>\n", _("Read all messages")
468 if (navbar_style == navbar_default) {
469 switch(WC->wc_view) {
470 case VIEW_ADDRESSBOOK:
472 "<td><a href=\"display_enter\">"
473 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
474 "border=\"0\"><span class=\"navbar_link\">"
476 "</span></a></td>\n", _("Add new contact")
481 "<td><a href=\"display_enter\">"
482 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
483 "border=\"0\"><span class=\"navbar_link\">"
485 "</span></a></td>\n", _("Add new event")
490 "<td><a href=\"display_enter\">"
491 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
492 "border=\"0\"><span class=\"navbar_link\">"
494 "</span></a></td>\n", _("Add new task")
499 "<td><a href=\"display_enter\">"
500 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
501 "border=\"0\"><span class=\"navbar_link\">"
503 "</span></a></td>\n", _("Add new note")
508 "<td><a href=\"display_enter\">"
509 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
510 "border=\"0\"><span class=\"navbar_link\">"
512 "</span></a></td>\n", _("Enter a message")
518 if (navbar_style == navbar_default) wprintf(
522 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
523 "<span class=\"navbar_link\">%s</span></a>"
525 _("Leave all messages marked as unread, go to next room with unread messages"),
529 if (navbar_style == navbar_default) wprintf(
531 "<a href=\"gotonext\" "
533 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
534 "<span class=\"navbar_link\">%s</span></a>"
536 _("Mark all messages as read, go to next room with unread messages"),
540 wprintf("</tr></table></div>\n");
550 * back end routine to take the session to a new room
553 int gotoroom(char *gname)
556 static long ls = (-1L);
559 /* store ungoto information */
560 strcpy(WC->ugname, WC->wc_roomname);
563 /* move to the new room */
564 serv_printf("GOTO %s", gname);
565 serv_getln(buf, sizeof buf);
569 serv_puts("GOTO _BASEROOM_");
570 serv_getln(buf, sizeof buf);
577 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
578 WC->room_flags = extract_int(&buf[4], 4);
579 /* highest_msg_read = extract_int(&buf[4],6);
580 maxmsgnum = extract_int(&buf[4],5);
582 WC->is_mailbox = extract_int(&buf[4],7);
583 ls = extract_long(&buf[4], 6);
584 WC->wc_floor = extract_int(&buf[4], 10);
585 WC->wc_view = extract_int(&buf[4], 11);
586 WC->wc_default_view = extract_int(&buf[4], 12);
589 WC->is_room_aide = WC->is_aide;
591 WC->is_room_aide = (char) extract_int(&buf[4], 8);
593 remove_march(WC->wc_roomname);
594 if (!strcasecmp(gname, "_BASEROOM_"))
602 * Locate the room on the march list which we most want to go to. Each room
603 * is measured given a "weight" of preference based on various factors.
605 char *pop_march(int desired_floor)
607 static char TheRoom[128];
609 int TheOrder = 32767;
612 struct march *mptr = NULL;
614 strcpy(TheRoom, "_BASEROOM_");
615 if (WC->march == NULL)
618 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
620 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
621 weight = weight + 10000;
622 if (mptr->march_floor == desired_floor)
623 weight = weight + 5000;
625 weight = weight + ((128 - (mptr->march_floor)) * 128);
626 weight = weight + (128 - (mptr->march_order));
628 if (weight > TheWeight) {
630 strcpy(TheRoom, mptr->march_name);
631 TheFloor = mptr->march_floor;
632 TheOrder = mptr->march_order;
640 /* Goto next room having unread messages.
641 * We want to skip over rooms that the user has already been to, and take the
642 * user back to the lobby when done. The room we end up in is placed in
643 * newroom - which is set to 0 (the lobby) initially.
644 * We start the search in the current room rather than the beginning to prevent
645 * two or more concurrent users from dragging each other back to the same room.
650 struct march *mptr, *mptr2;
653 /* First check to see if the march-mode list is already allocated.
654 * If it is, pop the first room off the list and go there.
657 if (WC->march == NULL) {
659 serv_getln(buf, sizeof buf);
661 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
662 mptr = (struct march *) malloc(sizeof(struct march));
664 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
665 mptr->march_floor = extract_int(buf, 2);
666 mptr->march_order = extract_int(buf, 3);
667 if (WC->march == NULL) {
671 while (mptr2->next != NULL)
676 /* add _BASEROOM_ to the end of the march list, so the user will end up
677 * in the system base room (usually the Lobby>) at the end of the loop
679 mptr = (struct march *) malloc(sizeof(struct march));
681 strcpy(mptr->march_name, "_BASEROOM_");
682 if (WC->march == NULL) {
686 while (mptr2->next != NULL)
691 * ...and remove the room we're currently in, so a <G>oto doesn't make us
692 * walk around in circles
694 remove_march(WC->wc_roomname);
696 if (WC->march != NULL) {
697 strcpy(next_room, pop_march(-1));
699 strcpy(next_room, "_BASEROOM_");
703 smart_goto(next_room);
707 void smart_goto(char *next_room) {
715 * mark all messages in current room as having been read
717 void slrp_highest(void)
722 serv_puts("SLRP HIGHEST");
723 serv_getln(buf, sizeof buf);
725 wprintf("<EM>%s</EM><br />\n", &buf[4]);
732 * un-goto the previous room
738 if (!strcmp(WC->ugname, "")) {
739 smart_goto(WC->wc_roomname);
742 serv_printf("GOTO %s", WC->ugname);
743 serv_getln(buf, sizeof buf);
745 smart_goto(WC->wc_roomname);
748 if (WC->uglsn >= 0L) {
749 serv_printf("SLRP %ld", WC->uglsn);
750 serv_getln(buf, sizeof buf);
752 strcpy(buf, WC->ugname);
753 strcpy(WC->ugname, "");
762 * Set/clear/read the "self-service list subscribe" flag for a room
764 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
765 * Always returns the new value.
768 int self_service(int newval) {
769 int current_value = 0;
775 int flags, floor, order, view, flags2;
778 serv_getln(buf, sizeof buf);
779 if (buf[0] != '2') return(0);
781 extract_token(name, &buf[4], 0, '|', sizeof name);
782 extract_token(password, &buf[4], 1, '|', sizeof password);
783 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
784 flags = extract_int(&buf[4], 3);
785 floor = extract_int(&buf[4], 4);
786 order = extract_int(&buf[4], 5);
787 view = extract_int(&buf[4], 6);
788 flags2 = extract_int(&buf[4], 7);
790 if (flags2 & QR2_SELFLIST) {
798 flags2 = flags2 | QR2_SELFLIST;
800 else if (newval == 0) {
801 flags2 = flags2 & ~QR2_SELFLIST;
804 return(current_value);
807 if (newval != current_value) {
808 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
809 name, password, dirname, flags,
810 floor, order, view, flags2);
811 serv_getln(buf, sizeof buf);
824 * display the form for editing a room
826 void display_editroom(void)
831 char remote_room[SIZ];
834 char er_password[10];
836 char er_roomaide[26];
842 char *not_shared_with;
849 if (strlen(tab) == 0) tab = "admin";
853 serv_getln(buf, sizeof buf);
856 strcpy(WC->ImportantMessage, &buf[4]);
860 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
861 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
862 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
863 er_flags = extract_int(&buf[4], 3);
864 er_floor = extract_int(&buf[4], 4);
866 output_headers(1, 1, 1, 0, 0, 0);
868 /* print the tabbed dialog */
870 "<div id=\"fix_scrollbar_bug\">"
871 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
873 "<TD> </TD>\n");
875 if (!strcmp(tab, "admin")) {
876 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
879 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
881 wprintf(_("Administration"));
882 if (!strcmp(tab, "admin")) {
883 wprintf("</SPAN></TD>\n");
886 wprintf("</A></TD>\n");
889 wprintf("<TD> </TD>\n");
891 if (!strcmp(tab, "config")) {
892 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
895 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
897 wprintf(_("Configuration"));
898 if (!strcmp(tab, "config")) {
899 wprintf("</SPAN></TD>\n");
902 wprintf("</A></TD>\n");
905 wprintf("<TD> </TD>\n");
907 if (!strcmp(tab, "expire")) {
908 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
911 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
913 wprintf(_("Message expire policy"));
914 if (!strcmp(tab, "expire")) {
915 wprintf("</SPAN></TD>\n");
918 wprintf("</A></TD>\n");
921 wprintf("<TD> </TD>\n");
923 if (!strcmp(tab, "access")) {
924 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
927 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
929 wprintf(_("Access controls"));
930 if (!strcmp(tab, "access")) {
931 wprintf("</SPAN></TD>\n");
934 wprintf("</A></TD>\n");
937 wprintf("<TD> </TD>\n");
939 if (!strcmp(tab, "sharing")) {
940 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
943 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
945 wprintf(_("Sharing"));
946 if (!strcmp(tab, "sharing")) {
947 wprintf("</SPAN></TD>\n");
950 wprintf("</A></TD>\n");
953 wprintf("<TD> </TD>\n");
955 if (!strcmp(tab, "listserv")) {
956 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
959 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
961 wprintf(_("Mailing list service"));
962 if (!strcmp(tab, "listserv")) {
963 wprintf("</SPAN></TD>\n");
966 wprintf("</A></TD>\n");
969 wprintf("<TD> </TD>\n");
971 wprintf("</TR></TABLE></div>\n");
972 /* end tabbed dialog */
974 /* begin content of whatever tab is open now */
975 wprintf("<div id=\"fix_scrollbar_bug\">"
976 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
979 if (!strcmp(tab, "admin")) {
981 "<LI><a href=\"delete_room\" "
982 "onClick=\"return confirm('");
983 wprintf(_("Are you sure you want to delete this room?"));
985 wprintf(_("Delete this room"));
987 "<LI><a href=\"display_editroompic\">\n");
988 wprintf(_("Set or change the icon for this room's banner"));
990 "<LI><a href=\"display_editinfo\">\n");
991 wprintf(_("Edit this room's Info file"));
996 if (!strcmp(tab, "config")) {
997 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1000 wprintf(_("Name of room: "));
1001 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1007 wprintf(_("Resides on floor: "));
1008 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1009 for (i = 0; i < 128; ++i)
1010 if (strlen(floorlist[i]) > 0) {
1011 wprintf("<OPTION ");
1013 wprintf("SELECTED ");
1014 wprintf("VALUE=\"%d\">", i);
1015 escputs(floorlist[i]);
1016 wprintf("</OPTION>\n");
1018 wprintf("</SELECT>\n");
1021 wprintf(_("Type of room:"));
1024 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1025 if ((er_flags & QR_PRIVATE) == 0)
1026 wprintf("CHECKED ");
1028 wprintf(_("Public room"));
1031 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1032 if ((er_flags & QR_PRIVATE) &&
1033 (er_flags & QR_GUESSNAME))
1034 wprintf("CHECKED ");
1036 wprintf(_("Private - guess name"));
1038 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1039 if ((er_flags & QR_PRIVATE) &&
1040 (er_flags & QR_PASSWORDED))
1041 wprintf("CHECKED ");
1043 wprintf(_("Private - require password:"));
1044 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1047 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1048 if ((er_flags & QR_PRIVATE)
1049 && ((er_flags & QR_GUESSNAME) == 0)
1050 && ((er_flags & QR_PASSWORDED) == 0))
1051 wprintf("CHECKED ");
1053 wprintf(_("Private - invitation only"));
1055 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1057 wprintf(_("If private, cause current users to forget room"));
1059 wprintf("\n</UL>\n");
1061 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1062 if (er_flags & QR_PREFONLY)
1063 wprintf("CHECKED ");
1065 wprintf(_("Preferred users only"));
1067 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1068 if (er_flags & QR_READONLY)
1069 wprintf("CHECKED ");
1071 wprintf(_("Read-only room"));
1073 /* directory stuff */
1074 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1075 if (er_flags & QR_DIRECTORY)
1076 wprintf("CHECKED ");
1078 wprintf(_("File directory room"));
1080 wprintf("\n<UL><LI>");
1081 wprintf(_("Directory name: "));
1082 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1085 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1086 if (er_flags & QR_UPLOAD)
1087 wprintf("CHECKED ");
1089 wprintf(_("Uploading allowed"));
1091 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1092 if (er_flags & QR_DOWNLOAD)
1093 wprintf("CHECKED ");
1095 wprintf(_("Downloading allowed"));
1097 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1098 if (er_flags & QR_VISDIR)
1099 wprintf("CHECKED ");
1101 wprintf(_("Visible directory"));
1104 /* end of directory stuff */
1106 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1107 if (er_flags & QR_NETWORK)
1108 wprintf("CHECKED ");
1110 wprintf(_("Network shared room"));
1112 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1113 if (er_flags & QR_PERMANENT)
1114 wprintf("CHECKED ");
1116 wprintf(_("Permanent (does not auto-purge)"));
1118 /* start of anon options */
1121 wprintf(_("Anonymous messages"));
1124 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1125 if (((er_flags & QR_ANONONLY) == 0)
1126 && ((er_flags & QR_ANONOPT) == 0))
1127 wprintf("CHECKED ");
1129 wprintf(_("No anonymous messages"));
1131 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1132 if (er_flags & QR_ANONONLY)
1133 wprintf("CHECKED ");
1135 wprintf(_("All messages are anonymous"));
1137 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1138 if (er_flags & QR_ANONOPT)
1139 wprintf("CHECKED ");
1141 wprintf(_("Prompt user when entering messages"));
1144 /* end of anon options */
1147 wprintf(_("Room aide: "));
1149 serv_getln(buf, sizeof buf);
1150 if (buf[0] != '2') {
1151 wprintf("<EM>%s</EM>\n", &buf[4]);
1153 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1154 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1157 wprintf("</UL><CENTER>\n");
1158 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1159 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1161 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1169 /* Sharing the room with other Citadel nodes... */
1170 if (!strcmp(tab, "sharing")) {
1172 shared_with = strdup("");
1173 not_shared_with = strdup("");
1175 /* Learn the current configuration */
1176 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1177 serv_getln(buf, sizeof buf);
1178 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1179 extract_token(node, buf, 0, '|', sizeof node);
1180 not_shared_with = realloc(not_shared_with,
1181 strlen(not_shared_with) + 32);
1182 strcat(not_shared_with, node);
1183 strcat(not_shared_with, "\n");
1187 serv_getln(buf, sizeof buf);
1188 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1189 extract_token(cmd, buf, 0, '|', sizeof cmd);
1190 extract_token(node, buf, 1, '|', sizeof node);
1191 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1192 if (!strcasecmp(cmd, "ignet_push_share")) {
1193 shared_with = realloc(shared_with,
1194 strlen(shared_with) + 32);
1195 strcat(shared_with, node);
1196 if (strlen(remote_room) > 0) {
1197 strcat(shared_with, "|");
1198 strcat(shared_with, remote_room);
1200 strcat(shared_with, "\n");
1204 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1205 extract_token(buf, shared_with, i, '\n', sizeof buf);
1206 extract_token(node, buf, 0, '|', sizeof node);
1207 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1208 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1209 if (!strcasecmp(node, cmd)) {
1210 remove_token(not_shared_with, j, '\n');
1215 /* Display the stuff */
1216 wprintf("<CENTER><br />"
1217 "<TABLE border=1 cellpadding=5><TR>"
1219 wprintf(_("Shared with"));
1220 wprintf("</I></B></TD>"
1222 wprintf(_("Not shared with"));
1223 wprintf("</I></B></TD></TR>\n"
1224 "<TR><TD VALIGN=TOP>\n");
1226 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1227 wprintf(_("Remote node name"));
1228 wprintf("</TD><TD>");
1229 wprintf(_("Remote room name"));
1230 wprintf("</TD><TD>");
1231 wprintf(_("Actions"));
1232 wprintf("</TD></TR>\n");
1234 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1235 extract_token(buf, shared_with, i, '\n', sizeof buf);
1236 extract_token(node, buf, 0, '|', sizeof node);
1237 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1238 if (strlen(node) > 0) {
1239 wprintf("<FORM METHOD=\"POST\" "
1240 "action=\"netedit\">"
1241 "<TR><TD>%s</TD>\n", node);
1244 if (strlen(remote_room) > 0) {
1245 escputs(remote_room);
1251 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1252 "VALUE=\"ignet_push_share|");
1254 if (strlen(remote_room) > 0) {
1256 urlescputs(remote_room);
1259 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1260 "VALUE=\"sharing\">\n");
1261 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1262 "VALUE=\"remove\">\n");
1263 wprintf("<INPUT TYPE=\"submit\" "
1264 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1265 wprintf("</TD></TR></FORM>\n");
1269 wprintf("</TABLE>\n");
1270 wprintf("</TD><TD VALIGN=TOP>\n");
1271 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1272 wprintf(_("Remote node name"));
1273 wprintf("</TD><TD>");
1274 wprintf(_("Remote room name"));
1275 wprintf("</TD><TD>");
1276 wprintf(_("Actions"));
1277 wprintf("</TD></TR>\n");
1279 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1280 extract_token(node, not_shared_with, i, '\n', sizeof node);
1281 if (strlen(node) > 0) {
1282 wprintf("<FORM METHOD=\"POST\" "
1283 "action=\"netedit\">"
1287 "<INPUT TYPE=\"INPUT\" "
1291 wprintf("<INPUT TYPE=\"hidden\" "
1293 "VALUE=\"ignet_push_share|");
1296 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1297 "VALUE=\"sharing\">\n");
1298 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1299 "VALUE=\"add\">\n");
1300 wprintf("<INPUT TYPE=\"submit\" "
1301 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1302 wprintf("</TD></TR></FORM>\n");
1306 wprintf("</TABLE>\n");
1307 wprintf("</TD></TR>"
1308 "</TABLE></CENTER><br />\n"
1309 "<I><B>%s</B><UL><LI>", _("Notes:"));
1310 wprintf(_("When sharing a room, "
1311 "it must be shared from both ends. Adding a node to "
1312 "the 'shared' list sends messages out, but in order to"
1313 " receive messages, the other nodes must be configured"
1314 " to send messages out to your system as well. "
1315 "<LI>If the remote room name is blank, it is assumed "
1316 "that the room name is identical on the remote node."
1317 "<LI>If the remote room name is different, the remote "
1318 "node must also configure the name of the room here."
1324 /* Mailing list management */
1325 if (!strcmp(tab, "listserv")) {
1327 wprintf("<br /><center>"
1328 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1329 "<TR><TD VALIGN=TOP>");
1331 wprintf(_("<i>The contents of this room are being "
1332 "mailed <b>as individual messages</b> "
1333 "to the following list recipients:"
1334 "</i><br /><br />\n"));
1337 serv_getln(buf, sizeof buf);
1338 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1339 extract_token(cmd, buf, 0, '|', sizeof cmd);
1340 if (!strcasecmp(cmd, "listrecp")) {
1341 extract_token(recp, buf, 1, '|', sizeof recp);
1344 wprintf(" <a href=\"netedit&cmd=remove&line="
1347 wprintf("&tab=listserv\">");
1348 wprintf(_("(remove)"));
1349 wprintf("</A><br />");
1352 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1353 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1354 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1355 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1356 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1357 wprintf("</FORM>\n");
1359 wprintf("</TD><TD VALIGN=TOP>\n");
1361 wprintf(_("<i>The contents of this room are being "
1362 "mailed <b>in digest form</b> "
1363 "to the following list recipients:"
1364 "</i><br /><br />\n"));
1367 serv_getln(buf, sizeof buf);
1368 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1369 extract_token(cmd, buf, 0, '|', sizeof cmd);
1370 if (!strcasecmp(cmd, "digestrecp")) {
1371 extract_token(recp, buf, 1, '|', sizeof recp);
1374 wprintf(" <a href=\"netedit&cmd=remove&line="
1377 wprintf("&tab=listserv\">");
1378 wprintf(_("(remove)"));
1379 wprintf("</A><br />");
1382 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1383 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1384 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1385 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1386 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1387 wprintf("</FORM>\n");
1389 wprintf("</TD></TR></TABLE><hr />\n");
1391 if (self_service(999) == 1) {
1392 wprintf(_("This room is configured to allow "
1393 "self-service subscribe/unsubscribe requests."));
1394 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1395 wprintf(_("Click to disable."));
1396 wprintf("</A><br />\n");
1397 wprintf(_("The URL for subscribe/unsubscribe is: "));
1398 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1399 (is_https ? "https" : "http"),
1403 wprintf(_("This room is <i>not</i> configured to allow "
1404 "self-service subscribe/unsubscribe requests."));
1405 wprintf(" <a href=\"toggle_self_service?newval=1&"
1407 wprintf(_("Click to enable."));
1408 wprintf("</A><br />\n");
1412 wprintf("</CENTER>\n");
1416 /* Mailing list management */
1417 if (!strcmp(tab, "expire")) {
1419 serv_puts("GPEX room");
1420 serv_getln(buf, sizeof buf);
1421 if (buf[0] == '2') {
1422 roompolicy = extract_int(&buf[4], 0);
1423 roomvalue = extract_int(&buf[4], 1);
1426 serv_puts("GPEX floor");
1427 serv_getln(buf, sizeof buf);
1428 if (buf[0] == '2') {
1429 floorpolicy = extract_int(&buf[4], 0);
1430 floorvalue = extract_int(&buf[4], 1);
1433 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1434 wprintf("<TABLE border=0 cellspacing=5>\n");
1435 wprintf("<TR><TD>");
1436 wprintf(_("Message expire policy for this room"));
1438 escputs(WC->wc_roomname);
1439 wprintf(")</TD><TD>");
1440 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1441 ((roompolicy == 0) ? "CHECKED" : "") );
1442 wprintf(_("Use the default policy for this floor"));
1443 wprintf("<br />\n");
1444 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1445 ((roompolicy == 1) ? "CHECKED" : "") );
1446 wprintf(_("Never automatically expire messages"));
1447 wprintf("<br />\n");
1448 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1449 ((roompolicy == 2) ? "CHECKED" : "") );
1450 wprintf(_("Expire by message count"));
1451 wprintf("<br />\n");
1452 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1453 ((roompolicy == 3) ? "CHECKED" : "") );
1454 wprintf(_("Expire by message age"));
1456 wprintf(_("Number of messages or days: "));
1457 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1458 wprintf("</TD></TR>\n");
1460 if (WC->axlevel >= 6) {
1461 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1462 wprintf("<TR><TD>");
1463 wprintf(_("Message expire policy for this floor"));
1465 escputs(floorlist[WC->wc_floor]);
1466 wprintf(")</TD><TD>");
1467 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1468 ((floorpolicy == 0) ? "CHECKED" : "") );
1469 wprintf(_("Use the system default"));
1470 wprintf("<br />\n");
1471 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1472 ((floorpolicy == 1) ? "CHECKED" : "") );
1473 wprintf(_("Never automatically expire messages"));
1474 wprintf("<br />\n");
1475 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1476 ((floorpolicy == 2) ? "CHECKED" : "") );
1477 wprintf(_("Expire by message count"));
1478 wprintf("<br />\n");
1479 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1480 ((floorpolicy == 3) ? "CHECKED" : "") );
1481 wprintf(_("Expire by message age"));
1483 wprintf(_("Number of messages or days: "));
1484 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1488 wprintf("<CENTER>\n");
1489 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1490 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1492 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1493 wprintf("</CENTER></TD><TR>\n");
1495 wprintf("</TABLE>\n"
1496 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1502 /* Mailing list management */
1503 if (!strcmp(tab, "access")) {
1507 /* end content of whatever tab is open now */
1508 wprintf("</TD></TR></TABLE></div>\n");
1515 * Toggle self-service list subscription
1517 void toggle_self_service(void) {
1520 newval = atoi(bstr("newval"));
1521 self_service(newval);
1528 * save new parameters for a room
1534 char er_password[10];
1535 char er_dirname[15];
1536 char er_roomaide[26];
1542 if (strlen(bstr("ok_button")) == 0) {
1543 strcpy(WC->ImportantMessage,
1544 _("Cancelled. Changes were not saved."));
1549 serv_getln(buf, sizeof buf);
1551 if (buf[0] != '2') {
1552 strcpy(WC->ImportantMessage, &buf[4]);
1556 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1557 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1558 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1559 er_flags = extract_int(&buf[4], 3);
1561 strcpy(er_roomaide, bstr("er_roomaide"));
1562 if (strlen(er_roomaide) == 0) {
1564 serv_getln(buf, sizeof buf);
1565 if (buf[0] != '2') {
1566 strcpy(er_roomaide, "");
1568 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1571 strcpy(buf, bstr("er_name"));
1573 if (strlen(buf) > 0) {
1574 strcpy(er_name, buf);
1577 strcpy(buf, bstr("er_password"));
1579 if (strlen(buf) > 0)
1580 strcpy(er_password, buf);
1582 strcpy(buf, bstr("er_dirname"));
1584 if (strlen(buf) > 0)
1585 strcpy(er_dirname, buf);
1587 strcpy(buf, bstr("type"));
1588 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1590 if (!strcmp(buf, "invonly")) {
1591 er_flags |= (QR_PRIVATE);
1593 if (!strcmp(buf, "hidden")) {
1594 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1596 if (!strcmp(buf, "passworded")) {
1597 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1599 if (!strcmp(bstr("prefonly"), "yes")) {
1600 er_flags |= QR_PREFONLY;
1602 er_flags &= ~QR_PREFONLY;
1605 if (!strcmp(bstr("readonly"), "yes")) {
1606 er_flags |= QR_READONLY;
1608 er_flags &= ~QR_READONLY;
1611 if (!strcmp(bstr("permanent"), "yes")) {
1612 er_flags |= QR_PERMANENT;
1614 er_flags &= ~QR_PERMANENT;
1617 if (!strcmp(bstr("network"), "yes")) {
1618 er_flags |= QR_NETWORK;
1620 er_flags &= ~QR_NETWORK;
1623 if (!strcmp(bstr("directory"), "yes")) {
1624 er_flags |= QR_DIRECTORY;
1626 er_flags &= ~QR_DIRECTORY;
1629 if (!strcmp(bstr("ulallowed"), "yes")) {
1630 er_flags |= QR_UPLOAD;
1632 er_flags &= ~QR_UPLOAD;
1635 if (!strcmp(bstr("dlallowed"), "yes")) {
1636 er_flags |= QR_DOWNLOAD;
1638 er_flags &= ~QR_DOWNLOAD;
1641 if (!strcmp(bstr("visdir"), "yes")) {
1642 er_flags |= QR_VISDIR;
1644 er_flags &= ~QR_VISDIR;
1647 strcpy(buf, bstr("anon"));
1649 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1650 if (!strcmp(buf, "anononly"))
1651 er_flags |= QR_ANONONLY;
1652 if (!strcmp(buf, "anon2"))
1653 er_flags |= QR_ANONOPT;
1656 if (!strcmp(bstr("bump"), "yes"))
1659 er_floor = atoi(bstr("er_floor"));
1661 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1662 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1664 serv_getln(buf, sizeof buf);
1665 if (buf[0] != '2') {
1666 strcpy(WC->ImportantMessage, &buf[4]);
1672 if (strlen(er_roomaide) > 0) {
1673 sprintf(buf, "SETA %s", er_roomaide);
1675 serv_getln(buf, sizeof buf);
1676 if (buf[0] != '2') {
1677 strcpy(WC->ImportantMessage, &buf[4]);
1678 display_main_menu();
1683 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1690 * Display form for Invite, Kick, and show Who Knows a room
1692 void do_invt_kick(void) {
1693 char buf[SIZ], room[SIZ], username[SIZ];
1696 serv_getln(buf, sizeof buf);
1698 if (buf[0] != '2') {
1702 extract_token(room, &buf[4], 0, '|', sizeof room);
1704 strcpy(username, bstr("username"));
1706 if (strlen(bstr("kick_button")) > 0) {
1707 sprintf(buf, "KICK %s", username);
1709 serv_getln(buf, sizeof buf);
1711 if (buf[0] != '2') {
1712 strcpy(WC->ImportantMessage, &buf[4]);
1714 sprintf(WC->ImportantMessage,
1715 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1720 if (strlen(bstr("invite_button")) > 0) {
1721 sprintf(buf, "INVT %s", username);
1723 serv_getln(buf, sizeof buf);
1725 if (buf[0] != '2') {
1726 strcpy(WC->ImportantMessage, &buf[4]);
1728 sprintf(WC->ImportantMessage,
1729 _("<B><I>User %s invited to room %s.</I></B>\n"),
1740 * Display form for Invite, Kick, and show Who Knows a room
1742 void display_whok(void)
1744 char buf[SIZ], room[SIZ], username[SIZ];
1747 serv_getln(buf, sizeof buf);
1749 if (buf[0] != '2') {
1753 extract_token(room, &buf[4], 0, '|', sizeof room);
1756 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1757 wprintf(_("The users listed below have access to this room. "
1758 "To remove a user from the access list, select the user "
1759 "name from the list and click 'Kick'."));
1760 wprintf("<br /><br />");
1762 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1763 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1764 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1766 serv_getln(buf, sizeof buf);
1767 if (buf[0] == '1') {
1768 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1769 extract_token(username, buf, 0, '|', sizeof username);
1770 wprintf("<OPTION>");
1775 wprintf("</SELECT><br />\n");
1777 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1778 wprintf("</FORM></CENTER>\n");
1780 wprintf("</TD><TD>");
1781 wprintf(_("To grant another user access to this room, enter the "
1782 "user name in the box below and click 'Invite'."));
1783 wprintf("<br /><br />");
1785 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1786 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1787 wprintf(_("Invite:"));
1789 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1790 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1791 "<input type=\"submit\" value=\"%s\">"
1792 "</FORM></CENTER>\n", _("Invite"));
1794 wprintf("</TD></TR></TABLE>\n");
1801 * display the form for entering a new room
1803 void display_entroom(void)
1808 serv_puts("CRE8 0");
1809 serv_getln(buf, sizeof buf);
1811 if (buf[0] != '2') {
1812 strcpy(WC->ImportantMessage, &buf[4]);
1813 display_main_menu();
1817 output_headers(1, 1, 2, 0, 0, 0);
1818 wprintf("<div id=\"banner\">\n"
1819 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1820 "<SPAN CLASS=\"titlebar\">");
1821 wprintf(_("Create a new room"));
1823 "</TD></TR></TABLE>\n"
1824 "</div>\n<div id=\"content\">\n"
1827 wprintf("<div id=\"fix_scrollbar_bug\">"
1828 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1830 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1832 wprintf("<UL><LI>");
1833 wprintf(_("Name of room: "));
1834 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1837 wprintf(_("Resides on floor: "));
1839 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1840 for (i = 0; i < 128; ++i)
1841 if (strlen(floorlist[i]) > 0) {
1842 wprintf("<OPTION ");
1843 wprintf("VALUE=\"%d\">", i);
1844 escputs(floorlist[i]);
1845 wprintf("</OPTION>\n");
1847 wprintf("</SELECT>\n");
1849 /* Our clever little snippet of JavaScript automatically selects
1850 * a public room if the view is set to Bulletin Board, and it
1851 * selects a mailbox room otherwise. The user can override this,
1855 wprintf(_("Default view for room: "));
1856 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1857 " if (this.form.er_view.value == 0) { "
1858 " this.form.type[0].checked=true; "
1859 " this.form.er_floor.disabled = false; "
1862 " this.form.type[4].checked=true; "
1863 " this.form.er_floor.disabled = true; "
1866 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1867 wprintf("<OPTION %s VALUE=\"%d\">",
1868 ((i == 0) ? "SELECTED" : ""), i );
1869 escputs(viewdefs[i]);
1870 wprintf("</OPTION>\n");
1872 wprintf("</SELECT>\n");
1875 wprintf(_("Type of room:"));
1878 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1879 wprintf("CHECKED OnChange=\""
1880 " if (this.form.type[0].checked == true) { "
1881 " this.form.er_floor.disabled = false; "
1884 wprintf(_("Public (automatically appears to everyone)"));
1886 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1887 " if (this.form.type[1].checked == true) { "
1888 " this.form.er_floor.disabled = false; "
1891 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1893 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1894 " if (this.form.type[2].checked == true) { "
1895 " this.form.er_floor.disabled = false; "
1898 wprintf(_("Private - require password: "));
1899 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1901 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1902 " if (this.form.type[3].checked == true) { "
1903 " this.form.er_floor.disabled = false; "
1906 wprintf(_("Private - invitation only"));
1908 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1910 " if (this.form.type[4].checked == true) { "
1911 " this.form.er_floor.disabled = true; "
1914 wprintf(_("Personal (mailbox for you only)"));
1916 wprintf("\n</UL>\n");
1918 wprintf("<CENTER>\n");
1919 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1921 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1922 wprintf("</CENTER>\n");
1923 wprintf("</FORM>\n<hr />");
1924 serv_printf("MESG roomaccess");
1925 serv_getln(buf, sizeof buf);
1926 if (buf[0] == '1') {
1929 wprintf("</td></tr></table></div>\n");
1937 * support function for entroom() -- sets the default view
1939 void er_set_default_view(int newview) {
1952 serv_getln(buf, sizeof buf);
1953 if (buf[0] != '2') return;
1955 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
1956 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
1957 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
1958 rm_bits1 = extract_int(&buf[4], 3);
1959 rm_floor = extract_int(&buf[4], 4);
1960 rm_listorder = extract_int(&buf[4], 5);
1961 rm_bits2 = extract_int(&buf[4], 7);
1963 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1964 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1965 rm_listorder, newview, rm_bits2
1967 serv_getln(buf, sizeof buf);
1980 char er_password[SIZ];
1985 if (strlen(bstr("ok_button")) == 0) {
1986 strcpy(WC->ImportantMessage,
1987 _("Cancelled. No new room was created."));
1988 display_main_menu();
1991 strcpy(er_name, bstr("er_name"));
1992 strcpy(er_type, bstr("type"));
1993 strcpy(er_password, bstr("er_password"));
1994 er_floor = atoi(bstr("er_floor"));
1995 er_view = atoi(bstr("er_view"));
1998 if (!strcmp(er_type, "hidden"))
2000 if (!strcmp(er_type, "passworded"))
2002 if (!strcmp(er_type, "invonly"))
2004 if (!strcmp(er_type, "personal"))
2007 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2008 er_name, er_num_type, er_password, er_floor, 0, er_view);
2010 serv_getln(buf, sizeof buf);
2011 if (buf[0] != '2') {
2012 strcpy(WC->ImportantMessage, &buf[4]);
2013 display_main_menu();
2017 do_change_view(er_view); /* Now go there */
2022 * display the screen to enter a private room
2024 void display_private(char *rname, int req_pass)
2026 output_headers(1, 1, 2, 0, 0, 0);
2027 wprintf("<div id=\"banner\">\n"
2028 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2029 "<SPAN CLASS=\"titlebar\">");
2030 wprintf(_("Go to a hidden room"));
2032 "</TD></TR></TABLE>\n"
2033 "</div>\n<div id=\"content\">\n"
2036 wprintf("<div id=\"fix_scrollbar_bug\">"
2037 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2039 wprintf("<CENTER>\n");
2041 wprintf(_("If you know the name of a hidden (guess-name) or "
2042 "passworded room, you can enter that room by typing "
2043 "its name below. Once you gain access to a private "
2044 "room, it will appear in your regular room listings "
2045 "so you don't have to keep returning here."));
2046 wprintf("\n<br /><br />");
2048 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2050 wprintf("<table border=\"0\" cellspacing=\"5\" "
2051 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2053 wprintf(_("Enter room name:"));
2055 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2056 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2059 wprintf("</TD></TR><TR><TD>");
2060 wprintf(_("Enter room password:"));
2061 wprintf("</TD><TD>");
2062 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2064 wprintf("</TD></TR></TABLE><br />\n");
2066 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2068 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2072 wprintf("</FORM>\n");
2073 wprintf("</td></tr></table></div>\n");
2078 * goto a private room
2080 void goto_private(void)
2085 if (strlen(bstr("ok_button")) == 0) {
2086 display_main_menu();
2089 strcpy(hold_rm, WC->wc_roomname);
2090 strcpy(buf, "GOTO ");
2091 strcat(buf, bstr("gr_name"));
2093 strcat(buf, bstr("gr_pass"));
2095 serv_getln(buf, sizeof buf);
2097 if (buf[0] == '2') {
2098 smart_goto(bstr("gr_name"));
2101 if (!strncmp(buf, "540", 3)) {
2102 display_private(bstr("gr_name"), 1);
2105 output_headers(1, 1, 1, 0, 0, 0);
2106 wprintf("%s\n", &buf[4]);
2113 * display the screen to zap a room
2115 void display_zap(void)
2117 output_headers(1, 1, 2, 0, 0, 0);
2119 wprintf("<div id=\"banner\">\n");
2120 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2121 wprintf("<SPAN CLASS=\"titlebar\">");
2122 wprintf(_("Zap (forget/unsubscribe) the current room"));
2123 wprintf("</SPAN>\n");
2124 wprintf("</TD></TR></TABLE>\n");
2125 wprintf("</div>\n<div id=\"content\">\n");
2127 wprintf(_("If you select this option, <em>%s</em> will "
2128 "disappear from your room list. Is this what you wish "
2129 "to do?<br />\n"), WC->wc_roomname);
2131 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2132 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2134 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2135 wprintf("</FORM>\n");
2146 char final_destination[SIZ];
2148 /* If the forget-room routine fails for any reason, we fall back
2149 * to the current room; otherwise, we go to the Lobby
2151 strcpy(final_destination, WC->wc_roomname);
2153 if (strlen(bstr("ok_button")) > 0) {
2154 serv_printf("GOTO %s", WC->wc_roomname);
2155 serv_getln(buf, sizeof buf);
2156 if (buf[0] == '2') {
2158 serv_getln(buf, sizeof buf);
2159 if (buf[0] == '2') {
2160 strcpy(final_destination, "_BASEROOM_");
2164 smart_goto(final_destination);
2170 * Delete the current room
2172 void delete_room(void)
2176 serv_puts("KILL 1");
2177 serv_getln(buf, sizeof buf);
2178 if (buf[0] != '2') {
2179 strcpy(WC->ImportantMessage, &buf[4]);
2180 display_main_menu();
2183 smart_goto("_BASEROOM_");
2190 * Perform changes to a room's network configuration
2192 void netedit(void) {
2201 if (strlen(bstr("line"))==0) {
2206 strcpy(line, bstr("prefix"));
2207 strcat(line, bstr("line"));
2208 strcat(line, bstr("suffix"));
2217 serv_getln(buf, sizeof buf);
2218 if (buf[0] != '1') {
2224 /* This loop works for add *or* remove. Spiffy, eh? */
2225 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2226 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2227 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2228 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2229 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2230 if ( (strcasecmp(cmpa0, cmpb0))
2231 || (strcasecmp(cmpa1, cmpb1)) ) {
2232 fprintf(fp, "%s\n", buf);
2238 serv_getln(buf, sizeof buf);
2239 if (buf[0] != '4') {
2245 while (fgets(buf, sizeof buf, fp) != NULL) {
2246 buf[strlen(buf)-1] = 0;
2250 if (strlen(bstr("add_button")) > 0) {
2262 * Convert a room name to a folder-ish-looking name.
2264 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2269 * For mailboxes, just do it straight...
2272 sprintf(folder, "My folders|%s", room);
2276 * Otherwise, prefix the floor name as a "public folders" moniker
2279 sprintf(folder, "%s|%s", floorlist[floor], room);
2283 * Replace "\" characters with "|" for pseudo-folder-delimiting
2285 for (i=0; i<strlen(folder); ++i) {
2286 if (folder[i] == '\\') folder[i] = '|';
2294 * Back end for change_view()
2296 void do_change_view(int newview) {
2299 serv_printf("VIEW %d", newview);
2300 serv_getln(buf, sizeof buf);
2301 WC->wc_view = newview;
2302 smart_goto(WC->wc_roomname);
2308 * Change the view for this room
2310 void change_view(void) {
2313 view = atol(bstr("view"));
2314 do_change_view(view);
2319 * One big expanded tree list view --- like a folder list
2321 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2325 int has_subfolders = 0;
2328 parents = malloc(max_folders * sizeof(int));
2330 /* BEGIN TREE MENU */
2331 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2333 /* include NanoTree */
2334 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2336 /* initialize NanoTree */
2337 wprintf("<script type=\"text/javascript\"> \n"
2338 " showRootNode = false; \n"
2339 " sortNodes = false; \n"
2340 " dragable = false; \n"
2342 " function standardClick(treeNode) { \n"
2345 " var closedGif = 'static/folder_closed.gif'; \n"
2346 " var openGif = 'static/folder_open.gif'; \n"
2348 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2352 for (i=0; i<max_folders; ++i) {
2355 if ((i+1) < max_folders) {
2356 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2357 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2362 levels = num_tokens(fold[i].name, '|');
2363 parents[levels] = i;
2365 wprintf("var node%d = new TreeNode(%d, '", i, i);
2367 if (fold[i].selectable) {
2368 wprintf("<a href=\"dotgoto?room=");
2369 urlescputs(fold[i].room);
2374 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2376 else if (fold[i].hasnewmsgs) {
2377 wprintf("<SPAN CLASS=\"roomlist_new\">");
2380 wprintf("<SPAN CLASS=\"roomlist_old\">");
2382 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2387 if (has_subfolders) {
2388 wprintf("new Array(closedGif, openGif)");
2390 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2391 wprintf("'static/viewcontacts_16x.gif'");
2393 else if (fold[i].view == VIEW_CALENDAR) {
2394 wprintf("'static/calarea_16x.gif'");
2396 else if (fold[i].view == VIEW_TASKS) {
2397 wprintf("'static/taskmanag_16x.gif'");
2399 else if (fold[i].view == VIEW_NOTES) {
2400 wprintf("'static/storenotes_16x.gif'");
2402 else if (fold[i].view == VIEW_MAILBOX) {
2403 wprintf("'static/privatemess_16x.gif'");
2406 wprintf("'static/chatrooms_16x.gif'");
2409 urlescputs(fold[i].name);
2413 wprintf("rootNode.addChild(node%d);\n", i);
2416 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2420 wprintf("container = document.getElementById('roomlist_div'); \n"
2430 * Boxes and rooms and lists ... oh my!
2432 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2434 char floor_name[256];
2435 char old_floor_name[256];
2437 int levels, oldlevels;
2440 static int columns = 3;
2441 int boxes_per_column = 0;
2442 int current_column = 0;
2445 strcpy(floor_name, "");
2446 strcpy(old_floor_name, "");
2449 while (nf % columns != 0) ++nf;
2450 boxes_per_column = (nf / columns);
2451 if (boxes_per_column < 1) boxes_per_column = 1;
2453 /* Outer table (for columnization) */
2454 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2455 "<tr><td valign=top>");
2459 for (i=0; i<max_folders; ++i) {
2461 levels = num_tokens(fold[i].name, '|');
2462 extract_token(floor_name, fold[i].name, 0,
2463 '|', sizeof floor_name);
2465 if ( (strcasecmp(floor_name, old_floor_name))
2466 && (strlen(old_floor_name) > 0) ) {
2468 do_template("endbox");
2471 if ((num_boxes % boxes_per_column) == 0) {
2473 if (current_column < columns) {
2474 wprintf("</td><td valign=top>\n");
2478 strcpy(old_floor_name, floor_name);
2481 /* Begin inner box */
2482 stresc(boxtitle, floor_name, 1, 0);
2483 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2484 do_template("beginbox");
2491 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2492 if (fold[i].selectable) {
2493 wprintf("<a href=\"dotgoto?room=");
2494 urlescputs(fold[i].room);
2500 if (fold[i].hasnewmsgs) {
2501 wprintf("<SPAN CLASS=\"roomlist_new\">");
2504 wprintf("<SPAN CLASS=\"roomlist_old\">");
2506 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2509 if (fold[i].selectable) {
2515 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2516 wprintf(" (INBOX)");
2518 wprintf("<br />\n");
2521 /* End the final inner box */
2522 do_template("endbox");
2524 wprintf("</TD></TR></TABLE>\n");
2528 void set_floordiv_expanded(char *which_floordiv) {
2529 begin_ajax_response();
2530 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2531 end_ajax_response();
2537 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2539 char floor_name[256];
2540 char old_floor_name[256];
2541 char floordivtitle[256];
2542 char floordiv_id[32];
2543 int levels, oldlevels;
2545 int num_drop_targets = 0;
2548 strcpy(floor_name, "");
2549 strcpy(old_floor_name, "");
2553 for (i=0; i<max_folders; ++i) {
2555 levels = num_tokens(fold[i].name, '|');
2556 extract_token(floor_name, fold[i].name, 0,
2557 '|', sizeof floor_name);
2559 if ( (strcasecmp(floor_name, old_floor_name))
2560 && (strlen(old_floor_name) > 0) ) {
2563 wprintf("</div>\n"); /* floordiv */
2565 strcpy(old_floor_name, floor_name);
2569 stresc(floordivtitle, floor_name, 0, 0);
2570 sprintf(floordiv_id, "floordiv%d", i);
2571 wprintf("<span class=\"ib_roomlist_floor\" "
2572 "onClick=\"expand_floor('%s')\">"
2573 "%s</span><br>\n", floordiv_id, floordivtitle);
2574 wprintf("<div id=\"%s\" style=\"display:%s\">",
2576 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2583 wprintf("<div id=\"roomdiv%d\">", i);
2585 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2587 /* choose the icon */
2588 if (fold[i].view == VIEW_ADDRESSBOOK) {
2589 icon = "viewcontacts_16x.gif" ;
2591 else if (fold[i].view == VIEW_CALENDAR) {
2592 icon = "calarea_16x.gif" ;
2594 else if (fold[i].view == VIEW_TASKS) {
2595 icon = "taskmanag_16x.gif" ;
2597 else if (fold[i].view == VIEW_NOTES) {
2598 icon = "storenotes_16x.gif" ;
2600 else if (fold[i].view == VIEW_MAILBOX) {
2601 icon = "privatemess_16x.gif" ;
2604 icon = "chatrooms_16x.gif" ;
2607 if (fold[i].selectable) {
2608 wprintf("<a href=\"dotgoto?room=");
2609 urlescputs(fold[i].room);
2611 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2616 if (fold[i].hasnewmsgs) {
2617 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2620 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2622 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2624 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2625 wprintf(" (INBOX)");
2628 if (fold[i].selectable) {
2635 wprintf("</div>\n"); /* roomdiv */
2638 wprintf("</div>\n"); /* floordiv */
2641 /* BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2642 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2644 num_drop_targets = 0;
2646 for (i=0; i<max_folders; ++i) {
2647 levels = num_tokens(fold[i].name, '|');
2649 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2650 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2651 jsescputs(fold[i].room);
2657 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2658 if (strlen(WC->floordiv_expanded) > 1) {
2659 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2663 /* END: The old invisible pixel trick, to get our JavaScript to initialize */
2669 * Show the room list. (only should get called by
2670 * knrooms() because that's where output_headers() is called from)
2673 void list_all_rooms_by_floor(char *viewpref) {
2676 struct folder *fold = NULL;
2678 int max_folders = 0;
2679 int alloc_folders = 0;
2683 int num_floors = 1; /* add an extra one for private folders */
2685 /* If our cached folder list is very old, burn it. */
2686 if (WC->cache_fold != NULL) {
2687 if ((time(NULL) - WC->cache_timestamp) > 300) {
2688 free(WC->cache_fold);
2689 WC->cache_fold = NULL;
2693 /* Can we do the iconbar roomlist from cache? */
2694 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2695 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2699 /* Grab the floor table so we know how to build the list... */
2702 /* Start with the mailboxes */
2705 fold = malloc(sizeof(struct folder));
2706 memset(fold, 0, sizeof(struct folder));
2707 strcpy(fold[0].name, "My folders");
2708 fold[0].is_mailbox = 1;
2710 /* Then add floors */
2712 serv_getln(buf, sizeof buf);
2713 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2714 if (max_folders >= alloc_folders) {
2715 alloc_folders = max_folders + 100;
2716 fold = realloc(fold,
2717 alloc_folders * sizeof(struct folder));
2719 memset(&fold[max_folders], 0, sizeof(struct folder));
2720 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2727 serv_getln(buf, sizeof buf);
2728 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2729 if (max_folders >= alloc_folders) {
2730 alloc_folders = max_folders + 100;
2731 fold = realloc(fold,
2732 alloc_folders * sizeof(struct folder));
2734 memset(&fold[max_folders], 0, sizeof(struct folder));
2735 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2736 ra_flags = extract_int(buf, 5);
2737 flags = extract_int(buf, 1);
2738 fold[max_folders].floor = extract_int(buf, 2);
2739 fold[max_folders].hasnewmsgs =
2740 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2741 if (flags & QR_MAILBOX) {
2742 fold[max_folders].is_mailbox = 1;
2744 fold[max_folders].view = extract_int(buf, 6);
2745 room_to_folder(fold[max_folders].name,
2746 fold[max_folders].room,
2747 fold[max_folders].floor,
2748 fold[max_folders].is_mailbox);
2749 fold[max_folders].selectable = 1;
2753 /* Bubble-sort the folder list */
2754 for (i=0; i<max_folders; ++i) {
2755 for (j=0; j<(max_folders-1)-i; ++j) {
2756 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2757 swap = strcasecmp(fold[j].name, fold[j+1].name);
2760 if ( (fold[j+1].is_mailbox)
2761 && (!fold[j].is_mailbox)) {
2769 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2770 memcpy(&fold[j], &fold[j+1],
2771 sizeof(struct folder));
2772 memcpy(&fold[j+1], &ftmp,
2773 sizeof(struct folder));
2779 if (!strcasecmp(viewpref, "folders")) {
2780 do_folder_view(fold, max_folders, num_floors);
2782 else if (!strcasecmp(viewpref, "hackish_view")) {
2783 for (i=0; i<max_folders; ++i) {
2784 escputs(fold[i].name);
2785 wprintf("<br />\n");
2788 else if (!strcasecmp(viewpref, "iconbar")) {
2789 do_iconbar_view(fold, max_folders, num_floors);
2792 do_rooms_view(fold, max_folders, num_floors);
2795 /* Don't free the folder list ... cache it for future use! */
2796 if (WC->cache_fold != NULL) {
2797 free(WC->cache_fold);
2799 WC->cache_fold = fold;
2800 WC->cache_max_folders = max_folders;
2801 WC->cache_num_floors = num_floors;
2802 WC->cache_timestamp = time(NULL);
2806 /* Do either a known rooms list or a folders list, depending on the
2810 char listviewpref[SIZ];
2812 output_headers(1, 1, 2, 0, 0, 0);
2814 /* Determine whether the user is trying to change views */
2815 if (bstr("view") != NULL) {
2816 if (strlen(bstr("view")) > 0) {
2817 set_preference("roomlistview", bstr("view"), 1);
2821 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2823 if ( (strcasecmp(listviewpref, "folders"))
2824 && (strcasecmp(listviewpref, "table")) ) {
2825 strcpy(listviewpref, "rooms");
2829 wprintf("<div id=\"banner\">\n"
2830 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2831 "<SPAN CLASS=\"titlebar\">"
2833 if (!strcasecmp(listviewpref, "rooms")) {
2834 wprintf("Room list");
2836 if (!strcasecmp(listviewpref, "folders")) {
2837 wprintf("Folder list");
2839 if (!strcasecmp(listviewpref, "table")) {
2840 wprintf("Room list");
2842 wprintf("</SPAN></TD>\n");
2844 /* offer the ability to switch views */
2845 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2846 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2847 "OnChange=\"location.href=roomlistomatic.newview.options"
2848 "[selectedIndex].value\">\n");
2850 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
2853 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2856 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
2857 "View as folder list"
2859 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2862 wprintf("</SELECT><br />");
2864 wprintf("</FORM></TD></TR></TABLE>\n");
2867 "<div id=\"content\">\n");
2869 /* Display the room list in the user's preferred format */
2870 list_all_rooms_by_floor(listviewpref);
2877 * Set the message expire policy for this room and/or floor
2879 void set_room_policy(void) {
2882 if (strlen(bstr("ok_button")) == 0) {
2883 strcpy(WC->ImportantMessage,
2884 _("Cancelled. Changes were not saved."));
2889 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2890 serv_getln(buf, sizeof buf);
2891 strcpy(WC->ImportantMessage, &buf[4]);
2893 if (WC->axlevel >= 6) {
2894 strcat(WC->ImportantMessage, "<br />\n");
2895 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2896 serv_getln(buf, sizeof buf);
2897 strcat(WC->ImportantMessage, &buf[4]);