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 */
829 wprintf("<br /><TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
831 "<TD> </TD>\n");
833 if (!strcmp(tab, "admin")) {
834 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
837 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
839 wprintf("Administration");
840 if (!strcmp(tab, "admin")) {
841 wprintf("</SPAN></TD>\n");
844 wprintf("</A></TD>\n");
847 wprintf("<TD> </TD>\n");
849 if (!strcmp(tab, "config")) {
850 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
853 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
855 wprintf("Configuration");
856 if (!strcmp(tab, "config")) {
857 wprintf("</SPAN></TD>\n");
860 wprintf("</A></TD>\n");
863 wprintf("<TD> </TD>\n");
865 if (!strcmp(tab, "expire")) {
866 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
869 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
871 wprintf("Message expire policy");
872 if (!strcmp(tab, "expire")) {
873 wprintf("</SPAN></TD>\n");
876 wprintf("</A></TD>\n");
879 wprintf("<TD> </TD>\n");
881 if (!strcmp(tab, "sharing")) {
882 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
885 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
888 if (!strcmp(tab, "sharing")) {
889 wprintf("</SPAN></TD>\n");
892 wprintf("</A></TD>\n");
895 wprintf("<TD> </TD>\n");
897 if (!strcmp(tab, "listserv")) {
898 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
901 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
903 wprintf("Mailing list service");
904 if (!strcmp(tab, "listserv")) {
905 wprintf("</SPAN></TD>\n");
908 wprintf("</A></TD>\n");
911 wprintf("<TD> </TD>\n");
913 wprintf("</TR></TABLE>\n");
914 /* end tabbed dialog */
916 /* begin content of whatever tab is open now */
917 wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
920 if (!strcmp(tab, "admin")) {
922 "<LI><A HREF=\"/confirm_delete_room\">\n"
923 "Delete this room</A>\n"
924 "<LI><A HREF=\"/display_editroompic\">\n"
925 "Set or change the graphic for this room's banner</A>\n"
926 "<LI><A HREF=\"/display_editinfo\">\n"
927 "Edit this room's Info file</A>\n"
931 if (!strcmp(tab, "config")) {
932 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
934 wprintf("<UL><LI>Name of room: ");
935 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
937 wprintf("<LI>Resides on floor: ");
938 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
939 for (i = 0; i < 128; ++i)
940 if (strlen(floorlist[i]) > 0) {
943 wprintf("SELECTED ");
944 wprintf("VALUE=\"%d\">", i);
945 escputs(floorlist[i]);
946 wprintf("</OPTION>\n");
948 wprintf("</SELECT>\n");
950 wprintf("<LI>Type of room:<UL>\n");
952 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
953 if ((er_flags & QR_PRIVATE) == 0)
955 wprintf("> Public room\n");
957 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
958 if ((er_flags & QR_PRIVATE) &&
959 (er_flags & QR_GUESSNAME))
961 wprintf("> Private - guess name\n");
963 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
964 if ((er_flags & QR_PRIVATE) &&
965 (er_flags & QR_PASSWORDED))
967 wprintf("> Private - require password:\n");
968 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
970 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
971 if ((er_flags & QR_PRIVATE)
972 && ((er_flags & QR_GUESSNAME) == 0)
973 && ((er_flags & QR_PASSWORDED) == 0))
975 wprintf("> Private - invitation only\n");
977 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
978 wprintf("> If private, cause current users to forget room\n");
982 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
983 if (er_flags & QR_PREFONLY)
985 wprintf("> Preferred users only\n");
987 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
988 if (er_flags & QR_READONLY)
990 wprintf("> Read-only room\n");
992 /* directory stuff */
993 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
994 if (er_flags & QR_DIRECTORY)
996 wprintf("> File directory room\n");
998 wprintf("<UL><LI>Directory name: ");
999 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
1001 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1002 if (er_flags & QR_UPLOAD)
1003 wprintf("CHECKED ");
1004 wprintf("> Uploading allowed\n");
1006 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1007 if (er_flags & QR_DOWNLOAD)
1008 wprintf("CHECKED ");
1009 wprintf("> Downloading allowed\n");
1011 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1012 if (er_flags & QR_VISDIR)
1013 wprintf("CHECKED ");
1014 wprintf("> Visible directory</UL>\n");
1016 /* end of directory stuff */
1018 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1019 if (er_flags & QR_NETWORK)
1020 wprintf("CHECKED ");
1021 wprintf("> Network shared room\n");
1023 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1024 if (er_flags & QR_PERMANENT)
1025 wprintf("CHECKED ");
1026 wprintf("> Permanent (does not auto-purge)\n");
1028 /* start of anon options */
1030 wprintf("<LI>Anonymous messages<UL>\n");
1032 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1033 if (((er_flags & QR_ANONONLY) == 0)
1034 && ((er_flags & QR_ANONOPT) == 0))
1035 wprintf("CHECKED ");
1036 wprintf("> No anonymous messages\n");
1038 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1039 if (er_flags & QR_ANONONLY)
1040 wprintf("CHECKED ");
1041 wprintf("> All messages are anonymous\n");
1043 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1044 if (er_flags & QR_ANONOPT)
1045 wprintf("CHECKED ");
1046 wprintf("> Prompt user when entering messages</UL>\n");
1048 /* end of anon options */
1050 wprintf("<LI>Room aide: \n");
1053 if (buf[0] != '2') {
1054 wprintf("<EM>%s</EM>\n", &buf[4]);
1056 extract(er_roomaide, &buf[4], 0);
1057 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1060 wprintf("</UL><CENTER>\n");
1061 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1062 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1064 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
1070 /* Sharing the room with other Citadel nodes... */
1071 if (!strcmp(tab, "sharing")) {
1073 shared_with = strdup("");
1074 not_shared_with = strdup("");
1076 /* Learn the current configuration */
1077 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1079 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1080 extract(node, buf, 0);
1081 not_shared_with = realloc(not_shared_with,
1082 strlen(not_shared_with) + 32);
1083 strcat(not_shared_with, node);
1084 strcat(not_shared_with, "\n");
1089 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1090 extract(cmd, buf, 0);
1091 extract(node, buf, 1);
1092 extract(remote_room, buf, 2);
1093 if (!strcasecmp(cmd, "ignet_push_share")) {
1094 shared_with = realloc(shared_with,
1095 strlen(shared_with) + 32);
1096 strcat(shared_with, node);
1097 if (strlen(remote_room) > 0) {
1098 strcat(shared_with, "|");
1099 strcat(shared_with, remote_room);
1101 strcat(shared_with, "\n");
1105 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1106 extract_token(buf, shared_with, i, '\n');
1107 extract_token(node, buf, 0, '|');
1108 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1109 extract_token(cmd, not_shared_with, j, '\n');
1110 if (!strcasecmp(node, cmd)) {
1111 remove_token(not_shared_with, j, '\n');
1116 /* Display the stuff */
1117 wprintf("<CENTER><br />"
1118 "<TABLE border=1 cellpadding=5><TR>"
1119 "<TD><B><I>Shared with</I></B></TD>"
1120 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1121 "<TR><TD VALIGN=TOP>\n");
1123 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1124 "<TD>Remote node name</TD>"
1125 "<TD>Remote room name</TD>"
1130 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1131 extract_token(buf, shared_with, i, '\n');
1132 extract_token(node, buf, 0, '|');
1133 extract_token(remote_room, buf, 1, '|');
1134 if (strlen(node) > 0) {
1135 wprintf("<FORM METHOD=\"POST\" "
1136 "ACTION=\"/netedit\">"
1137 "<TR><TD>%s</TD>\n", node);
1140 if (strlen(remote_room) > 0) {
1141 escputs(remote_room);
1147 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1148 "VALUE=\"ignet_push_share|");
1150 if (strlen(remote_room) > 0) {
1152 urlescputs(remote_room);
1155 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1156 "VALUE=\"sharing\">\n");
1157 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1158 "VALUE=\"remove\">\n");
1159 wprintf("<INPUT TYPE=\"submit\" "
1160 "NAME=\"sc\" VALUE=\"Unshare\">");
1161 wprintf("</TD></TR></FORM>\n");
1165 wprintf("</TABLE>\n");
1166 wprintf("</TD><TD VALIGN=TOP>\n");
1167 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1168 "<TD>Remote node name</TD>"
1169 "<TD>Remote room name</TD>"
1174 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1175 extract_token(node, not_shared_with, i, '\n');
1176 if (strlen(node) > 0) {
1177 wprintf("<FORM METHOD=\"POST\" "
1178 "ACTION=\"/netedit\">"
1182 "<INPUT TYPE=\"INPUT\" "
1186 wprintf("<INPUT TYPE=\"hidden\" "
1188 "VALUE=\"ignet_push_share|");
1191 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1192 "VALUE=\"sharing\">\n");
1193 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1194 "VALUE=\"add\">\n");
1195 wprintf("<INPUT TYPE=\"submit\" "
1196 "NAME=\"sc\" VALUE=\"Share\">");
1197 wprintf("</TD></TR></FORM>\n");
1201 wprintf("</TABLE>\n");
1202 wprintf("</TD></TR>"
1203 "</TABLE></CENTER><br />\n"
1204 "<I><B>Notes:</B><UL><LI>When sharing a room, "
1205 "it must be shared from both ends. Adding a node to "
1206 "the 'shared' list sends messages out, but in order to"
1207 " receive messages, the other nodes must be configured"
1208 " to send messages out to your system as well.\n"
1209 "<LI>If the remote room name is blank, it is assumed "
1210 "that the room name is identical on the remote node."
1211 "<LI>If the remote room name is different, the remote "
1212 "node must also configure the name of the room here."
1218 /* Mailing list management */
1219 if (!strcmp(tab, "listserv")) {
1221 wprintf("<br /><center>"
1222 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1223 "<TR><TD VALIGN=TOP>");
1225 wprintf("<i>The contents of this room are being "
1226 "mailed <b>as individual messages</b> "
1227 "to the following list recipients:"
1228 "</i><br /><br />\n");
1232 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1233 extract(cmd, buf, 0);
1234 if (!strcasecmp(cmd, "listrecp")) {
1235 extract(recp, buf, 1);
1238 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1241 wprintf("&tab=listserv\">(remove)</A><br />");
1245 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1246 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1247 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1248 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1249 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1250 wprintf("</FORM>\n");
1252 wprintf("</TD><TD VALIGN=TOP>\n");
1254 wprintf("<i>The contents of this room are being "
1255 "mailed <b>in digest form</b> "
1256 "to the following list recipients:"
1257 "</i><br /><br />\n");
1261 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1262 extract(cmd, buf, 0);
1263 if (!strcasecmp(cmd, "digestrecp")) {
1264 extract(recp, buf, 1);
1267 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1270 wprintf("&tab=listserv\">(remove)</A><br />");
1274 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1275 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1276 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1277 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1278 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1279 wprintf("</FORM>\n");
1281 wprintf("</TD></TR></TABLE><hr />\n");
1283 if (self_service(999) == 1) {
1284 wprintf("This room is configured to allow "
1285 "self-service subscribe/unsubscribe requests."
1286 " <A HREF=\"/toggle_self_service?newval=0&"
1288 "Click to disable.</A><br />\n"
1289 "The URL for subscribe/unsubscribe is: "
1290 "<TT>http://%s/listsub</TT><br />\n",
1295 wprintf("This room is <i>not</i> configured to allow "
1296 "self-service subscribe/unsubscribe requests."
1297 " <A HREF=\"/toggle_self_service?newval=1&"
1299 "Click to enable.</A><br />\n"
1304 wprintf("</CENTER>\n");
1308 /* Mailing list management */
1309 if (!strcmp(tab, "expire")) {
1311 serv_puts("GPEX room");
1313 if (buf[0] == '2') {
1314 roompolicy = extract_int(&buf[4], 0);
1315 roomvalue = extract_int(&buf[4], 1);
1318 serv_puts("GPEX floor");
1320 if (buf[0] == '2') {
1321 floorpolicy = extract_int(&buf[4], 0);
1322 floorvalue = extract_int(&buf[4], 1);
1325 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1326 wprintf("<TABLE border=0 cellspacing=5>\n");
1327 wprintf("<TR><TD>Message expire policy for this room<br />(");
1328 escputs(WC->wc_roomname);
1329 wprintf(")</TD><TD>");
1330 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1331 ((roompolicy == 0) ? "CHECKED" : "") );
1332 wprintf("Use the default policy for this floor<br />\n");
1333 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1334 ((roompolicy == 1) ? "CHECKED" : "") );
1335 wprintf("Never automatically expire messages<br />\n");
1336 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1337 ((roompolicy == 2) ? "CHECKED" : "") );
1338 wprintf("Expire by message count<br />\n");
1339 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1340 ((roompolicy == 3) ? "CHECKED" : "") );
1341 wprintf("Expire by message age<br />");
1342 wprintf("Number of messages or days: ");
1343 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1344 wprintf("</TD></TR>\n");
1346 if (WC->axlevel >= 6) {
1347 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1348 wprintf("<TR><TD>Message expire policy for this floor<br />(");
1349 escputs(floorlist[WC->wc_floor]);
1350 wprintf(")</TD><TD>");
1351 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1352 ((floorpolicy == 0) ? "CHECKED" : "") );
1353 wprintf("Use the system default<br />\n");
1354 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1355 ((floorpolicy == 1) ? "CHECKED" : "") );
1356 wprintf("Never automatically expire messages<br />\n");
1357 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1358 ((floorpolicy == 2) ? "CHECKED" : "") );
1359 wprintf("Expire by message count<br />\n");
1360 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1361 ((floorpolicy == 3) ? "CHECKED" : "") );
1362 wprintf("Expire by message age<br />");
1363 wprintf("Number of messages or days: ");
1364 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1368 wprintf("<CENTER>\n");
1369 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1370 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1372 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1373 wprintf("</CENTER></TD><TR>\n");
1375 wprintf("</TABLE>\n"
1376 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1383 /* end content of whatever tab is open now */
1384 wprintf("</TD></TR></TABLE>\n");
1391 * Toggle self-service list subscription
1393 void toggle_self_service(void) {
1396 newval = atoi(bstr("newval"));
1397 self_service(newval);
1404 * save new parameters for a room
1410 char er_password[10];
1411 char er_dirname[15];
1412 char er_roomaide[26];
1418 if (strcmp(bstr("sc"), "OK")) {
1419 strcpy(WC->ImportantMessage,
1420 "Cancelled. Changes were not saved.");
1427 if (buf[0] != '2') {
1428 strcpy(WC->ImportantMessage, &buf[4]);
1432 extract(er_name, &buf[4], 0);
1433 extract(er_password, &buf[4], 1);
1434 extract(er_dirname, &buf[4], 2);
1435 er_flags = extract_int(&buf[4], 3);
1437 strcpy(er_roomaide, bstr("er_roomaide"));
1438 if (strlen(er_roomaide) == 0) {
1441 if (buf[0] != '2') {
1442 strcpy(er_roomaide, "");
1444 extract(er_roomaide, &buf[4], 0);
1447 strcpy(buf, bstr("er_name"));
1449 if (strlen(buf) > 0)
1450 strcpy(er_name, buf);
1452 strcpy(buf, bstr("er_password"));
1454 if (strlen(buf) > 0)
1455 strcpy(er_password, buf);
1457 strcpy(buf, bstr("er_dirname"));
1459 if (strlen(buf) > 0)
1460 strcpy(er_dirname, buf);
1462 strcpy(buf, bstr("type"));
1463 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1465 if (!strcmp(buf, "invonly")) {
1466 er_flags |= (QR_PRIVATE);
1468 if (!strcmp(buf, "guessname")) {
1469 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1471 if (!strcmp(buf, "passworded")) {
1472 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1474 if (!strcmp(bstr("prefonly"), "yes")) {
1475 er_flags |= QR_PREFONLY;
1477 er_flags &= ~QR_PREFONLY;
1480 if (!strcmp(bstr("readonly"), "yes")) {
1481 er_flags |= QR_READONLY;
1483 er_flags &= ~QR_READONLY;
1486 if (!strcmp(bstr("permanent"), "yes")) {
1487 er_flags |= QR_PERMANENT;
1489 er_flags &= ~QR_PERMANENT;
1492 if (!strcmp(bstr("network"), "yes")) {
1493 er_flags |= QR_NETWORK;
1495 er_flags &= ~QR_NETWORK;
1498 if (!strcmp(bstr("directory"), "yes")) {
1499 er_flags |= QR_DIRECTORY;
1501 er_flags &= ~QR_DIRECTORY;
1504 if (!strcmp(bstr("ulallowed"), "yes")) {
1505 er_flags |= QR_UPLOAD;
1507 er_flags &= ~QR_UPLOAD;
1510 if (!strcmp(bstr("dlallowed"), "yes")) {
1511 er_flags |= QR_DOWNLOAD;
1513 er_flags &= ~QR_DOWNLOAD;
1516 if (!strcmp(bstr("visdir"), "yes")) {
1517 er_flags |= QR_VISDIR;
1519 er_flags &= ~QR_VISDIR;
1522 strcpy(buf, bstr("anon"));
1524 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1525 if (!strcmp(buf, "anononly"))
1526 er_flags |= QR_ANONONLY;
1527 if (!strcmp(buf, "anon2"))
1528 er_flags |= QR_ANONOPT;
1531 if (!strcmp(bstr("bump"), "yes"))
1534 er_floor = atoi(bstr("er_floor"));
1536 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1537 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1540 if (buf[0] != '2') {
1541 strcpy(WC->ImportantMessage, &buf[4]);
1547 if (strlen(er_roomaide) > 0) {
1548 sprintf(buf, "SETA %s", er_roomaide);
1551 if (buf[0] != '2') {
1552 strcpy(WC->ImportantMessage, &buf[4]);
1553 display_main_menu();
1558 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1564 * Invite, Kick, and show Who Knows a room
1566 void display_whok(void)
1568 char buf[SIZ], room[SIZ], username[SIZ];
1573 if (buf[0] != '2') {
1574 strcpy(WC->ImportantMessage, &buf[4]);
1575 display_main_menu();
1578 extract(room, &buf[4], 0);
1580 strcpy(username, bstr("username"));
1582 if(!strcmp(bstr("sc"), "Kick")) {
1583 sprintf(buf, "KICK %s", username);
1587 if (buf[0] != '2') {
1588 strcpy(WC->ImportantMessage, &buf[4]);
1590 sprintf(WC->ImportantMessage,
1591 "<B><I>User %s kicked out of room %s.</I></B>\n",
1594 } else if(!strcmp(bstr("sc"), "Invite")) {
1595 sprintf(buf, "INVT %s", username);
1599 if (buf[0] != '2') {
1600 strcpy(WC->ImportantMessage, &buf[4]);
1602 sprintf(WC->ImportantMessage,
1603 "<B><I>User %s invited to room %s.</I></B>\n",
1608 output_headers(1, 1, 1, 0, 0, 0, 0);
1609 stresc(buf, WC->wc_roomname, 1, 1);
1610 svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
1611 do_template("beginbox");
1613 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1614 "<TD>The users listed below have access to this room. "
1615 "To remove a user from the access list, select the user "
1616 "name from the list and click 'Kick'.<br /><br />");
1618 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1619 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1622 if (buf[0] == '1') {
1623 while (serv_gets(buf), strcmp(buf, "000")) {
1624 extract(username, buf, 0);
1625 wprintf("<OPTION>");
1630 wprintf("</SELECT><br />\n");
1632 wprintf("<input type=submit name=sc value=\"Kick\">");
1633 wprintf("</FORM></CENTER>\n");
1636 "To grant another user access to this room, enter the "
1637 "user name in the box below and click 'Invite'.<br /><br />");
1639 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1640 wprintf("Invite: ");
1641 wprintf("<input type=text name=username><br />\n"
1642 "<input type=hidden name=sc value=\"Invite\">"
1643 "<input type=submit value=\"Invite\">"
1644 "</FORM></CENTER>\n");
1646 wprintf("</TD></TR></TABLE>\n");
1647 do_template("endbox");
1654 * display the form for entering a new room
1656 void display_entroom(void)
1661 serv_puts("CRE8 0");
1664 if (buf[0] != '2') {
1665 strcpy(WC->ImportantMessage, &buf[4]);
1666 display_main_menu();
1670 output_headers(1, 1, 2, 0, 0, 0, 0);
1671 wprintf("<div id=\"banner\">\n"
1672 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1673 "<SPAN CLASS=\"titlebar\">Create a new room</SPAN>"
1674 "</TD></TR></TABLE>\n"
1675 "</div>\n<div id=\"content\">\n"
1678 wprintf("<center><table border=0 width=99%% bgcolor=\"#ffffff\"><tr><td>\n");
1680 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1682 wprintf("<UL><LI>Name of room: ");
1683 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1685 wprintf("<LI>Resides on floor: ");
1687 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1688 for (i = 0; i < 128; ++i)
1689 if (strlen(floorlist[i]) > 0) {
1690 wprintf("<OPTION ");
1691 wprintf("VALUE=\"%d\">", i);
1692 escputs(floorlist[i]);
1693 wprintf("</OPTION>\n");
1695 wprintf("</SELECT>\n");
1697 wprintf("<LI>Default view for room: ");
1698 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1699 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1700 wprintf("<OPTION %s VALUE=\"%d\">",
1701 ((i == 0) ? "SELECTED" : ""), i );
1702 escputs(viewdefs[i]);
1703 wprintf("</OPTION>\n");
1705 wprintf("</SELECT>\n");
1707 wprintf("<LI>Type of room:<UL>\n");
1709 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1710 wprintf("CHECKED > Public room\n");
1712 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1713 wprintf("> Private - guess name\n");
1715 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1716 wprintf("> Private - require password:\n");
1717 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1719 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1720 wprintf("> Private - invitation only\n");
1722 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1723 wprintf("> Personal (mailbox for you only)\n");
1726 wprintf("<CENTER>\n");
1727 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1729 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1730 wprintf("</CENTER>\n");
1731 wprintf("</FORM>\n<hr />");
1732 serv_printf("MESG roomaccess");
1734 if (buf[0] == '1') {
1735 fmout(NULL, "CENTER");
1737 wprintf("</td></tr></table></center>\n");
1745 * support function for entroom() -- sets the default view
1747 void er_set_default_view(int newview) {
1761 if (buf[0] != '2') return;
1763 extract(rm_name, &buf[4], 0);
1764 extract(rm_pass, &buf[4], 1);
1765 extract(rm_dir, &buf[4], 2);
1766 rm_bits1 = extract_int(&buf[4], 3);
1767 rm_floor = extract_int(&buf[4], 4);
1768 rm_listorder = extract_int(&buf[4], 5);
1769 rm_bits2 = extract_int(&buf[4], 7);
1771 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1772 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1773 rm_listorder, newview, rm_bits2
1788 char er_password[SIZ];
1793 if (strcmp(bstr("sc"), "OK")) {
1794 strcpy(WC->ImportantMessage,
1795 "Cancelled. No new room was created.");
1796 display_main_menu();
1799 strcpy(er_name, bstr("er_name"));
1800 strcpy(er_type, bstr("type"));
1801 strcpy(er_password, bstr("er_password"));
1802 er_floor = atoi(bstr("er_floor"));
1803 er_view = atoi(bstr("er_view"));
1806 if (!strcmp(er_type, "guessname"))
1808 if (!strcmp(er_type, "passworded"))
1810 if (!strcmp(er_type, "invonly"))
1812 if (!strcmp(er_type, "personal"))
1815 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1816 er_name, er_num_type, er_password, er_floor, 0, er_view);
1819 if (buf[0] != '2') {
1820 strcpy(WC->ImportantMessage, &buf[4]);
1821 display_main_menu();
1825 do_change_view(er_view); /* Now go there */
1830 * display the screen to enter a private room
1832 void display_private(char *rname, int req_pass)
1835 output_headers(1, 1, 0, 0, 0, 0, 0);
1837 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1838 do_template("beginbox");
1840 wprintf("<CENTER>\n");
1841 wprintf("<br />If you know the name of a hidden (guess-name) or\n");
1842 wprintf("passworded room, you can enter that room by typing\n");
1843 wprintf("its name below. Once you gain access to a private\n");
1844 wprintf("room, it will appear in your regular room listings\n");
1845 wprintf("so you don't have to keep returning here.\n");
1846 wprintf("<br /><br />");
1848 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1850 wprintf("<table border=\"0\" cellspacing=\"5\" "
1851 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1853 "Enter room name:</TD><TD>"
1854 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1855 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1858 wprintf("</TD></TR><TR><TD>");
1859 wprintf("Enter room password:</TD><TD>");
1860 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1862 wprintf("</TD></TR></TABLE><br />\n");
1864 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1866 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1867 wprintf("</FORM>\n");
1868 do_template("endbox");
1873 * goto a private room
1875 void goto_private(void)
1880 if (strcasecmp(bstr("sc"), "OK")) {
1881 display_main_menu();
1884 strcpy(hold_rm, WC->wc_roomname);
1885 strcpy(buf, "GOTO ");
1886 strcat(buf, bstr("gr_name"));
1888 strcat(buf, bstr("gr_pass"));
1892 if (buf[0] == '2') {
1893 smart_goto(bstr("gr_name"));
1896 if (!strncmp(buf, "540", 3)) {
1897 display_private(bstr("gr_name"), 1);
1900 output_headers(1, 1, 1, 0, 0, 0, 0);
1901 wprintf("%s\n", &buf[4]);
1908 * display the screen to zap a room
1910 void display_zap(void)
1912 output_headers(1, 1, 2, 0, 0, 0, 0);
1914 wprintf("<div id=\"banner\">\n");
1915 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1916 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget/unsubscribe) the current room</SPAN>\n");
1917 wprintf("</TD></TR></TABLE>\n");
1918 wprintf("</div>\n<div id=\"content\">\n");
1920 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1921 wprintf("disappear from your room list. Is this what you wish ");
1922 wprintf("to do?<br />\n");
1924 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1925 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1927 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1928 wprintf("</FORM>\n");
1939 char final_destination[SIZ];
1941 /* If the forget-room routine fails for any reason, we fall back
1942 * to the current room; otherwise, we go to the Lobby
1944 strcpy(final_destination, WC->wc_roomname);
1946 if (!strcasecmp(bstr("sc"), "OK")) {
1947 serv_printf("GOTO %s", WC->wc_roomname);
1949 if (buf[0] == '2') {
1952 if (buf[0] == '2') {
1953 strcpy(final_destination, "_BASEROOM_");
1957 smart_goto(final_destination);
1964 * Confirm deletion of the current room
1966 void confirm_delete_room(void)
1970 serv_puts("KILL 0");
1972 if (buf[0] != '2') {
1973 strcpy(WC->ImportantMessage, &buf[4]);
1974 display_main_menu();
1977 output_headers(1, 1, 2, 0, 0, 0, 0);
1978 wprintf("<div id=\"banner\">\n");
1979 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1980 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1981 wprintf("</TD></TR></TABLE>\n");
1982 wprintf("</div>\n<div id=\"content\">\n");
1984 wprintf("<CENTER>");
1985 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1987 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1988 escputs(WC->wc_roomname);
1989 wprintf("</FONT>?<br />\n");
1991 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1992 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1994 wprintf("</FORM></CENTER>\n");
2000 * Delete the current room
2002 void delete_room(void)
2007 strcpy(sc, bstr("sc"));
2009 if (strcasecmp(sc, "Delete")) {
2010 strcpy(WC->ImportantMessage,
2011 "Cancelled. This room was not deleted.");
2012 display_main_menu();
2015 serv_puts("KILL 1");
2017 if (buf[0] != '2') {
2018 strcpy(WC->ImportantMessage, &buf[4]);
2019 display_main_menu();
2022 smart_goto("_BASEROOM_");
2029 * Perform changes to a room's network configuration
2031 void netedit(void) {
2040 if (strlen(bstr("line"))==0) {
2045 strcpy(line, bstr("prefix"));
2046 strcat(line, bstr("line"));
2047 strcat(line, bstr("suffix"));
2057 if (buf[0] != '1') {
2063 /* This loop works for add *or* remove. Spiffy, eh? */
2064 while (serv_gets(buf), strcmp(buf, "000")) {
2065 extract(cmpa0, buf, 0);
2066 extract(cmpa1, buf, 1);
2067 extract(cmpb0, line, 0);
2068 extract(cmpb1, line, 1);
2069 if ( (strcasecmp(cmpa0, cmpb0))
2070 || (strcasecmp(cmpa1, cmpb1)) ) {
2071 fprintf(fp, "%s\n", buf);
2078 if (buf[0] != '4') {
2084 while (fgets(buf, sizeof buf, fp) != NULL) {
2085 buf[strlen(buf)-1] = 0;
2089 if (!strcasecmp(bstr("cmd"), "add")) {
2101 * Convert a room name to a folder-ish-looking name.
2103 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2108 * For mailboxes, just do it straight...
2111 sprintf(folder, "My folders|%s", room);
2115 * Otherwise, prefix the floor name as a "public folders" moniker
2118 sprintf(folder, "%s|%s", floorlist[floor], room);
2122 * Replace "\" characters with "|" for pseudo-folder-delimiting
2124 for (i=0; i<strlen(folder); ++i) {
2125 if (folder[i] == '\\') folder[i] = '|';
2133 * Back end for change_view()
2135 void do_change_view(int newview) {
2138 serv_printf("VIEW %d", newview);
2140 WC->wc_view = newview;
2141 smart_goto(WC->wc_roomname);
2147 * Change the view for this room
2149 void change_view(void) {
2152 view = atol(bstr("view"));
2153 do_change_view(view);
2158 * One big expanded tree list view --- like a folder list
2160 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2162 int levels, oldlevels;
2165 int has_subfolders = 0;
2167 /* Include the menu expanding/collapsing code */
2168 wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
2170 /* BEGIN TREE MENU */
2171 wprintf("<div style=\"background: white\">\n");
2172 wprintf("<div id=\"mainMenu\">\n");
2173 wprintf("<UL id=\"menuList\">\n");
2177 for (i=0; i<max_folders; ++i) {
2180 if ((i+1) < max_folders) {
2181 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2182 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2187 levels = num_tokens(fold[i].name, '|');
2189 if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
2190 for (t=0; t<(oldlevels-levels); ++t) {
2195 if (has_subfolders) {
2197 if (levels == 1) wprintf(" class=\"menubar\"");
2199 wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
2205 if (fold[i].selectable) {
2206 wprintf("<A HREF=\"/dotgoto?room=");
2207 urlescputs(fold[i].room);
2212 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2214 else if (fold[i].hasnewmsgs) {
2215 wprintf("<SPAN CLASS=\"roomlist_new\">");
2218 wprintf("<SPAN CLASS=\"roomlist_old\">");
2220 extract(buf, fold[i].name, levels-1);
2224 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2225 wprintf(" (INBOX)");
2228 if (fold[i].selectable) {
2233 if (has_subfolders) {
2234 wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
2236 ( (levels == 1) ? "menu" : "submenu")
2242 wprintf("</UL></UL>\n");
2243 wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
2244 for (i=0; i<actnum; ++i) {
2245 wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
2248 wprintf("</DIV>\n");
2253 * Boxes and rooms and lists ... oh my!
2255 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2258 int levels, oldlevels;
2261 static int columns = 3;
2262 int boxes_per_column = 0;
2263 int current_column = 0;
2267 while (nf % columns != 0) ++nf;
2268 boxes_per_column = (nf / columns);
2269 if (boxes_per_column < 1) boxes_per_column = 1;
2271 /* Outer table (for columnization) */
2272 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2273 "<tr><td valign=top>");
2277 for (i=0; i<max_folders; ++i) {
2279 levels = num_tokens(fold[i].name, '|');
2281 if ((levels == 1) && (oldlevels > 1)) {
2284 do_template("endbox");
2287 if ((num_boxes % boxes_per_column) == 0) {
2289 if (current_column < columns) {
2290 wprintf("</td><td valign=top>\n");
2297 /* Begin inner box */
2298 extract(buf, fold[i].name, levels-1);
2299 stresc(boxtitle, buf, 1, 0);
2300 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2301 do_template("beginbox");
2309 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2310 if (fold[i].selectable) {
2311 wprintf("<A HREF=\"/dotgoto?room=");
2312 urlescputs(fold[i].room);
2318 if (fold[i].hasnewmsgs) {
2319 wprintf("<SPAN CLASS=\"roomlist_new\">");
2322 wprintf("<SPAN CLASS=\"roomlist_old\">");
2324 extract(buf, fold[i].name, levels-1);
2327 if (fold[i].selectable) {
2333 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2334 wprintf(" (INBOX)");
2336 wprintf("<br />\n");
2339 /* End the final inner box */
2340 do_template("endbox");
2342 wprintf("</TD></TR></TABLE>\n");
2347 * Show the room list. (only should get called by
2348 * knrooms() because that's where output_headers() is called from)
2351 void list_all_rooms_by_floor(char *viewpref) {
2354 struct folder *fold = NULL;
2356 int max_folders = 0;
2357 int alloc_folders = 0;
2361 int num_floors = 1; /* add an extra one for private folders */
2363 /* Start with the mailboxes */
2366 fold = malloc(sizeof(struct folder));
2367 memset(fold, 0, sizeof(struct folder));
2368 strcpy(fold[0].name, "My folders");
2369 fold[0].is_mailbox = 1;
2371 /* Then add floors */
2374 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2375 if (max_folders >= alloc_folders) {
2376 alloc_folders = max_folders + 100;
2377 fold = realloc(fold,
2378 alloc_folders * sizeof(struct folder));
2380 memset(&fold[max_folders], 0, sizeof(struct folder));
2381 extract(fold[max_folders].name, buf, 1);
2389 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2390 if (max_folders >= alloc_folders) {
2391 alloc_folders = max_folders + 100;
2392 fold = realloc(fold,
2393 alloc_folders * sizeof(struct folder));
2395 memset(&fold[max_folders], 0, sizeof(struct folder));
2396 extract(fold[max_folders].room, buf, 0);
2397 ra_flags = extract_int(buf, 5);
2398 flags = extract_int(buf, 1);
2399 fold[max_folders].floor = extract_int(buf, 2);
2400 fold[max_folders].hasnewmsgs =
2401 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2402 if (flags & QR_MAILBOX) {
2403 fold[max_folders].is_mailbox = 1;
2405 room_to_folder(fold[max_folders].name,
2406 fold[max_folders].room,
2407 fold[max_folders].floor,
2408 fold[max_folders].is_mailbox);
2409 fold[max_folders].selectable = 1;
2413 /* Bubble-sort the folder list */
2414 for (i=0; i<max_folders; ++i) {
2415 for (j=0; j<(max_folders-1)-i; ++j) {
2416 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2417 swap = strcasecmp(fold[j].name, fold[j+1].name);
2420 if ( (fold[j+1].is_mailbox)
2421 && (!fold[j].is_mailbox)) {
2429 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2430 memcpy(&fold[j], &fold[j+1],
2431 sizeof(struct folder));
2432 memcpy(&fold[j+1], &ftmp,
2433 sizeof(struct folder));
2438 /* test only hackish view
2439 wprintf("<table><TR><TD>A Table</TD></TR></table>\n");
2440 for (i=0; i<max_folders; ++i) {
2441 escputs(fold[i].name);
2442 wprintf("<br />\n");
2446 if (!strcasecmp(viewpref, "folders")) {
2447 do_folder_view(fold, max_folders, num_floors);
2450 do_rooms_view(fold, max_folders, num_floors);
2458 /* Do either a known rooms list or a folders list, depending on the
2462 char listviewpref[SIZ];
2464 output_headers(1, 1, 2, 0, 0, 0, 0);
2467 /* Determine whether the user is trying to change views */
2468 if (bstr("view") != NULL) {
2469 if (strlen(bstr("view")) > 0) {
2470 set_preference("roomlistview", bstr("view"));
2474 get_preference("roomlistview", listviewpref);
2476 if ( (strcasecmp(listviewpref, "folders"))
2477 && (strcasecmp(listviewpref, "table")) ) {
2478 strcpy(listviewpref, "rooms");
2482 wprintf("<div id=\"banner\">\n"
2483 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2484 "<SPAN CLASS=\"titlebar\">"
2486 if (!strcasecmp(listviewpref, "rooms")) {
2487 wprintf("Room list");
2489 if (!strcasecmp(listviewpref, "folders")) {
2490 wprintf("Folder list");
2492 if (!strcasecmp(listviewpref, "table")) {
2493 wprintf("Room list");
2495 wprintf("</SPAN></TD>\n");
2497 /* offer the ability to switch views */
2498 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2499 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2500 "OnChange=\"location.href=roomlistomatic.newview.options"
2501 "[selectedIndex].value\">\n");
2503 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2506 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2509 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2510 "View as folder list"
2512 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2515 wprintf("</SELECT><br />");
2517 wprintf("</FORM></TD></TR></TABLE>\n");
2520 "<div id=\"content\">\n");
2522 /* Display the room list in the user's preferred format */
2523 list_all_rooms_by_floor(listviewpref);
2529 * Set the message expire policy for this room and/or floor
2531 void set_room_policy(void) {
2534 if (strcmp(bstr("sc"), "OK")) {
2535 strcpy(WC->ImportantMessage,
2536 "Cancelled. Changes were not saved.");
2541 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2543 strcpy(WC->ImportantMessage, &buf[4]);
2545 if (WC->axlevel >= 6) {
2546 strcat(WC->ImportantMessage, "<br />\n");
2547 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2549 strcat(WC->ImportantMessage, &buf[4]);