4 * Lots of different room-related operations.
28 char floorlist[128][SIZ];
31 * load the list of floors
33 void load_floorlist(void)
38 for (a = 0; a < 128; ++a)
42 serv_getln(buf, sizeof buf);
44 strcpy(floorlist[0], "Main Floor");
47 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
48 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
54 * remove a room from the march list
56 void remove_march(char *aaa)
58 struct march *mptr, *mptr2;
60 if (WC->march == NULL)
63 if (!strcasecmp(WC->march->march_name, aaa)) {
64 mptr = WC->march->next;
70 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
71 if (!strcasecmp(mptr->march_name, aaa)) {
72 mptr2->next = mptr->next;
85 void room_tree_list(struct roomlisting *rp)
94 room_tree_list(rp->lnext);
96 strcpy(rmname, rp->rlname);
99 wprintf("<A HREF=\"/dotgoto&room=");
103 escputs1(rmname, 1, 1);
104 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
106 else if (f & QR_DIRECTORY)
108 else if (f & QR_NETWORK)
112 wprintf("</A><TT> </TT>\n");
114 room_tree_list(rp->rnext);
120 * Room ordering stuff (compare first by floor, then by order)
122 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
124 if ((r1 == NULL) && (r2 == NULL))
130 if (r1->rlfloor < r2->rlfloor)
132 if (r1->rlfloor > r2->rlfloor)
134 if (r1->rlorder < r2->rlorder)
136 if (r1->rlorder > r2->rlorder)
143 * Common code for all room listings
145 void listrms(char *variety)
150 struct roomlisting *rl = NULL;
151 struct roomlisting *rp;
152 struct roomlisting *rs;
155 /* Ask the server for a room list */
157 serv_getln(buf, sizeof buf);
162 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
164 rp = malloc(sizeof(struct roomlisting));
165 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
166 rp->rlflags = extract_int(buf, 1);
167 rp->rlfloor = extract_int(buf, 2);
168 rp->rlorder = extract_int(buf, 3);
177 if (rordercmp(rp, rs) < 0) {
178 if (rs->lnext == NULL) {
185 if (rs->rnext == NULL) {
197 /* If no rooms were listed, print an nbsp to make the cell
198 * borders show up anyway.
200 if (num_rooms == 0) wprintf(" ");
205 * list all forgotten rooms
207 void zapped_list(void)
209 output_headers(1, 1, 0, 0, 0, 0);
211 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
212 do_template("beginbox");
216 wprintf("<br /><br />\n");
217 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
218 do_template("endbox");
224 * read this room's info file (set v to 1 for verbose mode)
231 serv_getln(buf, sizeof buf);
240 /* Display room banner icon. The server doesn't actually
241 * need the room name, but we supply it in order to
242 * keep the browser from using a cached icon from
245 void embed_room_graphic(void) {
248 serv_puts("OIMG _roompic_");
249 serv_getln(buf, sizeof buf);
251 wprintf("<IMG HEIGHT=64 SRC=\"/image&name=_roompic_&room=");
252 urlescputs(WC->wc_roomname);
255 serv_getln(buf, sizeof buf);
257 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
258 wprintf("<img height=48 width=48 src=\""
259 "static/viewcontacts_48x.gif"
263 else if (WC->wc_view == VIEW_CALENDAR) {
264 wprintf("<img height=48 width=48 src=\""
265 "static/calarea_48x.gif"
269 else if (WC->wc_view == VIEW_TASKS) {
270 wprintf("<img height=48 width=48 src=\""
271 "static/taskmanag_48x.gif"
275 else if (WC->wc_view == VIEW_NOTES) {
276 wprintf("<img height=48 width=48 src=\""
277 "static/storenotes_48x.gif"
281 else if (WC->wc_view == VIEW_MAILBOX) {
282 wprintf("<img height=48 width=48 src=\""
283 "static/privatemess_48x.gif"
288 wprintf("<img height=48 width=48 src=\""
289 "static/chatrooms_48x.gif"
297 /* Let the user know if new mail has arrived
299 void embed_newmail_button(void) {
300 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
302 "<A HREF=\"/dotgoto?room=_MAIL_\">"
303 "<IMG SRC=\"/static/privatemess_32x.gif\" border=0 "
305 wprintf(_("You have new mail"));
307 "<br /><SPAN CLASS=\"youhavemail\">");
308 wprintf(_("%d new mail"), WC->new_mail);
309 wprintf("</SPAN></A>");
310 WC->remember_new_mail = WC->new_mail;
317 * Display the current view and offer an option to change it
319 void embed_view_o_matic(void) {
322 wprintf("<form name=\"viewomatic\" action=\"/changeview\">\n"
323 "<span class=\"room_banner_new_messages\">View as: "
324 "<SELECT NAME=\"newview\" SIZE=\"1\" "
325 "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif;"
326 " font-size: 7pt; background: #444455; color: #ddddcc;\" "
327 "OnChange=\"location.href=viewomatic.newview.options"
328 "[selectedIndex].value\">\n");
330 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
332 * Only offer the views that make sense, given the default
333 * view for the room. For example, don't offer a Calendar
334 * view in a non-Calendar room.
338 || (i == WC->wc_default_view)
339 || ( (i == 0) && (WC->wc_default_view == 1) )
340 || ( (i == 1) && (WC->wc_default_view == 0) )
343 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
344 ((i == WC->wc_view) ? "SELECTED" : ""),
346 escputs(viewdefs[i]);
347 wprintf("</OPTION>\n");
350 wprintf("</select></span></form>\n");
355 void embed_room_banner(char *got, int navbar_style) {
358 /* We need to have the information returned by a GOTO server command.
359 * If it isn't supplied, we fake it by issuing our own GOTO.
362 serv_printf("GOTO %s", WC->wc_roomname);
363 serv_getln(fakegot, sizeof fakegot);
367 /* If the user happens to select the "make this my start page" link,
368 * we want it to remember the URL as a "/dotskip" one instead of
369 * a "skip" or "gotonext" or something like that.
371 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
374 /* Check for new mail. */
375 WC->new_mail = extract_int(&got[4], 9);
376 WC->wc_view = extract_int(&got[4], 11);
378 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
379 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
380 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
381 svcallback("ROOMPIC", embed_room_graphic);
382 svcallback("ROOMINFO", readinfo);
383 svcallback("YOUHAVEMAIL", embed_newmail_button);
384 svcallback("VIEWOMATIC", embed_view_o_matic);
385 svcallback("START", offer_start_page);
387 do_template("roombanner");
388 if (navbar_style != navbar_none) {
390 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
391 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
394 if (navbar_style == navbar_default) wprintf(
396 "<a href=\"/ungoto\">"
397 "<img align=\"middle\" src=\"/static/ungoto2_24x.gif\" border=\"0\">"
398 "<span class=\"navbar_link\">%s</span></A>"
399 "</td>\n", _("Ungoto")
402 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
405 "<A HREF=\"/readnew\">"
406 "<img align=\"middle\" src=\"/static/newmess2_24x.gif\" border=\"0\">"
407 "<span class=\"navbar_link\">%s</span></A>"
408 "</td>\n", _("Read new messages")
412 if (navbar_style == navbar_default) {
413 switch(WC->wc_view) {
414 case VIEW_ADDRESSBOOK:
417 "<A HREF=\"/readfwd\">"
418 "<img align=\"middle\" src=\"/static/viewcontacts_24x.gif\" "
420 "<span class=\"navbar_link\">"
422 "</span></a></td>\n", _("View contacts")
428 "<A HREF=\"/readfwd?calview=day\">"
429 "<img align=\"middle\" src=\"/static/taskday2_24x.gif\" "
431 "<span class=\"navbar_link\">"
433 "</span></a></td>\n", _("Day view")
437 "<A HREF=\"/readfwd?calview=month\">"
438 "<img align=\"middle\" src=\"/static/monthview2_24x.gif\" "
440 "<span class=\"navbar_link\">"
442 "</span></a></td>\n", _("Month view")
448 "<A HREF=\"/readfwd\">"
449 "<img align=\"middle\" src=\"/static/taskmanag_24x.gif\" "
451 "<span class=\"navbar_link\">"
453 "</span></a></td>\n", _("View tasks")
459 "<A HREF=\"/readfwd\">"
460 "<img align=\"middle\" src=\"/static/viewnotes_24x.gif\" "
462 "<span class=\"navbar_link\">"
464 "</span></a></td>\n", _("View notes")
470 "<A HREF=\"/readfwd\">"
471 "<img align=\"middle\" src=\"/static/readallmess3_24x.gif\" "
473 "<span class=\"navbar_link\">"
475 "</span></a></td>\n", _("View message list")
481 "<A HREF=\"/readfwd\">"
482 "<img align=\"middle\" src=\"/static/readallmess3_24x.gif\" "
484 "<span class=\"navbar_link\">"
486 "</span></a></td>\n", _("Read all messages")
492 if (navbar_style == navbar_default) {
493 switch(WC->wc_view) {
494 case VIEW_ADDRESSBOOK:
496 "<td><A HREF=\"/display_enter\">"
497 "<img align=\"middle\" src=\"/static/addnewcontact_24x.gif\" "
498 "border=\"0\"><span class=\"navbar_link\">"
500 "</span></a></td>\n", _("Add new contact")
505 "<td><A HREF=\"/display_enter\">"
506 "<img align=\"middle\" src=\"/static/addevent_24x.gif\" "
507 "border=\"0\"><span class=\"navbar_link\">"
509 "</span></a></td>\n", _("Add new event")
514 "<td><A HREF=\"/display_enter\">"
515 "<img align=\"middle\" src=\"/static/newmess3_24x.gif\" "
516 "border=\"0\"><span class=\"navbar_link\">"
518 "</span></a></td>\n", _("Add new task")
523 "<td><A HREF=\"/display_enter\">"
524 "<img align=\"middle\" src=\"/static/enternewnote_24x.gif\" "
525 "border=\"0\"><span class=\"navbar_link\">"
527 "</span></a></td>\n", _("Add new note")
532 "<td><A HREF=\"/display_enter\">"
533 "<img align=\"middle\" src=\"/static/newmess3_24x.gif\" "
534 "border=\"0\"><span class=\"navbar_link\">"
536 "</span></a></td>\n", _("Enter a message")
542 if (navbar_style == navbar_default) wprintf(
546 "<img align=\"middle\" src=\"/static/skipthisroom_24x.gif\" border=\"0\">"
547 "<span class=\"navbar_link\">%s</span></a>"
549 _("Leave all messages marked as unread, go to next room with unread messages"),
553 if (navbar_style == navbar_default) wprintf(
555 "<A HREF=\"/gotonext\" "
557 "<img align=\"middle\" src=\"/static/markngo_24x.gif\" border=\"0\">"
558 "<span class=\"navbar_link\">%s</span></a>"
560 _("Mark all messages as read, go to next room with unread messages"),
564 wprintf("</tr></table></div>\n");
574 * back end routine to take the session to a new room
577 int gotoroom(char *gname)
580 static long ls = (-1L);
583 /* store ungoto information */
584 strcpy(WC->ugname, WC->wc_roomname);
587 /* move to the new room */
588 serv_printf("GOTO %s", gname);
589 serv_getln(buf, sizeof buf);
593 serv_puts("GOTO _BASEROOM_");
594 serv_getln(buf, sizeof buf);
601 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
602 WC->room_flags = extract_int(&buf[4], 4);
603 /* highest_msg_read = extract_int(&buf[4],6);
604 maxmsgnum = extract_int(&buf[4],5);
605 is_mail = (char) extract_int(&buf[4],7); */
606 ls = extract_long(&buf[4], 6);
607 WC->wc_floor = extract_int(&buf[4], 10);
608 WC->wc_view = extract_int(&buf[4], 11);
609 WC->wc_default_view = extract_int(&buf[4], 12);
612 WC->is_room_aide = WC->is_aide;
614 WC->is_room_aide = (char) extract_int(&buf[4], 8);
616 remove_march(WC->wc_roomname);
617 if (!strcasecmp(gname, "_BASEROOM_"))
625 * Locate the room on the march list which we most want to go to. Each room
626 * is measured given a "weight" of preference based on various factors.
628 char *pop_march(int desired_floor)
630 static char TheRoom[128];
632 int TheOrder = 32767;
635 struct march *mptr = NULL;
637 strcpy(TheRoom, "_BASEROOM_");
638 if (WC->march == NULL)
641 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
643 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
644 weight = weight + 10000;
645 if (mptr->march_floor == desired_floor)
646 weight = weight + 5000;
648 weight = weight + ((128 - (mptr->march_floor)) * 128);
649 weight = weight + (128 - (mptr->march_order));
651 if (weight > TheWeight) {
653 strcpy(TheRoom, mptr->march_name);
654 TheFloor = mptr->march_floor;
655 TheOrder = mptr->march_order;
663 /* Goto next room having unread messages.
664 * We want to skip over rooms that the user has already been to, and take the
665 * user back to the lobby when done. The room we end up in is placed in
666 * newroom - which is set to 0 (the lobby) initially.
667 * We start the search in the current room rather than the beginning to prevent
668 * two or more concurrent users from dragging each other back to the same room.
673 struct march *mptr, *mptr2;
676 /* First check to see if the march-mode list is already allocated.
677 * If it is, pop the first room off the list and go there.
680 if (WC->march == NULL) {
682 serv_getln(buf, sizeof buf);
684 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
685 mptr = (struct march *) malloc(sizeof(struct march));
687 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
688 mptr->march_floor = extract_int(buf, 2);
689 mptr->march_order = extract_int(buf, 3);
690 if (WC->march == NULL) {
694 while (mptr2->next != NULL)
699 /* add _BASEROOM_ to the end of the march list, so the user will end up
700 * in the system base room (usually the Lobby>) at the end of the loop
702 mptr = (struct march *) malloc(sizeof(struct march));
704 strcpy(mptr->march_name, "_BASEROOM_");
705 if (WC->march == NULL) {
709 while (mptr2->next != NULL)
714 * ...and remove the room we're currently in, so a <G>oto doesn't make us
715 * walk around in circles
717 remove_march(WC->wc_roomname);
719 if (WC->march != NULL) {
720 strcpy(next_room, pop_march(-1));
722 strcpy(next_room, "_BASEROOM_");
726 smart_goto(next_room);
730 void smart_goto(char *next_room) {
738 * mark all messages in current room as having been read
740 void slrp_highest(void)
745 serv_puts("SLRP HIGHEST");
746 serv_getln(buf, sizeof buf);
748 wprintf("<EM>%s</EM><br />\n", &buf[4]);
755 * un-goto the previous room
761 if (!strcmp(WC->ugname, "")) {
762 smart_goto(WC->wc_roomname);
765 serv_printf("GOTO %s", WC->ugname);
766 serv_getln(buf, sizeof buf);
768 smart_goto(WC->wc_roomname);
771 if (WC->uglsn >= 0L) {
772 serv_printf("SLRP %ld", WC->uglsn);
773 serv_getln(buf, sizeof buf);
775 strcpy(buf, WC->ugname);
776 strcpy(WC->ugname, "");
785 * Set/clear/read the "self-service list subscribe" flag for a room
787 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
788 * Always returns the new value.
791 int self_service(int newval) {
792 int current_value = 0;
798 int flags, floor, order, view, flags2;
801 serv_getln(buf, sizeof buf);
802 if (buf[0] != '2') return(0);
804 extract_token(name, &buf[4], 0, '|', sizeof name);
805 extract_token(password, &buf[4], 1, '|', sizeof password);
806 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
807 flags = extract_int(&buf[4], 3);
808 floor = extract_int(&buf[4], 4);
809 order = extract_int(&buf[4], 5);
810 view = extract_int(&buf[4], 6);
811 flags2 = extract_int(&buf[4], 7);
813 if (flags2 & QR2_SELFLIST) {
821 flags2 = flags2 | QR2_SELFLIST;
823 else if (newval == 0) {
824 flags2 = flags2 & ~QR2_SELFLIST;
827 return(current_value);
830 if (newval != current_value) {
831 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
832 name, password, dirname, flags,
833 floor, order, view, flags2);
834 serv_getln(buf, sizeof buf);
847 * display the form for editing a room
849 void display_editroom(void)
854 char remote_room[SIZ];
857 char er_password[10];
859 char er_roomaide[26];
865 char *not_shared_with;
872 if (strlen(tab) == 0) tab = "admin";
876 serv_getln(buf, sizeof buf);
879 strcpy(WC->ImportantMessage, &buf[4]);
883 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
884 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
885 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
886 er_flags = extract_int(&buf[4], 3);
887 er_floor = extract_int(&buf[4], 4);
889 output_headers(1, 1, 1, 0, 0, 0);
891 /* print the tabbed dialog */
893 "<div id=\"fix_scrollbar_bug\">"
894 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
896 "<TD> </TD>\n");
898 if (!strcmp(tab, "admin")) {
899 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
902 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
904 wprintf(_("Administration"));
905 if (!strcmp(tab, "admin")) {
906 wprintf("</SPAN></TD>\n");
909 wprintf("</A></TD>\n");
912 wprintf("<TD> </TD>\n");
914 if (!strcmp(tab, "config")) {
915 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
918 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
920 wprintf(_("Configuration"));
921 if (!strcmp(tab, "config")) {
922 wprintf("</SPAN></TD>\n");
925 wprintf("</A></TD>\n");
928 wprintf("<TD> </TD>\n");
930 if (!strcmp(tab, "expire")) {
931 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
934 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
936 wprintf(_("Message expire policy"));
937 if (!strcmp(tab, "expire")) {
938 wprintf("</SPAN></TD>\n");
941 wprintf("</A></TD>\n");
944 wprintf("<TD> </TD>\n");
946 if (!strcmp(tab, "access")) {
947 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
950 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=access\">");
952 wprintf(_("Access controls"));
953 if (!strcmp(tab, "access")) {
954 wprintf("</SPAN></TD>\n");
957 wprintf("</A></TD>\n");
960 wprintf("<TD> </TD>\n");
962 if (!strcmp(tab, "sharing")) {
963 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
966 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
968 wprintf(_("Sharing"));
969 if (!strcmp(tab, "sharing")) {
970 wprintf("</SPAN></TD>\n");
973 wprintf("</A></TD>\n");
976 wprintf("<TD> </TD>\n");
978 if (!strcmp(tab, "listserv")) {
979 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
982 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
984 wprintf(_("Mailing list service"));
985 if (!strcmp(tab, "listserv")) {
986 wprintf("</SPAN></TD>\n");
989 wprintf("</A></TD>\n");
992 wprintf("<TD> </TD>\n");
994 wprintf("</TR></TABLE></div>\n");
995 /* end tabbed dialog */
997 /* begin content of whatever tab is open now */
998 wprintf("<div id=\"fix_scrollbar_bug\">"
999 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
1002 if (!strcmp(tab, "admin")) {
1004 "<LI><A HREF=\"/delete_room\" "
1005 "onClick=\"return confirm('");
1006 wprintf(_("Are you sure you want to delete this room?"));
1007 wprintf("');\">\n");
1008 wprintf(_("Delete this room"));
1010 "<LI><A HREF=\"/display_editroompic\">\n");
1011 wprintf(_("Set or change the icon for this room's banner"));
1013 "<LI><A HREF=\"/display_editinfo\">\n");
1014 wprintf(_("Edit this room's Info file"));
1019 if (!strcmp(tab, "config")) {
1020 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
1022 wprintf("<UL><LI>");
1023 wprintf(_("Name of room: "));
1024 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1030 wprintf(_("Resides on floor: "));
1031 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1032 for (i = 0; i < 128; ++i)
1033 if (strlen(floorlist[i]) > 0) {
1034 wprintf("<OPTION ");
1036 wprintf("SELECTED ");
1037 wprintf("VALUE=\"%d\">", i);
1038 escputs(floorlist[i]);
1039 wprintf("</OPTION>\n");
1041 wprintf("</SELECT>\n");
1044 wprintf(_("Type of room:"));
1047 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1048 if ((er_flags & QR_PRIVATE) == 0)
1049 wprintf("CHECKED ");
1051 wprintf(_("Public room"));
1054 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1055 if ((er_flags & QR_PRIVATE) &&
1056 (er_flags & QR_GUESSNAME))
1057 wprintf("CHECKED ");
1059 wprintf(_("Private - guess name"));
1061 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1062 if ((er_flags & QR_PRIVATE) &&
1063 (er_flags & QR_PASSWORDED))
1064 wprintf("CHECKED ");
1066 wprintf(_("Private - require password:"));
1067 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1070 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1071 if ((er_flags & QR_PRIVATE)
1072 && ((er_flags & QR_GUESSNAME) == 0)
1073 && ((er_flags & QR_PASSWORDED) == 0))
1074 wprintf("CHECKED ");
1076 wprintf(_("Private - invitation only"));
1078 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1080 wprintf(_("If private, cause current users to forget room"));
1082 wprintf("\n</UL>\n");
1084 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1085 if (er_flags & QR_PREFONLY)
1086 wprintf("CHECKED ");
1088 wprintf(_("Preferred users only"));
1090 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1091 if (er_flags & QR_READONLY)
1092 wprintf("CHECKED ");
1094 wprintf(_("Read-only room"));
1096 /* directory stuff */
1097 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1098 if (er_flags & QR_DIRECTORY)
1099 wprintf("CHECKED ");
1101 wprintf(_("File directory room"));
1103 wprintf("\n<UL><LI>");
1104 wprintf(_("Directory name: "));
1105 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1108 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1109 if (er_flags & QR_UPLOAD)
1110 wprintf("CHECKED ");
1112 wprintf(_("Uploading allowed"));
1114 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1115 if (er_flags & QR_DOWNLOAD)
1116 wprintf("CHECKED ");
1118 wprintf(_("Downloading allowed"));
1120 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1121 if (er_flags & QR_VISDIR)
1122 wprintf("CHECKED ");
1124 wprintf(_("Visible directory"));
1127 /* end of directory stuff */
1129 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1130 if (er_flags & QR_NETWORK)
1131 wprintf("CHECKED ");
1133 wprintf(_("Network shared room"));
1135 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1136 if (er_flags & QR_PERMANENT)
1137 wprintf("CHECKED ");
1139 wprintf(_("Permanent (does not auto-purge)"));
1141 /* start of anon options */
1144 wprintf(_("Anonymous messages"));
1147 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1148 if (((er_flags & QR_ANONONLY) == 0)
1149 && ((er_flags & QR_ANONOPT) == 0))
1150 wprintf("CHECKED ");
1152 wprintf(_("No anonymous messages"));
1154 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1155 if (er_flags & QR_ANONONLY)
1156 wprintf("CHECKED ");
1158 wprintf(_("All messages are anonymous"));
1160 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1161 if (er_flags & QR_ANONOPT)
1162 wprintf("CHECKED ");
1164 wprintf(_("Prompt user when entering messages"));
1167 /* end of anon options */
1170 wprintf(_("Room aide: "));
1172 serv_getln(buf, sizeof buf);
1173 if (buf[0] != '2') {
1174 wprintf("<EM>%s</EM>\n", &buf[4]);
1176 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1177 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1180 wprintf("</UL><CENTER>\n");
1181 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1182 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1184 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1192 /* Sharing the room with other Citadel nodes... */
1193 if (!strcmp(tab, "sharing")) {
1195 shared_with = strdup("");
1196 not_shared_with = strdup("");
1198 /* Learn the current configuration */
1199 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1200 serv_getln(buf, sizeof buf);
1201 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1202 extract_token(node, buf, 0, '|', sizeof node);
1203 not_shared_with = realloc(not_shared_with,
1204 strlen(not_shared_with) + 32);
1205 strcat(not_shared_with, node);
1206 strcat(not_shared_with, "\n");
1210 serv_getln(buf, sizeof buf);
1211 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1212 extract_token(cmd, buf, 0, '|', sizeof cmd);
1213 extract_token(node, buf, 1, '|', sizeof node);
1214 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1215 if (!strcasecmp(cmd, "ignet_push_share")) {
1216 shared_with = realloc(shared_with,
1217 strlen(shared_with) + 32);
1218 strcat(shared_with, node);
1219 if (strlen(remote_room) > 0) {
1220 strcat(shared_with, "|");
1221 strcat(shared_with, remote_room);
1223 strcat(shared_with, "\n");
1227 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1228 extract_token(buf, shared_with, i, '\n', sizeof buf);
1229 extract_token(node, buf, 0, '|', sizeof node);
1230 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1231 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1232 if (!strcasecmp(node, cmd)) {
1233 remove_token(not_shared_with, j, '\n');
1238 /* Display the stuff */
1239 wprintf("<CENTER><br />"
1240 "<TABLE border=1 cellpadding=5><TR>"
1242 wprintf(_("Shared with"));
1243 wprintf("</I></B></TD>"
1245 wprintf(_("Not shared with"));
1246 wprintf("</I></B></TD></TR>\n"
1247 "<TR><TD VALIGN=TOP>\n");
1249 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1250 wprintf(_("Remote node name"));
1251 wprintf("</TD><TD>");
1252 wprintf(_("Remote room name"));
1253 wprintf("</TD><TD>");
1254 wprintf(_("Actions"));
1255 wprintf("</TD></TR>\n");
1257 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1258 extract_token(buf, shared_with, i, '\n', sizeof buf);
1259 extract_token(node, buf, 0, '|', sizeof node);
1260 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1261 if (strlen(node) > 0) {
1262 wprintf("<FORM METHOD=\"POST\" "
1263 "ACTION=\"/netedit\">"
1264 "<TR><TD>%s</TD>\n", node);
1267 if (strlen(remote_room) > 0) {
1268 escputs(remote_room);
1274 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1275 "VALUE=\"ignet_push_share|");
1277 if (strlen(remote_room) > 0) {
1279 urlescputs(remote_room);
1282 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1283 "VALUE=\"sharing\">\n");
1284 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1285 "VALUE=\"remove\">\n");
1286 wprintf("<INPUT TYPE=\"submit\" "
1287 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1288 wprintf("</TD></TR></FORM>\n");
1292 wprintf("</TABLE>\n");
1293 wprintf("</TD><TD VALIGN=TOP>\n");
1294 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1295 wprintf(_("Remote node name"));
1296 wprintf("</TD><TD>");
1297 wprintf(_("Remote room name"));
1298 wprintf("</TD><TD>");
1299 wprintf(_("Actions"));
1300 wprintf("</TD></TR>\n");
1302 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1303 extract_token(node, not_shared_with, i, '\n', sizeof node);
1304 if (strlen(node) > 0) {
1305 wprintf("<FORM METHOD=\"POST\" "
1306 "ACTION=\"/netedit\">"
1310 "<INPUT TYPE=\"INPUT\" "
1314 wprintf("<INPUT TYPE=\"hidden\" "
1316 "VALUE=\"ignet_push_share|");
1319 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1320 "VALUE=\"sharing\">\n");
1321 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1322 "VALUE=\"add\">\n");
1323 wprintf("<INPUT TYPE=\"submit\" "
1324 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1325 wprintf("</TD></TR></FORM>\n");
1329 wprintf("</TABLE>\n");
1330 wprintf("</TD></TR>"
1331 "</TABLE></CENTER><br />\n"
1332 "<I><B>%s</B><UL><LI>", _("Notes:"));
1333 wprintf(_("When sharing a room, "
1334 "it must be shared from both ends. Adding a node to "
1335 "the 'shared' list sends messages out, but in order to"
1336 " receive messages, the other nodes must be configured"
1337 " to send messages out to your system as well. "
1338 "<LI>If the remote room name is blank, it is assumed "
1339 "that the room name is identical on the remote node."
1340 "<LI>If the remote room name is different, the remote "
1341 "node must also configure the name of the room here."
1347 /* Mailing list management */
1348 if (!strcmp(tab, "listserv")) {
1350 wprintf("<br /><center>"
1351 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1352 "<TR><TD VALIGN=TOP>");
1354 wprintf(_("<i>The contents of this room are being "
1355 "mailed <b>as individual messages</b> "
1356 "to the following list recipients:"
1357 "</i><br /><br />\n"));
1360 serv_getln(buf, sizeof buf);
1361 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1362 extract_token(cmd, buf, 0, '|', sizeof cmd);
1363 if (!strcasecmp(cmd, "listrecp")) {
1364 extract_token(recp, buf, 1, '|', sizeof recp);
1367 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1370 wprintf("&tab=listserv\">");
1371 wprintf(_("(remove)"));
1372 wprintf("</A><br />");
1375 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1376 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1377 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1378 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1379 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1380 wprintf("</FORM>\n");
1382 wprintf("</TD><TD VALIGN=TOP>\n");
1384 wprintf(_("<i>The contents of this room are being "
1385 "mailed <b>in digest form</b> "
1386 "to the following list recipients:"
1387 "</i><br /><br />\n"));
1390 serv_getln(buf, sizeof buf);
1391 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1392 extract_token(cmd, buf, 0, '|', sizeof cmd);
1393 if (!strcasecmp(cmd, "digestrecp")) {
1394 extract_token(recp, buf, 1, '|', sizeof recp);
1397 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1400 wprintf("&tab=listserv\">");
1401 wprintf(_("(remove)"));
1402 wprintf("</A><br />");
1405 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1406 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1407 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1408 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1409 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1410 wprintf("</FORM>\n");
1412 wprintf("</TD></TR></TABLE><hr />\n");
1414 if (self_service(999) == 1) {
1415 wprintf(_("This room is configured to allow "
1416 "self-service subscribe/unsubscribe requests."));
1417 wprintf("<A HREF=\"/toggle_self_service?newval=0&tab=listserv\">");
1418 wprintf(_("Click to disable."));
1419 wprintf("</A><br />\n");
1420 wprintf(_("The URL for subscribe/unsubscribe is: "));
1421 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1422 (is_https ? "https" : "http"),
1426 wprintf(_("This room is <i>not</i> configured to allow "
1427 "self-service subscribe/unsubscribe requests."));
1428 wprintf(" <A HREF=\"/toggle_self_service?newval=1&"
1430 wprintf(_("Click to enable."));
1431 wprintf("</A><br />\n");
1435 wprintf("</CENTER>\n");
1439 /* Mailing list management */
1440 if (!strcmp(tab, "expire")) {
1442 serv_puts("GPEX room");
1443 serv_getln(buf, sizeof buf);
1444 if (buf[0] == '2') {
1445 roompolicy = extract_int(&buf[4], 0);
1446 roomvalue = extract_int(&buf[4], 1);
1449 serv_puts("GPEX floor");
1450 serv_getln(buf, sizeof buf);
1451 if (buf[0] == '2') {
1452 floorpolicy = extract_int(&buf[4], 0);
1453 floorvalue = extract_int(&buf[4], 1);
1456 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1457 wprintf("<TABLE border=0 cellspacing=5>\n");
1458 wprintf("<TR><TD>");
1459 wprintf(_("Message expire policy for this room"));
1461 escputs(WC->wc_roomname);
1462 wprintf(")</TD><TD>");
1463 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1464 ((roompolicy == 0) ? "CHECKED" : "") );
1465 wprintf(_("Use the default policy for this floor"));
1466 wprintf("<br />\n");
1467 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1468 ((roompolicy == 1) ? "CHECKED" : "") );
1469 wprintf(_("Never automatically expire messages"));
1470 wprintf("<br />\n");
1471 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1472 ((roompolicy == 2) ? "CHECKED" : "") );
1473 wprintf("Expire by message count<br />\n");
1474 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1475 ((roompolicy == 3) ? "CHECKED" : "") );
1476 wprintf(_("Expire by message age"));
1478 wprintf(_("Number of messages or days: "));
1479 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1480 wprintf("</TD></TR>\n");
1482 if (WC->axlevel >= 6) {
1483 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1484 wprintf("<TR><TD>");
1485 wprintf(_("Message expire policy for this floor"));
1487 escputs(floorlist[WC->wc_floor]);
1488 wprintf(")</TD><TD>");
1489 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1490 ((floorpolicy == 0) ? "CHECKED" : "") );
1491 wprintf(_("Use the system default"));
1492 wprintf("<br />\n");
1493 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1494 ((floorpolicy == 1) ? "CHECKED" : "") );
1495 wprintf(_("Never automatically expire messages"));
1496 wprintf("<br />\n");
1497 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1498 ((floorpolicy == 2) ? "CHECKED" : "") );
1499 wprintf(_("Expire by message count"));
1500 wprintf("<br />\n");
1501 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1502 ((floorpolicy == 3) ? "CHECKED" : "") );
1503 wprintf(_("Expire by message age"));
1505 wprintf(_("Number of messages or days: "));
1506 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1510 wprintf("<CENTER>\n");
1511 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1512 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1514 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1515 wprintf("</CENTER></TD><TR>\n");
1517 wprintf("</TABLE>\n"
1518 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1524 /* Mailing list management */
1525 if (!strcmp(tab, "access")) {
1529 /* end content of whatever tab is open now */
1530 wprintf("</TD></TR></TABLE></div>\n");
1537 * Toggle self-service list subscription
1539 void toggle_self_service(void) {
1542 newval = atoi(bstr("newval"));
1543 self_service(newval);
1550 * save new parameters for a room
1556 char er_password[10];
1557 char er_dirname[15];
1558 char er_roomaide[26];
1564 if (strlen(bstr("ok_button")) == 0) {
1565 strcpy(WC->ImportantMessage,
1566 _("Cancelled. Changes were not saved."));
1571 serv_getln(buf, sizeof buf);
1573 if (buf[0] != '2') {
1574 strcpy(WC->ImportantMessage, &buf[4]);
1578 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1579 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1580 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1581 er_flags = extract_int(&buf[4], 3);
1583 strcpy(er_roomaide, bstr("er_roomaide"));
1584 if (strlen(er_roomaide) == 0) {
1586 serv_getln(buf, sizeof buf);
1587 if (buf[0] != '2') {
1588 strcpy(er_roomaide, "");
1590 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1593 strcpy(buf, bstr("er_name"));
1595 if (strlen(buf) > 0) {
1596 strcpy(er_name, buf);
1599 strcpy(buf, bstr("er_password"));
1601 if (strlen(buf) > 0)
1602 strcpy(er_password, buf);
1604 strcpy(buf, bstr("er_dirname"));
1606 if (strlen(buf) > 0)
1607 strcpy(er_dirname, buf);
1609 strcpy(buf, bstr("type"));
1610 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1612 if (!strcmp(buf, "invonly")) {
1613 er_flags |= (QR_PRIVATE);
1615 if (!strcmp(buf, "hidden")) {
1616 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1618 if (!strcmp(buf, "passworded")) {
1619 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1621 if (!strcmp(bstr("prefonly"), "yes")) {
1622 er_flags |= QR_PREFONLY;
1624 er_flags &= ~QR_PREFONLY;
1627 if (!strcmp(bstr("readonly"), "yes")) {
1628 er_flags |= QR_READONLY;
1630 er_flags &= ~QR_READONLY;
1633 if (!strcmp(bstr("permanent"), "yes")) {
1634 er_flags |= QR_PERMANENT;
1636 er_flags &= ~QR_PERMANENT;
1639 if (!strcmp(bstr("network"), "yes")) {
1640 er_flags |= QR_NETWORK;
1642 er_flags &= ~QR_NETWORK;
1645 if (!strcmp(bstr("directory"), "yes")) {
1646 er_flags |= QR_DIRECTORY;
1648 er_flags &= ~QR_DIRECTORY;
1651 if (!strcmp(bstr("ulallowed"), "yes")) {
1652 er_flags |= QR_UPLOAD;
1654 er_flags &= ~QR_UPLOAD;
1657 if (!strcmp(bstr("dlallowed"), "yes")) {
1658 er_flags |= QR_DOWNLOAD;
1660 er_flags &= ~QR_DOWNLOAD;
1663 if (!strcmp(bstr("visdir"), "yes")) {
1664 er_flags |= QR_VISDIR;
1666 er_flags &= ~QR_VISDIR;
1669 strcpy(buf, bstr("anon"));
1671 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1672 if (!strcmp(buf, "anononly"))
1673 er_flags |= QR_ANONONLY;
1674 if (!strcmp(buf, "anon2"))
1675 er_flags |= QR_ANONOPT;
1678 if (!strcmp(bstr("bump"), "yes"))
1681 er_floor = atoi(bstr("er_floor"));
1683 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1684 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1686 serv_getln(buf, sizeof buf);
1687 if (buf[0] != '2') {
1688 strcpy(WC->ImportantMessage, &buf[4]);
1694 if (strlen(er_roomaide) > 0) {
1695 sprintf(buf, "SETA %s", er_roomaide);
1697 serv_getln(buf, sizeof buf);
1698 if (buf[0] != '2') {
1699 strcpy(WC->ImportantMessage, &buf[4]);
1700 display_main_menu();
1705 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1712 * Display form for Invite, Kick, and show Who Knows a room
1714 void do_invt_kick(void) {
1715 char buf[SIZ], room[SIZ], username[SIZ];
1718 serv_getln(buf, sizeof buf);
1720 if (buf[0] != '2') {
1724 extract_token(room, &buf[4], 0, '|', sizeof room);
1726 strcpy(username, bstr("username"));
1728 if (strlen(bstr("kick_button")) > 0) {
1729 sprintf(buf, "KICK %s", username);
1731 serv_getln(buf, sizeof buf);
1733 if (buf[0] != '2') {
1734 strcpy(WC->ImportantMessage, &buf[4]);
1736 sprintf(WC->ImportantMessage,
1737 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1742 if (strlen(bstr("invite_button")) > 0) {
1743 sprintf(buf, "INVT %s", username);
1745 serv_getln(buf, sizeof buf);
1747 if (buf[0] != '2') {
1748 strcpy(WC->ImportantMessage, &buf[4]);
1750 sprintf(WC->ImportantMessage,
1751 _("<B><I>User %s invited to room %s.</I></B>\n"),
1762 * Display form for Invite, Kick, and show Who Knows a room
1764 void display_whok(void)
1766 char buf[SIZ], room[SIZ], username[SIZ];
1769 serv_getln(buf, sizeof buf);
1771 if (buf[0] != '2') {
1775 extract_token(room, &buf[4], 0, '|', sizeof room);
1778 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1779 wprintf(_("The users listed below have access to this room. "
1780 "To remove a user from the access list, select the user "
1781 "name from the list and click 'Kick'."));
1782 wprintf("<br /><br />");
1784 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1785 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1786 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1788 serv_getln(buf, sizeof buf);
1789 if (buf[0] == '1') {
1790 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1791 extract_token(username, buf, 0, '|', sizeof username);
1792 wprintf("<OPTION>");
1797 wprintf("</SELECT><br />\n");
1799 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1800 wprintf("</FORM></CENTER>\n");
1802 wprintf("</TD><TD>");
1803 wprintf(_("To grant another user access to this room, enter the "
1804 "user name in the box below and click 'Invite'."));
1805 wprintf("<br /><br />");
1807 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1808 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1809 wprintf("Invite: ");
1810 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1811 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1812 "<input type=\"submit\" value=\"%s\">"
1813 "</FORM></CENTER>\n", _("Invite"));
1815 wprintf("</TD></TR></TABLE>\n");
1822 * display the form for entering a new room
1824 void display_entroom(void)
1829 serv_puts("CRE8 0");
1830 serv_getln(buf, sizeof buf);
1832 if (buf[0] != '2') {
1833 strcpy(WC->ImportantMessage, &buf[4]);
1834 display_main_menu();
1838 output_headers(1, 1, 2, 0, 0, 0);
1839 wprintf("<div id=\"banner\">\n"
1840 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1841 "<SPAN CLASS=\"titlebar\">");
1842 wprintf(_("Create a new room"));
1844 "</TD></TR></TABLE>\n"
1845 "</div>\n<div id=\"content\">\n"
1848 wprintf("<div id=\"fix_scrollbar_bug\">"
1849 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1851 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"/entroom\">\n");
1853 wprintf("<UL><LI>");
1854 wprintf(_("Name of room: "));
1855 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1858 wprintf(_("Resides on floor: "));
1860 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1861 for (i = 0; i < 128; ++i)
1862 if (strlen(floorlist[i]) > 0) {
1863 wprintf("<OPTION ");
1864 wprintf("VALUE=\"%d\">", i);
1865 escputs(floorlist[i]);
1866 wprintf("</OPTION>\n");
1868 wprintf("</SELECT>\n");
1870 /* Our clever little snippet of JavaScript automatically selects
1871 * a public room if the view is set to Bulletin Board, and it
1872 * selects a mailbox room otherwise. The user can override this,
1876 wprintf(_("Default view for room: "));
1877 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1878 " if (this.form.er_view.value == 0) { "
1879 " this.form.type[0].checked=true; "
1880 " this.form.er_floor.disabled = false; "
1883 " this.form.type[4].checked=true; "
1884 " this.form.er_floor.disabled = true; "
1887 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1888 wprintf("<OPTION %s VALUE=\"%d\">",
1889 ((i == 0) ? "SELECTED" : ""), i );
1890 escputs(viewdefs[i]);
1891 wprintf("</OPTION>\n");
1893 wprintf("</SELECT>\n");
1896 wprintf(_("Type of room:"));
1899 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1900 wprintf("CHECKED OnChange=\""
1901 " if (this.form.type[0].checked == true) { "
1902 " this.form.er_floor.disabled = false; "
1905 wprintf(_("Public (automatically appears to everyone)"));
1907 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1908 " if (this.form.type[1].checked == true) { "
1909 " this.form.er_floor.disabled = false; "
1912 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1914 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1915 " if (this.form.type[2].checked == true) { "
1916 " this.form.er_floor.disabled = false; "
1919 wprintf(_("Private - require password: "));
1920 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1922 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1923 " if (this.form.type[3].checked == true) { "
1924 " this.form.er_floor.disabled = false; "
1927 wprintf(_("Private - invitation only"));
1929 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1931 " if (this.form.type[4].checked == true) { "
1932 " this.form.er_floor.disabled = true; "
1935 wprintf(_("Personal (mailbox for you only)"));
1937 wprintf("\n</UL>\n");
1939 wprintf("<CENTER>\n");
1940 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1942 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1943 wprintf("</CENTER>\n");
1944 wprintf("</FORM>\n<hr />");
1945 serv_printf("MESG roomaccess");
1946 serv_getln(buf, sizeof buf);
1947 if (buf[0] == '1') {
1950 wprintf("</td></tr></table></div>\n");
1958 * support function for entroom() -- sets the default view
1960 void er_set_default_view(int newview) {
1973 serv_getln(buf, sizeof buf);
1974 if (buf[0] != '2') return;
1976 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
1977 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
1978 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
1979 rm_bits1 = extract_int(&buf[4], 3);
1980 rm_floor = extract_int(&buf[4], 4);
1981 rm_listorder = extract_int(&buf[4], 5);
1982 rm_bits2 = extract_int(&buf[4], 7);
1984 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1985 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1986 rm_listorder, newview, rm_bits2
1988 serv_getln(buf, sizeof buf);
2001 char er_password[SIZ];
2006 if (strlen(bstr("ok_button")) == 0) {
2007 strcpy(WC->ImportantMessage,
2008 _("Cancelled. No new room was created."));
2009 display_main_menu();
2012 strcpy(er_name, bstr("er_name"));
2013 strcpy(er_type, bstr("type"));
2014 strcpy(er_password, bstr("er_password"));
2015 er_floor = atoi(bstr("er_floor"));
2016 er_view = atoi(bstr("er_view"));
2019 if (!strcmp(er_type, "hidden"))
2021 if (!strcmp(er_type, "passworded"))
2023 if (!strcmp(er_type, "invonly"))
2025 if (!strcmp(er_type, "personal"))
2028 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2029 er_name, er_num_type, er_password, er_floor, 0, er_view);
2031 serv_getln(buf, sizeof buf);
2032 if (buf[0] != '2') {
2033 strcpy(WC->ImportantMessage, &buf[4]);
2034 display_main_menu();
2038 do_change_view(er_view); /* Now go there */
2043 * display the screen to enter a private room
2045 void display_private(char *rname, int req_pass)
2047 output_headers(1, 1, 2, 0, 0, 0);
2048 wprintf("<div id=\"banner\">\n"
2049 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2050 "<SPAN CLASS=\"titlebar\">");
2051 wprintf(_("Go to a hidden room"));
2053 "</TD></TR></TABLE>\n"
2054 "</div>\n<div id=\"content\">\n"
2057 wprintf("<div id=\"fix_scrollbar_bug\">"
2058 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2060 wprintf("<CENTER>\n");
2062 wprintf(_("If you know the name of a hidden (guess-name) or "
2063 "passworded room, you can enter that room by typing "
2064 "its name below. Once you gain access to a private "
2065 "room, it will appear in your regular room listings "
2066 "so you don't have to keep returning here."));
2067 wprintf("\n<br /><br />");
2069 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
2071 wprintf("<table border=\"0\" cellspacing=\"5\" "
2072 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2074 wprintf(_("Enter room name:"));
2076 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2077 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2080 wprintf("</TD></TR><TR><TD>");
2081 wprintf(_("Enter room password:"));
2082 wprintf("</TD><TD>");
2083 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2085 wprintf("</TD></TR></TABLE><br />\n");
2087 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2089 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2093 wprintf("</FORM>\n");
2094 wprintf("</td></tr></table></div>\n");
2099 * goto a private room
2101 void goto_private(void)
2106 if (strlen(bstr("ok_button")) == 0) {
2107 display_main_menu();
2110 strcpy(hold_rm, WC->wc_roomname);
2111 strcpy(buf, "GOTO ");
2112 strcat(buf, bstr("gr_name"));
2114 strcat(buf, bstr("gr_pass"));
2116 serv_getln(buf, sizeof buf);
2118 if (buf[0] == '2') {
2119 smart_goto(bstr("gr_name"));
2122 if (!strncmp(buf, "540", 3)) {
2123 display_private(bstr("gr_name"), 1);
2126 output_headers(1, 1, 1, 0, 0, 0);
2127 wprintf("%s\n", &buf[4]);
2134 * display the screen to zap a room
2136 void display_zap(void)
2138 output_headers(1, 1, 2, 0, 0, 0);
2140 wprintf("<div id=\"banner\">\n");
2141 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2142 wprintf("<SPAN CLASS=\"titlebar\">");
2143 wprintf(_("Zap (forget/unsubscribe) the current room"));
2144 wprintf("</SPAN>\n");
2145 wprintf("</TD></TR></TABLE>\n");
2146 wprintf("</div>\n<div id=\"content\">\n");
2148 wprintf(_("If you select this option, <em>%s</em> will "
2149 "disappear from your room list. Is this what you wish "
2150 "to do?<br />\n"), WC->wc_roomname);
2152 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
2153 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2155 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2156 wprintf("</FORM>\n");
2167 char final_destination[SIZ];
2169 /* If the forget-room routine fails for any reason, we fall back
2170 * to the current room; otherwise, we go to the Lobby
2172 strcpy(final_destination, WC->wc_roomname);
2174 if (strlen(bstr("ok_button")) > 0) {
2175 serv_printf("GOTO %s", WC->wc_roomname);
2176 serv_getln(buf, sizeof buf);
2177 if (buf[0] == '2') {
2179 serv_getln(buf, sizeof buf);
2180 if (buf[0] == '2') {
2181 strcpy(final_destination, "_BASEROOM_");
2185 smart_goto(final_destination);
2191 * Delete the current room
2193 void delete_room(void)
2197 serv_puts("KILL 1");
2198 serv_getln(buf, sizeof buf);
2199 if (buf[0] != '2') {
2200 strcpy(WC->ImportantMessage, &buf[4]);
2201 display_main_menu();
2204 smart_goto("_BASEROOM_");
2211 * Perform changes to a room's network configuration
2213 void netedit(void) {
2222 if (strlen(bstr("line"))==0) {
2227 strcpy(line, bstr("prefix"));
2228 strcat(line, bstr("line"));
2229 strcat(line, bstr("suffix"));
2238 serv_getln(buf, sizeof buf);
2239 if (buf[0] != '1') {
2245 /* This loop works for add *or* remove. Spiffy, eh? */
2246 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2247 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2248 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2249 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2250 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2251 if ( (strcasecmp(cmpa0, cmpb0))
2252 || (strcasecmp(cmpa1, cmpb1)) ) {
2253 fprintf(fp, "%s\n", buf);
2259 serv_getln(buf, sizeof buf);
2260 if (buf[0] != '4') {
2266 while (fgets(buf, sizeof buf, fp) != NULL) {
2267 buf[strlen(buf)-1] = 0;
2271 if (strlen(bstr("add_button")) > 0) {
2283 * Convert a room name to a folder-ish-looking name.
2285 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2290 * For mailboxes, just do it straight...
2293 sprintf(folder, "My folders|%s", room);
2297 * Otherwise, prefix the floor name as a "public folders" moniker
2300 sprintf(folder, "%s|%s", floorlist[floor], room);
2304 * Replace "\" characters with "|" for pseudo-folder-delimiting
2306 for (i=0; i<strlen(folder); ++i) {
2307 if (folder[i] == '\\') folder[i] = '|';
2315 * Back end for change_view()
2317 void do_change_view(int newview) {
2320 serv_printf("VIEW %d", newview);
2321 serv_getln(buf, sizeof buf);
2322 WC->wc_view = newview;
2323 smart_goto(WC->wc_roomname);
2329 * Change the view for this room
2331 void change_view(void) {
2334 view = atol(bstr("view"));
2335 do_change_view(view);
2340 * One big expanded tree list view --- like a folder list
2342 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2346 int has_subfolders = 0;
2349 parents = malloc(max_folders * sizeof(int));
2351 /* BEGIN TREE MENU */
2352 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2354 /* include NanoTree */
2355 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2357 /* initialize NanoTree */
2358 wprintf("<script type=\"text/javascript\"> \n"
2359 " showRootNode = false; \n"
2360 " sortNodes = false; \n"
2361 " dragable = false; \n"
2363 " function standardClick(treeNode) { \n"
2366 " var closedGif = 'static/folder_closed.gif'; \n"
2367 " var openGif = 'static/folder_open.gif'; \n"
2369 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2373 for (i=0; i<max_folders; ++i) {
2376 if ((i+1) < max_folders) {
2377 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2378 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2383 levels = num_tokens(fold[i].name, '|');
2384 parents[levels] = i;
2386 wprintf("var node%d = new TreeNode(%d, '", i, i);
2388 if (fold[i].selectable) {
2389 wprintf("<A HREF=\"/dotgoto?room=");
2390 urlescputs(fold[i].room);
2395 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2397 else if (fold[i].hasnewmsgs) {
2398 wprintf("<SPAN CLASS=\"roomlist_new\">");
2401 wprintf("<SPAN CLASS=\"roomlist_old\">");
2403 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2408 if (has_subfolders) {
2409 wprintf("new Array(closedGif, openGif)");
2411 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2412 wprintf("'static/viewcontacts_16x.gif'");
2414 else if (fold[i].view == VIEW_CALENDAR) {
2415 wprintf("'static/calarea_16x.gif'");
2417 else if (fold[i].view == VIEW_TASKS) {
2418 wprintf("'static/taskmanag_16x.gif'");
2420 else if (fold[i].view == VIEW_NOTES) {
2421 wprintf("'static/storenotes_16x.gif'");
2423 else if (fold[i].view == VIEW_MAILBOX) {
2424 wprintf("'static/privatemess_16x.gif'");
2427 wprintf("'static/chatrooms_16x.gif'");
2430 urlescputs(fold[i].name);
2434 wprintf("rootNode.addChild(node%d);\n", i);
2437 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2441 wprintf("container = document.getElementById('roomlist_div'); \n"
2451 * Boxes and rooms and lists ... oh my!
2453 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2456 int levels, oldlevels;
2459 static int columns = 3;
2460 int boxes_per_column = 0;
2461 int current_column = 0;
2465 while (nf % columns != 0) ++nf;
2466 boxes_per_column = (nf / columns);
2467 if (boxes_per_column < 1) boxes_per_column = 1;
2469 /* Outer table (for columnization) */
2470 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2471 "<tr><td valign=top>");
2475 for (i=0; i<max_folders; ++i) {
2477 levels = num_tokens(fold[i].name, '|');
2479 if ((levels == 1) && (oldlevels > 1)) {
2482 do_template("endbox");
2485 if ((num_boxes % boxes_per_column) == 0) {
2487 if (current_column < columns) {
2488 wprintf("</td><td valign=top>\n");
2495 /* Begin inner box */
2496 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2497 stresc(boxtitle, buf, 1, 0);
2498 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2499 do_template("beginbox");
2507 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2508 if (fold[i].selectable) {
2509 wprintf("<A HREF=\"/dotgoto?room=");
2510 urlescputs(fold[i].room);
2516 if (fold[i].hasnewmsgs) {
2517 wprintf("<SPAN CLASS=\"roomlist_new\">");
2520 wprintf("<SPAN CLASS=\"roomlist_old\">");
2522 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2525 if (fold[i].selectable) {
2531 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2532 wprintf(" (INBOX)");
2534 wprintf("<br />\n");
2537 /* End the final inner box */
2538 do_template("endbox");
2540 wprintf("</TD></TR></TABLE>\n");
2545 * Show the room list. (only should get called by
2546 * knrooms() because that's where output_headers() is called from)
2549 void list_all_rooms_by_floor(char *viewpref) {
2552 struct folder *fold = NULL;
2554 int max_folders = 0;
2555 int alloc_folders = 0;
2559 int num_floors = 1; /* add an extra one for private folders */
2561 /* Start with the mailboxes */
2564 fold = malloc(sizeof(struct folder));
2565 memset(fold, 0, sizeof(struct folder));
2566 strcpy(fold[0].name, "My folders");
2567 fold[0].is_mailbox = 1;
2569 /* Then add floors */
2571 serv_getln(buf, sizeof buf);
2572 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2573 if (max_folders >= alloc_folders) {
2574 alloc_folders = max_folders + 100;
2575 fold = realloc(fold,
2576 alloc_folders * sizeof(struct folder));
2578 memset(&fold[max_folders], 0, sizeof(struct folder));
2579 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2586 serv_getln(buf, sizeof buf);
2587 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2588 if (max_folders >= alloc_folders) {
2589 alloc_folders = max_folders + 100;
2590 fold = realloc(fold,
2591 alloc_folders * sizeof(struct folder));
2593 memset(&fold[max_folders], 0, sizeof(struct folder));
2594 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2595 ra_flags = extract_int(buf, 5);
2596 flags = extract_int(buf, 1);
2597 fold[max_folders].floor = extract_int(buf, 2);
2598 fold[max_folders].hasnewmsgs =
2599 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2600 if (flags & QR_MAILBOX) {
2601 fold[max_folders].is_mailbox = 1;
2603 fold[max_folders].view = extract_int(buf, 6);
2604 room_to_folder(fold[max_folders].name,
2605 fold[max_folders].room,
2606 fold[max_folders].floor,
2607 fold[max_folders].is_mailbox);
2608 fold[max_folders].selectable = 1;
2612 /* Bubble-sort the folder list */
2613 for (i=0; i<max_folders; ++i) {
2614 for (j=0; j<(max_folders-1)-i; ++j) {
2615 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2616 swap = strcasecmp(fold[j].name, fold[j+1].name);
2619 if ( (fold[j+1].is_mailbox)
2620 && (!fold[j].is_mailbox)) {
2628 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2629 memcpy(&fold[j], &fold[j+1],
2630 sizeof(struct folder));
2631 memcpy(&fold[j+1], &ftmp,
2632 sizeof(struct folder));
2637 /* test only hackish view
2638 wprintf("<table><TR><TD>A Table</TD></TR></table>\n");
2639 for (i=0; i<max_folders; ++i) {
2640 escputs(fold[i].name);
2641 wprintf("<br />\n");
2645 if (!strcasecmp(viewpref, "folders")) {
2646 do_folder_view(fold, max_folders, num_floors);
2649 do_rooms_view(fold, max_folders, num_floors);
2657 /* Do either a known rooms list or a folders list, depending on the
2661 char listviewpref[SIZ];
2663 output_headers(1, 1, 2, 0, 0, 0);
2666 /* Determine whether the user is trying to change views */
2667 if (bstr("view") != NULL) {
2668 if (strlen(bstr("view")) > 0) {
2669 set_preference("roomlistview", bstr("view"), 1);
2673 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2675 if ( (strcasecmp(listviewpref, "folders"))
2676 && (strcasecmp(listviewpref, "table")) ) {
2677 strcpy(listviewpref, "rooms");
2681 wprintf("<div id=\"banner\">\n"
2682 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2683 "<SPAN CLASS=\"titlebar\">"
2685 if (!strcasecmp(listviewpref, "rooms")) {
2686 wprintf("Room list");
2688 if (!strcasecmp(listviewpref, "folders")) {
2689 wprintf("Folder list");
2691 if (!strcasecmp(listviewpref, "table")) {
2692 wprintf("Room list");
2694 wprintf("</SPAN></TD>\n");
2696 /* offer the ability to switch views */
2697 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2698 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2699 "OnChange=\"location.href=roomlistomatic.newview.options"
2700 "[selectedIndex].value\">\n");
2702 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2705 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2708 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2709 "View as folder list"
2711 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2714 wprintf("</SELECT><br />");
2716 wprintf("</FORM></TD></TR></TABLE>\n");
2719 "<div id=\"content\">\n");
2721 /* Display the room list in the user's preferred format */
2722 list_all_rooms_by_floor(listviewpref);
2728 * Set the message expire policy for this room and/or floor
2730 void set_room_policy(void) {
2733 if (strlen(bstr("ok_button")) == 0) {
2734 strcpy(WC->ImportantMessage,
2735 _("Cancelled. Changes were not saved."));
2740 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2741 serv_getln(buf, sizeof buf);
2742 strcpy(WC->ImportantMessage, &buf[4]);
2744 if (WC->axlevel >= 6) {
2745 strcat(WC->ImportantMessage, "<br />\n");
2746 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2747 serv_getln(buf, sizeof buf);
2748 strcat(WC->ImportantMessage, &buf[4]);