4 * Lots of different room-related operations.
19 char floorlist[128][SIZ];
23 void initialize_viewdefs(void) {
24 viewdefs[0] = _("Bulletin Board");
25 viewdefs[1] = _("Mail Folder");
26 viewdefs[2] = _("Address Book");
27 viewdefs[3] = _("Calendar");
28 viewdefs[4] = _("Task List");
29 viewdefs[5] = _("Notes List");
34 * load the list of floors
36 void load_floorlist(void)
41 for (a = 0; a < 128; ++a)
45 serv_getln(buf, sizeof buf);
47 strcpy(floorlist[0], "Main Floor");
50 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
51 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
57 * remove a room from the march list
59 void remove_march(char *aaa)
61 struct march *mptr, *mptr2;
63 if (WC->march == NULL)
66 if (!strcasecmp(WC->march->march_name, aaa)) {
67 mptr = WC->march->next;
73 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
74 if (!strcasecmp(mptr->march_name, aaa)) {
75 mptr2->next = mptr->next;
88 void room_tree_list(struct roomlisting *rp)
97 room_tree_list(rp->lnext);
99 strcpy(rmname, rp->rlname);
102 wprintf("<a href=\"dotgoto&room=");
106 escputs1(rmname, 1, 1);
107 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
109 else if (f & QR_DIRECTORY)
111 else if (f & QR_NETWORK)
115 wprintf("</A><TT> </TT>\n");
117 room_tree_list(rp->rnext);
123 * Room ordering stuff (compare first by floor, then by order)
125 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
127 if ((r1 == NULL) && (r2 == NULL))
133 if (r1->rlfloor < r2->rlfloor)
135 if (r1->rlfloor > r2->rlfloor)
137 if (r1->rlorder < r2->rlorder)
139 if (r1->rlorder > r2->rlorder)
146 * Common code for all room listings
148 void listrms(char *variety)
153 struct roomlisting *rl = NULL;
154 struct roomlisting *rp;
155 struct roomlisting *rs;
158 /* Ask the server for a room list */
160 serv_getln(buf, sizeof buf);
165 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
167 rp = malloc(sizeof(struct roomlisting));
168 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
169 rp->rlflags = extract_int(buf, 1);
170 rp->rlfloor = extract_int(buf, 2);
171 rp->rlorder = extract_int(buf, 3);
180 if (rordercmp(rp, rs) < 0) {
181 if (rs->lnext == NULL) {
188 if (rs->rnext == NULL) {
200 /* If no rooms were listed, print an nbsp to make the cell
201 * borders show up anyway.
203 if (num_rooms == 0) wprintf(" ");
208 * list all forgotten rooms
210 void zapped_list(void)
212 output_headers(1, 1, 0, 0, 0, 0);
214 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
215 do_template("beginbox");
219 wprintf("<br /><br />\n");
220 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
221 do_template("endbox");
227 * read this room's info file (set v to 1 for verbose mode)
234 serv_getln(buf, sizeof buf);
243 /* Display room banner icon. The server doesn't actually
244 * need the room name, but we supply it in order to
245 * keep the browser from using a cached icon from
248 void embed_room_graphic(void) {
251 serv_puts("OIMG _roompic_");
252 serv_getln(buf, sizeof buf);
254 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
255 urlescputs(WC->wc_roomname);
258 serv_getln(buf, sizeof buf);
260 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
261 wprintf("<img height=48 width=48 src=\""
262 "static/viewcontacts_48x.gif"
266 else if (WC->wc_view == VIEW_CALENDAR) {
267 wprintf("<img height=48 width=48 src=\""
268 "static/calarea_48x.gif"
272 else if (WC->wc_view == VIEW_TASKS) {
273 wprintf("<img height=48 width=48 src=\""
274 "static/taskmanag_48x.gif"
278 else if (WC->wc_view == VIEW_NOTES) {
279 wprintf("<img height=48 width=48 src=\""
280 "static/storenotes_48x.gif"
284 else if (WC->wc_view == VIEW_MAILBOX) {
285 wprintf("<img height=48 width=48 src=\""
286 "static/privatemess_48x.gif"
291 wprintf("<img height=48 width=48 src=\""
292 "static/chatrooms_48x.gif"
302 * Display the current view and offer an option to change it
304 void embed_view_o_matic(void) {
307 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
308 "<span class=\"room_banner_new_messages\">View as: "
309 "<SELECT NAME=\"newview\" SIZE=\"1\" "
310 "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif;"
311 " font-size: 7pt; background: #444455; color: #ddddcc;\" "
312 "OnChange=\"location.href=viewomatic.newview.options"
313 "[selectedIndex].value\">\n");
315 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
317 * Only offer the views that make sense, given the default
318 * view for the room. For example, don't offer a Calendar
319 * view in a non-Calendar room.
323 || (i == WC->wc_default_view)
324 || ( (i == 0) && (WC->wc_default_view == 1) )
325 || ( (i == 1) && (WC->wc_default_view == 0) )
328 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
329 ((i == WC->wc_view) ? "SELECTED" : ""),
331 escputs(viewdefs[i]);
332 wprintf("</OPTION>\n");
335 wprintf("</select></span></form>\n");
340 void embed_room_banner(char *got, int navbar_style) {
343 /* We need to have the information returned by a GOTO server command.
344 * If it isn't supplied, we fake it by issuing our own GOTO.
347 serv_printf("GOTO %s", WC->wc_roomname);
348 serv_getln(fakegot, sizeof fakegot);
352 /* If the user happens to select the "make this my start page" link,
353 * we want it to remember the URL as a "/dotskip" one instead of
354 * a "skip" or "gotonext" or something like that.
356 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
359 /* Check for new mail. */
360 WC->new_mail = extract_int(&got[4], 9);
361 WC->wc_view = extract_int(&got[4], 11);
363 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
364 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
365 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
366 svcallback("ROOMPIC", embed_room_graphic);
367 svcallback("ROOMINFO", readinfo);
368 svcallback("VIEWOMATIC", embed_view_o_matic);
369 svcallback("START", offer_start_page);
371 do_template("roombanner");
372 if (navbar_style != navbar_none) {
374 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
375 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
378 if (navbar_style == navbar_default) wprintf(
380 "<a href=\"ungoto\">"
381 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
382 "<span class=\"navbar_link\">%s</span></A>"
383 "</td>\n", _("Ungoto")
386 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
389 "<a href=\"readnew\">"
390 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
391 "<span class=\"navbar_link\">%s</span></A>"
392 "</td>\n", _("Read new messages")
396 if (navbar_style == navbar_default) {
397 switch(WC->wc_view) {
398 case VIEW_ADDRESSBOOK:
401 "<a href=\"readfwd\">"
402 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
404 "<span class=\"navbar_link\">"
406 "</span></a></td>\n", _("View contacts")
412 "<a href=\"readfwd?calview=day\">"
413 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
415 "<span class=\"navbar_link\">"
417 "</span></a></td>\n", _("Day view")
421 "<a href=\"readfwd?calview=month\">"
422 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
424 "<span class=\"navbar_link\">"
426 "</span></a></td>\n", _("Month view")
432 "<a href=\"readfwd\">"
433 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
435 "<span class=\"navbar_link\">"
437 "</span></a></td>\n", _("View tasks")
443 "<a href=\"readfwd\">"
444 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
446 "<span class=\"navbar_link\">"
448 "</span></a></td>\n", _("View notes")
454 "<a href=\"readfwd\">"
455 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
457 "<span class=\"navbar_link\">"
459 "</span></a></td>\n", _("View message list")
465 "<a href=\"readfwd\">"
466 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
468 "<span class=\"navbar_link\">"
470 "</span></a></td>\n", _("Read all messages")
476 if (navbar_style == navbar_default) {
477 switch(WC->wc_view) {
478 case VIEW_ADDRESSBOOK:
480 "<td><a href=\"display_enter\">"
481 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
482 "border=\"0\"><span class=\"navbar_link\">"
484 "</span></a></td>\n", _("Add new contact")
489 "<td><a href=\"display_enter\">"
490 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
491 "border=\"0\"><span class=\"navbar_link\">"
493 "</span></a></td>\n", _("Add new event")
498 "<td><a href=\"display_enter\">"
499 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
500 "border=\"0\"><span class=\"navbar_link\">"
502 "</span></a></td>\n", _("Add new task")
507 "<td><a href=\"display_enter\">"
508 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
509 "border=\"0\"><span class=\"navbar_link\">"
511 "</span></a></td>\n", _("Add new note")
516 "<td><a href=\"display_enter\">"
517 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
518 "border=\"0\"><span class=\"navbar_link\">"
520 "</span></a></td>\n", _("Enter a message")
526 if (navbar_style == navbar_default) wprintf(
530 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
531 "<span class=\"navbar_link\">%s</span></a>"
533 _("Leave all messages marked as unread, go to next room with unread messages"),
537 if (navbar_style == navbar_default) wprintf(
539 "<a href=\"gotonext\" "
541 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
542 "<span class=\"navbar_link\">%s</span></a>"
544 _("Mark all messages as read, go to next room with unread messages"),
548 wprintf("</tr></table></div>\n");
558 * back end routine to take the session to a new room
561 int gotoroom(char *gname)
564 static long ls = (-1L);
567 /* store ungoto information */
568 strcpy(WC->ugname, WC->wc_roomname);
571 /* move to the new room */
572 serv_printf("GOTO %s", gname);
573 serv_getln(buf, sizeof buf);
577 serv_puts("GOTO _BASEROOM_");
578 serv_getln(buf, sizeof buf);
585 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
586 WC->room_flags = extract_int(&buf[4], 4);
587 /* highest_msg_read = extract_int(&buf[4],6);
588 maxmsgnum = extract_int(&buf[4],5);
590 WC->is_mailbox = extract_int(&buf[4],7);
591 ls = extract_long(&buf[4], 6);
592 WC->wc_floor = extract_int(&buf[4], 10);
593 WC->wc_view = extract_int(&buf[4], 11);
594 WC->wc_default_view = extract_int(&buf[4], 12);
597 WC->is_room_aide = WC->is_aide;
599 WC->is_room_aide = (char) extract_int(&buf[4], 8);
601 remove_march(WC->wc_roomname);
602 if (!strcasecmp(gname, "_BASEROOM_"))
610 * Locate the room on the march list which we most want to go to. Each room
611 * is measured given a "weight" of preference based on various factors.
613 char *pop_march(int desired_floor)
615 static char TheRoom[128];
617 int TheOrder = 32767;
620 struct march *mptr = NULL;
622 strcpy(TheRoom, "_BASEROOM_");
623 if (WC->march == NULL)
626 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
628 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
629 weight = weight + 10000;
630 if (mptr->march_floor == desired_floor)
631 weight = weight + 5000;
633 weight = weight + ((128 - (mptr->march_floor)) * 128);
634 weight = weight + (128 - (mptr->march_order));
636 if (weight > TheWeight) {
638 strcpy(TheRoom, mptr->march_name);
639 TheFloor = mptr->march_floor;
640 TheOrder = mptr->march_order;
648 /* Goto next room having unread messages.
649 * We want to skip over rooms that the user has already been to, and take the
650 * user back to the lobby when done. The room we end up in is placed in
651 * newroom - which is set to 0 (the lobby) initially.
652 * We start the search in the current room rather than the beginning to prevent
653 * two or more concurrent users from dragging each other back to the same room.
658 struct march *mptr, *mptr2;
661 /* First check to see if the march-mode list is already allocated.
662 * If it is, pop the first room off the list and go there.
665 if (WC->march == NULL) {
667 serv_getln(buf, sizeof buf);
669 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
670 mptr = (struct march *) malloc(sizeof(struct march));
672 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
673 mptr->march_floor = extract_int(buf, 2);
674 mptr->march_order = extract_int(buf, 3);
675 if (WC->march == NULL) {
679 while (mptr2->next != NULL)
684 /* add _BASEROOM_ to the end of the march list, so the user will end up
685 * in the system base room (usually the Lobby>) at the end of the loop
687 mptr = (struct march *) malloc(sizeof(struct march));
689 strcpy(mptr->march_name, "_BASEROOM_");
690 if (WC->march == NULL) {
694 while (mptr2->next != NULL)
699 * ...and remove the room we're currently in, so a <G>oto doesn't make us
700 * walk around in circles
702 remove_march(WC->wc_roomname);
704 if (WC->march != NULL) {
705 strcpy(next_room, pop_march(-1));
707 strcpy(next_room, "_BASEROOM_");
711 smart_goto(next_room);
715 void smart_goto(char *next_room) {
723 * mark all messages in current room as having been read
725 void slrp_highest(void)
730 serv_puts("SLRP HIGHEST");
731 serv_getln(buf, sizeof buf);
733 wprintf("<EM>%s</EM><br />\n", &buf[4]);
740 * un-goto the previous room
746 if (!strcmp(WC->ugname, "")) {
747 smart_goto(WC->wc_roomname);
750 serv_printf("GOTO %s", WC->ugname);
751 serv_getln(buf, sizeof buf);
753 smart_goto(WC->wc_roomname);
756 if (WC->uglsn >= 0L) {
757 serv_printf("SLRP %ld", WC->uglsn);
758 serv_getln(buf, sizeof buf);
760 strcpy(buf, WC->ugname);
761 strcpy(WC->ugname, "");
770 * Set/clear/read the "self-service list subscribe" flag for a room
772 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
773 * Always returns the new value.
776 int self_service(int newval) {
777 int current_value = 0;
783 int flags, floor, order, view, flags2;
786 serv_getln(buf, sizeof buf);
787 if (buf[0] != '2') return(0);
789 extract_token(name, &buf[4], 0, '|', sizeof name);
790 extract_token(password, &buf[4], 1, '|', sizeof password);
791 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
792 flags = extract_int(&buf[4], 3);
793 floor = extract_int(&buf[4], 4);
794 order = extract_int(&buf[4], 5);
795 view = extract_int(&buf[4], 6);
796 flags2 = extract_int(&buf[4], 7);
798 if (flags2 & QR2_SELFLIST) {
806 flags2 = flags2 | QR2_SELFLIST;
808 else if (newval == 0) {
809 flags2 = flags2 & ~QR2_SELFLIST;
812 return(current_value);
815 if (newval != current_value) {
816 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
817 name, password, dirname, flags,
818 floor, order, view, flags2);
819 serv_getln(buf, sizeof buf);
832 * display the form for editing a room
834 void display_editroom(void)
839 char remote_room[SIZ];
842 char er_password[10];
844 char er_roomaide[26];
850 char *not_shared_with;
857 if (strlen(tab) == 0) tab = "admin";
861 serv_getln(buf, sizeof buf);
864 strcpy(WC->ImportantMessage, &buf[4]);
868 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
869 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
870 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
871 er_flags = extract_int(&buf[4], 3);
872 er_floor = extract_int(&buf[4], 4);
874 output_headers(1, 1, 1, 0, 0, 0);
876 /* print the tabbed dialog */
878 "<div id=\"fix_scrollbar_bug\">"
879 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
881 "<TD> </TD>\n");
883 if (!strcmp(tab, "admin")) {
884 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
887 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
889 wprintf(_("Administration"));
890 if (!strcmp(tab, "admin")) {
891 wprintf("</SPAN></TD>\n");
894 wprintf("</A></TD>\n");
897 wprintf("<TD> </TD>\n");
899 if (!strcmp(tab, "config")) {
900 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
903 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
905 wprintf(_("Configuration"));
906 if (!strcmp(tab, "config")) {
907 wprintf("</SPAN></TD>\n");
910 wprintf("</A></TD>\n");
913 wprintf("<TD> </TD>\n");
915 if (!strcmp(tab, "expire")) {
916 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
919 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
921 wprintf(_("Message expire policy"));
922 if (!strcmp(tab, "expire")) {
923 wprintf("</SPAN></TD>\n");
926 wprintf("</A></TD>\n");
929 wprintf("<TD> </TD>\n");
931 if (!strcmp(tab, "access")) {
932 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
935 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
937 wprintf(_("Access controls"));
938 if (!strcmp(tab, "access")) {
939 wprintf("</SPAN></TD>\n");
942 wprintf("</A></TD>\n");
945 wprintf("<TD> </TD>\n");
947 if (!strcmp(tab, "sharing")) {
948 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
951 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
953 wprintf(_("Sharing"));
954 if (!strcmp(tab, "sharing")) {
955 wprintf("</SPAN></TD>\n");
958 wprintf("</A></TD>\n");
961 wprintf("<TD> </TD>\n");
963 if (!strcmp(tab, "listserv")) {
964 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
967 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
969 wprintf(_("Mailing list service"));
970 if (!strcmp(tab, "listserv")) {
971 wprintf("</SPAN></TD>\n");
974 wprintf("</A></TD>\n");
977 wprintf("<TD> </TD>\n");
979 wprintf("</TR></TABLE></div>\n");
980 /* end tabbed dialog */
982 /* begin content of whatever tab is open now */
983 wprintf("<div id=\"fix_scrollbar_bug\">"
984 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
987 if (!strcmp(tab, "admin")) {
989 "<LI><a href=\"delete_room\" "
990 "onClick=\"return confirm('");
991 wprintf(_("Are you sure you want to delete this room?"));
993 wprintf(_("Delete this room"));
995 "<LI><a href=\"display_editroompic\">\n");
996 wprintf(_("Set or change the icon for this room's banner"));
998 "<LI><a href=\"display_editinfo\">\n");
999 wprintf(_("Edit this room's Info file"));
1004 if (!strcmp(tab, "config")) {
1005 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1007 wprintf("<UL><LI>");
1008 wprintf(_("Name of room: "));
1009 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1015 wprintf(_("Resides on floor: "));
1016 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1017 for (i = 0; i < 128; ++i)
1018 if (strlen(floorlist[i]) > 0) {
1019 wprintf("<OPTION ");
1021 wprintf("SELECTED ");
1022 wprintf("VALUE=\"%d\">", i);
1023 escputs(floorlist[i]);
1024 wprintf("</OPTION>\n");
1026 wprintf("</SELECT>\n");
1029 wprintf(_("Type of room:"));
1032 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1033 if ((er_flags & QR_PRIVATE) == 0)
1034 wprintf("CHECKED ");
1036 wprintf(_("Public room"));
1039 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1040 if ((er_flags & QR_PRIVATE) &&
1041 (er_flags & QR_GUESSNAME))
1042 wprintf("CHECKED ");
1044 wprintf(_("Private - guess name"));
1046 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1047 if ((er_flags & QR_PRIVATE) &&
1048 (er_flags & QR_PASSWORDED))
1049 wprintf("CHECKED ");
1051 wprintf(_("Private - require password:"));
1052 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1055 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1056 if ((er_flags & QR_PRIVATE)
1057 && ((er_flags & QR_GUESSNAME) == 0)
1058 && ((er_flags & QR_PASSWORDED) == 0))
1059 wprintf("CHECKED ");
1061 wprintf(_("Private - invitation only"));
1063 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1065 wprintf(_("If private, cause current users to forget room"));
1067 wprintf("\n</UL>\n");
1069 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1070 if (er_flags & QR_PREFONLY)
1071 wprintf("CHECKED ");
1073 wprintf(_("Preferred users only"));
1075 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1076 if (er_flags & QR_READONLY)
1077 wprintf("CHECKED ");
1079 wprintf(_("Read-only room"));
1081 /* directory stuff */
1082 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1083 if (er_flags & QR_DIRECTORY)
1084 wprintf("CHECKED ");
1086 wprintf(_("File directory room"));
1088 wprintf("\n<UL><LI>");
1089 wprintf(_("Directory name: "));
1090 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1093 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1094 if (er_flags & QR_UPLOAD)
1095 wprintf("CHECKED ");
1097 wprintf(_("Uploading allowed"));
1099 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1100 if (er_flags & QR_DOWNLOAD)
1101 wprintf("CHECKED ");
1103 wprintf(_("Downloading allowed"));
1105 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1106 if (er_flags & QR_VISDIR)
1107 wprintf("CHECKED ");
1109 wprintf(_("Visible directory"));
1112 /* end of directory stuff */
1114 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1115 if (er_flags & QR_NETWORK)
1116 wprintf("CHECKED ");
1118 wprintf(_("Network shared room"));
1120 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1121 if (er_flags & QR_PERMANENT)
1122 wprintf("CHECKED ");
1124 wprintf(_("Permanent (does not auto-purge)"));
1126 /* start of anon options */
1129 wprintf(_("Anonymous messages"));
1132 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1133 if (((er_flags & QR_ANONONLY) == 0)
1134 && ((er_flags & QR_ANONOPT) == 0))
1135 wprintf("CHECKED ");
1137 wprintf(_("No anonymous messages"));
1139 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1140 if (er_flags & QR_ANONONLY)
1141 wprintf("CHECKED ");
1143 wprintf(_("All messages are anonymous"));
1145 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1146 if (er_flags & QR_ANONOPT)
1147 wprintf("CHECKED ");
1149 wprintf(_("Prompt user when entering messages"));
1152 /* end of anon options */
1155 wprintf(_("Room aide: "));
1157 serv_getln(buf, sizeof buf);
1158 if (buf[0] != '2') {
1159 wprintf("<EM>%s</EM>\n", &buf[4]);
1161 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1162 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1165 wprintf("</UL><CENTER>\n");
1166 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1167 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1169 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1177 /* Sharing the room with other Citadel nodes... */
1178 if (!strcmp(tab, "sharing")) {
1180 shared_with = strdup("");
1181 not_shared_with = strdup("");
1183 /* Learn the current configuration */
1184 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1185 serv_getln(buf, sizeof buf);
1186 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1187 extract_token(node, buf, 0, '|', sizeof node);
1188 not_shared_with = realloc(not_shared_with,
1189 strlen(not_shared_with) + 32);
1190 strcat(not_shared_with, node);
1191 strcat(not_shared_with, "\n");
1195 serv_getln(buf, sizeof buf);
1196 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1197 extract_token(cmd, buf, 0, '|', sizeof cmd);
1198 extract_token(node, buf, 1, '|', sizeof node);
1199 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1200 if (!strcasecmp(cmd, "ignet_push_share")) {
1201 shared_with = realloc(shared_with,
1202 strlen(shared_with) + 32);
1203 strcat(shared_with, node);
1204 if (strlen(remote_room) > 0) {
1205 strcat(shared_with, "|");
1206 strcat(shared_with, remote_room);
1208 strcat(shared_with, "\n");
1212 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1213 extract_token(buf, shared_with, i, '\n', sizeof buf);
1214 extract_token(node, buf, 0, '|', sizeof node);
1215 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1216 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1217 if (!strcasecmp(node, cmd)) {
1218 remove_token(not_shared_with, j, '\n');
1223 /* Display the stuff */
1224 wprintf("<CENTER><br />"
1225 "<TABLE border=1 cellpadding=5><TR>"
1227 wprintf(_("Shared with"));
1228 wprintf("</I></B></TD>"
1230 wprintf(_("Not shared with"));
1231 wprintf("</I></B></TD></TR>\n"
1232 "<TR><TD VALIGN=TOP>\n");
1234 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1235 wprintf(_("Remote node name"));
1236 wprintf("</TD><TD>");
1237 wprintf(_("Remote room name"));
1238 wprintf("</TD><TD>");
1239 wprintf(_("Actions"));
1240 wprintf("</TD></TR>\n");
1242 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1243 extract_token(buf, shared_with, i, '\n', sizeof buf);
1244 extract_token(node, buf, 0, '|', sizeof node);
1245 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1246 if (strlen(node) > 0) {
1247 wprintf("<FORM METHOD=\"POST\" "
1248 "action=\"netedit\">"
1249 "<TR><TD>%s</TD>\n", node);
1252 if (strlen(remote_room) > 0) {
1253 escputs(remote_room);
1259 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1260 "VALUE=\"ignet_push_share|");
1262 if (strlen(remote_room) > 0) {
1264 urlescputs(remote_room);
1267 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1268 "VALUE=\"sharing\">\n");
1269 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1270 "VALUE=\"remove\">\n");
1271 wprintf("<INPUT TYPE=\"submit\" "
1272 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1273 wprintf("</TD></TR></FORM>\n");
1277 wprintf("</TABLE>\n");
1278 wprintf("</TD><TD VALIGN=TOP>\n");
1279 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1280 wprintf(_("Remote node name"));
1281 wprintf("</TD><TD>");
1282 wprintf(_("Remote room name"));
1283 wprintf("</TD><TD>");
1284 wprintf(_("Actions"));
1285 wprintf("</TD></TR>\n");
1287 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1288 extract_token(node, not_shared_with, i, '\n', sizeof node);
1289 if (strlen(node) > 0) {
1290 wprintf("<FORM METHOD=\"POST\" "
1291 "action=\"netedit\">"
1295 "<INPUT TYPE=\"INPUT\" "
1299 wprintf("<INPUT TYPE=\"hidden\" "
1301 "VALUE=\"ignet_push_share|");
1304 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1305 "VALUE=\"sharing\">\n");
1306 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1307 "VALUE=\"add\">\n");
1308 wprintf("<INPUT TYPE=\"submit\" "
1309 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1310 wprintf("</TD></TR></FORM>\n");
1314 wprintf("</TABLE>\n");
1315 wprintf("</TD></TR>"
1316 "</TABLE></CENTER><br />\n"
1317 "<I><B>%s</B><UL><LI>", _("Notes:"));
1318 wprintf(_("When sharing a room, "
1319 "it must be shared from both ends. Adding a node to "
1320 "the 'shared' list sends messages out, but in order to"
1321 " receive messages, the other nodes must be configured"
1322 " to send messages out to your system as well. "
1323 "<LI>If the remote room name is blank, it is assumed "
1324 "that the room name is identical on the remote node."
1325 "<LI>If the remote room name is different, the remote "
1326 "node must also configure the name of the room here."
1332 /* Mailing list management */
1333 if (!strcmp(tab, "listserv")) {
1335 wprintf("<br /><center>"
1336 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1337 "<TR><TD VALIGN=TOP>");
1339 wprintf(_("<i>The contents of this room are being "
1340 "mailed <b>as individual messages</b> "
1341 "to the following list recipients:"
1342 "</i><br /><br />\n"));
1345 serv_getln(buf, sizeof buf);
1346 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1347 extract_token(cmd, buf, 0, '|', sizeof cmd);
1348 if (!strcasecmp(cmd, "listrecp")) {
1349 extract_token(recp, buf, 1, '|', sizeof recp);
1352 wprintf(" <a href=\"netedit&cmd=remove&line="
1355 wprintf("&tab=listserv\">");
1356 wprintf(_("(remove)"));
1357 wprintf("</A><br />");
1360 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1361 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1362 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1363 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1364 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1365 wprintf("</FORM>\n");
1367 wprintf("</TD><TD VALIGN=TOP>\n");
1369 wprintf(_("<i>The contents of this room are being "
1370 "mailed <b>in digest form</b> "
1371 "to the following list recipients:"
1372 "</i><br /><br />\n"));
1375 serv_getln(buf, sizeof buf);
1376 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1377 extract_token(cmd, buf, 0, '|', sizeof cmd);
1378 if (!strcasecmp(cmd, "digestrecp")) {
1379 extract_token(recp, buf, 1, '|', sizeof recp);
1382 wprintf(" <a href=\"netedit&cmd=remove&line="
1385 wprintf("&tab=listserv\">");
1386 wprintf(_("(remove)"));
1387 wprintf("</A><br />");
1390 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1391 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1392 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1393 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1394 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1395 wprintf("</FORM>\n");
1397 wprintf("</TD></TR></TABLE><hr />\n");
1399 if (self_service(999) == 1) {
1400 wprintf(_("This room is configured to allow "
1401 "self-service subscribe/unsubscribe requests."));
1402 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1403 wprintf(_("Click to disable."));
1404 wprintf("</A><br />\n");
1405 wprintf(_("The URL for subscribe/unsubscribe is: "));
1406 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1407 (is_https ? "https" : "http"),
1411 wprintf(_("This room is <i>not</i> configured to allow "
1412 "self-service subscribe/unsubscribe requests."));
1413 wprintf(" <a href=\"toggle_self_service?newval=1&"
1415 wprintf(_("Click to enable."));
1416 wprintf("</A><br />\n");
1420 wprintf("</CENTER>\n");
1424 /* Mailing list management */
1425 if (!strcmp(tab, "expire")) {
1427 serv_puts("GPEX room");
1428 serv_getln(buf, sizeof buf);
1429 if (buf[0] == '2') {
1430 roompolicy = extract_int(&buf[4], 0);
1431 roomvalue = extract_int(&buf[4], 1);
1434 serv_puts("GPEX floor");
1435 serv_getln(buf, sizeof buf);
1436 if (buf[0] == '2') {
1437 floorpolicy = extract_int(&buf[4], 0);
1438 floorvalue = extract_int(&buf[4], 1);
1441 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1442 wprintf("<TABLE border=0 cellspacing=5>\n");
1443 wprintf("<TR><TD>");
1444 wprintf(_("Message expire policy for this room"));
1446 escputs(WC->wc_roomname);
1447 wprintf(")</TD><TD>");
1448 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1449 ((roompolicy == 0) ? "CHECKED" : "") );
1450 wprintf(_("Use the default policy for this floor"));
1451 wprintf("<br />\n");
1452 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1453 ((roompolicy == 1) ? "CHECKED" : "") );
1454 wprintf(_("Never automatically expire messages"));
1455 wprintf("<br />\n");
1456 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1457 ((roompolicy == 2) ? "CHECKED" : "") );
1458 wprintf("Expire by message count<br />\n");
1459 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1460 ((roompolicy == 3) ? "CHECKED" : "") );
1461 wprintf(_("Expire by message age"));
1463 wprintf(_("Number of messages or days: "));
1464 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1465 wprintf("</TD></TR>\n");
1467 if (WC->axlevel >= 6) {
1468 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1469 wprintf("<TR><TD>");
1470 wprintf(_("Message expire policy for this floor"));
1472 escputs(floorlist[WC->wc_floor]);
1473 wprintf(")</TD><TD>");
1474 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1475 ((floorpolicy == 0) ? "CHECKED" : "") );
1476 wprintf(_("Use the system default"));
1477 wprintf("<br />\n");
1478 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1479 ((floorpolicy == 1) ? "CHECKED" : "") );
1480 wprintf(_("Never automatically expire messages"));
1481 wprintf("<br />\n");
1482 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1483 ((floorpolicy == 2) ? "CHECKED" : "") );
1484 wprintf(_("Expire by message count"));
1485 wprintf("<br />\n");
1486 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1487 ((floorpolicy == 3) ? "CHECKED" : "") );
1488 wprintf(_("Expire by message age"));
1490 wprintf(_("Number of messages or days: "));
1491 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1495 wprintf("<CENTER>\n");
1496 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1497 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1499 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1500 wprintf("</CENTER></TD><TR>\n");
1502 wprintf("</TABLE>\n"
1503 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1509 /* Mailing list management */
1510 if (!strcmp(tab, "access")) {
1514 /* end content of whatever tab is open now */
1515 wprintf("</TD></TR></TABLE></div>\n");
1522 * Toggle self-service list subscription
1524 void toggle_self_service(void) {
1527 newval = atoi(bstr("newval"));
1528 self_service(newval);
1535 * save new parameters for a room
1541 char er_password[10];
1542 char er_dirname[15];
1543 char er_roomaide[26];
1549 if (strlen(bstr("ok_button")) == 0) {
1550 strcpy(WC->ImportantMessage,
1551 _("Cancelled. Changes were not saved."));
1556 serv_getln(buf, sizeof buf);
1558 if (buf[0] != '2') {
1559 strcpy(WC->ImportantMessage, &buf[4]);
1563 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1564 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1565 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1566 er_flags = extract_int(&buf[4], 3);
1568 strcpy(er_roomaide, bstr("er_roomaide"));
1569 if (strlen(er_roomaide) == 0) {
1571 serv_getln(buf, sizeof buf);
1572 if (buf[0] != '2') {
1573 strcpy(er_roomaide, "");
1575 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1578 strcpy(buf, bstr("er_name"));
1580 if (strlen(buf) > 0) {
1581 strcpy(er_name, buf);
1584 strcpy(buf, bstr("er_password"));
1586 if (strlen(buf) > 0)
1587 strcpy(er_password, buf);
1589 strcpy(buf, bstr("er_dirname"));
1591 if (strlen(buf) > 0)
1592 strcpy(er_dirname, buf);
1594 strcpy(buf, bstr("type"));
1595 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1597 if (!strcmp(buf, "invonly")) {
1598 er_flags |= (QR_PRIVATE);
1600 if (!strcmp(buf, "hidden")) {
1601 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1603 if (!strcmp(buf, "passworded")) {
1604 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1606 if (!strcmp(bstr("prefonly"), "yes")) {
1607 er_flags |= QR_PREFONLY;
1609 er_flags &= ~QR_PREFONLY;
1612 if (!strcmp(bstr("readonly"), "yes")) {
1613 er_flags |= QR_READONLY;
1615 er_flags &= ~QR_READONLY;
1618 if (!strcmp(bstr("permanent"), "yes")) {
1619 er_flags |= QR_PERMANENT;
1621 er_flags &= ~QR_PERMANENT;
1624 if (!strcmp(bstr("network"), "yes")) {
1625 er_flags |= QR_NETWORK;
1627 er_flags &= ~QR_NETWORK;
1630 if (!strcmp(bstr("directory"), "yes")) {
1631 er_flags |= QR_DIRECTORY;
1633 er_flags &= ~QR_DIRECTORY;
1636 if (!strcmp(bstr("ulallowed"), "yes")) {
1637 er_flags |= QR_UPLOAD;
1639 er_flags &= ~QR_UPLOAD;
1642 if (!strcmp(bstr("dlallowed"), "yes")) {
1643 er_flags |= QR_DOWNLOAD;
1645 er_flags &= ~QR_DOWNLOAD;
1648 if (!strcmp(bstr("visdir"), "yes")) {
1649 er_flags |= QR_VISDIR;
1651 er_flags &= ~QR_VISDIR;
1654 strcpy(buf, bstr("anon"));
1656 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1657 if (!strcmp(buf, "anononly"))
1658 er_flags |= QR_ANONONLY;
1659 if (!strcmp(buf, "anon2"))
1660 er_flags |= QR_ANONOPT;
1663 if (!strcmp(bstr("bump"), "yes"))
1666 er_floor = atoi(bstr("er_floor"));
1668 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1669 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1671 serv_getln(buf, sizeof buf);
1672 if (buf[0] != '2') {
1673 strcpy(WC->ImportantMessage, &buf[4]);
1679 if (strlen(er_roomaide) > 0) {
1680 sprintf(buf, "SETA %s", er_roomaide);
1682 serv_getln(buf, sizeof buf);
1683 if (buf[0] != '2') {
1684 strcpy(WC->ImportantMessage, &buf[4]);
1685 display_main_menu();
1690 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1697 * Display form for Invite, Kick, and show Who Knows a room
1699 void do_invt_kick(void) {
1700 char buf[SIZ], room[SIZ], username[SIZ];
1703 serv_getln(buf, sizeof buf);
1705 if (buf[0] != '2') {
1709 extract_token(room, &buf[4], 0, '|', sizeof room);
1711 strcpy(username, bstr("username"));
1713 if (strlen(bstr("kick_button")) > 0) {
1714 sprintf(buf, "KICK %s", username);
1716 serv_getln(buf, sizeof buf);
1718 if (buf[0] != '2') {
1719 strcpy(WC->ImportantMessage, &buf[4]);
1721 sprintf(WC->ImportantMessage,
1722 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1727 if (strlen(bstr("invite_button")) > 0) {
1728 sprintf(buf, "INVT %s", username);
1730 serv_getln(buf, sizeof buf);
1732 if (buf[0] != '2') {
1733 strcpy(WC->ImportantMessage, &buf[4]);
1735 sprintf(WC->ImportantMessage,
1736 _("<B><I>User %s invited to room %s.</I></B>\n"),
1747 * Display form for Invite, Kick, and show Who Knows a room
1749 void display_whok(void)
1751 char buf[SIZ], room[SIZ], username[SIZ];
1754 serv_getln(buf, sizeof buf);
1756 if (buf[0] != '2') {
1760 extract_token(room, &buf[4], 0, '|', sizeof room);
1763 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1764 wprintf(_("The users listed below have access to this room. "
1765 "To remove a user from the access list, select the user "
1766 "name from the list and click 'Kick'."));
1767 wprintf("<br /><br />");
1769 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1770 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1771 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1773 serv_getln(buf, sizeof buf);
1774 if (buf[0] == '1') {
1775 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1776 extract_token(username, buf, 0, '|', sizeof username);
1777 wprintf("<OPTION>");
1782 wprintf("</SELECT><br />\n");
1784 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1785 wprintf("</FORM></CENTER>\n");
1787 wprintf("</TD><TD>");
1788 wprintf(_("To grant another user access to this room, enter the "
1789 "user name in the box below and click 'Invite'."));
1790 wprintf("<br /><br />");
1792 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1793 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1794 wprintf("Invite: ");
1795 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1796 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1797 "<input type=\"submit\" value=\"%s\">"
1798 "</FORM></CENTER>\n", _("Invite"));
1800 wprintf("</TD></TR></TABLE>\n");
1807 * display the form for entering a new room
1809 void display_entroom(void)
1814 serv_puts("CRE8 0");
1815 serv_getln(buf, sizeof buf);
1817 if (buf[0] != '2') {
1818 strcpy(WC->ImportantMessage, &buf[4]);
1819 display_main_menu();
1823 output_headers(1, 1, 2, 0, 0, 0);
1824 wprintf("<div id=\"banner\">\n"
1825 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1826 "<SPAN CLASS=\"titlebar\">");
1827 wprintf(_("Create a new room"));
1829 "</TD></TR></TABLE>\n"
1830 "</div>\n<div id=\"content\">\n"
1833 wprintf("<div id=\"fix_scrollbar_bug\">"
1834 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1836 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1838 wprintf("<UL><LI>");
1839 wprintf(_("Name of room: "));
1840 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1843 wprintf(_("Resides on floor: "));
1845 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1846 for (i = 0; i < 128; ++i)
1847 if (strlen(floorlist[i]) > 0) {
1848 wprintf("<OPTION ");
1849 wprintf("VALUE=\"%d\">", i);
1850 escputs(floorlist[i]);
1851 wprintf("</OPTION>\n");
1853 wprintf("</SELECT>\n");
1855 /* Our clever little snippet of JavaScript automatically selects
1856 * a public room if the view is set to Bulletin Board, and it
1857 * selects a mailbox room otherwise. The user can override this,
1861 wprintf(_("Default view for room: "));
1862 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1863 " if (this.form.er_view.value == 0) { "
1864 " this.form.type[0].checked=true; "
1865 " this.form.er_floor.disabled = false; "
1868 " this.form.type[4].checked=true; "
1869 " this.form.er_floor.disabled = true; "
1872 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1873 wprintf("<OPTION %s VALUE=\"%d\">",
1874 ((i == 0) ? "SELECTED" : ""), i );
1875 escputs(viewdefs[i]);
1876 wprintf("</OPTION>\n");
1878 wprintf("</SELECT>\n");
1881 wprintf(_("Type of room:"));
1884 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1885 wprintf("CHECKED OnChange=\""
1886 " if (this.form.type[0].checked == true) { "
1887 " this.form.er_floor.disabled = false; "
1890 wprintf(_("Public (automatically appears to everyone)"));
1892 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1893 " if (this.form.type[1].checked == true) { "
1894 " this.form.er_floor.disabled = false; "
1897 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1899 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1900 " if (this.form.type[2].checked == true) { "
1901 " this.form.er_floor.disabled = false; "
1904 wprintf(_("Private - require password: "));
1905 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1907 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1908 " if (this.form.type[3].checked == true) { "
1909 " this.form.er_floor.disabled = false; "
1912 wprintf(_("Private - invitation only"));
1914 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1916 " if (this.form.type[4].checked == true) { "
1917 " this.form.er_floor.disabled = true; "
1920 wprintf(_("Personal (mailbox for you only)"));
1922 wprintf("\n</UL>\n");
1924 wprintf("<CENTER>\n");
1925 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1927 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1928 wprintf("</CENTER>\n");
1929 wprintf("</FORM>\n<hr />");
1930 serv_printf("MESG roomaccess");
1931 serv_getln(buf, sizeof buf);
1932 if (buf[0] == '1') {
1935 wprintf("</td></tr></table></div>\n");
1943 * support function for entroom() -- sets the default view
1945 void er_set_default_view(int newview) {
1958 serv_getln(buf, sizeof buf);
1959 if (buf[0] != '2') return;
1961 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
1962 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
1963 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
1964 rm_bits1 = extract_int(&buf[4], 3);
1965 rm_floor = extract_int(&buf[4], 4);
1966 rm_listorder = extract_int(&buf[4], 5);
1967 rm_bits2 = extract_int(&buf[4], 7);
1969 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1970 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1971 rm_listorder, newview, rm_bits2
1973 serv_getln(buf, sizeof buf);
1986 char er_password[SIZ];
1991 if (strlen(bstr("ok_button")) == 0) {
1992 strcpy(WC->ImportantMessage,
1993 _("Cancelled. No new room was created."));
1994 display_main_menu();
1997 strcpy(er_name, bstr("er_name"));
1998 strcpy(er_type, bstr("type"));
1999 strcpy(er_password, bstr("er_password"));
2000 er_floor = atoi(bstr("er_floor"));
2001 er_view = atoi(bstr("er_view"));
2004 if (!strcmp(er_type, "hidden"))
2006 if (!strcmp(er_type, "passworded"))
2008 if (!strcmp(er_type, "invonly"))
2010 if (!strcmp(er_type, "personal"))
2013 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2014 er_name, er_num_type, er_password, er_floor, 0, er_view);
2016 serv_getln(buf, sizeof buf);
2017 if (buf[0] != '2') {
2018 strcpy(WC->ImportantMessage, &buf[4]);
2019 display_main_menu();
2023 do_change_view(er_view); /* Now go there */
2028 * display the screen to enter a private room
2030 void display_private(char *rname, int req_pass)
2032 output_headers(1, 1, 2, 0, 0, 0);
2033 wprintf("<div id=\"banner\">\n"
2034 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2035 "<SPAN CLASS=\"titlebar\">");
2036 wprintf(_("Go to a hidden room"));
2038 "</TD></TR></TABLE>\n"
2039 "</div>\n<div id=\"content\">\n"
2042 wprintf("<div id=\"fix_scrollbar_bug\">"
2043 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2045 wprintf("<CENTER>\n");
2047 wprintf(_("If you know the name of a hidden (guess-name) or "
2048 "passworded room, you can enter that room by typing "
2049 "its name below. Once you gain access to a private "
2050 "room, it will appear in your regular room listings "
2051 "so you don't have to keep returning here."));
2052 wprintf("\n<br /><br />");
2054 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2056 wprintf("<table border=\"0\" cellspacing=\"5\" "
2057 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2059 wprintf(_("Enter room name:"));
2061 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2062 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2065 wprintf("</TD></TR><TR><TD>");
2066 wprintf(_("Enter room password:"));
2067 wprintf("</TD><TD>");
2068 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2070 wprintf("</TD></TR></TABLE><br />\n");
2072 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2074 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2078 wprintf("</FORM>\n");
2079 wprintf("</td></tr></table></div>\n");
2084 * goto a private room
2086 void goto_private(void)
2091 if (strlen(bstr("ok_button")) == 0) {
2092 display_main_menu();
2095 strcpy(hold_rm, WC->wc_roomname);
2096 strcpy(buf, "GOTO ");
2097 strcat(buf, bstr("gr_name"));
2099 strcat(buf, bstr("gr_pass"));
2101 serv_getln(buf, sizeof buf);
2103 if (buf[0] == '2') {
2104 smart_goto(bstr("gr_name"));
2107 if (!strncmp(buf, "540", 3)) {
2108 display_private(bstr("gr_name"), 1);
2111 output_headers(1, 1, 1, 0, 0, 0);
2112 wprintf("%s\n", &buf[4]);
2119 * display the screen to zap a room
2121 void display_zap(void)
2123 output_headers(1, 1, 2, 0, 0, 0);
2125 wprintf("<div id=\"banner\">\n");
2126 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2127 wprintf("<SPAN CLASS=\"titlebar\">");
2128 wprintf(_("Zap (forget/unsubscribe) the current room"));
2129 wprintf("</SPAN>\n");
2130 wprintf("</TD></TR></TABLE>\n");
2131 wprintf("</div>\n<div id=\"content\">\n");
2133 wprintf(_("If you select this option, <em>%s</em> will "
2134 "disappear from your room list. Is this what you wish "
2135 "to do?<br />\n"), WC->wc_roomname);
2137 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2138 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2140 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2141 wprintf("</FORM>\n");
2152 char final_destination[SIZ];
2154 /* If the forget-room routine fails for any reason, we fall back
2155 * to the current room; otherwise, we go to the Lobby
2157 strcpy(final_destination, WC->wc_roomname);
2159 if (strlen(bstr("ok_button")) > 0) {
2160 serv_printf("GOTO %s", WC->wc_roomname);
2161 serv_getln(buf, sizeof buf);
2162 if (buf[0] == '2') {
2164 serv_getln(buf, sizeof buf);
2165 if (buf[0] == '2') {
2166 strcpy(final_destination, "_BASEROOM_");
2170 smart_goto(final_destination);
2176 * Delete the current room
2178 void delete_room(void)
2182 serv_puts("KILL 1");
2183 serv_getln(buf, sizeof buf);
2184 if (buf[0] != '2') {
2185 strcpy(WC->ImportantMessage, &buf[4]);
2186 display_main_menu();
2189 smart_goto("_BASEROOM_");
2196 * Perform changes to a room's network configuration
2198 void netedit(void) {
2207 if (strlen(bstr("line"))==0) {
2212 strcpy(line, bstr("prefix"));
2213 strcat(line, bstr("line"));
2214 strcat(line, bstr("suffix"));
2223 serv_getln(buf, sizeof buf);
2224 if (buf[0] != '1') {
2230 /* This loop works for add *or* remove. Spiffy, eh? */
2231 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2232 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2233 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2234 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2235 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2236 if ( (strcasecmp(cmpa0, cmpb0))
2237 || (strcasecmp(cmpa1, cmpb1)) ) {
2238 fprintf(fp, "%s\n", buf);
2244 serv_getln(buf, sizeof buf);
2245 if (buf[0] != '4') {
2251 while (fgets(buf, sizeof buf, fp) != NULL) {
2252 buf[strlen(buf)-1] = 0;
2256 if (strlen(bstr("add_button")) > 0) {
2268 * Convert a room name to a folder-ish-looking name.
2270 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2275 * For mailboxes, just do it straight...
2278 sprintf(folder, "My folders|%s", room);
2282 * Otherwise, prefix the floor name as a "public folders" moniker
2285 sprintf(folder, "%s|%s", floorlist[floor], room);
2289 * Replace "\" characters with "|" for pseudo-folder-delimiting
2291 for (i=0; i<strlen(folder); ++i) {
2292 if (folder[i] == '\\') folder[i] = '|';
2300 * Back end for change_view()
2302 void do_change_view(int newview) {
2305 serv_printf("VIEW %d", newview);
2306 serv_getln(buf, sizeof buf);
2307 WC->wc_view = newview;
2308 smart_goto(WC->wc_roomname);
2314 * Change the view for this room
2316 void change_view(void) {
2319 view = atol(bstr("view"));
2320 do_change_view(view);
2325 * One big expanded tree list view --- like a folder list
2327 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2331 int has_subfolders = 0;
2334 parents = malloc(max_folders * sizeof(int));
2336 /* BEGIN TREE MENU */
2337 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2339 /* include NanoTree */
2340 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2342 /* initialize NanoTree */
2343 wprintf("<script type=\"text/javascript\"> \n"
2344 " showRootNode = false; \n"
2345 " sortNodes = false; \n"
2346 " dragable = false; \n"
2348 " function standardClick(treeNode) { \n"
2351 " var closedGif = 'static/folder_closed.gif'; \n"
2352 " var openGif = 'static/folder_open.gif'; \n"
2354 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2358 for (i=0; i<max_folders; ++i) {
2361 if ((i+1) < max_folders) {
2362 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2363 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2368 levels = num_tokens(fold[i].name, '|');
2369 parents[levels] = i;
2371 wprintf("var node%d = new TreeNode(%d, '", i, i);
2373 if (fold[i].selectable) {
2374 wprintf("<a href=\"dotgoto?room=");
2375 urlescputs(fold[i].room);
2380 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2382 else if (fold[i].hasnewmsgs) {
2383 wprintf("<SPAN CLASS=\"roomlist_new\">");
2386 wprintf("<SPAN CLASS=\"roomlist_old\">");
2388 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2393 if (has_subfolders) {
2394 wprintf("new Array(closedGif, openGif)");
2396 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2397 wprintf("'static/viewcontacts_16x.gif'");
2399 else if (fold[i].view == VIEW_CALENDAR) {
2400 wprintf("'static/calarea_16x.gif'");
2402 else if (fold[i].view == VIEW_TASKS) {
2403 wprintf("'static/taskmanag_16x.gif'");
2405 else if (fold[i].view == VIEW_NOTES) {
2406 wprintf("'static/storenotes_16x.gif'");
2408 else if (fold[i].view == VIEW_MAILBOX) {
2409 wprintf("'static/privatemess_16x.gif'");
2412 wprintf("'static/chatrooms_16x.gif'");
2415 urlescputs(fold[i].name);
2419 wprintf("rootNode.addChild(node%d);\n", i);
2422 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2426 wprintf("container = document.getElementById('roomlist_div'); \n"
2436 * Boxes and rooms and lists ... oh my!
2438 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2440 char floor_name[256];
2441 char old_floor_name[256];
2443 int levels, oldlevels;
2446 static int columns = 3;
2447 int boxes_per_column = 0;
2448 int current_column = 0;
2451 strcpy(floor_name, "");
2452 strcpy(old_floor_name, "");
2455 while (nf % columns != 0) ++nf;
2456 boxes_per_column = (nf / columns);
2457 if (boxes_per_column < 1) boxes_per_column = 1;
2459 /* Outer table (for columnization) */
2460 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2461 "<tr><td valign=top>");
2465 for (i=0; i<max_folders; ++i) {
2467 levels = num_tokens(fold[i].name, '|');
2468 extract_token(floor_name, fold[i].name, 0,
2469 '|', sizeof floor_name);
2471 if ( (strcasecmp(floor_name, old_floor_name))
2472 && (strlen(old_floor_name) > 0) ) {
2474 do_template("endbox");
2477 if ((num_boxes % boxes_per_column) == 0) {
2479 if (current_column < columns) {
2480 wprintf("</td><td valign=top>\n");
2484 strcpy(old_floor_name, floor_name);
2487 /* Begin inner box */
2488 stresc(boxtitle, floor_name, 1, 0);
2489 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2490 do_template("beginbox");
2497 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2498 if (fold[i].selectable) {
2499 wprintf("<a href=\"dotgoto?room=");
2500 urlescputs(fold[i].room);
2506 if (fold[i].hasnewmsgs) {
2507 wprintf("<SPAN CLASS=\"roomlist_new\">");
2510 wprintf("<SPAN CLASS=\"roomlist_old\">");
2512 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2515 if (fold[i].selectable) {
2521 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2522 wprintf(" (INBOX)");
2524 wprintf("<br />\n");
2527 /* End the final inner box */
2528 do_template("endbox");
2530 wprintf("</TD></TR></TABLE>\n");
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];
2542 int levels, oldlevels;
2546 strcpy(floor_name, "");
2547 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) ) {
2564 strcpy(old_floor_name, floor_name);
2567 /* Begin inner box */
2568 stresc(boxtitle, floor_name, 1, 0);
2569 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2570 wprintf("<span class=\"ib_roomlist_floor\">%s</span><br>\n", boxtitle);
2577 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2578 if (fold[i].selectable) {
2579 wprintf("<a href=\"dotgoto?room=");
2580 urlescputs(fold[i].room);
2586 if (fold[i].hasnewmsgs) {
2587 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2590 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2592 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2595 if (fold[i].selectable) {
2601 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2602 wprintf(" (INBOX)");
2604 wprintf("<br />\n");
2612 * Show the room list. (only should get called by
2613 * knrooms() because that's where output_headers() is called from)
2616 void list_all_rooms_by_floor(char *viewpref) {
2619 struct folder *fold = NULL;
2621 int max_folders = 0;
2622 int alloc_folders = 0;
2626 int num_floors = 1; /* add an extra one for private folders */
2630 /* Start with the mailboxes */
2633 fold = malloc(sizeof(struct folder));
2634 memset(fold, 0, sizeof(struct folder));
2635 strcpy(fold[0].name, "My folders");
2636 fold[0].is_mailbox = 1;
2638 /* Then add floors */
2640 serv_getln(buf, sizeof buf);
2641 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2642 if (max_folders >= alloc_folders) {
2643 alloc_folders = max_folders + 100;
2644 fold = realloc(fold,
2645 alloc_folders * sizeof(struct folder));
2647 memset(&fold[max_folders], 0, sizeof(struct folder));
2648 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2655 serv_getln(buf, sizeof buf);
2656 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2657 if (max_folders >= alloc_folders) {
2658 alloc_folders = max_folders + 100;
2659 fold = realloc(fold,
2660 alloc_folders * sizeof(struct folder));
2662 memset(&fold[max_folders], 0, sizeof(struct folder));
2663 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2664 ra_flags = extract_int(buf, 5);
2665 flags = extract_int(buf, 1);
2666 fold[max_folders].floor = extract_int(buf, 2);
2667 fold[max_folders].hasnewmsgs =
2668 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2669 if (flags & QR_MAILBOX) {
2670 fold[max_folders].is_mailbox = 1;
2672 fold[max_folders].view = extract_int(buf, 6);
2673 room_to_folder(fold[max_folders].name,
2674 fold[max_folders].room,
2675 fold[max_folders].floor,
2676 fold[max_folders].is_mailbox);
2677 fold[max_folders].selectable = 1;
2681 /* Bubble-sort the folder list */
2682 for (i=0; i<max_folders; ++i) {
2683 for (j=0; j<(max_folders-1)-i; ++j) {
2684 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2685 swap = strcasecmp(fold[j].name, fold[j+1].name);
2688 if ( (fold[j+1].is_mailbox)
2689 && (!fold[j].is_mailbox)) {
2697 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2698 memcpy(&fold[j], &fold[j+1],
2699 sizeof(struct folder));
2700 memcpy(&fold[j+1], &ftmp,
2701 sizeof(struct folder));
2707 if (!strcasecmp(viewpref, "folders")) {
2708 do_folder_view(fold, max_folders, num_floors);
2710 else if (!strcasecmp(viewpref, "hackish_view")) {
2711 for (i=0; i<max_folders; ++i) {
2712 escputs(fold[i].name);
2713 wprintf("<br />\n");
2716 else if (!strcasecmp(viewpref, "iconbar")) {
2717 do_iconbar_view(fold, max_folders, num_floors);
2720 do_rooms_view(fold, max_folders, num_floors);
2727 /* Do either a known rooms list or a folders list, depending on the
2731 char listviewpref[SIZ];
2733 output_headers(1, 1, 2, 0, 0, 0);
2735 /* Determine whether the user is trying to change views */
2736 if (bstr("view") != NULL) {
2737 if (strlen(bstr("view")) > 0) {
2738 set_preference("roomlistview", bstr("view"), 1);
2742 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2744 if ( (strcasecmp(listviewpref, "folders"))
2745 && (strcasecmp(listviewpref, "table")) ) {
2746 strcpy(listviewpref, "rooms");
2750 wprintf("<div id=\"banner\">\n"
2751 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2752 "<SPAN CLASS=\"titlebar\">"
2754 if (!strcasecmp(listviewpref, "rooms")) {
2755 wprintf("Room list");
2757 if (!strcasecmp(listviewpref, "folders")) {
2758 wprintf("Folder list");
2760 if (!strcasecmp(listviewpref, "table")) {
2761 wprintf("Room list");
2763 wprintf("</SPAN></TD>\n");
2765 /* offer the ability to switch views */
2766 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2767 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2768 "OnChange=\"location.href=roomlistomatic.newview.options"
2769 "[selectedIndex].value\">\n");
2771 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
2774 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2777 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
2778 "View as folder list"
2780 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2783 wprintf("</SELECT><br />");
2785 wprintf("</FORM></TD></TR></TABLE>\n");
2788 "<div id=\"content\">\n");
2790 /* Display the room list in the user's preferred format */
2791 list_all_rooms_by_floor(listviewpref);
2798 * Set the message expire policy for this room and/or floor
2800 void set_room_policy(void) {
2803 if (strlen(bstr("ok_button")) == 0) {
2804 strcpy(WC->ImportantMessage,
2805 _("Cancelled. Changes were not saved."));
2810 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2811 serv_getln(buf, sizeof buf);
2812 strcpy(WC->ImportantMessage, &buf[4]);
2814 if (WC->axlevel >= 6) {
2815 strcat(WC->ImportantMessage, "<br />\n");
2816 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2817 serv_getln(buf, sizeof buf);
2818 strcat(WC->ImportantMessage, &buf[4]);