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);
606 WC->is_mailbox = extract_int(&buf[4],7);
607 ls = extract_long(&buf[4], 6);
608 WC->wc_floor = extract_int(&buf[4], 10);
609 WC->wc_view = extract_int(&buf[4], 11);
610 WC->wc_default_view = extract_int(&buf[4], 12);
613 WC->is_room_aide = WC->is_aide;
615 WC->is_room_aide = (char) extract_int(&buf[4], 8);
617 remove_march(WC->wc_roomname);
618 if (!strcasecmp(gname, "_BASEROOM_"))
626 * Locate the room on the march list which we most want to go to. Each room
627 * is measured given a "weight" of preference based on various factors.
629 char *pop_march(int desired_floor)
631 static char TheRoom[128];
633 int TheOrder = 32767;
636 struct march *mptr = NULL;
638 strcpy(TheRoom, "_BASEROOM_");
639 if (WC->march == NULL)
642 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
644 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
645 weight = weight + 10000;
646 if (mptr->march_floor == desired_floor)
647 weight = weight + 5000;
649 weight = weight + ((128 - (mptr->march_floor)) * 128);
650 weight = weight + (128 - (mptr->march_order));
652 if (weight > TheWeight) {
654 strcpy(TheRoom, mptr->march_name);
655 TheFloor = mptr->march_floor;
656 TheOrder = mptr->march_order;
664 /* Goto next room having unread messages.
665 * We want to skip over rooms that the user has already been to, and take the
666 * user back to the lobby when done. The room we end up in is placed in
667 * newroom - which is set to 0 (the lobby) initially.
668 * We start the search in the current room rather than the beginning to prevent
669 * two or more concurrent users from dragging each other back to the same room.
674 struct march *mptr, *mptr2;
677 /* First check to see if the march-mode list is already allocated.
678 * If it is, pop the first room off the list and go there.
681 if (WC->march == NULL) {
683 serv_getln(buf, sizeof buf);
685 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
686 mptr = (struct march *) malloc(sizeof(struct march));
688 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
689 mptr->march_floor = extract_int(buf, 2);
690 mptr->march_order = extract_int(buf, 3);
691 if (WC->march == NULL) {
695 while (mptr2->next != NULL)
700 /* add _BASEROOM_ to the end of the march list, so the user will end up
701 * in the system base room (usually the Lobby>) at the end of the loop
703 mptr = (struct march *) malloc(sizeof(struct march));
705 strcpy(mptr->march_name, "_BASEROOM_");
706 if (WC->march == NULL) {
710 while (mptr2->next != NULL)
715 * ...and remove the room we're currently in, so a <G>oto doesn't make us
716 * walk around in circles
718 remove_march(WC->wc_roomname);
720 if (WC->march != NULL) {
721 strcpy(next_room, pop_march(-1));
723 strcpy(next_room, "_BASEROOM_");
727 smart_goto(next_room);
731 void smart_goto(char *next_room) {
739 * mark all messages in current room as having been read
741 void slrp_highest(void)
746 serv_puts("SLRP HIGHEST");
747 serv_getln(buf, sizeof buf);
749 wprintf("<EM>%s</EM><br />\n", &buf[4]);
756 * un-goto the previous room
762 if (!strcmp(WC->ugname, "")) {
763 smart_goto(WC->wc_roomname);
766 serv_printf("GOTO %s", WC->ugname);
767 serv_getln(buf, sizeof buf);
769 smart_goto(WC->wc_roomname);
772 if (WC->uglsn >= 0L) {
773 serv_printf("SLRP %ld", WC->uglsn);
774 serv_getln(buf, sizeof buf);
776 strcpy(buf, WC->ugname);
777 strcpy(WC->ugname, "");
786 * Set/clear/read the "self-service list subscribe" flag for a room
788 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
789 * Always returns the new value.
792 int self_service(int newval) {
793 int current_value = 0;
799 int flags, floor, order, view, flags2;
802 serv_getln(buf, sizeof buf);
803 if (buf[0] != '2') return(0);
805 extract_token(name, &buf[4], 0, '|', sizeof name);
806 extract_token(password, &buf[4], 1, '|', sizeof password);
807 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
808 flags = extract_int(&buf[4], 3);
809 floor = extract_int(&buf[4], 4);
810 order = extract_int(&buf[4], 5);
811 view = extract_int(&buf[4], 6);
812 flags2 = extract_int(&buf[4], 7);
814 if (flags2 & QR2_SELFLIST) {
822 flags2 = flags2 | QR2_SELFLIST;
824 else if (newval == 0) {
825 flags2 = flags2 & ~QR2_SELFLIST;
828 return(current_value);
831 if (newval != current_value) {
832 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
833 name, password, dirname, flags,
834 floor, order, view, flags2);
835 serv_getln(buf, sizeof buf);
848 * display the form for editing a room
850 void display_editroom(void)
855 char remote_room[SIZ];
858 char er_password[10];
860 char er_roomaide[26];
866 char *not_shared_with;
873 if (strlen(tab) == 0) tab = "admin";
877 serv_getln(buf, sizeof buf);
880 strcpy(WC->ImportantMessage, &buf[4]);
884 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
885 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
886 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
887 er_flags = extract_int(&buf[4], 3);
888 er_floor = extract_int(&buf[4], 4);
890 output_headers(1, 1, 1, 0, 0, 0);
892 /* print the tabbed dialog */
894 "<div id=\"fix_scrollbar_bug\">"
895 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
897 "<TD> </TD>\n");
899 if (!strcmp(tab, "admin")) {
900 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
903 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
905 wprintf(_("Administration"));
906 if (!strcmp(tab, "admin")) {
907 wprintf("</SPAN></TD>\n");
910 wprintf("</A></TD>\n");
913 wprintf("<TD> </TD>\n");
915 if (!strcmp(tab, "config")) {
916 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
919 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
921 wprintf(_("Configuration"));
922 if (!strcmp(tab, "config")) {
923 wprintf("</SPAN></TD>\n");
926 wprintf("</A></TD>\n");
929 wprintf("<TD> </TD>\n");
931 if (!strcmp(tab, "expire")) {
932 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
935 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
937 wprintf(_("Message expire policy"));
938 if (!strcmp(tab, "expire")) {
939 wprintf("</SPAN></TD>\n");
942 wprintf("</A></TD>\n");
945 wprintf("<TD> </TD>\n");
947 if (!strcmp(tab, "access")) {
948 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
951 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=access\">");
953 wprintf(_("Access controls"));
954 if (!strcmp(tab, "access")) {
955 wprintf("</SPAN></TD>\n");
958 wprintf("</A></TD>\n");
961 wprintf("<TD> </TD>\n");
963 if (!strcmp(tab, "sharing")) {
964 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
967 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
969 wprintf(_("Sharing"));
970 if (!strcmp(tab, "sharing")) {
971 wprintf("</SPAN></TD>\n");
974 wprintf("</A></TD>\n");
977 wprintf("<TD> </TD>\n");
979 if (!strcmp(tab, "listserv")) {
980 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
983 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
985 wprintf(_("Mailing list service"));
986 if (!strcmp(tab, "listserv")) {
987 wprintf("</SPAN></TD>\n");
990 wprintf("</A></TD>\n");
993 wprintf("<TD> </TD>\n");
995 wprintf("</TR></TABLE></div>\n");
996 /* end tabbed dialog */
998 /* begin content of whatever tab is open now */
999 wprintf("<div id=\"fix_scrollbar_bug\">"
1000 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
1003 if (!strcmp(tab, "admin")) {
1005 "<LI><A HREF=\"/delete_room\" "
1006 "onClick=\"return confirm('");
1007 wprintf(_("Are you sure you want to delete this room?"));
1008 wprintf("');\">\n");
1009 wprintf(_("Delete this room"));
1011 "<LI><A HREF=\"/display_editroompic\">\n");
1012 wprintf(_("Set or change the icon for this room's banner"));
1014 "<LI><A HREF=\"/display_editinfo\">\n");
1015 wprintf(_("Edit this room's Info file"));
1020 if (!strcmp(tab, "config")) {
1021 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
1023 wprintf("<UL><LI>");
1024 wprintf(_("Name of room: "));
1025 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1031 wprintf(_("Resides on floor: "));
1032 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1033 for (i = 0; i < 128; ++i)
1034 if (strlen(floorlist[i]) > 0) {
1035 wprintf("<OPTION ");
1037 wprintf("SELECTED ");
1038 wprintf("VALUE=\"%d\">", i);
1039 escputs(floorlist[i]);
1040 wprintf("</OPTION>\n");
1042 wprintf("</SELECT>\n");
1045 wprintf(_("Type of room:"));
1048 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1049 if ((er_flags & QR_PRIVATE) == 0)
1050 wprintf("CHECKED ");
1052 wprintf(_("Public room"));
1055 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1056 if ((er_flags & QR_PRIVATE) &&
1057 (er_flags & QR_GUESSNAME))
1058 wprintf("CHECKED ");
1060 wprintf(_("Private - guess name"));
1062 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1063 if ((er_flags & QR_PRIVATE) &&
1064 (er_flags & QR_PASSWORDED))
1065 wprintf("CHECKED ");
1067 wprintf(_("Private - require password:"));
1068 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1071 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1072 if ((er_flags & QR_PRIVATE)
1073 && ((er_flags & QR_GUESSNAME) == 0)
1074 && ((er_flags & QR_PASSWORDED) == 0))
1075 wprintf("CHECKED ");
1077 wprintf(_("Private - invitation only"));
1079 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1081 wprintf(_("If private, cause current users to forget room"));
1083 wprintf("\n</UL>\n");
1085 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1086 if (er_flags & QR_PREFONLY)
1087 wprintf("CHECKED ");
1089 wprintf(_("Preferred users only"));
1091 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1092 if (er_flags & QR_READONLY)
1093 wprintf("CHECKED ");
1095 wprintf(_("Read-only room"));
1097 /* directory stuff */
1098 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1099 if (er_flags & QR_DIRECTORY)
1100 wprintf("CHECKED ");
1102 wprintf(_("File directory room"));
1104 wprintf("\n<UL><LI>");
1105 wprintf(_("Directory name: "));
1106 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1109 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1110 if (er_flags & QR_UPLOAD)
1111 wprintf("CHECKED ");
1113 wprintf(_("Uploading allowed"));
1115 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1116 if (er_flags & QR_DOWNLOAD)
1117 wprintf("CHECKED ");
1119 wprintf(_("Downloading allowed"));
1121 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1122 if (er_flags & QR_VISDIR)
1123 wprintf("CHECKED ");
1125 wprintf(_("Visible directory"));
1128 /* end of directory stuff */
1130 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1131 if (er_flags & QR_NETWORK)
1132 wprintf("CHECKED ");
1134 wprintf(_("Network shared room"));
1136 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1137 if (er_flags & QR_PERMANENT)
1138 wprintf("CHECKED ");
1140 wprintf(_("Permanent (does not auto-purge)"));
1142 /* start of anon options */
1145 wprintf(_("Anonymous messages"));
1148 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1149 if (((er_flags & QR_ANONONLY) == 0)
1150 && ((er_flags & QR_ANONOPT) == 0))
1151 wprintf("CHECKED ");
1153 wprintf(_("No anonymous messages"));
1155 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1156 if (er_flags & QR_ANONONLY)
1157 wprintf("CHECKED ");
1159 wprintf(_("All messages are anonymous"));
1161 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1162 if (er_flags & QR_ANONOPT)
1163 wprintf("CHECKED ");
1165 wprintf(_("Prompt user when entering messages"));
1168 /* end of anon options */
1171 wprintf(_("Room aide: "));
1173 serv_getln(buf, sizeof buf);
1174 if (buf[0] != '2') {
1175 wprintf("<EM>%s</EM>\n", &buf[4]);
1177 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1178 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1181 wprintf("</UL><CENTER>\n");
1182 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1183 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1185 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1193 /* Sharing the room with other Citadel nodes... */
1194 if (!strcmp(tab, "sharing")) {
1196 shared_with = strdup("");
1197 not_shared_with = strdup("");
1199 /* Learn the current configuration */
1200 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1201 serv_getln(buf, sizeof buf);
1202 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1203 extract_token(node, buf, 0, '|', sizeof node);
1204 not_shared_with = realloc(not_shared_with,
1205 strlen(not_shared_with) + 32);
1206 strcat(not_shared_with, node);
1207 strcat(not_shared_with, "\n");
1211 serv_getln(buf, sizeof buf);
1212 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1213 extract_token(cmd, buf, 0, '|', sizeof cmd);
1214 extract_token(node, buf, 1, '|', sizeof node);
1215 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1216 if (!strcasecmp(cmd, "ignet_push_share")) {
1217 shared_with = realloc(shared_with,
1218 strlen(shared_with) + 32);
1219 strcat(shared_with, node);
1220 if (strlen(remote_room) > 0) {
1221 strcat(shared_with, "|");
1222 strcat(shared_with, remote_room);
1224 strcat(shared_with, "\n");
1228 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1229 extract_token(buf, shared_with, i, '\n', sizeof buf);
1230 extract_token(node, buf, 0, '|', sizeof node);
1231 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1232 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1233 if (!strcasecmp(node, cmd)) {
1234 remove_token(not_shared_with, j, '\n');
1239 /* Display the stuff */
1240 wprintf("<CENTER><br />"
1241 "<TABLE border=1 cellpadding=5><TR>"
1243 wprintf(_("Shared with"));
1244 wprintf("</I></B></TD>"
1246 wprintf(_("Not shared with"));
1247 wprintf("</I></B></TD></TR>\n"
1248 "<TR><TD VALIGN=TOP>\n");
1250 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1251 wprintf(_("Remote node name"));
1252 wprintf("</TD><TD>");
1253 wprintf(_("Remote room name"));
1254 wprintf("</TD><TD>");
1255 wprintf(_("Actions"));
1256 wprintf("</TD></TR>\n");
1258 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1259 extract_token(buf, shared_with, i, '\n', sizeof buf);
1260 extract_token(node, buf, 0, '|', sizeof node);
1261 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1262 if (strlen(node) > 0) {
1263 wprintf("<FORM METHOD=\"POST\" "
1264 "ACTION=\"/netedit\">"
1265 "<TR><TD>%s</TD>\n", node);
1268 if (strlen(remote_room) > 0) {
1269 escputs(remote_room);
1275 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1276 "VALUE=\"ignet_push_share|");
1278 if (strlen(remote_room) > 0) {
1280 urlescputs(remote_room);
1283 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1284 "VALUE=\"sharing\">\n");
1285 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1286 "VALUE=\"remove\">\n");
1287 wprintf("<INPUT TYPE=\"submit\" "
1288 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1289 wprintf("</TD></TR></FORM>\n");
1293 wprintf("</TABLE>\n");
1294 wprintf("</TD><TD VALIGN=TOP>\n");
1295 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1296 wprintf(_("Remote node name"));
1297 wprintf("</TD><TD>");
1298 wprintf(_("Remote room name"));
1299 wprintf("</TD><TD>");
1300 wprintf(_("Actions"));
1301 wprintf("</TD></TR>\n");
1303 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1304 extract_token(node, not_shared_with, i, '\n', sizeof node);
1305 if (strlen(node) > 0) {
1306 wprintf("<FORM METHOD=\"POST\" "
1307 "ACTION=\"/netedit\">"
1311 "<INPUT TYPE=\"INPUT\" "
1315 wprintf("<INPUT TYPE=\"hidden\" "
1317 "VALUE=\"ignet_push_share|");
1320 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1321 "VALUE=\"sharing\">\n");
1322 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1323 "VALUE=\"add\">\n");
1324 wprintf("<INPUT TYPE=\"submit\" "
1325 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1326 wprintf("</TD></TR></FORM>\n");
1330 wprintf("</TABLE>\n");
1331 wprintf("</TD></TR>"
1332 "</TABLE></CENTER><br />\n"
1333 "<I><B>%s</B><UL><LI>", _("Notes:"));
1334 wprintf(_("When sharing a room, "
1335 "it must be shared from both ends. Adding a node to "
1336 "the 'shared' list sends messages out, but in order to"
1337 " receive messages, the other nodes must be configured"
1338 " to send messages out to your system as well. "
1339 "<LI>If the remote room name is blank, it is assumed "
1340 "that the room name is identical on the remote node."
1341 "<LI>If the remote room name is different, the remote "
1342 "node must also configure the name of the room here."
1348 /* Mailing list management */
1349 if (!strcmp(tab, "listserv")) {
1351 wprintf("<br /><center>"
1352 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1353 "<TR><TD VALIGN=TOP>");
1355 wprintf(_("<i>The contents of this room are being "
1356 "mailed <b>as individual messages</b> "
1357 "to the following list recipients:"
1358 "</i><br /><br />\n"));
1361 serv_getln(buf, sizeof buf);
1362 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1363 extract_token(cmd, buf, 0, '|', sizeof cmd);
1364 if (!strcasecmp(cmd, "listrecp")) {
1365 extract_token(recp, buf, 1, '|', sizeof recp);
1368 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1371 wprintf("&tab=listserv\">");
1372 wprintf(_("(remove)"));
1373 wprintf("</A><br />");
1376 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1377 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1378 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1379 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1380 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1381 wprintf("</FORM>\n");
1383 wprintf("</TD><TD VALIGN=TOP>\n");
1385 wprintf(_("<i>The contents of this room are being "
1386 "mailed <b>in digest form</b> "
1387 "to the following list recipients:"
1388 "</i><br /><br />\n"));
1391 serv_getln(buf, sizeof buf);
1392 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1393 extract_token(cmd, buf, 0, '|', sizeof cmd);
1394 if (!strcasecmp(cmd, "digestrecp")) {
1395 extract_token(recp, buf, 1, '|', sizeof recp);
1398 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1401 wprintf("&tab=listserv\">");
1402 wprintf(_("(remove)"));
1403 wprintf("</A><br />");
1406 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1407 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1408 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1409 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1410 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1411 wprintf("</FORM>\n");
1413 wprintf("</TD></TR></TABLE><hr />\n");
1415 if (self_service(999) == 1) {
1416 wprintf(_("This room is configured to allow "
1417 "self-service subscribe/unsubscribe requests."));
1418 wprintf("<A HREF=\"/toggle_self_service?newval=0&tab=listserv\">");
1419 wprintf(_("Click to disable."));
1420 wprintf("</A><br />\n");
1421 wprintf(_("The URL for subscribe/unsubscribe is: "));
1422 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1423 (is_https ? "https" : "http"),
1427 wprintf(_("This room is <i>not</i> configured to allow "
1428 "self-service subscribe/unsubscribe requests."));
1429 wprintf(" <A HREF=\"/toggle_self_service?newval=1&"
1431 wprintf(_("Click to enable."));
1432 wprintf("</A><br />\n");
1436 wprintf("</CENTER>\n");
1440 /* Mailing list management */
1441 if (!strcmp(tab, "expire")) {
1443 serv_puts("GPEX room");
1444 serv_getln(buf, sizeof buf);
1445 if (buf[0] == '2') {
1446 roompolicy = extract_int(&buf[4], 0);
1447 roomvalue = extract_int(&buf[4], 1);
1450 serv_puts("GPEX floor");
1451 serv_getln(buf, sizeof buf);
1452 if (buf[0] == '2') {
1453 floorpolicy = extract_int(&buf[4], 0);
1454 floorvalue = extract_int(&buf[4], 1);
1457 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1458 wprintf("<TABLE border=0 cellspacing=5>\n");
1459 wprintf("<TR><TD>");
1460 wprintf(_("Message expire policy for this room"));
1462 escputs(WC->wc_roomname);
1463 wprintf(")</TD><TD>");
1464 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1465 ((roompolicy == 0) ? "CHECKED" : "") );
1466 wprintf(_("Use the default policy for this floor"));
1467 wprintf("<br />\n");
1468 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1469 ((roompolicy == 1) ? "CHECKED" : "") );
1470 wprintf(_("Never automatically expire messages"));
1471 wprintf("<br />\n");
1472 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1473 ((roompolicy == 2) ? "CHECKED" : "") );
1474 wprintf("Expire by message count<br />\n");
1475 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1476 ((roompolicy == 3) ? "CHECKED" : "") );
1477 wprintf(_("Expire by message age"));
1479 wprintf(_("Number of messages or days: "));
1480 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1481 wprintf("</TD></TR>\n");
1483 if (WC->axlevel >= 6) {
1484 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1485 wprintf("<TR><TD>");
1486 wprintf(_("Message expire policy for this floor"));
1488 escputs(floorlist[WC->wc_floor]);
1489 wprintf(")</TD><TD>");
1490 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1491 ((floorpolicy == 0) ? "CHECKED" : "") );
1492 wprintf(_("Use the system default"));
1493 wprintf("<br />\n");
1494 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1495 ((floorpolicy == 1) ? "CHECKED" : "") );
1496 wprintf(_("Never automatically expire messages"));
1497 wprintf("<br />\n");
1498 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1499 ((floorpolicy == 2) ? "CHECKED" : "") );
1500 wprintf(_("Expire by message count"));
1501 wprintf("<br />\n");
1502 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1503 ((floorpolicy == 3) ? "CHECKED" : "") );
1504 wprintf(_("Expire by message age"));
1506 wprintf(_("Number of messages or days: "));
1507 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1511 wprintf("<CENTER>\n");
1512 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1513 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1515 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1516 wprintf("</CENTER></TD><TR>\n");
1518 wprintf("</TABLE>\n"
1519 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1525 /* Mailing list management */
1526 if (!strcmp(tab, "access")) {
1530 /* end content of whatever tab is open now */
1531 wprintf("</TD></TR></TABLE></div>\n");
1538 * Toggle self-service list subscription
1540 void toggle_self_service(void) {
1543 newval = atoi(bstr("newval"));
1544 self_service(newval);
1551 * save new parameters for a room
1557 char er_password[10];
1558 char er_dirname[15];
1559 char er_roomaide[26];
1565 if (strlen(bstr("ok_button")) == 0) {
1566 strcpy(WC->ImportantMessage,
1567 _("Cancelled. Changes were not saved."));
1572 serv_getln(buf, sizeof buf);
1574 if (buf[0] != '2') {
1575 strcpy(WC->ImportantMessage, &buf[4]);
1579 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1580 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1581 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1582 er_flags = extract_int(&buf[4], 3);
1584 strcpy(er_roomaide, bstr("er_roomaide"));
1585 if (strlen(er_roomaide) == 0) {
1587 serv_getln(buf, sizeof buf);
1588 if (buf[0] != '2') {
1589 strcpy(er_roomaide, "");
1591 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1594 strcpy(buf, bstr("er_name"));
1596 if (strlen(buf) > 0) {
1597 strcpy(er_name, buf);
1600 strcpy(buf, bstr("er_password"));
1602 if (strlen(buf) > 0)
1603 strcpy(er_password, buf);
1605 strcpy(buf, bstr("er_dirname"));
1607 if (strlen(buf) > 0)
1608 strcpy(er_dirname, buf);
1610 strcpy(buf, bstr("type"));
1611 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1613 if (!strcmp(buf, "invonly")) {
1614 er_flags |= (QR_PRIVATE);
1616 if (!strcmp(buf, "hidden")) {
1617 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1619 if (!strcmp(buf, "passworded")) {
1620 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1622 if (!strcmp(bstr("prefonly"), "yes")) {
1623 er_flags |= QR_PREFONLY;
1625 er_flags &= ~QR_PREFONLY;
1628 if (!strcmp(bstr("readonly"), "yes")) {
1629 er_flags |= QR_READONLY;
1631 er_flags &= ~QR_READONLY;
1634 if (!strcmp(bstr("permanent"), "yes")) {
1635 er_flags |= QR_PERMANENT;
1637 er_flags &= ~QR_PERMANENT;
1640 if (!strcmp(bstr("network"), "yes")) {
1641 er_flags |= QR_NETWORK;
1643 er_flags &= ~QR_NETWORK;
1646 if (!strcmp(bstr("directory"), "yes")) {
1647 er_flags |= QR_DIRECTORY;
1649 er_flags &= ~QR_DIRECTORY;
1652 if (!strcmp(bstr("ulallowed"), "yes")) {
1653 er_flags |= QR_UPLOAD;
1655 er_flags &= ~QR_UPLOAD;
1658 if (!strcmp(bstr("dlallowed"), "yes")) {
1659 er_flags |= QR_DOWNLOAD;
1661 er_flags &= ~QR_DOWNLOAD;
1664 if (!strcmp(bstr("visdir"), "yes")) {
1665 er_flags |= QR_VISDIR;
1667 er_flags &= ~QR_VISDIR;
1670 strcpy(buf, bstr("anon"));
1672 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1673 if (!strcmp(buf, "anononly"))
1674 er_flags |= QR_ANONONLY;
1675 if (!strcmp(buf, "anon2"))
1676 er_flags |= QR_ANONOPT;
1679 if (!strcmp(bstr("bump"), "yes"))
1682 er_floor = atoi(bstr("er_floor"));
1684 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1685 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1687 serv_getln(buf, sizeof buf);
1688 if (buf[0] != '2') {
1689 strcpy(WC->ImportantMessage, &buf[4]);
1695 if (strlen(er_roomaide) > 0) {
1696 sprintf(buf, "SETA %s", er_roomaide);
1698 serv_getln(buf, sizeof buf);
1699 if (buf[0] != '2') {
1700 strcpy(WC->ImportantMessage, &buf[4]);
1701 display_main_menu();
1706 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1713 * Display form for Invite, Kick, and show Who Knows a room
1715 void do_invt_kick(void) {
1716 char buf[SIZ], room[SIZ], username[SIZ];
1719 serv_getln(buf, sizeof buf);
1721 if (buf[0] != '2') {
1725 extract_token(room, &buf[4], 0, '|', sizeof room);
1727 strcpy(username, bstr("username"));
1729 if (strlen(bstr("kick_button")) > 0) {
1730 sprintf(buf, "KICK %s", username);
1732 serv_getln(buf, sizeof buf);
1734 if (buf[0] != '2') {
1735 strcpy(WC->ImportantMessage, &buf[4]);
1737 sprintf(WC->ImportantMessage,
1738 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1743 if (strlen(bstr("invite_button")) > 0) {
1744 sprintf(buf, "INVT %s", username);
1746 serv_getln(buf, sizeof buf);
1748 if (buf[0] != '2') {
1749 strcpy(WC->ImportantMessage, &buf[4]);
1751 sprintf(WC->ImportantMessage,
1752 _("<B><I>User %s invited to room %s.</I></B>\n"),
1763 * Display form for Invite, Kick, and show Who Knows a room
1765 void display_whok(void)
1767 char buf[SIZ], room[SIZ], username[SIZ];
1770 serv_getln(buf, sizeof buf);
1772 if (buf[0] != '2') {
1776 extract_token(room, &buf[4], 0, '|', sizeof room);
1779 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1780 wprintf(_("The users listed below have access to this room. "
1781 "To remove a user from the access list, select the user "
1782 "name from the list and click 'Kick'."));
1783 wprintf("<br /><br />");
1785 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1786 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1787 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1789 serv_getln(buf, sizeof buf);
1790 if (buf[0] == '1') {
1791 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1792 extract_token(username, buf, 0, '|', sizeof username);
1793 wprintf("<OPTION>");
1798 wprintf("</SELECT><br />\n");
1800 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1801 wprintf("</FORM></CENTER>\n");
1803 wprintf("</TD><TD>");
1804 wprintf(_("To grant another user access to this room, enter the "
1805 "user name in the box below and click 'Invite'."));
1806 wprintf("<br /><br />");
1808 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1809 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1810 wprintf("Invite: ");
1811 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1812 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1813 "<input type=\"submit\" value=\"%s\">"
1814 "</FORM></CENTER>\n", _("Invite"));
1816 wprintf("</TD></TR></TABLE>\n");
1823 * display the form for entering a new room
1825 void display_entroom(void)
1830 serv_puts("CRE8 0");
1831 serv_getln(buf, sizeof buf);
1833 if (buf[0] != '2') {
1834 strcpy(WC->ImportantMessage, &buf[4]);
1835 display_main_menu();
1839 output_headers(1, 1, 2, 0, 0, 0);
1840 wprintf("<div id=\"banner\">\n"
1841 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1842 "<SPAN CLASS=\"titlebar\">");
1843 wprintf(_("Create a new room"));
1845 "</TD></TR></TABLE>\n"
1846 "</div>\n<div id=\"content\">\n"
1849 wprintf("<div id=\"fix_scrollbar_bug\">"
1850 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1852 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"/entroom\">\n");
1854 wprintf("<UL><LI>");
1855 wprintf(_("Name of room: "));
1856 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1859 wprintf(_("Resides on floor: "));
1861 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1862 for (i = 0; i < 128; ++i)
1863 if (strlen(floorlist[i]) > 0) {
1864 wprintf("<OPTION ");
1865 wprintf("VALUE=\"%d\">", i);
1866 escputs(floorlist[i]);
1867 wprintf("</OPTION>\n");
1869 wprintf("</SELECT>\n");
1871 /* Our clever little snippet of JavaScript automatically selects
1872 * a public room if the view is set to Bulletin Board, and it
1873 * selects a mailbox room otherwise. The user can override this,
1877 wprintf(_("Default view for room: "));
1878 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1879 " if (this.form.er_view.value == 0) { "
1880 " this.form.type[0].checked=true; "
1881 " this.form.er_floor.disabled = false; "
1884 " this.form.type[4].checked=true; "
1885 " this.form.er_floor.disabled = true; "
1888 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1889 wprintf("<OPTION %s VALUE=\"%d\">",
1890 ((i == 0) ? "SELECTED" : ""), i );
1891 escputs(viewdefs[i]);
1892 wprintf("</OPTION>\n");
1894 wprintf("</SELECT>\n");
1897 wprintf(_("Type of room:"));
1900 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1901 wprintf("CHECKED OnChange=\""
1902 " if (this.form.type[0].checked == true) { "
1903 " this.form.er_floor.disabled = false; "
1906 wprintf(_("Public (automatically appears to everyone)"));
1908 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1909 " if (this.form.type[1].checked == true) { "
1910 " this.form.er_floor.disabled = false; "
1913 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1915 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1916 " if (this.form.type[2].checked == true) { "
1917 " this.form.er_floor.disabled = false; "
1920 wprintf(_("Private - require password: "));
1921 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1923 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1924 " if (this.form.type[3].checked == true) { "
1925 " this.form.er_floor.disabled = false; "
1928 wprintf(_("Private - invitation only"));
1930 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1932 " if (this.form.type[4].checked == true) { "
1933 " this.form.er_floor.disabled = true; "
1936 wprintf(_("Personal (mailbox for you only)"));
1938 wprintf("\n</UL>\n");
1940 wprintf("<CENTER>\n");
1941 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1943 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1944 wprintf("</CENTER>\n");
1945 wprintf("</FORM>\n<hr />");
1946 serv_printf("MESG roomaccess");
1947 serv_getln(buf, sizeof buf);
1948 if (buf[0] == '1') {
1951 wprintf("</td></tr></table></div>\n");
1959 * support function for entroom() -- sets the default view
1961 void er_set_default_view(int newview) {
1974 serv_getln(buf, sizeof buf);
1975 if (buf[0] != '2') return;
1977 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
1978 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
1979 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
1980 rm_bits1 = extract_int(&buf[4], 3);
1981 rm_floor = extract_int(&buf[4], 4);
1982 rm_listorder = extract_int(&buf[4], 5);
1983 rm_bits2 = extract_int(&buf[4], 7);
1985 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1986 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1987 rm_listorder, newview, rm_bits2
1989 serv_getln(buf, sizeof buf);
2002 char er_password[SIZ];
2007 if (strlen(bstr("ok_button")) == 0) {
2008 strcpy(WC->ImportantMessage,
2009 _("Cancelled. No new room was created."));
2010 display_main_menu();
2013 strcpy(er_name, bstr("er_name"));
2014 strcpy(er_type, bstr("type"));
2015 strcpy(er_password, bstr("er_password"));
2016 er_floor = atoi(bstr("er_floor"));
2017 er_view = atoi(bstr("er_view"));
2020 if (!strcmp(er_type, "hidden"))
2022 if (!strcmp(er_type, "passworded"))
2024 if (!strcmp(er_type, "invonly"))
2026 if (!strcmp(er_type, "personal"))
2029 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2030 er_name, er_num_type, er_password, er_floor, 0, er_view);
2032 serv_getln(buf, sizeof buf);
2033 if (buf[0] != '2') {
2034 strcpy(WC->ImportantMessage, &buf[4]);
2035 display_main_menu();
2039 do_change_view(er_view); /* Now go there */
2044 * display the screen to enter a private room
2046 void display_private(char *rname, int req_pass)
2048 output_headers(1, 1, 2, 0, 0, 0);
2049 wprintf("<div id=\"banner\">\n"
2050 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2051 "<SPAN CLASS=\"titlebar\">");
2052 wprintf(_("Go to a hidden room"));
2054 "</TD></TR></TABLE>\n"
2055 "</div>\n<div id=\"content\">\n"
2058 wprintf("<div id=\"fix_scrollbar_bug\">"
2059 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2061 wprintf("<CENTER>\n");
2063 wprintf(_("If you know the name of a hidden (guess-name) or "
2064 "passworded room, you can enter that room by typing "
2065 "its name below. Once you gain access to a private "
2066 "room, it will appear in your regular room listings "
2067 "so you don't have to keep returning here."));
2068 wprintf("\n<br /><br />");
2070 wprintf("<FORM METHOD=\"POST\" ACTION=\"/goto_private\">\n");
2072 wprintf("<table border=\"0\" cellspacing=\"5\" "
2073 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2075 wprintf(_("Enter room name:"));
2077 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2078 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2081 wprintf("</TD></TR><TR><TD>");
2082 wprintf(_("Enter room password:"));
2083 wprintf("</TD><TD>");
2084 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2086 wprintf("</TD></TR></TABLE><br />\n");
2088 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2090 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2094 wprintf("</FORM>\n");
2095 wprintf("</td></tr></table></div>\n");
2100 * goto a private room
2102 void goto_private(void)
2107 if (strlen(bstr("ok_button")) == 0) {
2108 display_main_menu();
2111 strcpy(hold_rm, WC->wc_roomname);
2112 strcpy(buf, "GOTO ");
2113 strcat(buf, bstr("gr_name"));
2115 strcat(buf, bstr("gr_pass"));
2117 serv_getln(buf, sizeof buf);
2119 if (buf[0] == '2') {
2120 smart_goto(bstr("gr_name"));
2123 if (!strncmp(buf, "540", 3)) {
2124 display_private(bstr("gr_name"), 1);
2127 output_headers(1, 1, 1, 0, 0, 0);
2128 wprintf("%s\n", &buf[4]);
2135 * display the screen to zap a room
2137 void display_zap(void)
2139 output_headers(1, 1, 2, 0, 0, 0);
2141 wprintf("<div id=\"banner\">\n");
2142 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2143 wprintf("<SPAN CLASS=\"titlebar\">");
2144 wprintf(_("Zap (forget/unsubscribe) the current room"));
2145 wprintf("</SPAN>\n");
2146 wprintf("</TD></TR></TABLE>\n");
2147 wprintf("</div>\n<div id=\"content\">\n");
2149 wprintf(_("If you select this option, <em>%s</em> will "
2150 "disappear from your room list. Is this what you wish "
2151 "to do?<br />\n"), WC->wc_roomname);
2153 wprintf("<FORM METHOD=\"POST\" ACTION=\"/zap\">\n");
2154 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2156 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2157 wprintf("</FORM>\n");
2168 char final_destination[SIZ];
2170 /* If the forget-room routine fails for any reason, we fall back
2171 * to the current room; otherwise, we go to the Lobby
2173 strcpy(final_destination, WC->wc_roomname);
2175 if (strlen(bstr("ok_button")) > 0) {
2176 serv_printf("GOTO %s", WC->wc_roomname);
2177 serv_getln(buf, sizeof buf);
2178 if (buf[0] == '2') {
2180 serv_getln(buf, sizeof buf);
2181 if (buf[0] == '2') {
2182 strcpy(final_destination, "_BASEROOM_");
2186 smart_goto(final_destination);
2192 * Delete the current room
2194 void delete_room(void)
2198 serv_puts("KILL 1");
2199 serv_getln(buf, sizeof buf);
2200 if (buf[0] != '2') {
2201 strcpy(WC->ImportantMessage, &buf[4]);
2202 display_main_menu();
2205 smart_goto("_BASEROOM_");
2212 * Perform changes to a room's network configuration
2214 void netedit(void) {
2223 if (strlen(bstr("line"))==0) {
2228 strcpy(line, bstr("prefix"));
2229 strcat(line, bstr("line"));
2230 strcat(line, bstr("suffix"));
2239 serv_getln(buf, sizeof buf);
2240 if (buf[0] != '1') {
2246 /* This loop works for add *or* remove. Spiffy, eh? */
2247 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2248 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2249 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2250 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2251 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2252 if ( (strcasecmp(cmpa0, cmpb0))
2253 || (strcasecmp(cmpa1, cmpb1)) ) {
2254 fprintf(fp, "%s\n", buf);
2260 serv_getln(buf, sizeof buf);
2261 if (buf[0] != '4') {
2267 while (fgets(buf, sizeof buf, fp) != NULL) {
2268 buf[strlen(buf)-1] = 0;
2272 if (strlen(bstr("add_button")) > 0) {
2284 * Convert a room name to a folder-ish-looking name.
2286 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2291 * For mailboxes, just do it straight...
2294 sprintf(folder, "My folders|%s", room);
2298 * Otherwise, prefix the floor name as a "public folders" moniker
2301 sprintf(folder, "%s|%s", floorlist[floor], room);
2305 * Replace "\" characters with "|" for pseudo-folder-delimiting
2307 for (i=0; i<strlen(folder); ++i) {
2308 if (folder[i] == '\\') folder[i] = '|';
2316 * Back end for change_view()
2318 void do_change_view(int newview) {
2321 serv_printf("VIEW %d", newview);
2322 serv_getln(buf, sizeof buf);
2323 WC->wc_view = newview;
2324 smart_goto(WC->wc_roomname);
2330 * Change the view for this room
2332 void change_view(void) {
2335 view = atol(bstr("view"));
2336 do_change_view(view);
2341 * One big expanded tree list view --- like a folder list
2343 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2347 int has_subfolders = 0;
2350 parents = malloc(max_folders * sizeof(int));
2352 /* BEGIN TREE MENU */
2353 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2355 /* include NanoTree */
2356 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2358 /* initialize NanoTree */
2359 wprintf("<script type=\"text/javascript\"> \n"
2360 " showRootNode = false; \n"
2361 " sortNodes = false; \n"
2362 " dragable = false; \n"
2364 " function standardClick(treeNode) { \n"
2367 " var closedGif = 'static/folder_closed.gif'; \n"
2368 " var openGif = 'static/folder_open.gif'; \n"
2370 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2374 for (i=0; i<max_folders; ++i) {
2377 if ((i+1) < max_folders) {
2378 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2379 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2384 levels = num_tokens(fold[i].name, '|');
2385 parents[levels] = i;
2387 wprintf("var node%d = new TreeNode(%d, '", i, i);
2389 if (fold[i].selectable) {
2390 wprintf("<A HREF=\"/dotgoto?room=");
2391 urlescputs(fold[i].room);
2396 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2398 else if (fold[i].hasnewmsgs) {
2399 wprintf("<SPAN CLASS=\"roomlist_new\">");
2402 wprintf("<SPAN CLASS=\"roomlist_old\">");
2404 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2409 if (has_subfolders) {
2410 wprintf("new Array(closedGif, openGif)");
2412 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2413 wprintf("'static/viewcontacts_16x.gif'");
2415 else if (fold[i].view == VIEW_CALENDAR) {
2416 wprintf("'static/calarea_16x.gif'");
2418 else if (fold[i].view == VIEW_TASKS) {
2419 wprintf("'static/taskmanag_16x.gif'");
2421 else if (fold[i].view == VIEW_NOTES) {
2422 wprintf("'static/storenotes_16x.gif'");
2424 else if (fold[i].view == VIEW_MAILBOX) {
2425 wprintf("'static/privatemess_16x.gif'");
2428 wprintf("'static/chatrooms_16x.gif'");
2431 urlescputs(fold[i].name);
2435 wprintf("rootNode.addChild(node%d);\n", i);
2438 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2442 wprintf("container = document.getElementById('roomlist_div'); \n"
2452 * Boxes and rooms and lists ... oh my!
2454 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2457 int levels, oldlevels;
2460 static int columns = 3;
2461 int boxes_per_column = 0;
2462 int current_column = 0;
2466 while (nf % columns != 0) ++nf;
2467 boxes_per_column = (nf / columns);
2468 if (boxes_per_column < 1) boxes_per_column = 1;
2470 /* Outer table (for columnization) */
2471 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2472 "<tr><td valign=top>");
2476 for (i=0; i<max_folders; ++i) {
2478 levels = num_tokens(fold[i].name, '|');
2480 if ((levels == 1) && (oldlevels > 1)) {
2483 do_template("endbox");
2486 if ((num_boxes % boxes_per_column) == 0) {
2488 if (current_column < columns) {
2489 wprintf("</td><td valign=top>\n");
2496 /* Begin inner box */
2497 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2498 stresc(boxtitle, buf, 1, 0);
2499 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2500 do_template("beginbox");
2508 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2509 if (fold[i].selectable) {
2510 wprintf("<A HREF=\"/dotgoto?room=");
2511 urlescputs(fold[i].room);
2517 if (fold[i].hasnewmsgs) {
2518 wprintf("<SPAN CLASS=\"roomlist_new\">");
2521 wprintf("<SPAN CLASS=\"roomlist_old\">");
2523 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2526 if (fold[i].selectable) {
2532 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2533 wprintf(" (INBOX)");
2535 wprintf("<br />\n");
2538 /* End the final inner box */
2539 do_template("endbox");
2541 wprintf("</TD></TR></TABLE>\n");
2546 * Show the room list. (only should get called by
2547 * knrooms() because that's where output_headers() is called from)
2550 void list_all_rooms_by_floor(char *viewpref) {
2553 struct folder *fold = NULL;
2555 int max_folders = 0;
2556 int alloc_folders = 0;
2560 int num_floors = 1; /* add an extra one for private folders */
2562 /* Start with the mailboxes */
2565 fold = malloc(sizeof(struct folder));
2566 memset(fold, 0, sizeof(struct folder));
2567 strcpy(fold[0].name, "My folders");
2568 fold[0].is_mailbox = 1;
2570 /* Then add floors */
2572 serv_getln(buf, sizeof buf);
2573 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2574 if (max_folders >= alloc_folders) {
2575 alloc_folders = max_folders + 100;
2576 fold = realloc(fold,
2577 alloc_folders * sizeof(struct folder));
2579 memset(&fold[max_folders], 0, sizeof(struct folder));
2580 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2587 serv_getln(buf, sizeof buf);
2588 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2589 if (max_folders >= alloc_folders) {
2590 alloc_folders = max_folders + 100;
2591 fold = realloc(fold,
2592 alloc_folders * sizeof(struct folder));
2594 memset(&fold[max_folders], 0, sizeof(struct folder));
2595 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2596 ra_flags = extract_int(buf, 5);
2597 flags = extract_int(buf, 1);
2598 fold[max_folders].floor = extract_int(buf, 2);
2599 fold[max_folders].hasnewmsgs =
2600 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2601 if (flags & QR_MAILBOX) {
2602 fold[max_folders].is_mailbox = 1;
2604 fold[max_folders].view = extract_int(buf, 6);
2605 room_to_folder(fold[max_folders].name,
2606 fold[max_folders].room,
2607 fold[max_folders].floor,
2608 fold[max_folders].is_mailbox);
2609 fold[max_folders].selectable = 1;
2613 /* Bubble-sort the folder list */
2614 for (i=0; i<max_folders; ++i) {
2615 for (j=0; j<(max_folders-1)-i; ++j) {
2616 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2617 swap = strcasecmp(fold[j].name, fold[j+1].name);
2620 if ( (fold[j+1].is_mailbox)
2621 && (!fold[j].is_mailbox)) {
2629 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2630 memcpy(&fold[j], &fold[j+1],
2631 sizeof(struct folder));
2632 memcpy(&fold[j+1], &ftmp,
2633 sizeof(struct folder));
2638 /* test only hackish view
2639 wprintf("<table><TR><TD>A Table</TD></TR></table>\n");
2640 for (i=0; i<max_folders; ++i) {
2641 escputs(fold[i].name);
2642 wprintf("<br />\n");
2646 if (!strcasecmp(viewpref, "folders")) {
2647 do_folder_view(fold, max_folders, num_floors);
2650 do_rooms_view(fold, max_folders, num_floors);
2658 /* Do either a known rooms list or a folders list, depending on the
2662 char listviewpref[SIZ];
2664 output_headers(1, 1, 2, 0, 0, 0);
2667 /* Determine whether the user is trying to change views */
2668 if (bstr("view") != NULL) {
2669 if (strlen(bstr("view")) > 0) {
2670 set_preference("roomlistview", bstr("view"), 1);
2674 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2676 if ( (strcasecmp(listviewpref, "folders"))
2677 && (strcasecmp(listviewpref, "table")) ) {
2678 strcpy(listviewpref, "rooms");
2682 wprintf("<div id=\"banner\">\n"
2683 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2684 "<SPAN CLASS=\"titlebar\">"
2686 if (!strcasecmp(listviewpref, "rooms")) {
2687 wprintf("Room list");
2689 if (!strcasecmp(listviewpref, "folders")) {
2690 wprintf("Folder list");
2692 if (!strcasecmp(listviewpref, "table")) {
2693 wprintf("Room list");
2695 wprintf("</SPAN></TD>\n");
2697 /* offer the ability to switch views */
2698 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2699 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2700 "OnChange=\"location.href=roomlistomatic.newview.options"
2701 "[selectedIndex].value\">\n");
2703 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2706 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2709 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2710 "View as folder list"
2712 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2715 wprintf("</SELECT><br />");
2717 wprintf("</FORM></TD></TR></TABLE>\n");
2720 "<div id=\"content\">\n");
2722 /* Display the room list in the user's preferred format */
2723 list_all_rooms_by_floor(listviewpref);
2729 * Set the message expire policy for this room and/or floor
2731 void set_room_policy(void) {
2734 if (strlen(bstr("ok_button")) == 0) {
2735 strcpy(WC->ImportantMessage,
2736 _("Cancelled. Changes were not saved."));
2741 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2742 serv_getln(buf, sizeof buf);
2743 strcpy(WC->ImportantMessage, &buf[4]);
2745 if (WC->axlevel >= 6) {
2746 strcat(WC->ImportantMessage, "<br />\n");
2747 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2748 serv_getln(buf, sizeof buf);
2749 strcat(WC->ImportantMessage, &buf[4]);