4 * Lots of different room-related operations.
13 #include <sys/types.h>
15 #include <sys/socket.h>
18 #include <netinet/in.h>
46 char floorlist[128][SIZ];
49 * load the list of floors
51 void load_floorlist(void)
56 for (a = 0; a < 128; ++a)
62 strcpy(floorlist[0], "Main Floor");
65 while (serv_gets(buf), strcmp(buf, "000")) {
66 extract(floorlist[extract_int(buf, 0)], buf, 1);
72 * remove a room from the march list
74 void remove_march(char *aaa)
76 struct march *mptr, *mptr2;
78 if (WC->march == NULL)
81 if (!strcasecmp(WC->march->march_name, aaa)) {
82 mptr = WC->march->next;
88 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
89 if (!strcasecmp(mptr->march_name, aaa)) {
90 mptr2->next = mptr->next;
103 void room_tree_list(struct roomlisting *rp)
112 room_tree_list(rp->lnext);
114 strcpy(rmname, rp->rlname);
117 wprintf("<A HREF=\"/dotgoto&room=");
121 escputs1(rmname, 1, 1);
122 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
124 else if (f & QR_DIRECTORY)
126 else if (f & QR_NETWORK)
130 wprintf("</A><TT> </TT>\n");
132 room_tree_list(rp->rnext);
138 * Room ordering stuff (compare first by floor, then by order)
140 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
142 if ((r1 == NULL) && (r2 == NULL))
148 if (r1->rlfloor < r2->rlfloor)
150 if (r1->rlfloor > r2->rlfloor)
152 if (r1->rlorder < r2->rlorder)
154 if (r1->rlorder > r2->rlorder)
161 * Common code for all room listings
163 void listrms(char *variety)
168 struct roomlisting *rl = NULL;
169 struct roomlisting *rp;
170 struct roomlisting *rs;
173 /* Ask the server for a room list */
180 while (serv_gets(buf), strcmp(buf, "000")) {
182 rp = malloc(sizeof(struct roomlisting));
183 extract(rp->rlname, buf, 0);
184 rp->rlflags = extract_int(buf, 1);
185 rp->rlfloor = extract_int(buf, 2);
186 rp->rlorder = extract_int(buf, 3);
195 if (rordercmp(rp, rs) < 0) {
196 if (rs->lnext == NULL) {
203 if (rs->rnext == NULL) {
215 /* If no rooms were listed, print an nbsp to make the cell
216 * borders show up anyway.
218 if (num_rooms == 0) wprintf(" ");
223 * list all forgotten rooms
225 void zapped_list(void)
227 output_headers(1, 1, 0, 0, 0, 0, 0);
229 svprintf("BOXTITLE", WCS_STRING, "Zapped (forgotten) rooms");
230 do_template("beginbox");
234 wprintf("<br /><br />\n");
235 wprintf("Click on any room to un-zap it and goto that room.\n");
236 do_template("endbox");
242 * read this room's info file (set v to 1 for verbose mode)
251 fmout(NULL, "CENTER");
258 /* Display room graphic. The server doesn't actually
259 * need the room name, but we supply it in order to
260 * keep the browser from using a cached graphic from
263 void embed_room_graphic(void) {
266 serv_puts("OIMG _roompic_");
269 wprintf("<TD BGCOLOR=\"#444455\">");
270 wprintf("<IMG HEIGHT=64 SRC=\"/image&name=_roompic_&room=");
271 urlescputs(WC->wc_roomname);
280 /* Let the user know if new mail has arrived
282 void embed_newmail_button(void) {
283 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
285 "<A HREF=\"/dotgoto?room=_MAIL_\">"
286 "<IMG SRC=\"/static/mail.gif\" border=0 "
287 "ALT=\"You have new mail\">"
288 "<br /><SPAN CLASS=\"youhavemail\">"
289 "%d new mail</SPAN></A>", WC->new_mail);
290 WC->remember_new_mail = WC->new_mail;
297 * Display the current view and offer an option to change it
299 void embed_view_o_matic(void) {
302 wprintf("<FORM NAME=\"viewomatic\">\n"
303 "<SELECT NAME=\"newview\" SIZE=\"1\" "
304 "OnChange=\"location.href=viewomatic.newview.options"
305 "[selectedIndex].value\">\n");
307 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
309 * Only offer the views that make sense, given the default
310 * view for the room. For example, don't offer a Calendar
311 * view in a non-Calendar room.
315 || (i == WC->wc_default_view)
316 || ( (i == 0) && (WC->wc_default_view == 1) )
317 || ( (i == 1) && (WC->wc_default_view == 0) )
320 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
321 ((i == WC->wc_view) ? "SELECTED" : ""),
323 escputs(viewdefs[i]);
324 wprintf("</OPTION>\n");
327 wprintf("</SELECT></FORM>\n");
332 void embed_room_banner(char *got, int navbar_style) {
335 /* We need to have the information returned by a GOTO server command.
336 * If it isn't supplied, we fake it by issuing our own GOTO.
339 serv_printf("GOTO %s", WC->wc_roomname);
344 /* If the user happens to select the "make this my start page" link,
345 * we want it to remember the URL as a "/dotskip" one instead of
346 * a "skip" or "gotonext" or something like that.
348 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
351 /* Check for new mail. */
352 WC->new_mail = extract_int(&got[4], 9);
353 WC->wc_view = extract_int(&got[4], 11);
355 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
356 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
357 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
358 svcallback("ROOMPIC", embed_room_graphic);
359 svcallback("ROOMINFO", readinfo);
360 svcallback("YOUHAVEMAIL", embed_newmail_button);
361 svcallback("VIEWOMATIC", embed_view_o_matic);
362 svcallback("START", offer_start_page);
364 do_template("roombanner");
365 if (navbar_style != navbar_none) {
367 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
368 "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%%\"><tr>\n");
371 if (navbar_style == navbar_default) wprintf(
373 "<a href=\"/ungoto\">"
374 "<img align=\"middle\" src=\"/static/back.gif\" border=\"0\">"
375 "<span class=\"navbar_link\">Ungoto</span></A>"
379 if ( (navbar_style == navbar_default)
380 && (WC->wc_view != VIEW_CALENDAR)
381 && (WC->wc_view != VIEW_ADDRESSBOOK)
382 && (WC->wc_view != VIEW_NOTES)
383 && (WC->wc_view != VIEW_TASKS)
387 "<A HREF=\"/readnew\">"
388 "<img align=\"middle\" src=\"/static/readmsgs.gif\" border=\"0\">"
389 "<span class=\"navbar_link\">Read new messages</span></A>"
394 if (navbar_style == navbar_default) {
395 switch(WC->wc_view) {
396 case VIEW_ADDRESSBOOK:
399 "<A HREF=\"/readfwd\">"
400 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
402 "<span class=\"navbar_link\">"
410 "<A HREF=\"/readfwd?calview=day\">"
411 "<img align=\"middle\" src=\"/static/day_view.gif\" "
413 "<span class=\"navbar_link\">"
419 "<A HREF=\"/readfwd?calview=month\">"
420 "<img align=\"middle\" src=\"/static/month_view.gif\" "
422 "<span class=\"navbar_link\">"
430 "<A HREF=\"/readfwd\">"
431 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
433 "<span class=\"navbar_link\">"
441 "<A HREF=\"/readfwd\">"
442 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
444 "<span class=\"navbar_link\">"
452 "<A HREF=\"/readfwd\">"
453 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
455 "<span class=\"navbar_link\">"
463 if (navbar_style == navbar_default) {
466 "<A HREF=\"/display_enter\">"
467 "<img align=\"middle\" src=\"/static/enter.gif\" border=\"0\">"
468 "<span class=\"navbar_link\">"
470 switch(WC->wc_view) {
471 case VIEW_ADDRESSBOOK:
472 wprintf("Add new contact");
475 wprintf("Add new event");
478 wprintf("Add new task");
481 wprintf("Add new note");
484 wprintf("Enter a message");
487 wprintf("</span></a></td>\n");
490 if (navbar_style == navbar_default) wprintf(
493 "TITLE=\"Leave all messages marked as unread, go to next room with unread messages\">"
494 "<span class=\"navbar_link\">Skip this room</span>"
495 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
499 if (navbar_style == navbar_default) wprintf(
501 "<A HREF=\"/gotonext\" "
502 "TITLE=\"Mark all messages as read, go to next room with unread messages\">"
503 "<span class=\"navbar_link\">Goto next room</span>"
504 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
508 wprintf("</tr></table></div>\n");
518 * back end routine to take the session to a new room
521 void gotoroom(char *gname)
524 static long ls = (-1L);
526 /* store ungoto information */
527 strcpy(WC->ugname, WC->wc_roomname);
530 /* move to the new room */
531 serv_printf("GOTO %s", gname);
534 serv_puts("GOTO _BASEROOM_");
540 extract(WC->wc_roomname, &buf[4], 0);
541 WC->room_flags = extract_int(&buf[4], 4);
542 /* highest_msg_read = extract_int(&buf[4],6);
543 maxmsgnum = extract_int(&buf[4],5);
544 is_mail = (char) extract_int(&buf[4],7); */
545 ls = extract_long(&buf[4], 6);
546 WC->wc_floor = extract_int(&buf[4], 10);
547 WC->wc_view = extract_int(&buf[4], 11);
548 WC->wc_default_view = extract_int(&buf[4], 12);
551 WC->is_room_aide = WC->is_aide;
553 WC->is_room_aide = (char) extract_int(&buf[4], 8);
555 remove_march(WC->wc_roomname);
556 if (!strcasecmp(gname, "_BASEROOM_"))
562 * Locate the room on the march list which we most want to go to. Each room
563 * is measured given a "weight" of preference based on various factors.
565 char *pop_march(int desired_floor)
567 static char TheRoom[128];
569 int TheOrder = 32767;
572 struct march *mptr = NULL;
574 strcpy(TheRoom, "_BASEROOM_");
575 if (WC->march == NULL)
578 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
580 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
581 weight = weight + 10000;
582 if (mptr->march_floor == desired_floor)
583 weight = weight + 5000;
585 weight = weight + ((128 - (mptr->march_floor)) * 128);
586 weight = weight + (128 - (mptr->march_order));
588 if (weight > TheWeight) {
590 strcpy(TheRoom, mptr->march_name);
591 TheFloor = mptr->march_floor;
592 TheOrder = mptr->march_order;
600 /* Goto next room having unread messages.
601 * We want to skip over rooms that the user has already been to, and take the
602 * user back to the lobby when done. The room we end up in is placed in
603 * newroom - which is set to 0 (the lobby) initially.
604 * We start the search in the current room rather than the beginning to prevent
605 * two or more concurrent users from dragging each other back to the same room.
610 struct march *mptr, *mptr2;
613 /* First check to see if the march-mode list is already allocated.
614 * If it is, pop the first room off the list and go there.
617 if (WC->march == NULL) {
621 while (serv_gets(buf), strcmp(buf, "000")) {
622 mptr = (struct march *) malloc(sizeof(struct march));
624 extract(mptr->march_name, buf, 0);
625 mptr->march_floor = extract_int(buf, 2);
626 mptr->march_order = extract_int(buf, 3);
627 if (WC->march == NULL) {
631 while (mptr2->next != NULL)
636 /* add _BASEROOM_ to the end of the march list, so the user will end up
637 * in the system base room (usually the Lobby>) at the end of the loop
639 mptr = (struct march *) malloc(sizeof(struct march));
641 strcpy(mptr->march_name, "_BASEROOM_");
642 if (WC->march == NULL) {
646 while (mptr2->next != NULL)
651 * ...and remove the room we're currently in, so a <G>oto doesn't make us
652 * walk around in circles
654 remove_march(WC->wc_roomname);
656 if (WC->march != NULL) {
657 strcpy(next_room, pop_march(-1));
659 strcpy(next_room, "_BASEROOM_");
663 smart_goto(next_room);
667 void smart_goto(char *next_room) {
675 * mark all messages in current room as having been read
677 void slrp_highest(void)
682 serv_puts("SLRP HIGHEST");
685 wprintf("<EM>%s</EM><br />\n", &buf[4]);
692 * un-goto the previous room
698 if (!strcmp(WC->ugname, "")) {
699 smart_goto(WC->wc_roomname);
702 serv_printf("GOTO %s", WC->ugname);
705 smart_goto(WC->wc_roomname);
708 if (WC->uglsn >= 0L) {
709 serv_printf("SLRP %ld", WC->uglsn);
712 strcpy(buf, WC->ugname);
713 strcpy(WC->ugname, "");
722 * Set/clear/read the "self-service list subscribe" flag for a room
724 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
725 * Always returns the new value.
728 int self_service(int newval) {
729 int current_value = 0;
735 int flags, floor, order, view, flags2;
739 if (buf[0] != '2') return(0);
741 extract(name, &buf[4], 0);
742 extract(password, &buf[4], 1);
743 extract(dirname, &buf[4], 2);
744 flags = extract_int(&buf[4], 3);
745 floor = extract_int(&buf[4], 4);
746 order = extract_int(&buf[4], 5);
747 view = extract_int(&buf[4], 6);
748 flags2 = extract_int(&buf[4], 7);
750 if (flags2 & QR2_SELFLIST) {
758 flags2 = flags2 | QR2_SELFLIST;
760 else if (newval == 0) {
761 flags2 = flags2 & ~QR2_SELFLIST;
764 return(current_value);
767 if (newval != current_value) {
768 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
769 name, password, dirname, flags,
770 floor, order, view, flags2);
784 * display the form for editing a room
786 void display_editroom(void)
791 char remote_room[SIZ];
794 char er_password[10];
796 char er_roomaide[26];
802 char *not_shared_with;
809 if (strlen(tab) == 0) tab = "admin";
816 strcpy(WC->ImportantMessage, &buf[4]);
820 extract(er_name, &buf[4], 0);
821 extract(er_password, &buf[4], 1);
822 extract(er_dirname, &buf[4], 2);
823 er_flags = extract_int(&buf[4], 3);
824 er_floor = extract_int(&buf[4], 4);
826 output_headers(1, 1, 1, 0, 0, 0, 0);
828 /* print the tabbed dialog */
830 "<div style=\"margin-right:1px\">"
831 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
833 "<TD> </TD>\n");
835 if (!strcmp(tab, "admin")) {
836 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
839 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
841 wprintf("Administration");
842 if (!strcmp(tab, "admin")) {
843 wprintf("</SPAN></TD>\n");
846 wprintf("</A></TD>\n");
849 wprintf("<TD> </TD>\n");
851 if (!strcmp(tab, "config")) {
852 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
855 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
857 wprintf("Configuration");
858 if (!strcmp(tab, "config")) {
859 wprintf("</SPAN></TD>\n");
862 wprintf("</A></TD>\n");
865 wprintf("<TD> </TD>\n");
867 if (!strcmp(tab, "expire")) {
868 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
871 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
873 wprintf("Message expire policy");
874 if (!strcmp(tab, "expire")) {
875 wprintf("</SPAN></TD>\n");
878 wprintf("</A></TD>\n");
881 wprintf("<TD> </TD>\n");
883 if (!strcmp(tab, "access")) {
884 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
887 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=access\">");
889 wprintf("Access controls");
890 if (!strcmp(tab, "access")) {
891 wprintf("</SPAN></TD>\n");
894 wprintf("</A></TD>\n");
897 wprintf("<TD> </TD>\n");
899 if (!strcmp(tab, "sharing")) {
900 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
903 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
906 if (!strcmp(tab, "sharing")) {
907 wprintf("</SPAN></TD>\n");
910 wprintf("</A></TD>\n");
913 wprintf("<TD> </TD>\n");
915 if (!strcmp(tab, "listserv")) {
916 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
919 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
921 wprintf("Mailing list service");
922 if (!strcmp(tab, "listserv")) {
923 wprintf("</SPAN></TD>\n");
926 wprintf("</A></TD>\n");
929 wprintf("<TD> </TD>\n");
931 wprintf("</TR></TABLE></div>\n");
932 /* end tabbed dialog */
934 /* begin content of whatever tab is open now */
935 wprintf("<div style=\"margin-right:1px\">"
936 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
939 if (!strcmp(tab, "admin")) {
941 "<LI><A HREF=\"/confirm_delete_room\">\n"
942 "Delete this room</A>\n"
943 "<LI><A HREF=\"/display_editroompic\">\n"
944 "Set or change the graphic for this room's banner</A>\n"
945 "<LI><A HREF=\"/display_editinfo\">\n"
946 "Edit this room's Info file</A>\n"
950 if (!strcmp(tab, "config")) {
951 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
953 wprintf("<UL><LI>Name of room: ");
954 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
956 wprintf("<LI>Resides on floor: ");
957 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
958 for (i = 0; i < 128; ++i)
959 if (strlen(floorlist[i]) > 0) {
962 wprintf("SELECTED ");
963 wprintf("VALUE=\"%d\">", i);
964 escputs(floorlist[i]);
965 wprintf("</OPTION>\n");
967 wprintf("</SELECT>\n");
969 wprintf("<LI>Type of room:<UL>\n");
971 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
972 if ((er_flags & QR_PRIVATE) == 0)
974 wprintf("> Public room\n");
976 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
977 if ((er_flags & QR_PRIVATE) &&
978 (er_flags & QR_GUESSNAME))
980 wprintf("> Private - guess name\n");
982 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
983 if ((er_flags & QR_PRIVATE) &&
984 (er_flags & QR_PASSWORDED))
986 wprintf("> Private - require password:\n");
987 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
989 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
990 if ((er_flags & QR_PRIVATE)
991 && ((er_flags & QR_GUESSNAME) == 0)
992 && ((er_flags & QR_PASSWORDED) == 0))
994 wprintf("> Private - invitation only\n");
996 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
997 wprintf("> If private, cause current users to forget room\n");
1001 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1002 if (er_flags & QR_PREFONLY)
1003 wprintf("CHECKED ");
1004 wprintf("> Preferred users only\n");
1006 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1007 if (er_flags & QR_READONLY)
1008 wprintf("CHECKED ");
1009 wprintf("> Read-only room\n");
1011 /* directory stuff */
1012 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1013 if (er_flags & QR_DIRECTORY)
1014 wprintf("CHECKED ");
1015 wprintf("> File directory room\n");
1017 wprintf("<UL><LI>Directory name: ");
1018 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
1020 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1021 if (er_flags & QR_UPLOAD)
1022 wprintf("CHECKED ");
1023 wprintf("> Uploading allowed\n");
1025 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1026 if (er_flags & QR_DOWNLOAD)
1027 wprintf("CHECKED ");
1028 wprintf("> Downloading allowed\n");
1030 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1031 if (er_flags & QR_VISDIR)
1032 wprintf("CHECKED ");
1033 wprintf("> Visible directory</UL>\n");
1035 /* end of directory stuff */
1037 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1038 if (er_flags & QR_NETWORK)
1039 wprintf("CHECKED ");
1040 wprintf("> Network shared room\n");
1042 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1043 if (er_flags & QR_PERMANENT)
1044 wprintf("CHECKED ");
1045 wprintf("> Permanent (does not auto-purge)\n");
1047 /* start of anon options */
1049 wprintf("<LI>Anonymous messages<UL>\n");
1051 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1052 if (((er_flags & QR_ANONONLY) == 0)
1053 && ((er_flags & QR_ANONOPT) == 0))
1054 wprintf("CHECKED ");
1055 wprintf("> No anonymous messages\n");
1057 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1058 if (er_flags & QR_ANONONLY)
1059 wprintf("CHECKED ");
1060 wprintf("> All messages are anonymous\n");
1062 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1063 if (er_flags & QR_ANONOPT)
1064 wprintf("CHECKED ");
1065 wprintf("> Prompt user when entering messages</UL>\n");
1067 /* end of anon options */
1069 wprintf("<LI>Room aide: \n");
1072 if (buf[0] != '2') {
1073 wprintf("<EM>%s</EM>\n", &buf[4]);
1075 extract(er_roomaide, &buf[4], 0);
1076 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1079 wprintf("</UL><CENTER>\n");
1080 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1081 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1083 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
1089 /* Sharing the room with other Citadel nodes... */
1090 if (!strcmp(tab, "sharing")) {
1092 shared_with = strdup("");
1093 not_shared_with = strdup("");
1095 /* Learn the current configuration */
1096 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1098 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1099 extract(node, buf, 0);
1100 not_shared_with = realloc(not_shared_with,
1101 strlen(not_shared_with) + 32);
1102 strcat(not_shared_with, node);
1103 strcat(not_shared_with, "\n");
1108 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1109 extract(cmd, buf, 0);
1110 extract(node, buf, 1);
1111 extract(remote_room, buf, 2);
1112 if (!strcasecmp(cmd, "ignet_push_share")) {
1113 shared_with = realloc(shared_with,
1114 strlen(shared_with) + 32);
1115 strcat(shared_with, node);
1116 if (strlen(remote_room) > 0) {
1117 strcat(shared_with, "|");
1118 strcat(shared_with, remote_room);
1120 strcat(shared_with, "\n");
1124 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1125 extract_token(buf, shared_with, i, '\n');
1126 extract_token(node, buf, 0, '|');
1127 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1128 extract_token(cmd, not_shared_with, j, '\n');
1129 if (!strcasecmp(node, cmd)) {
1130 remove_token(not_shared_with, j, '\n');
1135 /* Display the stuff */
1136 wprintf("<CENTER><br />"
1137 "<TABLE border=1 cellpadding=5><TR>"
1138 "<TD><B><I>Shared with</I></B></TD>"
1139 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1140 "<TR><TD VALIGN=TOP>\n");
1142 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1143 "<TD>Remote node name</TD>"
1144 "<TD>Remote room name</TD>"
1149 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1150 extract_token(buf, shared_with, i, '\n');
1151 extract_token(node, buf, 0, '|');
1152 extract_token(remote_room, buf, 1, '|');
1153 if (strlen(node) > 0) {
1154 wprintf("<FORM METHOD=\"POST\" "
1155 "ACTION=\"/netedit\">"
1156 "<TR><TD>%s</TD>\n", node);
1159 if (strlen(remote_room) > 0) {
1160 escputs(remote_room);
1166 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1167 "VALUE=\"ignet_push_share|");
1169 if (strlen(remote_room) > 0) {
1171 urlescputs(remote_room);
1174 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1175 "VALUE=\"sharing\">\n");
1176 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1177 "VALUE=\"remove\">\n");
1178 wprintf("<INPUT TYPE=\"submit\" "
1179 "NAME=\"sc\" VALUE=\"Unshare\">");
1180 wprintf("</TD></TR></FORM>\n");
1184 wprintf("</TABLE>\n");
1185 wprintf("</TD><TD VALIGN=TOP>\n");
1186 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1187 "<TD>Remote node name</TD>"
1188 "<TD>Remote room name</TD>"
1193 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1194 extract_token(node, not_shared_with, i, '\n');
1195 if (strlen(node) > 0) {
1196 wprintf("<FORM METHOD=\"POST\" "
1197 "ACTION=\"/netedit\">"
1201 "<INPUT TYPE=\"INPUT\" "
1205 wprintf("<INPUT TYPE=\"hidden\" "
1207 "VALUE=\"ignet_push_share|");
1210 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1211 "VALUE=\"sharing\">\n");
1212 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1213 "VALUE=\"add\">\n");
1214 wprintf("<INPUT TYPE=\"submit\" "
1215 "NAME=\"sc\" VALUE=\"Share\">");
1216 wprintf("</TD></TR></FORM>\n");
1220 wprintf("</TABLE>\n");
1221 wprintf("</TD></TR>"
1222 "</TABLE></CENTER><br />\n"
1223 "<I><B>Notes:</B><UL><LI>When sharing a room, "
1224 "it must be shared from both ends. Adding a node to "
1225 "the 'shared' list sends messages out, but in order to"
1226 " receive messages, the other nodes must be configured"
1227 " to send messages out to your system as well.\n"
1228 "<LI>If the remote room name is blank, it is assumed "
1229 "that the room name is identical on the remote node."
1230 "<LI>If the remote room name is different, the remote "
1231 "node must also configure the name of the room here."
1237 /* Mailing list management */
1238 if (!strcmp(tab, "listserv")) {
1240 wprintf("<br /><center>"
1241 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1242 "<TR><TD VALIGN=TOP>");
1244 wprintf("<i>The contents of this room are being "
1245 "mailed <b>as individual messages</b> "
1246 "to the following list recipients:"
1247 "</i><br /><br />\n");
1251 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1252 extract(cmd, buf, 0);
1253 if (!strcasecmp(cmd, "listrecp")) {
1254 extract(recp, buf, 1);
1257 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1260 wprintf("&tab=listserv\">(remove)</A><br />");
1264 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1265 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1266 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1267 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1268 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1269 wprintf("</FORM>\n");
1271 wprintf("</TD><TD VALIGN=TOP>\n");
1273 wprintf("<i>The contents of this room are being "
1274 "mailed <b>in digest form</b> "
1275 "to the following list recipients:"
1276 "</i><br /><br />\n");
1280 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1281 extract(cmd, buf, 0);
1282 if (!strcasecmp(cmd, "digestrecp")) {
1283 extract(recp, buf, 1);
1286 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1289 wprintf("&tab=listserv\">(remove)</A><br />");
1293 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1294 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1295 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1296 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1297 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1298 wprintf("</FORM>\n");
1300 wprintf("</TD></TR></TABLE><hr />\n");
1302 if (self_service(999) == 1) {
1303 wprintf("This room is configured to allow "
1304 "self-service subscribe/unsubscribe requests."
1305 " <A HREF=\"/toggle_self_service?newval=0&"
1307 "Click to disable.</A><br />\n"
1308 "The URL for subscribe/unsubscribe is: "
1309 "<TT>http://%s/listsub</TT><br />\n",
1314 wprintf("This room is <i>not</i> configured to allow "
1315 "self-service subscribe/unsubscribe requests."
1316 " <A HREF=\"/toggle_self_service?newval=1&"
1318 "Click to enable.</A><br />\n"
1323 wprintf("</CENTER>\n");
1327 /* Mailing list management */
1328 if (!strcmp(tab, "expire")) {
1330 serv_puts("GPEX room");
1332 if (buf[0] == '2') {
1333 roompolicy = extract_int(&buf[4], 0);
1334 roomvalue = extract_int(&buf[4], 1);
1337 serv_puts("GPEX floor");
1339 if (buf[0] == '2') {
1340 floorpolicy = extract_int(&buf[4], 0);
1341 floorvalue = extract_int(&buf[4], 1);
1344 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1345 wprintf("<TABLE border=0 cellspacing=5>\n");
1346 wprintf("<TR><TD>Message expire policy for this room<br />(");
1347 escputs(WC->wc_roomname);
1348 wprintf(")</TD><TD>");
1349 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1350 ((roompolicy == 0) ? "CHECKED" : "") );
1351 wprintf("Use the default policy for this floor<br />\n");
1352 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1353 ((roompolicy == 1) ? "CHECKED" : "") );
1354 wprintf("Never automatically expire messages<br />\n");
1355 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1356 ((roompolicy == 2) ? "CHECKED" : "") );
1357 wprintf("Expire by message count<br />\n");
1358 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1359 ((roompolicy == 3) ? "CHECKED" : "") );
1360 wprintf("Expire by message age<br />");
1361 wprintf("Number of messages or days: ");
1362 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1363 wprintf("</TD></TR>\n");
1365 if (WC->axlevel >= 6) {
1366 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1367 wprintf("<TR><TD>Message expire policy for this floor<br />(");
1368 escputs(floorlist[WC->wc_floor]);
1369 wprintf(")</TD><TD>");
1370 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1371 ((floorpolicy == 0) ? "CHECKED" : "") );
1372 wprintf("Use the system default<br />\n");
1373 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1374 ((floorpolicy == 1) ? "CHECKED" : "") );
1375 wprintf("Never automatically expire messages<br />\n");
1376 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1377 ((floorpolicy == 2) ? "CHECKED" : "") );
1378 wprintf("Expire by message count<br />\n");
1379 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1380 ((floorpolicy == 3) ? "CHECKED" : "") );
1381 wprintf("Expire by message age<br />");
1382 wprintf("Number of messages or days: ");
1383 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1387 wprintf("<CENTER>\n");
1388 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1389 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1391 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1392 wprintf("</CENTER></TD><TR>\n");
1394 wprintf("</TABLE>\n"
1395 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1401 /* Mailing list management */
1402 if (!strcmp(tab, "access")) {
1406 /* end content of whatever tab is open now */
1407 wprintf("</TD></TR></TABLE></div>\n");
1414 * Toggle self-service list subscription
1416 void toggle_self_service(void) {
1419 newval = atoi(bstr("newval"));
1420 self_service(newval);
1427 * save new parameters for a room
1433 char er_password[10];
1434 char er_dirname[15];
1435 char er_roomaide[26];
1441 if (strcmp(bstr("sc"), "OK")) {
1442 strcpy(WC->ImportantMessage,
1443 "Cancelled. Changes were not saved.");
1450 if (buf[0] != '2') {
1451 strcpy(WC->ImportantMessage, &buf[4]);
1455 extract(er_name, &buf[4], 0);
1456 extract(er_password, &buf[4], 1);
1457 extract(er_dirname, &buf[4], 2);
1458 er_flags = extract_int(&buf[4], 3);
1460 strcpy(er_roomaide, bstr("er_roomaide"));
1461 if (strlen(er_roomaide) == 0) {
1464 if (buf[0] != '2') {
1465 strcpy(er_roomaide, "");
1467 extract(er_roomaide, &buf[4], 0);
1470 strcpy(buf, bstr("er_name"));
1472 if (strlen(buf) > 0)
1473 strcpy(er_name, buf);
1475 strcpy(buf, bstr("er_password"));
1477 if (strlen(buf) > 0)
1478 strcpy(er_password, buf);
1480 strcpy(buf, bstr("er_dirname"));
1482 if (strlen(buf) > 0)
1483 strcpy(er_dirname, buf);
1485 strcpy(buf, bstr("type"));
1486 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1488 if (!strcmp(buf, "invonly")) {
1489 er_flags |= (QR_PRIVATE);
1491 if (!strcmp(buf, "guessname")) {
1492 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1494 if (!strcmp(buf, "passworded")) {
1495 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1497 if (!strcmp(bstr("prefonly"), "yes")) {
1498 er_flags |= QR_PREFONLY;
1500 er_flags &= ~QR_PREFONLY;
1503 if (!strcmp(bstr("readonly"), "yes")) {
1504 er_flags |= QR_READONLY;
1506 er_flags &= ~QR_READONLY;
1509 if (!strcmp(bstr("permanent"), "yes")) {
1510 er_flags |= QR_PERMANENT;
1512 er_flags &= ~QR_PERMANENT;
1515 if (!strcmp(bstr("network"), "yes")) {
1516 er_flags |= QR_NETWORK;
1518 er_flags &= ~QR_NETWORK;
1521 if (!strcmp(bstr("directory"), "yes")) {
1522 er_flags |= QR_DIRECTORY;
1524 er_flags &= ~QR_DIRECTORY;
1527 if (!strcmp(bstr("ulallowed"), "yes")) {
1528 er_flags |= QR_UPLOAD;
1530 er_flags &= ~QR_UPLOAD;
1533 if (!strcmp(bstr("dlallowed"), "yes")) {
1534 er_flags |= QR_DOWNLOAD;
1536 er_flags &= ~QR_DOWNLOAD;
1539 if (!strcmp(bstr("visdir"), "yes")) {
1540 er_flags |= QR_VISDIR;
1542 er_flags &= ~QR_VISDIR;
1545 strcpy(buf, bstr("anon"));
1547 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1548 if (!strcmp(buf, "anononly"))
1549 er_flags |= QR_ANONONLY;
1550 if (!strcmp(buf, "anon2"))
1551 er_flags |= QR_ANONOPT;
1554 if (!strcmp(bstr("bump"), "yes"))
1557 er_floor = atoi(bstr("er_floor"));
1559 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1560 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1563 if (buf[0] != '2') {
1564 strcpy(WC->ImportantMessage, &buf[4]);
1570 if (strlen(er_roomaide) > 0) {
1571 sprintf(buf, "SETA %s", er_roomaide);
1574 if (buf[0] != '2') {
1575 strcpy(WC->ImportantMessage, &buf[4]);
1576 display_main_menu();
1581 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1588 * Display form for Invite, Kick, and show Who Knows a room
1590 void do_invt_kick(void) {
1591 char buf[SIZ], room[SIZ], username[SIZ];
1596 if (buf[0] != '2') {
1600 extract(room, &buf[4], 0);
1602 strcpy(username, bstr("username"));
1604 if (!strcmp(bstr("sc"), "Kick")) {
1605 sprintf(buf, "KICK %s", username);
1609 if (buf[0] != '2') {
1610 strcpy(WC->ImportantMessage, &buf[4]);
1612 sprintf(WC->ImportantMessage,
1613 "<B><I>User %s kicked out of room %s.</I></B>\n",
1618 if (!strcmp(bstr("sc"), "Invite")) {
1619 sprintf(buf, "INVT %s", username);
1623 if (buf[0] != '2') {
1624 strcpy(WC->ImportantMessage, &buf[4]);
1626 sprintf(WC->ImportantMessage,
1627 "<B><I>User %s invited to room %s.</I></B>\n",
1638 * Display form for Invite, Kick, and show Who Knows a room
1640 void display_whok(void)
1642 char buf[SIZ], room[SIZ], username[SIZ];
1647 if (buf[0] != '2') {
1651 extract(room, &buf[4], 0);
1654 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1655 "<TD>The users listed below have access to this room. "
1656 "To remove a user from the access list, select the user "
1657 "name from the list and click 'Kick'.<br /><br />");
1659 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1660 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1661 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1664 if (buf[0] == '1') {
1665 while (serv_gets(buf), strcmp(buf, "000")) {
1666 extract(username, buf, 0);
1667 wprintf("<OPTION>");
1672 wprintf("</SELECT><br />\n");
1674 wprintf("<input type=submit name=sc value=\"Kick\">");
1675 wprintf("</FORM></CENTER>\n");
1678 "To grant another user access to this room, enter the "
1679 "user name in the box below and click 'Invite'.<br /><br />");
1681 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1682 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1683 wprintf("Invite: ");
1684 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1685 "<input type=\"hidden\" name=\"sc\" value=\"Invite\">"
1686 "<input type=\"submit\" value=\"Invite\">"
1687 "</FORM></CENTER>\n");
1689 wprintf("</TD></TR></TABLE>\n");
1696 * display the form for entering a new room
1698 void display_entroom(void)
1703 serv_puts("CRE8 0");
1706 if (buf[0] != '2') {
1707 strcpy(WC->ImportantMessage, &buf[4]);
1708 display_main_menu();
1712 output_headers(1, 1, 2, 0, 0, 0, 0);
1713 wprintf("<div id=\"banner\">\n"
1714 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1715 "<SPAN CLASS=\"titlebar\">Create a new room</SPAN>"
1716 "</TD></TR></TABLE>\n"
1717 "</div>\n<div id=\"content\">\n"
1720 wprintf("<div style=\"margin-right:1px\">"
1721 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1723 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1725 wprintf("<UL><LI>Name of room: ");
1726 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1728 wprintf("<LI>Resides on floor: ");
1730 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1731 for (i = 0; i < 128; ++i)
1732 if (strlen(floorlist[i]) > 0) {
1733 wprintf("<OPTION ");
1734 wprintf("VALUE=\"%d\">", i);
1735 escputs(floorlist[i]);
1736 wprintf("</OPTION>\n");
1738 wprintf("</SELECT>\n");
1740 wprintf("<LI>Default view for room: ");
1741 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1742 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1743 wprintf("<OPTION %s VALUE=\"%d\">",
1744 ((i == 0) ? "SELECTED" : ""), i );
1745 escputs(viewdefs[i]);
1746 wprintf("</OPTION>\n");
1748 wprintf("</SELECT>\n");
1750 wprintf("<LI>Type of room:<UL>\n");
1752 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1753 wprintf("CHECKED > Public room\n");
1755 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1756 wprintf("> Private - guess name\n");
1758 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1759 wprintf("> Private - require password:\n");
1760 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1762 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1763 wprintf("> Private - invitation only\n");
1765 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1766 wprintf("> Personal (mailbox for you only)\n");
1769 wprintf("<CENTER>\n");
1770 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1772 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1773 wprintf("</CENTER>\n");
1774 wprintf("</FORM>\n<hr />");
1775 serv_printf("MESG roomaccess");
1777 if (buf[0] == '1') {
1778 fmout(NULL, "CENTER");
1780 wprintf("</td></tr></table></div>\n");
1788 * support function for entroom() -- sets the default view
1790 void er_set_default_view(int newview) {
1804 if (buf[0] != '2') return;
1806 extract(rm_name, &buf[4], 0);
1807 extract(rm_pass, &buf[4], 1);
1808 extract(rm_dir, &buf[4], 2);
1809 rm_bits1 = extract_int(&buf[4], 3);
1810 rm_floor = extract_int(&buf[4], 4);
1811 rm_listorder = extract_int(&buf[4], 5);
1812 rm_bits2 = extract_int(&buf[4], 7);
1814 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1815 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1816 rm_listorder, newview, rm_bits2
1831 char er_password[SIZ];
1836 if (strcmp(bstr("sc"), "OK")) {
1837 strcpy(WC->ImportantMessage,
1838 "Cancelled. No new room was created.");
1839 display_main_menu();
1842 strcpy(er_name, bstr("er_name"));
1843 strcpy(er_type, bstr("type"));
1844 strcpy(er_password, bstr("er_password"));
1845 er_floor = atoi(bstr("er_floor"));
1846 er_view = atoi(bstr("er_view"));
1849 if (!strcmp(er_type, "guessname"))
1851 if (!strcmp(er_type, "passworded"))
1853 if (!strcmp(er_type, "invonly"))
1855 if (!strcmp(er_type, "personal"))
1858 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1859 er_name, er_num_type, er_password, er_floor, 0, er_view);
1862 if (buf[0] != '2') {
1863 strcpy(WC->ImportantMessage, &buf[4]);
1864 display_main_menu();
1868 do_change_view(er_view); /* Now go there */
1873 * display the screen to enter a private room
1875 void display_private(char *rname, int req_pass)
1878 output_headers(1, 1, 0, 0, 0, 0, 0);
1880 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1881 do_template("beginbox");
1883 wprintf("<CENTER>\n");
1884 wprintf("<br />If you know the name of a hidden (guess-name) or\n");
1885 wprintf("passworded room, you can enter that room by typing\n");
1886 wprintf("its name below. Once you gain access to a private\n");
1887 wprintf("room, it will appear in your regular room listings\n");
1888 wprintf("so you don't have to keep returning here.\n");
1889 wprintf("<br /><br />");
1891 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1893 wprintf("<table border=\"0\" cellspacing=\"5\" "
1894 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1896 "Enter room name:</TD><TD>"
1897 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1898 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1901 wprintf("</TD></TR><TR><TD>");
1902 wprintf("Enter room password:</TD><TD>");
1903 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1905 wprintf("</TD></TR></TABLE><br />\n");
1907 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1909 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1910 wprintf("</FORM>\n");
1911 do_template("endbox");
1916 * goto a private room
1918 void goto_private(void)
1923 if (strcasecmp(bstr("sc"), "OK")) {
1924 display_main_menu();
1927 strcpy(hold_rm, WC->wc_roomname);
1928 strcpy(buf, "GOTO ");
1929 strcat(buf, bstr("gr_name"));
1931 strcat(buf, bstr("gr_pass"));
1935 if (buf[0] == '2') {
1936 smart_goto(bstr("gr_name"));
1939 if (!strncmp(buf, "540", 3)) {
1940 display_private(bstr("gr_name"), 1);
1943 output_headers(1, 1, 1, 0, 0, 0, 0);
1944 wprintf("%s\n", &buf[4]);
1951 * display the screen to zap a room
1953 void display_zap(void)
1955 output_headers(1, 1, 2, 0, 0, 0, 0);
1957 wprintf("<div id=\"banner\">\n");
1958 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1959 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget/unsubscribe) the current room</SPAN>\n");
1960 wprintf("</TD></TR></TABLE>\n");
1961 wprintf("</div>\n<div id=\"content\">\n");
1963 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1964 wprintf("disappear from your room list. Is this what you wish ");
1965 wprintf("to do?<br />\n");
1967 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1968 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1970 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1971 wprintf("</FORM>\n");
1982 char final_destination[SIZ];
1984 /* If the forget-room routine fails for any reason, we fall back
1985 * to the current room; otherwise, we go to the Lobby
1987 strcpy(final_destination, WC->wc_roomname);
1989 if (!strcasecmp(bstr("sc"), "OK")) {
1990 serv_printf("GOTO %s", WC->wc_roomname);
1992 if (buf[0] == '2') {
1995 if (buf[0] == '2') {
1996 strcpy(final_destination, "_BASEROOM_");
2000 smart_goto(final_destination);
2007 * Confirm deletion of the current room
2009 void confirm_delete_room(void)
2013 serv_puts("KILL 0");
2015 if (buf[0] != '2') {
2016 strcpy(WC->ImportantMessage, &buf[4]);
2017 display_main_menu();
2020 output_headers(1, 1, 2, 0, 0, 0, 0);
2021 wprintf("<div id=\"banner\">\n");
2022 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2023 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
2024 wprintf("</TD></TR></TABLE>\n");
2025 wprintf("</div>\n<div id=\"content\">\n");
2027 wprintf("<CENTER>");
2028 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
2030 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
2031 escputs(WC->wc_roomname);
2032 wprintf("</FONT>?<br />\n");
2034 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
2035 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
2037 wprintf("</FORM></CENTER>\n");
2043 * Delete the current room
2045 void delete_room(void)
2050 strcpy(sc, bstr("sc"));
2052 if (strcasecmp(sc, "Delete")) {
2053 strcpy(WC->ImportantMessage,
2054 "Cancelled. This room was not deleted.");
2055 display_main_menu();
2058 serv_puts("KILL 1");
2060 if (buf[0] != '2') {
2061 strcpy(WC->ImportantMessage, &buf[4]);
2062 display_main_menu();
2065 smart_goto("_BASEROOM_");
2072 * Perform changes to a room's network configuration
2074 void netedit(void) {
2083 if (strlen(bstr("line"))==0) {
2088 strcpy(line, bstr("prefix"));
2089 strcat(line, bstr("line"));
2090 strcat(line, bstr("suffix"));
2100 if (buf[0] != '1') {
2106 /* This loop works for add *or* remove. Spiffy, eh? */
2107 while (serv_gets(buf), strcmp(buf, "000")) {
2108 extract(cmpa0, buf, 0);
2109 extract(cmpa1, buf, 1);
2110 extract(cmpb0, line, 0);
2111 extract(cmpb1, line, 1);
2112 if ( (strcasecmp(cmpa0, cmpb0))
2113 || (strcasecmp(cmpa1, cmpb1)) ) {
2114 fprintf(fp, "%s\n", buf);
2121 if (buf[0] != '4') {
2127 while (fgets(buf, sizeof buf, fp) != NULL) {
2128 buf[strlen(buf)-1] = 0;
2132 if (!strcasecmp(bstr("cmd"), "add")) {
2144 * Convert a room name to a folder-ish-looking name.
2146 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2151 * For mailboxes, just do it straight...
2154 sprintf(folder, "My folders|%s", room);
2158 * Otherwise, prefix the floor name as a "public folders" moniker
2161 sprintf(folder, "%s|%s", floorlist[floor], room);
2165 * Replace "\" characters with "|" for pseudo-folder-delimiting
2167 for (i=0; i<strlen(folder); ++i) {
2168 if (folder[i] == '\\') folder[i] = '|';
2176 * Back end for change_view()
2178 void do_change_view(int newview) {
2181 serv_printf("VIEW %d", newview);
2183 WC->wc_view = newview;
2184 smart_goto(WC->wc_roomname);
2190 * Change the view for this room
2192 void change_view(void) {
2195 view = atol(bstr("view"));
2196 do_change_view(view);
2201 * One big expanded tree list view --- like a folder list
2203 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2205 int levels, oldlevels;
2208 int has_subfolders = 0;
2210 /* Include the menu expanding/collapsing code */
2211 wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
2213 /* BEGIN TREE MENU */
2214 wprintf("<div style=\"background: white\">\n");
2215 wprintf("<div id=\"mainMenu\">\n");
2216 wprintf("<UL id=\"menuList\">\n");
2220 for (i=0; i<max_folders; ++i) {
2223 if ((i+1) < max_folders) {
2224 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2225 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2230 levels = num_tokens(fold[i].name, '|');
2232 if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
2233 for (t=0; t<(oldlevels-levels); ++t) {
2238 if (has_subfolders) {
2240 if (levels == 1) wprintf(" class=\"menubar\"");
2242 wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
2248 if (fold[i].selectable) {
2249 wprintf("<A HREF=\"/dotgoto?room=");
2250 urlescputs(fold[i].room);
2255 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2257 else if (fold[i].hasnewmsgs) {
2258 wprintf("<SPAN CLASS=\"roomlist_new\">");
2261 wprintf("<SPAN CLASS=\"roomlist_old\">");
2263 extract(buf, fold[i].name, levels-1);
2267 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2268 wprintf(" (INBOX)");
2271 if (fold[i].selectable) {
2276 if (has_subfolders) {
2277 wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
2279 ( (levels == 1) ? "menu" : "submenu")
2285 wprintf("</UL></UL>\n");
2286 wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
2287 for (i=0; i<actnum; ++i) {
2288 wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
2291 wprintf("</DIV>\n");
2296 * Boxes and rooms and lists ... oh my!
2298 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2301 int levels, oldlevels;
2304 static int columns = 3;
2305 int boxes_per_column = 0;
2306 int current_column = 0;
2310 while (nf % columns != 0) ++nf;
2311 boxes_per_column = (nf / columns);
2312 if (boxes_per_column < 1) boxes_per_column = 1;
2314 /* Outer table (for columnization) */
2315 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2316 "<tr><td valign=top>");
2320 for (i=0; i<max_folders; ++i) {
2322 levels = num_tokens(fold[i].name, '|');
2324 if ((levels == 1) && (oldlevels > 1)) {
2327 do_template("endbox");
2330 if ((num_boxes % boxes_per_column) == 0) {
2332 if (current_column < columns) {
2333 wprintf("</td><td valign=top>\n");
2340 /* Begin inner box */
2341 extract(buf, fold[i].name, levels-1);
2342 stresc(boxtitle, buf, 1, 0);
2343 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2344 do_template("beginbox");
2352 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2353 if (fold[i].selectable) {
2354 wprintf("<A HREF=\"/dotgoto?room=");
2355 urlescputs(fold[i].room);
2361 if (fold[i].hasnewmsgs) {
2362 wprintf("<SPAN CLASS=\"roomlist_new\">");
2365 wprintf("<SPAN CLASS=\"roomlist_old\">");
2367 extract(buf, fold[i].name, levels-1);
2370 if (fold[i].selectable) {
2376 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2377 wprintf(" (INBOX)");
2379 wprintf("<br />\n");
2382 /* End the final inner box */
2383 do_template("endbox");
2385 wprintf("</TD></TR></TABLE>\n");
2390 * Show the room list. (only should get called by
2391 * knrooms() because that's where output_headers() is called from)
2394 void list_all_rooms_by_floor(char *viewpref) {
2397 struct folder *fold = NULL;
2399 int max_folders = 0;
2400 int alloc_folders = 0;
2404 int num_floors = 1; /* add an extra one for private folders */
2406 /* Start with the mailboxes */
2409 fold = malloc(sizeof(struct folder));
2410 memset(fold, 0, sizeof(struct folder));
2411 strcpy(fold[0].name, "My folders");
2412 fold[0].is_mailbox = 1;
2414 /* Then add floors */
2417 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2418 if (max_folders >= alloc_folders) {
2419 alloc_folders = max_folders + 100;
2420 fold = realloc(fold,
2421 alloc_folders * sizeof(struct folder));
2423 memset(&fold[max_folders], 0, sizeof(struct folder));
2424 extract(fold[max_folders].name, buf, 1);
2432 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2433 if (max_folders >= alloc_folders) {
2434 alloc_folders = max_folders + 100;
2435 fold = realloc(fold,
2436 alloc_folders * sizeof(struct folder));
2438 memset(&fold[max_folders], 0, sizeof(struct folder));
2439 extract(fold[max_folders].room, buf, 0);
2440 ra_flags = extract_int(buf, 5);
2441 flags = extract_int(buf, 1);
2442 fold[max_folders].floor = extract_int(buf, 2);
2443 fold[max_folders].hasnewmsgs =
2444 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2445 if (flags & QR_MAILBOX) {
2446 fold[max_folders].is_mailbox = 1;
2448 room_to_folder(fold[max_folders].name,
2449 fold[max_folders].room,
2450 fold[max_folders].floor,
2451 fold[max_folders].is_mailbox);
2452 fold[max_folders].selectable = 1;
2456 /* Bubble-sort the folder list */
2457 for (i=0; i<max_folders; ++i) {
2458 for (j=0; j<(max_folders-1)-i; ++j) {
2459 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2460 swap = strcasecmp(fold[j].name, fold[j+1].name);
2463 if ( (fold[j+1].is_mailbox)
2464 && (!fold[j].is_mailbox)) {
2472 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2473 memcpy(&fold[j], &fold[j+1],
2474 sizeof(struct folder));
2475 memcpy(&fold[j+1], &ftmp,
2476 sizeof(struct folder));
2481 /* test only hackish view
2482 wprintf("<table><TR><TD>A Table</TD></TR></table>\n");
2483 for (i=0; i<max_folders; ++i) {
2484 escputs(fold[i].name);
2485 wprintf("<br />\n");
2489 if (!strcasecmp(viewpref, "folders")) {
2490 do_folder_view(fold, max_folders, num_floors);
2493 do_rooms_view(fold, max_folders, num_floors);
2501 /* Do either a known rooms list or a folders list, depending on the
2505 char listviewpref[SIZ];
2507 output_headers(1, 1, 2, 0, 0, 0, 0);
2510 /* Determine whether the user is trying to change views */
2511 if (bstr("view") != NULL) {
2512 if (strlen(bstr("view")) > 0) {
2513 set_preference("roomlistview", bstr("view"));
2517 get_preference("roomlistview", listviewpref);
2519 if ( (strcasecmp(listviewpref, "folders"))
2520 && (strcasecmp(listviewpref, "table")) ) {
2521 strcpy(listviewpref, "rooms");
2525 wprintf("<div id=\"banner\">\n"
2526 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2527 "<SPAN CLASS=\"titlebar\">"
2529 if (!strcasecmp(listviewpref, "rooms")) {
2530 wprintf("Room list");
2532 if (!strcasecmp(listviewpref, "folders")) {
2533 wprintf("Folder list");
2535 if (!strcasecmp(listviewpref, "table")) {
2536 wprintf("Room list");
2538 wprintf("</SPAN></TD>\n");
2540 /* offer the ability to switch views */
2541 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2542 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2543 "OnChange=\"location.href=roomlistomatic.newview.options"
2544 "[selectedIndex].value\">\n");
2546 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2549 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2552 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2553 "View as folder list"
2555 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2558 wprintf("</SELECT><br />");
2560 wprintf("</FORM></TD></TR></TABLE>\n");
2563 "<div id=\"content\">\n");
2565 /* Display the room list in the user's preferred format */
2566 list_all_rooms_by_floor(listviewpref);
2572 * Set the message expire policy for this room and/or floor
2574 void set_room_policy(void) {
2577 if (strcmp(bstr("sc"), "OK")) {
2578 strcpy(WC->ImportantMessage,
2579 "Cancelled. Changes were not saved.");
2584 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2586 strcpy(WC->ImportantMessage, &buf[4]);
2588 if (WC->axlevel >= 6) {
2589 strcat(WC->ImportantMessage, "<br />\n");
2590 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2592 strcat(WC->ImportantMessage, &buf[4]);