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 "<span class=\"room_banner_new_messages\">View as: "
304 "<SELECT NAME=\"newview\" SIZE=\"1\" "
305 "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif; font-size: 7pt; background: #444455; color: #ddddcc;\" "
306 "OnChange=\"location.href=viewomatic.newview.options"
307 "[selectedIndex].value\">\n");
309 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
311 * Only offer the views that make sense, given the default
312 * view for the room. For example, don't offer a Calendar
313 * view in a non-Calendar room.
317 || (i == WC->wc_default_view)
318 || ( (i == 0) && (WC->wc_default_view == 1) )
319 || ( (i == 1) && (WC->wc_default_view == 0) )
322 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
323 ((i == WC->wc_view) ? "SELECTED" : ""),
325 escputs(viewdefs[i]);
326 wprintf("</OPTION>\n");
329 wprintf("</select></span></form>\n");
334 void embed_room_banner(char *got, int navbar_style) {
337 /* We need to have the information returned by a GOTO server command.
338 * If it isn't supplied, we fake it by issuing our own GOTO.
341 serv_printf("GOTO %s", WC->wc_roomname);
346 /* If the user happens to select the "make this my start page" link,
347 * we want it to remember the URL as a "/dotskip" one instead of
348 * a "skip" or "gotonext" or something like that.
350 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
353 /* Check for new mail. */
354 WC->new_mail = extract_int(&got[4], 9);
355 WC->wc_view = extract_int(&got[4], 11);
357 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
358 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
359 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
360 svcallback("ROOMPIC", embed_room_graphic);
361 svcallback("ROOMINFO", readinfo);
362 svcallback("YOUHAVEMAIL", embed_newmail_button);
363 svcallback("VIEWOMATIC", embed_view_o_matic);
364 svcallback("START", offer_start_page);
366 do_template("roombanner");
367 if (navbar_style != navbar_none) {
369 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
370 "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%%\"><tr>\n");
373 if (navbar_style == navbar_default) wprintf(
375 "<a href=\"/ungoto\">"
376 "<img align=\"middle\" src=\"/static/back.gif\" border=\"0\">"
377 "<span class=\"navbar_link\">Ungoto</span></A>"
381 if ( (navbar_style == navbar_default)
382 && (WC->wc_view != VIEW_CALENDAR)
383 && (WC->wc_view != VIEW_ADDRESSBOOK)
384 && (WC->wc_view != VIEW_NOTES)
385 && (WC->wc_view != VIEW_TASKS)
389 "<A HREF=\"/readnew\">"
390 "<img align=\"middle\" src=\"/static/readmsgs.gif\" border=\"0\">"
391 "<span class=\"navbar_link\">Read new messages</span></A>"
396 if (navbar_style == navbar_default) {
397 switch(WC->wc_view) {
398 case VIEW_ADDRESSBOOK:
401 "<A HREF=\"/readfwd\">"
402 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
404 "<span class=\"navbar_link\">"
412 "<A HREF=\"/readfwd?calview=day\">"
413 "<img align=\"middle\" src=\"/static/day_view.gif\" "
415 "<span class=\"navbar_link\">"
421 "<A HREF=\"/readfwd?calview=month\">"
422 "<img align=\"middle\" src=\"/static/month_view.gif\" "
424 "<span class=\"navbar_link\">"
432 "<A HREF=\"/readfwd\">"
433 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
435 "<span class=\"navbar_link\">"
443 "<A HREF=\"/readfwd\">"
444 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
446 "<span class=\"navbar_link\">"
454 "<A HREF=\"/readfwd\">"
455 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
457 "<span class=\"navbar_link\">"
465 if (navbar_style == navbar_default) {
468 "<A HREF=\"/display_enter\">"
469 "<img align=\"middle\" src=\"/static/enter.gif\" border=\"0\">"
470 "<span class=\"navbar_link\">"
472 switch(WC->wc_view) {
473 case VIEW_ADDRESSBOOK:
474 wprintf("Add new contact");
477 wprintf("Add new event");
480 wprintf("Add new task");
483 wprintf("Add new note");
486 wprintf("Enter a message");
489 wprintf("</span></a></td>\n");
492 if (navbar_style == navbar_default) wprintf(
495 "TITLE=\"Leave all messages marked as unread, go to next room with unread messages\">"
496 "<span class=\"navbar_link\">Skip this room</span>"
497 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
501 if (navbar_style == navbar_default) wprintf(
503 "<A HREF=\"/gotonext\" "
504 "TITLE=\"Mark all messages as read, go to next room with unread messages\">"
505 "<span class=\"navbar_link\">Goto next room</span>"
506 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
510 wprintf("</tr></table></div>\n");
520 * back end routine to take the session to a new room
523 void gotoroom(char *gname)
526 static long ls = (-1L);
528 /* store ungoto information */
529 strcpy(WC->ugname, WC->wc_roomname);
532 /* move to the new room */
533 serv_printf("GOTO %s", gname);
536 serv_puts("GOTO _BASEROOM_");
542 extract(WC->wc_roomname, &buf[4], 0);
543 WC->room_flags = extract_int(&buf[4], 4);
544 /* highest_msg_read = extract_int(&buf[4],6);
545 maxmsgnum = extract_int(&buf[4],5);
546 is_mail = (char) extract_int(&buf[4],7); */
547 ls = extract_long(&buf[4], 6);
548 WC->wc_floor = extract_int(&buf[4], 10);
549 WC->wc_view = extract_int(&buf[4], 11);
550 WC->wc_default_view = extract_int(&buf[4], 12);
553 WC->is_room_aide = WC->is_aide;
555 WC->is_room_aide = (char) extract_int(&buf[4], 8);
557 remove_march(WC->wc_roomname);
558 if (!strcasecmp(gname, "_BASEROOM_"))
564 * Locate the room on the march list which we most want to go to. Each room
565 * is measured given a "weight" of preference based on various factors.
567 char *pop_march(int desired_floor)
569 static char TheRoom[128];
571 int TheOrder = 32767;
574 struct march *mptr = NULL;
576 strcpy(TheRoom, "_BASEROOM_");
577 if (WC->march == NULL)
580 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
582 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
583 weight = weight + 10000;
584 if (mptr->march_floor == desired_floor)
585 weight = weight + 5000;
587 weight = weight + ((128 - (mptr->march_floor)) * 128);
588 weight = weight + (128 - (mptr->march_order));
590 if (weight > TheWeight) {
592 strcpy(TheRoom, mptr->march_name);
593 TheFloor = mptr->march_floor;
594 TheOrder = mptr->march_order;
602 /* Goto next room having unread messages.
603 * We want to skip over rooms that the user has already been to, and take the
604 * user back to the lobby when done. The room we end up in is placed in
605 * newroom - which is set to 0 (the lobby) initially.
606 * We start the search in the current room rather than the beginning to prevent
607 * two or more concurrent users from dragging each other back to the same room.
612 struct march *mptr, *mptr2;
615 /* First check to see if the march-mode list is already allocated.
616 * If it is, pop the first room off the list and go there.
619 if (WC->march == NULL) {
623 while (serv_gets(buf), strcmp(buf, "000")) {
624 mptr = (struct march *) malloc(sizeof(struct march));
626 extract(mptr->march_name, buf, 0);
627 mptr->march_floor = extract_int(buf, 2);
628 mptr->march_order = extract_int(buf, 3);
629 if (WC->march == NULL) {
633 while (mptr2->next != NULL)
638 /* add _BASEROOM_ to the end of the march list, so the user will end up
639 * in the system base room (usually the Lobby>) at the end of the loop
641 mptr = (struct march *) malloc(sizeof(struct march));
643 strcpy(mptr->march_name, "_BASEROOM_");
644 if (WC->march == NULL) {
648 while (mptr2->next != NULL)
653 * ...and remove the room we're currently in, so a <G>oto doesn't make us
654 * walk around in circles
656 remove_march(WC->wc_roomname);
658 if (WC->march != NULL) {
659 strcpy(next_room, pop_march(-1));
661 strcpy(next_room, "_BASEROOM_");
665 smart_goto(next_room);
669 void smart_goto(char *next_room) {
677 * mark all messages in current room as having been read
679 void slrp_highest(void)
684 serv_puts("SLRP HIGHEST");
687 wprintf("<EM>%s</EM><br />\n", &buf[4]);
694 * un-goto the previous room
700 if (!strcmp(WC->ugname, "")) {
701 smart_goto(WC->wc_roomname);
704 serv_printf("GOTO %s", WC->ugname);
707 smart_goto(WC->wc_roomname);
710 if (WC->uglsn >= 0L) {
711 serv_printf("SLRP %ld", WC->uglsn);
714 strcpy(buf, WC->ugname);
715 strcpy(WC->ugname, "");
724 * Set/clear/read the "self-service list subscribe" flag for a room
726 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
727 * Always returns the new value.
730 int self_service(int newval) {
731 int current_value = 0;
737 int flags, floor, order, view, flags2;
741 if (buf[0] != '2') return(0);
743 extract(name, &buf[4], 0);
744 extract(password, &buf[4], 1);
745 extract(dirname, &buf[4], 2);
746 flags = extract_int(&buf[4], 3);
747 floor = extract_int(&buf[4], 4);
748 order = extract_int(&buf[4], 5);
749 view = extract_int(&buf[4], 6);
750 flags2 = extract_int(&buf[4], 7);
752 if (flags2 & QR2_SELFLIST) {
760 flags2 = flags2 | QR2_SELFLIST;
762 else if (newval == 0) {
763 flags2 = flags2 & ~QR2_SELFLIST;
766 return(current_value);
769 if (newval != current_value) {
770 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
771 name, password, dirname, flags,
772 floor, order, view, flags2);
786 * display the form for editing a room
788 void display_editroom(void)
793 char remote_room[SIZ];
796 char er_password[10];
798 char er_roomaide[26];
804 char *not_shared_with;
811 if (strlen(tab) == 0) tab = "admin";
818 strcpy(WC->ImportantMessage, &buf[4]);
822 extract(er_name, &buf[4], 0);
823 extract(er_password, &buf[4], 1);
824 extract(er_dirname, &buf[4], 2);
825 er_flags = extract_int(&buf[4], 3);
826 er_floor = extract_int(&buf[4], 4);
828 output_headers(1, 1, 1, 0, 0, 0, 0);
830 /* print the tabbed dialog */
832 "<div id=\"fix_scrollbar_bug\">"
833 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
835 "<TD> </TD>\n");
837 if (!strcmp(tab, "admin")) {
838 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
841 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
843 wprintf("Administration");
844 if (!strcmp(tab, "admin")) {
845 wprintf("</SPAN></TD>\n");
848 wprintf("</A></TD>\n");
851 wprintf("<TD> </TD>\n");
853 if (!strcmp(tab, "config")) {
854 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
857 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
859 wprintf("Configuration");
860 if (!strcmp(tab, "config")) {
861 wprintf("</SPAN></TD>\n");
864 wprintf("</A></TD>\n");
867 wprintf("<TD> </TD>\n");
869 if (!strcmp(tab, "expire")) {
870 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
873 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
875 wprintf("Message expire policy");
876 if (!strcmp(tab, "expire")) {
877 wprintf("</SPAN></TD>\n");
880 wprintf("</A></TD>\n");
883 wprintf("<TD> </TD>\n");
885 if (!strcmp(tab, "access")) {
886 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
889 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=access\">");
891 wprintf("Access controls");
892 if (!strcmp(tab, "access")) {
893 wprintf("</SPAN></TD>\n");
896 wprintf("</A></TD>\n");
899 wprintf("<TD> </TD>\n");
901 if (!strcmp(tab, "sharing")) {
902 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
905 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
908 if (!strcmp(tab, "sharing")) {
909 wprintf("</SPAN></TD>\n");
912 wprintf("</A></TD>\n");
915 wprintf("<TD> </TD>\n");
917 if (!strcmp(tab, "listserv")) {
918 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
921 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
923 wprintf("Mailing list service");
924 if (!strcmp(tab, "listserv")) {
925 wprintf("</SPAN></TD>\n");
928 wprintf("</A></TD>\n");
931 wprintf("<TD> </TD>\n");
933 wprintf("</TR></TABLE></div>\n");
934 /* end tabbed dialog */
936 /* begin content of whatever tab is open now */
937 wprintf("<div id=\"fix_scrollbar_bug\">"
938 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
941 if (!strcmp(tab, "admin")) {
943 "<LI><A HREF=\"/confirm_delete_room\">\n"
944 "Delete this room</A>\n"
945 "<LI><A HREF=\"/display_editroompic\">\n"
946 "Set or change the graphic for this room's banner</A>\n"
947 "<LI><A HREF=\"/display_editinfo\">\n"
948 "Edit this room's Info file</A>\n"
952 if (!strcmp(tab, "config")) {
953 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
955 wprintf("<UL><LI>Name of room: ");
956 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
958 wprintf("<LI>Resides on floor: ");
959 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
960 for (i = 0; i < 128; ++i)
961 if (strlen(floorlist[i]) > 0) {
964 wprintf("SELECTED ");
965 wprintf("VALUE=\"%d\">", i);
966 escputs(floorlist[i]);
967 wprintf("</OPTION>\n");
969 wprintf("</SELECT>\n");
971 wprintf("<LI>Type of room:<UL>\n");
973 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
974 if ((er_flags & QR_PRIVATE) == 0)
976 wprintf("> Public room\n");
978 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
979 if ((er_flags & QR_PRIVATE) &&
980 (er_flags & QR_GUESSNAME))
982 wprintf("> Private - guess name\n");
984 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
985 if ((er_flags & QR_PRIVATE) &&
986 (er_flags & QR_PASSWORDED))
988 wprintf("> Private - require password:\n");
989 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
991 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
992 if ((er_flags & QR_PRIVATE)
993 && ((er_flags & QR_GUESSNAME) == 0)
994 && ((er_flags & QR_PASSWORDED) == 0))
996 wprintf("> Private - invitation only\n");
998 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
999 wprintf("> If private, cause current users to forget room\n");
1003 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1004 if (er_flags & QR_PREFONLY)
1005 wprintf("CHECKED ");
1006 wprintf("> Preferred users only\n");
1008 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1009 if (er_flags & QR_READONLY)
1010 wprintf("CHECKED ");
1011 wprintf("> Read-only room\n");
1013 /* directory stuff */
1014 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1015 if (er_flags & QR_DIRECTORY)
1016 wprintf("CHECKED ");
1017 wprintf("> File directory room\n");
1019 wprintf("<UL><LI>Directory name: ");
1020 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
1022 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1023 if (er_flags & QR_UPLOAD)
1024 wprintf("CHECKED ");
1025 wprintf("> Uploading allowed\n");
1027 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1028 if (er_flags & QR_DOWNLOAD)
1029 wprintf("CHECKED ");
1030 wprintf("> Downloading allowed\n");
1032 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1033 if (er_flags & QR_VISDIR)
1034 wprintf("CHECKED ");
1035 wprintf("> Visible directory</UL>\n");
1037 /* end of directory stuff */
1039 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1040 if (er_flags & QR_NETWORK)
1041 wprintf("CHECKED ");
1042 wprintf("> Network shared room\n");
1044 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1045 if (er_flags & QR_PERMANENT)
1046 wprintf("CHECKED ");
1047 wprintf("> Permanent (does not auto-purge)\n");
1049 /* start of anon options */
1051 wprintf("<LI>Anonymous messages<UL>\n");
1053 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1054 if (((er_flags & QR_ANONONLY) == 0)
1055 && ((er_flags & QR_ANONOPT) == 0))
1056 wprintf("CHECKED ");
1057 wprintf("> No anonymous messages\n");
1059 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1060 if (er_flags & QR_ANONONLY)
1061 wprintf("CHECKED ");
1062 wprintf("> All messages are anonymous\n");
1064 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1065 if (er_flags & QR_ANONOPT)
1066 wprintf("CHECKED ");
1067 wprintf("> Prompt user when entering messages</UL>\n");
1069 /* end of anon options */
1071 wprintf("<LI>Room aide: \n");
1074 if (buf[0] != '2') {
1075 wprintf("<EM>%s</EM>\n", &buf[4]);
1077 extract(er_roomaide, &buf[4], 0);
1078 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1081 wprintf("</UL><CENTER>\n");
1082 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1083 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1085 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
1091 /* Sharing the room with other Citadel nodes... */
1092 if (!strcmp(tab, "sharing")) {
1094 shared_with = strdup("");
1095 not_shared_with = strdup("");
1097 /* Learn the current configuration */
1098 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1100 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1101 extract(node, buf, 0);
1102 not_shared_with = realloc(not_shared_with,
1103 strlen(not_shared_with) + 32);
1104 strcat(not_shared_with, node);
1105 strcat(not_shared_with, "\n");
1110 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1111 extract(cmd, buf, 0);
1112 extract(node, buf, 1);
1113 extract(remote_room, buf, 2);
1114 if (!strcasecmp(cmd, "ignet_push_share")) {
1115 shared_with = realloc(shared_with,
1116 strlen(shared_with) + 32);
1117 strcat(shared_with, node);
1118 if (strlen(remote_room) > 0) {
1119 strcat(shared_with, "|");
1120 strcat(shared_with, remote_room);
1122 strcat(shared_with, "\n");
1126 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1127 extract_token(buf, shared_with, i, '\n');
1128 extract_token(node, buf, 0, '|');
1129 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1130 extract_token(cmd, not_shared_with, j, '\n');
1131 if (!strcasecmp(node, cmd)) {
1132 remove_token(not_shared_with, j, '\n');
1137 /* Display the stuff */
1138 wprintf("<CENTER><br />"
1139 "<TABLE border=1 cellpadding=5><TR>"
1140 "<TD><B><I>Shared with</I></B></TD>"
1141 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1142 "<TR><TD VALIGN=TOP>\n");
1144 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1145 "<TD>Remote node name</TD>"
1146 "<TD>Remote room name</TD>"
1151 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1152 extract_token(buf, shared_with, i, '\n');
1153 extract_token(node, buf, 0, '|');
1154 extract_token(remote_room, buf, 1, '|');
1155 if (strlen(node) > 0) {
1156 wprintf("<FORM METHOD=\"POST\" "
1157 "ACTION=\"/netedit\">"
1158 "<TR><TD>%s</TD>\n", node);
1161 if (strlen(remote_room) > 0) {
1162 escputs(remote_room);
1168 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1169 "VALUE=\"ignet_push_share|");
1171 if (strlen(remote_room) > 0) {
1173 urlescputs(remote_room);
1176 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1177 "VALUE=\"sharing\">\n");
1178 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1179 "VALUE=\"remove\">\n");
1180 wprintf("<INPUT TYPE=\"submit\" "
1181 "NAME=\"sc\" VALUE=\"Unshare\">");
1182 wprintf("</TD></TR></FORM>\n");
1186 wprintf("</TABLE>\n");
1187 wprintf("</TD><TD VALIGN=TOP>\n");
1188 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1189 "<TD>Remote node name</TD>"
1190 "<TD>Remote room name</TD>"
1195 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1196 extract_token(node, not_shared_with, i, '\n');
1197 if (strlen(node) > 0) {
1198 wprintf("<FORM METHOD=\"POST\" "
1199 "ACTION=\"/netedit\">"
1203 "<INPUT TYPE=\"INPUT\" "
1207 wprintf("<INPUT TYPE=\"hidden\" "
1209 "VALUE=\"ignet_push_share|");
1212 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1213 "VALUE=\"sharing\">\n");
1214 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1215 "VALUE=\"add\">\n");
1216 wprintf("<INPUT TYPE=\"submit\" "
1217 "NAME=\"sc\" VALUE=\"Share\">");
1218 wprintf("</TD></TR></FORM>\n");
1222 wprintf("</TABLE>\n");
1223 wprintf("</TD></TR>"
1224 "</TABLE></CENTER><br />\n"
1225 "<I><B>Notes:</B><UL><LI>When sharing a room, "
1226 "it must be shared from both ends. Adding a node to "
1227 "the 'shared' list sends messages out, but in order to"
1228 " receive messages, the other nodes must be configured"
1229 " to send messages out to your system as well.\n"
1230 "<LI>If the remote room name is blank, it is assumed "
1231 "that the room name is identical on the remote node."
1232 "<LI>If the remote room name is different, the remote "
1233 "node must also configure the name of the room here."
1239 /* Mailing list management */
1240 if (!strcmp(tab, "listserv")) {
1242 wprintf("<br /><center>"
1243 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1244 "<TR><TD VALIGN=TOP>");
1246 wprintf("<i>The contents of this room are being "
1247 "mailed <b>as individual messages</b> "
1248 "to the following list recipients:"
1249 "</i><br /><br />\n");
1253 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1254 extract(cmd, buf, 0);
1255 if (!strcasecmp(cmd, "listrecp")) {
1256 extract(recp, buf, 1);
1259 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1262 wprintf("&tab=listserv\">(remove)</A><br />");
1266 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1267 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1268 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1269 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1270 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1271 wprintf("</FORM>\n");
1273 wprintf("</TD><TD VALIGN=TOP>\n");
1275 wprintf("<i>The contents of this room are being "
1276 "mailed <b>in digest form</b> "
1277 "to the following list recipients:"
1278 "</i><br /><br />\n");
1282 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1283 extract(cmd, buf, 0);
1284 if (!strcasecmp(cmd, "digestrecp")) {
1285 extract(recp, buf, 1);
1288 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1291 wprintf("&tab=listserv\">(remove)</A><br />");
1295 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1296 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1297 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1298 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1299 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1300 wprintf("</FORM>\n");
1302 wprintf("</TD></TR></TABLE><hr />\n");
1304 if (self_service(999) == 1) {
1305 wprintf("This room is configured to allow "
1306 "self-service subscribe/unsubscribe requests."
1307 " <A HREF=\"/toggle_self_service?newval=0&"
1309 "Click to disable.</A><br />\n"
1310 "The URL for subscribe/unsubscribe is: "
1311 "<TT>http://%s/listsub</TT><br />\n",
1316 wprintf("This room is <i>not</i> configured to allow "
1317 "self-service subscribe/unsubscribe requests."
1318 " <A HREF=\"/toggle_self_service?newval=1&"
1320 "Click to enable.</A><br />\n"
1325 wprintf("</CENTER>\n");
1329 /* Mailing list management */
1330 if (!strcmp(tab, "expire")) {
1332 serv_puts("GPEX room");
1334 if (buf[0] == '2') {
1335 roompolicy = extract_int(&buf[4], 0);
1336 roomvalue = extract_int(&buf[4], 1);
1339 serv_puts("GPEX floor");
1341 if (buf[0] == '2') {
1342 floorpolicy = extract_int(&buf[4], 0);
1343 floorvalue = extract_int(&buf[4], 1);
1346 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1347 wprintf("<TABLE border=0 cellspacing=5>\n");
1348 wprintf("<TR><TD>Message expire policy for this room<br />(");
1349 escputs(WC->wc_roomname);
1350 wprintf(")</TD><TD>");
1351 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1352 ((roompolicy == 0) ? "CHECKED" : "") );
1353 wprintf("Use the default policy for this floor<br />\n");
1354 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1355 ((roompolicy == 1) ? "CHECKED" : "") );
1356 wprintf("Never automatically expire messages<br />\n");
1357 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1358 ((roompolicy == 2) ? "CHECKED" : "") );
1359 wprintf("Expire by message count<br />\n");
1360 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1361 ((roompolicy == 3) ? "CHECKED" : "") );
1362 wprintf("Expire by message age<br />");
1363 wprintf("Number of messages or days: ");
1364 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1365 wprintf("</TD></TR>\n");
1367 if (WC->axlevel >= 6) {
1368 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1369 wprintf("<TR><TD>Message expire policy for this floor<br />(");
1370 escputs(floorlist[WC->wc_floor]);
1371 wprintf(")</TD><TD>");
1372 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1373 ((floorpolicy == 0) ? "CHECKED" : "") );
1374 wprintf("Use the system default<br />\n");
1375 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1376 ((floorpolicy == 1) ? "CHECKED" : "") );
1377 wprintf("Never automatically expire messages<br />\n");
1378 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1379 ((floorpolicy == 2) ? "CHECKED" : "") );
1380 wprintf("Expire by message count<br />\n");
1381 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1382 ((floorpolicy == 3) ? "CHECKED" : "") );
1383 wprintf("Expire by message age<br />");
1384 wprintf("Number of messages or days: ");
1385 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1389 wprintf("<CENTER>\n");
1390 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1391 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1393 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1394 wprintf("</CENTER></TD><TR>\n");
1396 wprintf("</TABLE>\n"
1397 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1403 /* Mailing list management */
1404 if (!strcmp(tab, "access")) {
1408 /* end content of whatever tab is open now */
1409 wprintf("</TD></TR></TABLE></div>\n");
1416 * Toggle self-service list subscription
1418 void toggle_self_service(void) {
1421 newval = atoi(bstr("newval"));
1422 self_service(newval);
1429 * save new parameters for a room
1435 char er_password[10];
1436 char er_dirname[15];
1437 char er_roomaide[26];
1443 if (strcmp(bstr("sc"), "OK")) {
1444 strcpy(WC->ImportantMessage,
1445 "Cancelled. Changes were not saved.");
1452 if (buf[0] != '2') {
1453 strcpy(WC->ImportantMessage, &buf[4]);
1457 extract(er_name, &buf[4], 0);
1458 extract(er_password, &buf[4], 1);
1459 extract(er_dirname, &buf[4], 2);
1460 er_flags = extract_int(&buf[4], 3);
1462 strcpy(er_roomaide, bstr("er_roomaide"));
1463 if (strlen(er_roomaide) == 0) {
1466 if (buf[0] != '2') {
1467 strcpy(er_roomaide, "");
1469 extract(er_roomaide, &buf[4], 0);
1472 strcpy(buf, bstr("er_name"));
1474 if (strlen(buf) > 0)
1475 strcpy(er_name, buf);
1477 strcpy(buf, bstr("er_password"));
1479 if (strlen(buf) > 0)
1480 strcpy(er_password, buf);
1482 strcpy(buf, bstr("er_dirname"));
1484 if (strlen(buf) > 0)
1485 strcpy(er_dirname, buf);
1487 strcpy(buf, bstr("type"));
1488 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1490 if (!strcmp(buf, "invonly")) {
1491 er_flags |= (QR_PRIVATE);
1493 if (!strcmp(buf, "guessname")) {
1494 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1496 if (!strcmp(buf, "passworded")) {
1497 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1499 if (!strcmp(bstr("prefonly"), "yes")) {
1500 er_flags |= QR_PREFONLY;
1502 er_flags &= ~QR_PREFONLY;
1505 if (!strcmp(bstr("readonly"), "yes")) {
1506 er_flags |= QR_READONLY;
1508 er_flags &= ~QR_READONLY;
1511 if (!strcmp(bstr("permanent"), "yes")) {
1512 er_flags |= QR_PERMANENT;
1514 er_flags &= ~QR_PERMANENT;
1517 if (!strcmp(bstr("network"), "yes")) {
1518 er_flags |= QR_NETWORK;
1520 er_flags &= ~QR_NETWORK;
1523 if (!strcmp(bstr("directory"), "yes")) {
1524 er_flags |= QR_DIRECTORY;
1526 er_flags &= ~QR_DIRECTORY;
1529 if (!strcmp(bstr("ulallowed"), "yes")) {
1530 er_flags |= QR_UPLOAD;
1532 er_flags &= ~QR_UPLOAD;
1535 if (!strcmp(bstr("dlallowed"), "yes")) {
1536 er_flags |= QR_DOWNLOAD;
1538 er_flags &= ~QR_DOWNLOAD;
1541 if (!strcmp(bstr("visdir"), "yes")) {
1542 er_flags |= QR_VISDIR;
1544 er_flags &= ~QR_VISDIR;
1547 strcpy(buf, bstr("anon"));
1549 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1550 if (!strcmp(buf, "anononly"))
1551 er_flags |= QR_ANONONLY;
1552 if (!strcmp(buf, "anon2"))
1553 er_flags |= QR_ANONOPT;
1556 if (!strcmp(bstr("bump"), "yes"))
1559 er_floor = atoi(bstr("er_floor"));
1561 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1562 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1565 if (buf[0] != '2') {
1566 strcpy(WC->ImportantMessage, &buf[4]);
1572 if (strlen(er_roomaide) > 0) {
1573 sprintf(buf, "SETA %s", er_roomaide);
1576 if (buf[0] != '2') {
1577 strcpy(WC->ImportantMessage, &buf[4]);
1578 display_main_menu();
1583 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1590 * Display form for Invite, Kick, and show Who Knows a room
1592 void do_invt_kick(void) {
1593 char buf[SIZ], room[SIZ], username[SIZ];
1598 if (buf[0] != '2') {
1602 extract(room, &buf[4], 0);
1604 strcpy(username, bstr("username"));
1606 if (!strcmp(bstr("sc"), "Kick")) {
1607 sprintf(buf, "KICK %s", username);
1611 if (buf[0] != '2') {
1612 strcpy(WC->ImportantMessage, &buf[4]);
1614 sprintf(WC->ImportantMessage,
1615 "<B><I>User %s kicked out of room %s.</I></B>\n",
1620 if (!strcmp(bstr("sc"), "Invite")) {
1621 sprintf(buf, "INVT %s", username);
1625 if (buf[0] != '2') {
1626 strcpy(WC->ImportantMessage, &buf[4]);
1628 sprintf(WC->ImportantMessage,
1629 "<B><I>User %s invited to room %s.</I></B>\n",
1640 * Display form for Invite, Kick, and show Who Knows a room
1642 void display_whok(void)
1644 char buf[SIZ], room[SIZ], username[SIZ];
1649 if (buf[0] != '2') {
1653 extract(room, &buf[4], 0);
1656 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1657 "<TD>The users listed below have access to this room. "
1658 "To remove a user from the access list, select the user "
1659 "name from the list and click 'Kick'.<br /><br />");
1661 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1662 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1663 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1666 if (buf[0] == '1') {
1667 while (serv_gets(buf), strcmp(buf, "000")) {
1668 extract(username, buf, 0);
1669 wprintf("<OPTION>");
1674 wprintf("</SELECT><br />\n");
1676 wprintf("<input type=submit name=sc value=\"Kick\">");
1677 wprintf("</FORM></CENTER>\n");
1680 "To grant another user access to this room, enter the "
1681 "user name in the box below and click 'Invite'.<br /><br />");
1683 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
1684 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1685 wprintf("Invite: ");
1686 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1687 "<input type=\"hidden\" name=\"sc\" value=\"Invite\">"
1688 "<input type=\"submit\" value=\"Invite\">"
1689 "</FORM></CENTER>\n");
1691 wprintf("</TD></TR></TABLE>\n");
1698 * display the form for entering a new room
1700 void display_entroom(void)
1705 serv_puts("CRE8 0");
1708 if (buf[0] != '2') {
1709 strcpy(WC->ImportantMessage, &buf[4]);
1710 display_main_menu();
1714 output_headers(1, 1, 2, 0, 0, 0, 0);
1715 wprintf("<div id=\"banner\">\n"
1716 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1717 "<SPAN CLASS=\"titlebar\">Create a new room</SPAN>"
1718 "</TD></TR></TABLE>\n"
1719 "</div>\n<div id=\"content\">\n"
1722 wprintf("<div id=\"fix_scrollbar_bug\">"
1723 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1725 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1727 wprintf("<UL><LI>Name of room: ");
1728 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1730 wprintf("<LI>Resides on floor: ");
1732 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1733 for (i = 0; i < 128; ++i)
1734 if (strlen(floorlist[i]) > 0) {
1735 wprintf("<OPTION ");
1736 wprintf("VALUE=\"%d\">", i);
1737 escputs(floorlist[i]);
1738 wprintf("</OPTION>\n");
1740 wprintf("</SELECT>\n");
1742 wprintf("<LI>Default view for room: ");
1743 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1744 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1745 wprintf("<OPTION %s VALUE=\"%d\">",
1746 ((i == 0) ? "SELECTED" : ""), i );
1747 escputs(viewdefs[i]);
1748 wprintf("</OPTION>\n");
1750 wprintf("</SELECT>\n");
1752 wprintf("<LI>Type of room:<UL>\n");
1754 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1755 wprintf("CHECKED > Public room\n");
1757 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1758 wprintf("> Private - guess name\n");
1760 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1761 wprintf("> Private - require password:\n");
1762 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1764 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1765 wprintf("> Private - invitation only\n");
1767 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1768 wprintf("> Personal (mailbox for you only)\n");
1771 wprintf("<CENTER>\n");
1772 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1774 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1775 wprintf("</CENTER>\n");
1776 wprintf("</FORM>\n<hr />");
1777 serv_printf("MESG roomaccess");
1779 if (buf[0] == '1') {
1780 fmout(NULL, "CENTER");
1782 wprintf("</td></tr></table></div>\n");
1790 * support function for entroom() -- sets the default view
1792 void er_set_default_view(int newview) {
1806 if (buf[0] != '2') return;
1808 extract(rm_name, &buf[4], 0);
1809 extract(rm_pass, &buf[4], 1);
1810 extract(rm_dir, &buf[4], 2);
1811 rm_bits1 = extract_int(&buf[4], 3);
1812 rm_floor = extract_int(&buf[4], 4);
1813 rm_listorder = extract_int(&buf[4], 5);
1814 rm_bits2 = extract_int(&buf[4], 7);
1816 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1817 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1818 rm_listorder, newview, rm_bits2
1833 char er_password[SIZ];
1838 if (strcmp(bstr("sc"), "OK")) {
1839 strcpy(WC->ImportantMessage,
1840 "Cancelled. No new room was created.");
1841 display_main_menu();
1844 strcpy(er_name, bstr("er_name"));
1845 strcpy(er_type, bstr("type"));
1846 strcpy(er_password, bstr("er_password"));
1847 er_floor = atoi(bstr("er_floor"));
1848 er_view = atoi(bstr("er_view"));
1851 if (!strcmp(er_type, "guessname"))
1853 if (!strcmp(er_type, "passworded"))
1855 if (!strcmp(er_type, "invonly"))
1857 if (!strcmp(er_type, "personal"))
1860 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1861 er_name, er_num_type, er_password, er_floor, 0, er_view);
1864 if (buf[0] != '2') {
1865 strcpy(WC->ImportantMessage, &buf[4]);
1866 display_main_menu();
1870 do_change_view(er_view); /* Now go there */
1875 * display the screen to enter a private room
1877 void display_private(char *rname, int req_pass)
1880 output_headers(1, 1, 0, 0, 0, 0, 0);
1882 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1883 do_template("beginbox");
1885 wprintf("<CENTER>\n");
1886 wprintf("<br />If you know the name of a hidden (guess-name) or\n");
1887 wprintf("passworded room, you can enter that room by typing\n");
1888 wprintf("its name below. Once you gain access to a private\n");
1889 wprintf("room, it will appear in your regular room listings\n");
1890 wprintf("so you don't have to keep returning here.\n");
1891 wprintf("<br /><br />");
1893 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1895 wprintf("<table border=\"0\" cellspacing=\"5\" "
1896 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1898 "Enter room name:</TD><TD>"
1899 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1900 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1903 wprintf("</TD></TR><TR><TD>");
1904 wprintf("Enter room password:</TD><TD>");
1905 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1907 wprintf("</TD></TR></TABLE><br />\n");
1909 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1911 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1912 wprintf("</FORM>\n");
1913 do_template("endbox");
1918 * goto a private room
1920 void goto_private(void)
1925 if (strcasecmp(bstr("sc"), "OK")) {
1926 display_main_menu();
1929 strcpy(hold_rm, WC->wc_roomname);
1930 strcpy(buf, "GOTO ");
1931 strcat(buf, bstr("gr_name"));
1933 strcat(buf, bstr("gr_pass"));
1937 if (buf[0] == '2') {
1938 smart_goto(bstr("gr_name"));
1941 if (!strncmp(buf, "540", 3)) {
1942 display_private(bstr("gr_name"), 1);
1945 output_headers(1, 1, 1, 0, 0, 0, 0);
1946 wprintf("%s\n", &buf[4]);
1953 * display the screen to zap a room
1955 void display_zap(void)
1957 output_headers(1, 1, 2, 0, 0, 0, 0);
1959 wprintf("<div id=\"banner\">\n");
1960 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1961 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget/unsubscribe) the current room</SPAN>\n");
1962 wprintf("</TD></TR></TABLE>\n");
1963 wprintf("</div>\n<div id=\"content\">\n");
1965 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1966 wprintf("disappear from your room list. Is this what you wish ");
1967 wprintf("to do?<br />\n");
1969 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1970 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1972 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1973 wprintf("</FORM>\n");
1984 char final_destination[SIZ];
1986 /* If the forget-room routine fails for any reason, we fall back
1987 * to the current room; otherwise, we go to the Lobby
1989 strcpy(final_destination, WC->wc_roomname);
1991 if (!strcasecmp(bstr("sc"), "OK")) {
1992 serv_printf("GOTO %s", WC->wc_roomname);
1994 if (buf[0] == '2') {
1997 if (buf[0] == '2') {
1998 strcpy(final_destination, "_BASEROOM_");
2002 smart_goto(final_destination);
2009 * Confirm deletion of the current room
2011 void confirm_delete_room(void)
2015 serv_puts("KILL 0");
2017 if (buf[0] != '2') {
2018 strcpy(WC->ImportantMessage, &buf[4]);
2019 display_main_menu();
2022 output_headers(1, 1, 2, 0, 0, 0, 0);
2023 wprintf("<div id=\"banner\">\n");
2024 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2025 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
2026 wprintf("</TD></TR></TABLE>\n");
2027 wprintf("</div>\n<div id=\"content\">\n");
2029 wprintf("<CENTER>");
2030 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
2032 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
2033 escputs(WC->wc_roomname);
2034 wprintf("</FONT>?<br />\n");
2036 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
2037 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
2039 wprintf("</FORM></CENTER>\n");
2045 * Delete the current room
2047 void delete_room(void)
2052 strcpy(sc, bstr("sc"));
2054 if (strcasecmp(sc, "Delete")) {
2055 strcpy(WC->ImportantMessage,
2056 "Cancelled. This room was not deleted.");
2057 display_main_menu();
2060 serv_puts("KILL 1");
2062 if (buf[0] != '2') {
2063 strcpy(WC->ImportantMessage, &buf[4]);
2064 display_main_menu();
2067 smart_goto("_BASEROOM_");
2074 * Perform changes to a room's network configuration
2076 void netedit(void) {
2085 if (strlen(bstr("line"))==0) {
2090 strcpy(line, bstr("prefix"));
2091 strcat(line, bstr("line"));
2092 strcat(line, bstr("suffix"));
2102 if (buf[0] != '1') {
2108 /* This loop works for add *or* remove. Spiffy, eh? */
2109 while (serv_gets(buf), strcmp(buf, "000")) {
2110 extract(cmpa0, buf, 0);
2111 extract(cmpa1, buf, 1);
2112 extract(cmpb0, line, 0);
2113 extract(cmpb1, line, 1);
2114 if ( (strcasecmp(cmpa0, cmpb0))
2115 || (strcasecmp(cmpa1, cmpb1)) ) {
2116 fprintf(fp, "%s\n", buf);
2123 if (buf[0] != '4') {
2129 while (fgets(buf, sizeof buf, fp) != NULL) {
2130 buf[strlen(buf)-1] = 0;
2134 if (!strcasecmp(bstr("cmd"), "add")) {
2146 * Convert a room name to a folder-ish-looking name.
2148 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2153 * For mailboxes, just do it straight...
2156 sprintf(folder, "My folders|%s", room);
2160 * Otherwise, prefix the floor name as a "public folders" moniker
2163 sprintf(folder, "%s|%s", floorlist[floor], room);
2167 * Replace "\" characters with "|" for pseudo-folder-delimiting
2169 for (i=0; i<strlen(folder); ++i) {
2170 if (folder[i] == '\\') folder[i] = '|';
2178 * Back end for change_view()
2180 void do_change_view(int newview) {
2183 serv_printf("VIEW %d", newview);
2185 WC->wc_view = newview;
2186 smart_goto(WC->wc_roomname);
2192 * Change the view for this room
2194 void change_view(void) {
2197 view = atol(bstr("view"));
2198 do_change_view(view);
2203 * One big expanded tree list view --- like a folder list
2205 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2207 int levels, oldlevels;
2210 int has_subfolders = 0;
2212 /* Include the menu expanding/collapsing code */
2213 wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
2215 /* BEGIN TREE MENU */
2216 wprintf("<div style=\"background: white\">\n");
2217 wprintf("<div id=\"mainMenu\">\n");
2218 wprintf("<UL id=\"menuList\">\n");
2222 for (i=0; i<max_folders; ++i) {
2225 if ((i+1) < max_folders) {
2226 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2227 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2232 levels = num_tokens(fold[i].name, '|');
2234 if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
2235 for (t=0; t<(oldlevels-levels); ++t) {
2240 if (has_subfolders) {
2242 if (levels == 1) wprintf(" class=\"menubar\"");
2244 wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
2250 if (fold[i].selectable) {
2251 wprintf("<A HREF=\"/dotgoto?room=");
2252 urlescputs(fold[i].room);
2257 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2259 else if (fold[i].hasnewmsgs) {
2260 wprintf("<SPAN CLASS=\"roomlist_new\">");
2263 wprintf("<SPAN CLASS=\"roomlist_old\">");
2265 extract(buf, fold[i].name, levels-1);
2269 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2270 wprintf(" (INBOX)");
2273 if (fold[i].selectable) {
2278 if (has_subfolders) {
2279 wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
2281 ( (levels == 1) ? "menu" : "submenu")
2287 wprintf("</UL></UL>\n");
2288 wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
2289 for (i=0; i<actnum; ++i) {
2290 wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
2293 wprintf("</DIV>\n");
2298 * Boxes and rooms and lists ... oh my!
2300 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2303 int levels, oldlevels;
2306 static int columns = 3;
2307 int boxes_per_column = 0;
2308 int current_column = 0;
2312 while (nf % columns != 0) ++nf;
2313 boxes_per_column = (nf / columns);
2314 if (boxes_per_column < 1) boxes_per_column = 1;
2316 /* Outer table (for columnization) */
2317 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2318 "<tr><td valign=top>");
2322 for (i=0; i<max_folders; ++i) {
2324 levels = num_tokens(fold[i].name, '|');
2326 if ((levels == 1) && (oldlevels > 1)) {
2329 do_template("endbox");
2332 if ((num_boxes % boxes_per_column) == 0) {
2334 if (current_column < columns) {
2335 wprintf("</td><td valign=top>\n");
2342 /* Begin inner box */
2343 extract(buf, fold[i].name, levels-1);
2344 stresc(boxtitle, buf, 1, 0);
2345 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2346 do_template("beginbox");
2354 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2355 if (fold[i].selectable) {
2356 wprintf("<A HREF=\"/dotgoto?room=");
2357 urlescputs(fold[i].room);
2363 if (fold[i].hasnewmsgs) {
2364 wprintf("<SPAN CLASS=\"roomlist_new\">");
2367 wprintf("<SPAN CLASS=\"roomlist_old\">");
2369 extract(buf, fold[i].name, levels-1);
2372 if (fold[i].selectable) {
2378 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2379 wprintf(" (INBOX)");
2381 wprintf("<br />\n");
2384 /* End the final inner box */
2385 do_template("endbox");
2387 wprintf("</TD></TR></TABLE>\n");
2392 * Show the room list. (only should get called by
2393 * knrooms() because that's where output_headers() is called from)
2396 void list_all_rooms_by_floor(char *viewpref) {
2399 struct folder *fold = NULL;
2401 int max_folders = 0;
2402 int alloc_folders = 0;
2406 int num_floors = 1; /* add an extra one for private folders */
2408 /* Start with the mailboxes */
2411 fold = malloc(sizeof(struct folder));
2412 memset(fold, 0, sizeof(struct folder));
2413 strcpy(fold[0].name, "My folders");
2414 fold[0].is_mailbox = 1;
2416 /* Then add floors */
2419 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2420 if (max_folders >= alloc_folders) {
2421 alloc_folders = max_folders + 100;
2422 fold = realloc(fold,
2423 alloc_folders * sizeof(struct folder));
2425 memset(&fold[max_folders], 0, sizeof(struct folder));
2426 extract(fold[max_folders].name, buf, 1);
2434 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2435 if (max_folders >= alloc_folders) {
2436 alloc_folders = max_folders + 100;
2437 fold = realloc(fold,
2438 alloc_folders * sizeof(struct folder));
2440 memset(&fold[max_folders], 0, sizeof(struct folder));
2441 extract(fold[max_folders].room, buf, 0);
2442 ra_flags = extract_int(buf, 5);
2443 flags = extract_int(buf, 1);
2444 fold[max_folders].floor = extract_int(buf, 2);
2445 fold[max_folders].hasnewmsgs =
2446 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2447 if (flags & QR_MAILBOX) {
2448 fold[max_folders].is_mailbox = 1;
2450 room_to_folder(fold[max_folders].name,
2451 fold[max_folders].room,
2452 fold[max_folders].floor,
2453 fold[max_folders].is_mailbox);
2454 fold[max_folders].selectable = 1;
2458 /* Bubble-sort the folder list */
2459 for (i=0; i<max_folders; ++i) {
2460 for (j=0; j<(max_folders-1)-i; ++j) {
2461 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2462 swap = strcasecmp(fold[j].name, fold[j+1].name);
2465 if ( (fold[j+1].is_mailbox)
2466 && (!fold[j].is_mailbox)) {
2474 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2475 memcpy(&fold[j], &fold[j+1],
2476 sizeof(struct folder));
2477 memcpy(&fold[j+1], &ftmp,
2478 sizeof(struct folder));
2483 /* test only hackish view
2484 wprintf("<table><TR><TD>A Table</TD></TR></table>\n");
2485 for (i=0; i<max_folders; ++i) {
2486 escputs(fold[i].name);
2487 wprintf("<br />\n");
2491 if (!strcasecmp(viewpref, "folders")) {
2492 do_folder_view(fold, max_folders, num_floors);
2495 do_rooms_view(fold, max_folders, num_floors);
2503 /* Do either a known rooms list or a folders list, depending on the
2507 char listviewpref[SIZ];
2509 output_headers(1, 1, 2, 0, 0, 0, 0);
2512 /* Determine whether the user is trying to change views */
2513 if (bstr("view") != NULL) {
2514 if (strlen(bstr("view")) > 0) {
2515 set_preference("roomlistview", bstr("view"));
2519 get_preference("roomlistview", listviewpref);
2521 if ( (strcasecmp(listviewpref, "folders"))
2522 && (strcasecmp(listviewpref, "table")) ) {
2523 strcpy(listviewpref, "rooms");
2527 wprintf("<div id=\"banner\">\n"
2528 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2529 "<SPAN CLASS=\"titlebar\">"
2531 if (!strcasecmp(listviewpref, "rooms")) {
2532 wprintf("Room list");
2534 if (!strcasecmp(listviewpref, "folders")) {
2535 wprintf("Folder list");
2537 if (!strcasecmp(listviewpref, "table")) {
2538 wprintf("Room list");
2540 wprintf("</SPAN></TD>\n");
2542 /* offer the ability to switch views */
2543 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2544 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2545 "OnChange=\"location.href=roomlistomatic.newview.options"
2546 "[selectedIndex].value\">\n");
2548 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2551 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2554 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2555 "View as folder list"
2557 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2560 wprintf("</SELECT><br />");
2562 wprintf("</FORM></TD></TR></TABLE>\n");
2565 "<div id=\"content\">\n");
2567 /* Display the room list in the user's preferred format */
2568 list_all_rooms_by_floor(listviewpref);
2574 * Set the message expire policy for this room and/or floor
2576 void set_room_policy(void) {
2579 if (strcmp(bstr("sc"), "OK")) {
2580 strcpy(WC->ImportantMessage,
2581 "Cancelled. Changes were not saved.");
2586 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2588 strcpy(WC->ImportantMessage, &buf[4]);
2590 if (WC->axlevel >= 6) {
2591 strcat(WC->ImportantMessage, "<br />\n");
2592 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2594 strcat(WC->ImportantMessage, &buf[4]);