10 #include <sys/types.h>
12 #include <sys/socket.h>
15 #include <netinet/in.h>
43 char floorlist[128][SIZ];
46 * load the list of floors
48 void load_floorlist(void)
53 for (a = 0; a < 128; ++a)
59 strcpy(floorlist[0], "Main Floor");
62 while (serv_gets(buf), strcmp(buf, "000")) {
63 extract(floorlist[extract_int(buf, 0)], buf, 1);
69 * remove a room from the march list
71 void remove_march(char *aaa)
73 struct march *mptr, *mptr2;
75 if (WC->march == NULL)
78 if (!strcasecmp(WC->march->march_name, aaa)) {
79 mptr = WC->march->next;
85 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
86 if (!strcasecmp(mptr->march_name, aaa)) {
87 mptr2->next = mptr->next;
100 void room_tree_list(struct roomlisting *rp)
109 room_tree_list(rp->lnext);
111 strcpy(rmname, rp->rlname);
114 wprintf("<A HREF=\"/dotgoto&room=");
118 escputs1(rmname, 1, 1);
119 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
121 else if (f & QR_DIRECTORY)
123 else if (f & QR_NETWORK)
127 wprintf("</A><TT> </TT>\n");
129 room_tree_list(rp->rnext);
135 * Room ordering stuff (compare first by floor, then by order)
137 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
139 if ((r1 == NULL) && (r2 == NULL))
145 if (r1->rlfloor < r2->rlfloor)
147 if (r1->rlfloor > r2->rlfloor)
149 if (r1->rlorder < r2->rlorder)
151 if (r1->rlorder > r2->rlorder)
158 * Common code for all room listings
160 void listrms(char *variety)
165 struct roomlisting *rl = NULL;
166 struct roomlisting *rp;
167 struct roomlisting *rs;
170 /* Ask the server for a room list */
177 while (serv_gets(buf), strcmp(buf, "000")) {
179 rp = malloc(sizeof(struct roomlisting));
180 extract(rp->rlname, buf, 0);
181 rp->rlflags = extract_int(buf, 1);
182 rp->rlfloor = extract_int(buf, 2);
183 rp->rlorder = extract_int(buf, 3);
192 if (rordercmp(rp, rs) < 0) {
193 if (rs->lnext == NULL) {
200 if (rs->rnext == NULL) {
212 /* If no rooms were listed, print an nbsp to make the cell
213 * borders show up anyway.
215 if (num_rooms == 0) wprintf(" ");
220 * list all forgotten rooms
222 void zapped_list(void)
224 output_headers(1, 1, 0, 0, 0, 0, 0);
226 svprintf("BOXTITLE", WCS_STRING, "Zapped (forgotten) rooms");
227 do_template("beginbox");
231 wprintf("<br /><br />\n");
232 wprintf("Click on any room to un-zap it and goto that room.\n");
233 do_template("endbox");
239 * read this room's info file (set v to 1 for verbose mode)
248 fmout(NULL, "CENTER");
255 /* Display room graphic. The server doesn't actually
256 * need the room name, but we supply it in order to
257 * keep the browser from using a cached graphic from
260 void embed_room_graphic(void) {
263 serv_puts("OIMG _roompic_");
266 wprintf("<TD BGCOLOR=\"#444455\">");
267 wprintf("<IMG HEIGHT=64 SRC=\"/image&name=_roompic_&room=");
268 urlescputs(WC->wc_roomname);
277 /* Let the user know if new mail has arrived
279 void embed_newmail_button(void) {
280 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
282 "<A HREF=\"/dotgoto?room=_MAIL_\">"
283 "<IMG SRC=\"/static/mail.gif\" border=0 "
284 "ALT=\"You have new mail\">"
285 "<br /><SPAN CLASS=\"youhavemail\">"
286 "%d new mail</SPAN></A>", WC->new_mail);
287 WC->remember_new_mail = WC->new_mail;
294 * Display the current view and offer an option to change it
296 void embed_view_o_matic(void) {
299 wprintf("<FORM NAME=\"viewomatic\">\n"
300 "<SELECT NAME=\"newview\" SIZE=\"1\" "
301 "OnChange=\"location.href=viewomatic.newview.options"
302 "[selectedIndex].value\">\n");
304 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
306 * Only offer the views that make sense, given the default
307 * view for the room. For example, don't offer a Calendar
308 * view in a non-Calendar room.
312 || (i == WC->wc_default_view)
313 || ( (i == 0) && (WC->wc_default_view == 1) )
314 || ( (i == 1) && (WC->wc_default_view == 0) )
317 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
318 ((i == WC->wc_view) ? "SELECTED" : ""),
320 escputs(viewdefs[i]);
321 wprintf("</OPTION>\n");
324 wprintf("</SELECT></FORM>\n");
329 void embed_room_banner(char *got, int navbar_style) {
332 /* We need to have the information returned by a GOTO server command.
333 * If it isn't supplied, we fake it by issuing our own GOTO.
336 serv_printf("GOTO %s", WC->wc_roomname);
341 /* If the user happens to select the "make this my start page" link,
342 * we want it to remember the URL as a "/dotskip" one instead of
343 * a "skip" or "gotonext" or something like that.
345 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
348 /* Check for new mail. */
349 WC->new_mail = extract_int(&got[4], 9);
350 WC->wc_view = extract_int(&got[4], 11);
352 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
353 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
354 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
355 svcallback("ROOMPIC", embed_room_graphic);
356 svcallback("ROOMINFO", readinfo);
357 svcallback("YOUHAVEMAIL", embed_newmail_button);
358 svcallback("VIEWOMATIC", embed_view_o_matic);
359 svcallback("START", offer_start_page);
361 do_template("roombanner");
362 if (navbar_style != navbar_none) {
364 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
365 "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%%\"><tr>\n");
368 if (navbar_style == navbar_default) wprintf(
370 "<a href=\"/ungoto\">"
371 "<img align=\"middle\" src=\"/static/back.gif\" border=\"0\">"
372 "<span class=\"navbar_link\">Ungoto</span></A>"
376 if ( (navbar_style == navbar_default)
377 && (WC->wc_view != VIEW_CALENDAR)
378 && (WC->wc_view != VIEW_ADDRESSBOOK)
379 && (WC->wc_view != VIEW_NOTES)
380 && (WC->wc_view != VIEW_TASKS)
384 "<A HREF=\"/readnew\">"
385 "<img align=\"middle\" src=\"/static/readmsgs.gif\" border=\"0\">"
386 "<span class=\"navbar_link\">New messages</span></A>"
391 if (navbar_style == navbar_default) {
392 switch(WC->wc_view) {
393 case VIEW_ADDRESSBOOK:
396 "<A HREF=\"/readfwd\">"
397 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
399 "<span class=\"navbar_link\">"
407 "<A HREF=\"/readfwd?calview=day\">"
408 "<img align=\"middle\" src=\"/static/day_view.gif\" "
410 "<span class=\"navbar_link\">"
416 "<A HREF=\"/readfwd?calview=month\">"
417 "<img align=\"middle\" src=\"/static/month_view.gif\" "
419 "<span class=\"navbar_link\">"
427 "<A HREF=\"/readfwd\">"
428 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
430 "<span class=\"navbar_link\">"
438 "<A HREF=\"/readfwd\">"
439 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
441 "<span class=\"navbar_link\">"
449 "<A HREF=\"/readfwd\">"
450 "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
452 "<span class=\"navbar_link\">"
460 if (navbar_style == navbar_default) {
463 "<A HREF=\"/display_enter\">"
464 "<img align=\"middle\" src=\"/static/enter.gif\" border=\"0\">"
465 "<span class=\"navbar_link\">"
467 switch(WC->wc_view) {
468 case VIEW_ADDRESSBOOK:
469 wprintf("Add new contact");
472 wprintf("Add new event");
475 wprintf("Add new task");
478 wprintf("Add new note");
481 wprintf("Enter a message");
484 wprintf("</span></a></td>\n");
487 if (navbar_style == navbar_default) wprintf(
490 "<span class=\"navbar_link\">Skip this room</span>"
491 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
495 if (navbar_style == navbar_default) wprintf(
497 "<A HREF=\"/gotonext\">"
498 "<span class=\"navbar_link\">Goto next room</span>"
499 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
503 wprintf("</tr></table></div>\n");
513 * back end routine to take the session to a new room
516 void gotoroom(char *gname)
519 static long ls = (-1L);
521 /* store ungoto information */
522 strcpy(WC->ugname, WC->wc_roomname);
525 /* move to the new room */
526 serv_printf("GOTO %s", gname);
529 serv_puts("GOTO _BASEROOM_");
535 extract(WC->wc_roomname, &buf[4], 0);
536 WC->room_flags = extract_int(&buf[4], 4);
537 /* highest_msg_read = extract_int(&buf[4],6);
538 maxmsgnum = extract_int(&buf[4],5);
539 is_mail = (char) extract_int(&buf[4],7); */
540 ls = extract_long(&buf[4], 6);
541 WC->wc_floor = extract_int(&buf[4], 10);
542 WC->wc_view = extract_int(&buf[4], 11);
543 WC->wc_default_view = extract_int(&buf[4], 12);
546 WC->is_room_aide = WC->is_aide;
548 WC->is_room_aide = (char) extract_int(&buf[4], 8);
550 remove_march(WC->wc_roomname);
551 if (!strcasecmp(gname, "_BASEROOM_"))
557 * Locate the room on the march list which we most want to go to. Each room
558 * is measured given a "weight" of preference based on various factors.
560 char *pop_march(int desired_floor)
562 static char TheRoom[128];
564 int TheOrder = 32767;
567 struct march *mptr = NULL;
569 strcpy(TheRoom, "_BASEROOM_");
570 if (WC->march == NULL)
573 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
575 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
576 weight = weight + 10000;
577 if (mptr->march_floor == desired_floor)
578 weight = weight + 5000;
580 weight = weight + ((128 - (mptr->march_floor)) * 128);
581 weight = weight + (128 - (mptr->march_order));
583 if (weight > TheWeight) {
585 strcpy(TheRoom, mptr->march_name);
586 TheFloor = mptr->march_floor;
587 TheOrder = mptr->march_order;
595 /* Goto next room having unread messages.
596 * We want to skip over rooms that the user has already been to, and take the
597 * user back to the lobby when done. The room we end up in is placed in
598 * newroom - which is set to 0 (the lobby) initially.
599 * We start the search in the current room rather than the beginning to prevent
600 * two or more concurrent users from dragging each other back to the same room.
605 struct march *mptr, *mptr2;
608 /* First check to see if the march-mode list is already allocated.
609 * If it is, pop the first room off the list and go there.
612 if (WC->march == NULL) {
616 while (serv_gets(buf), strcmp(buf, "000")) {
617 mptr = (struct march *) malloc(sizeof(struct march));
619 extract(mptr->march_name, buf, 0);
620 mptr->march_floor = extract_int(buf, 2);
621 mptr->march_order = extract_int(buf, 3);
622 if (WC->march == NULL) {
626 while (mptr2->next != NULL)
631 /* add _BASEROOM_ to the end of the march list, so the user will end up
632 * in the system base room (usually the Lobby>) at the end of the loop
634 mptr = (struct march *) malloc(sizeof(struct march));
636 strcpy(mptr->march_name, "_BASEROOM_");
637 if (WC->march == NULL) {
641 while (mptr2->next != NULL)
646 * ...and remove the room we're currently in, so a <G>oto doesn't make us
647 * walk around in circles
649 remove_march(WC->wc_roomname);
651 if (WC->march != NULL) {
652 strcpy(next_room, pop_march(-1));
654 strcpy(next_room, "_BASEROOM_");
658 smart_goto(next_room);
662 void smart_goto(char *next_room) {
670 * mark all messages in current room as having been read
672 void slrp_highest(void)
677 serv_puts("SLRP HIGHEST");
680 wprintf("<EM>%s</EM><br />\n", &buf[4]);
687 * un-goto the previous room
693 if (!strcmp(WC->ugname, "")) {
694 smart_goto(WC->wc_roomname);
697 serv_printf("GOTO %s", WC->ugname);
700 smart_goto(WC->wc_roomname);
703 if (WC->uglsn >= 0L) {
704 serv_printf("SLRP %ld", WC->uglsn);
707 strcpy(buf, WC->ugname);
708 strcpy(WC->ugname, "");
717 * Set/clear/read the "self-service list subscribe" flag for a room
719 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
720 * Always returns the new value.
723 int self_service(int newval) {
724 int current_value = 0;
730 int flags, floor, order, view, flags2;
734 if (buf[0] != '2') return(0);
736 extract(name, &buf[4], 0);
737 extract(password, &buf[4], 1);
738 extract(dirname, &buf[4], 2);
739 flags = extract_int(&buf[4], 3);
740 floor = extract_int(&buf[4], 4);
741 order = extract_int(&buf[4], 5);
742 view = extract_int(&buf[4], 6);
743 flags2 = extract_int(&buf[4], 7);
745 if (flags2 & QR2_SELFLIST) {
753 flags2 = flags2 | QR2_SELFLIST;
755 else if (newval == 0) {
756 flags2 = flags2 & ~QR2_SELFLIST;
759 return(current_value);
762 if (newval != current_value) {
763 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
764 name, password, dirname, flags,
765 floor, order, view, flags2);
779 * display the form for editing a room
781 void display_editroom(void)
786 char remote_room[SIZ];
789 char er_password[10];
791 char er_roomaide[26];
797 char *not_shared_with;
804 if (strlen(tab) == 0) tab = "admin";
811 strcpy(WC->ImportantMessage, &buf[4]);
815 extract(er_name, &buf[4], 0);
816 extract(er_password, &buf[4], 1);
817 extract(er_dirname, &buf[4], 2);
818 er_flags = extract_int(&buf[4], 3);
819 er_floor = extract_int(&buf[4], 4);
821 output_headers(1, 1, 1, 0, 0, 0, 0);
823 /* print the tabbed dialog */
824 wprintf("<br /><TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
826 "<TD> </TD>\n");
828 if (!strcmp(tab, "admin")) {
829 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
832 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
834 wprintf("Administration");
835 if (!strcmp(tab, "admin")) {
836 wprintf("</SPAN></TD>\n");
839 wprintf("</A></TD>\n");
842 wprintf("<TD> </TD>\n");
844 if (!strcmp(tab, "config")) {
845 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
848 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
850 wprintf("Configuration");
851 if (!strcmp(tab, "config")) {
852 wprintf("</SPAN></TD>\n");
855 wprintf("</A></TD>\n");
858 wprintf("<TD> </TD>\n");
860 if (!strcmp(tab, "expire")) {
861 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
864 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
866 wprintf("Message expire policy");
867 if (!strcmp(tab, "expire")) {
868 wprintf("</SPAN></TD>\n");
871 wprintf("</A></TD>\n");
874 wprintf("<TD> </TD>\n");
876 if (!strcmp(tab, "sharing")) {
877 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
880 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
883 if (!strcmp(tab, "sharing")) {
884 wprintf("</SPAN></TD>\n");
887 wprintf("</A></TD>\n");
890 wprintf("<TD> </TD>\n");
892 if (!strcmp(tab, "listserv")) {
893 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
896 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
898 wprintf("Mailing list service");
899 if (!strcmp(tab, "listserv")) {
900 wprintf("</SPAN></TD>\n");
903 wprintf("</A></TD>\n");
906 wprintf("<TD> </TD>\n");
908 wprintf("</TR></TABLE>\n");
909 /* end tabbed dialog */
911 /* begin content of whatever tab is open now */
912 wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
915 if (!strcmp(tab, "admin")) {
917 "<LI><A HREF=\"/confirm_delete_room\">\n"
918 "Delete this room</A>\n"
919 "<LI><A HREF=\"/display_editroompic\">\n"
920 "Set or change the graphic for this room's banner</A>\n"
921 "<LI><A HREF=\"/display_editinfo\">\n"
922 "Edit this room's Info file</A>\n"
926 if (!strcmp(tab, "config")) {
927 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
929 wprintf("<UL><LI>Name of room: ");
930 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
932 wprintf("<LI>Resides on floor: ");
933 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
934 for (i = 0; i < 128; ++i)
935 if (strlen(floorlist[i]) > 0) {
938 wprintf("SELECTED ");
939 wprintf("VALUE=\"%d\">", i);
940 escputs(floorlist[i]);
941 wprintf("</OPTION>\n");
943 wprintf("</SELECT>\n");
945 wprintf("<LI>Type of room:<UL>\n");
947 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
948 if ((er_flags & QR_PRIVATE) == 0)
950 wprintf("> Public room\n");
952 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
953 if ((er_flags & QR_PRIVATE) &&
954 (er_flags & QR_GUESSNAME))
956 wprintf("> Private - guess name\n");
958 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
959 if ((er_flags & QR_PRIVATE) &&
960 (er_flags & QR_PASSWORDED))
962 wprintf("> Private - require password:\n");
963 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
965 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
966 if ((er_flags & QR_PRIVATE)
967 && ((er_flags & QR_GUESSNAME) == 0)
968 && ((er_flags & QR_PASSWORDED) == 0))
970 wprintf("> Private - invitation only\n");
972 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
973 wprintf("> If private, cause current users to forget room\n");
977 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
978 if (er_flags & QR_PREFONLY)
980 wprintf("> Preferred users only\n");
982 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
983 if (er_flags & QR_READONLY)
985 wprintf("> Read-only room\n");
987 /* directory stuff */
988 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
989 if (er_flags & QR_DIRECTORY)
991 wprintf("> File directory room\n");
993 wprintf("<UL><LI>Directory name: ");
994 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
996 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
997 if (er_flags & QR_UPLOAD)
999 wprintf("> Uploading allowed\n");
1001 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1002 if (er_flags & QR_DOWNLOAD)
1003 wprintf("CHECKED ");
1004 wprintf("> Downloading allowed\n");
1006 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1007 if (er_flags & QR_VISDIR)
1008 wprintf("CHECKED ");
1009 wprintf("> Visible directory</UL>\n");
1011 /* end of directory stuff */
1013 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1014 if (er_flags & QR_NETWORK)
1015 wprintf("CHECKED ");
1016 wprintf("> Network shared room\n");
1018 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1019 if (er_flags & QR_PERMANENT)
1020 wprintf("CHECKED ");
1021 wprintf("> Permanent (does not auto-purge)\n");
1023 /* start of anon options */
1025 wprintf("<LI>Anonymous messages<UL>\n");
1027 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1028 if (((er_flags & QR_ANONONLY) == 0)
1029 && ((er_flags & QR_ANONOPT) == 0))
1030 wprintf("CHECKED ");
1031 wprintf("> No anonymous messages\n");
1033 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1034 if (er_flags & QR_ANONONLY)
1035 wprintf("CHECKED ");
1036 wprintf("> All messages are anonymous\n");
1038 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1039 if (er_flags & QR_ANONOPT)
1040 wprintf("CHECKED ");
1041 wprintf("> Prompt user when entering messages</UL>\n");
1043 /* end of anon options */
1045 wprintf("<LI>Room aide: \n");
1048 if (buf[0] != '2') {
1049 wprintf("<EM>%s</EM>\n", &buf[4]);
1051 extract(er_roomaide, &buf[4], 0);
1052 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1055 wprintf("</UL><CENTER>\n");
1056 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1057 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1059 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
1065 /* Sharing the room with other Citadel nodes... */
1066 if (!strcmp(tab, "sharing")) {
1068 shared_with = strdup("");
1069 not_shared_with = strdup("");
1071 /* Learn the current configuration */
1072 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1074 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1075 extract(node, buf, 0);
1076 not_shared_with = realloc(not_shared_with,
1077 strlen(not_shared_with) + 32);
1078 strcat(not_shared_with, node);
1079 strcat(not_shared_with, "\n");
1084 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1085 extract(cmd, buf, 0);
1086 extract(node, buf, 1);
1087 extract(remote_room, buf, 2);
1088 if (!strcasecmp(cmd, "ignet_push_share")) {
1089 shared_with = realloc(shared_with,
1090 strlen(shared_with) + 32);
1091 strcat(shared_with, node);
1092 if (strlen(remote_room) > 0) {
1093 strcat(shared_with, "|");
1094 strcat(shared_with, remote_room);
1096 strcat(shared_with, "\n");
1100 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1101 extract_token(buf, shared_with, i, '\n');
1102 extract_token(node, buf, 0, '|');
1103 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1104 extract_token(cmd, not_shared_with, j, '\n');
1105 if (!strcasecmp(node, cmd)) {
1106 remove_token(not_shared_with, j, '\n');
1111 /* Display the stuff */
1112 wprintf("<CENTER><br />"
1113 "<TABLE border=1 cellpadding=5><TR>"
1114 "<TD><B><I>Shared with</I></B></TD>"
1115 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1116 "<TR><TD VALIGN=TOP>\n");
1118 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1119 "<TD>Remote node name</TD>"
1120 "<TD>Remote room name</TD>"
1125 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1126 extract_token(buf, shared_with, i, '\n');
1127 extract_token(node, buf, 0, '|');
1128 extract_token(remote_room, buf, 1, '|');
1129 if (strlen(node) > 0) {
1130 wprintf("<FORM METHOD=\"POST\" "
1131 "ACTION=\"/netedit\">"
1132 "<TR><TD>%s</TD>\n", node);
1135 if (strlen(remote_room) > 0) {
1136 escputs(remote_room);
1142 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1143 "VALUE=\"ignet_push_share|");
1145 if (strlen(remote_room) > 0) {
1147 urlescputs(remote_room);
1150 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1151 "VALUE=\"sharing\">\n");
1152 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1153 "VALUE=\"remove\">\n");
1154 wprintf("<INPUT TYPE=\"submit\" "
1155 "NAME=\"sc\" VALUE=\"Unshare\">");
1156 wprintf("</TD></TR></FORM>\n");
1160 wprintf("</TABLE>\n");
1161 wprintf("</TD><TD VALIGN=TOP>\n");
1162 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1163 "<TD>Remote node name</TD>"
1164 "<TD>Remote room name</TD>"
1169 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1170 extract_token(node, not_shared_with, i, '\n');
1171 if (strlen(node) > 0) {
1172 wprintf("<FORM METHOD=\"POST\" "
1173 "ACTION=\"/netedit\">"
1177 "<INPUT TYPE=\"INPUT\" "
1181 wprintf("<INPUT TYPE=\"hidden\" "
1183 "VALUE=\"ignet_push_share|");
1186 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1187 "VALUE=\"sharing\">\n");
1188 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1189 "VALUE=\"add\">\n");
1190 wprintf("<INPUT TYPE=\"submit\" "
1191 "NAME=\"sc\" VALUE=\"Share\">");
1192 wprintf("</TD></TR></FORM>\n");
1196 wprintf("</TABLE>\n");
1197 wprintf("</TD></TR>"
1198 "</TABLE></CENTER><br />\n"
1199 "<I><B>Notes:</B><UL><LI>When sharing a room, "
1200 "it must be shared from both ends. Adding a node to "
1201 "the 'shared' list sends messages out, but in order to"
1202 " receive messages, the other nodes must be configured"
1203 " to send messages out to your system as well.\n"
1204 "<LI>If the remote room name is blank, it is assumed "
1205 "that the room name is identical on the remote node."
1206 "<LI>If the remote room name is different, the remote "
1207 "node must also configure the name of the room here."
1213 /* Mailing list management */
1214 if (!strcmp(tab, "listserv")) {
1216 wprintf("<br /><center>"
1217 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1218 "<TR><TD VALIGN=TOP>");
1220 wprintf("<i>The contents of this room are being "
1221 "mailed <b>as individual messages</b> "
1222 "to the following list recipients:"
1223 "</i><br /><br />\n");
1227 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1228 extract(cmd, buf, 0);
1229 if (!strcasecmp(cmd, "listrecp")) {
1230 extract(recp, buf, 1);
1233 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1236 wprintf("&tab=listserv\">(remove)</A><br />");
1240 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1241 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1242 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1243 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1244 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1245 wprintf("</FORM>\n");
1247 wprintf("</TD><TD VALIGN=TOP>\n");
1249 wprintf("<i>The contents of this room are being "
1250 "mailed <b>in digest form</b> "
1251 "to the following list recipients:"
1252 "</i><br /><br />\n");
1256 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1257 extract(cmd, buf, 0);
1258 if (!strcasecmp(cmd, "digestrecp")) {
1259 extract(recp, buf, 1);
1262 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1265 wprintf("&tab=listserv\">(remove)</A><br />");
1269 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1270 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1271 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1272 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1273 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1274 wprintf("</FORM>\n");
1276 wprintf("</TD></TR></TABLE><hr />\n");
1278 if (self_service(999) == 1) {
1279 wprintf("This room is configured to allow "
1280 "self-service subscribe/unsubscribe requests."
1281 " <A HREF=\"/toggle_self_service?newval=0&"
1283 "Click to disable.</A><br />\n"
1284 "The URL for subscribe/unsubscribe is: "
1285 "<TT>http://%s/listsub</TT><br />\n",
1290 wprintf("This room is <i>not</i> configured to allow "
1291 "self-service subscribe/unsubscribe requests."
1292 " <A HREF=\"/toggle_self_service?newval=1&"
1294 "Click to enable.</A><br />\n"
1299 wprintf("</CENTER>\n");
1303 /* Mailing list management */
1304 if (!strcmp(tab, "expire")) {
1306 serv_puts("GPEX room");
1308 if (buf[0] == '2') {
1309 roompolicy = extract_int(&buf[4], 0);
1310 roomvalue = extract_int(&buf[4], 1);
1313 serv_puts("GPEX floor");
1315 if (buf[0] == '2') {
1316 floorpolicy = extract_int(&buf[4], 0);
1317 floorvalue = extract_int(&buf[4], 1);
1320 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1321 wprintf("<TABLE border=0 cellspacing=5>\n");
1322 wprintf("<TR><TD>Message expire policy for this room<br />(");
1323 escputs(WC->wc_roomname);
1324 wprintf(")</TD><TD>");
1325 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1326 ((roompolicy == 0) ? "CHECKED" : "") );
1327 wprintf("Use the default policy for this floor<br />\n");
1328 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1329 ((roompolicy == 1) ? "CHECKED" : "") );
1330 wprintf("Never automatically expire messages<br />\n");
1331 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1332 ((roompolicy == 2) ? "CHECKED" : "") );
1333 wprintf("Expire by message count<br />\n");
1334 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1335 ((roompolicy == 3) ? "CHECKED" : "") );
1336 wprintf("Expire by message age<br />");
1337 wprintf("Number of messages or days: ");
1338 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1339 wprintf("</TD></TR>\n");
1341 if (WC->axlevel >= 6) {
1342 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1343 wprintf("<TR><TD>Message expire policy for this floor<br />(");
1344 escputs(floorlist[WC->wc_floor]);
1345 wprintf(")</TD><TD>");
1346 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1347 ((floorpolicy == 0) ? "CHECKED" : "") );
1348 wprintf("Use the system default<br />\n");
1349 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1350 ((floorpolicy == 1) ? "CHECKED" : "") );
1351 wprintf("Never automatically expire messages<br />\n");
1352 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1353 ((floorpolicy == 2) ? "CHECKED" : "") );
1354 wprintf("Expire by message count<br />\n");
1355 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1356 ((floorpolicy == 3) ? "CHECKED" : "") );
1357 wprintf("Expire by message age<br />");
1358 wprintf("Number of messages or days: ");
1359 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1363 wprintf("<CENTER>\n");
1364 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1365 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1367 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1368 wprintf("</CENTER></TD><TR>\n");
1370 wprintf("</TABLE>\n"
1371 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1378 /* end content of whatever tab is open now */
1379 wprintf("</TD></TR></TABLE>\n");
1386 * Toggle self-service list subscription
1388 void toggle_self_service(void) {
1391 newval = atoi(bstr("newval"));
1392 self_service(newval);
1399 * save new parameters for a room
1405 char er_password[10];
1406 char er_dirname[15];
1407 char er_roomaide[26];
1413 if (strcmp(bstr("sc"), "OK")) {
1414 strcpy(WC->ImportantMessage,
1415 "Cancelled. Changes were not saved.");
1422 if (buf[0] != '2') {
1423 strcpy(WC->ImportantMessage, &buf[4]);
1427 extract(er_name, &buf[4], 0);
1428 extract(er_password, &buf[4], 1);
1429 extract(er_dirname, &buf[4], 2);
1430 er_flags = extract_int(&buf[4], 3);
1432 strcpy(er_roomaide, bstr("er_roomaide"));
1433 if (strlen(er_roomaide) == 0) {
1436 if (buf[0] != '2') {
1437 strcpy(er_roomaide, "");
1439 extract(er_roomaide, &buf[4], 0);
1442 strcpy(buf, bstr("er_name"));
1444 if (strlen(buf) > 0)
1445 strcpy(er_name, buf);
1447 strcpy(buf, bstr("er_password"));
1449 if (strlen(buf) > 0)
1450 strcpy(er_password, buf);
1452 strcpy(buf, bstr("er_dirname"));
1454 if (strlen(buf) > 0)
1455 strcpy(er_dirname, buf);
1457 strcpy(buf, bstr("type"));
1458 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1460 if (!strcmp(buf, "invonly")) {
1461 er_flags |= (QR_PRIVATE);
1463 if (!strcmp(buf, "guessname")) {
1464 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1466 if (!strcmp(buf, "passworded")) {
1467 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1469 if (!strcmp(bstr("prefonly"), "yes")) {
1470 er_flags |= QR_PREFONLY;
1472 er_flags &= ~QR_PREFONLY;
1475 if (!strcmp(bstr("readonly"), "yes")) {
1476 er_flags |= QR_READONLY;
1478 er_flags &= ~QR_READONLY;
1481 if (!strcmp(bstr("permanent"), "yes")) {
1482 er_flags |= QR_PERMANENT;
1484 er_flags &= ~QR_PERMANENT;
1487 if (!strcmp(bstr("network"), "yes")) {
1488 er_flags |= QR_NETWORK;
1490 er_flags &= ~QR_NETWORK;
1493 if (!strcmp(bstr("directory"), "yes")) {
1494 er_flags |= QR_DIRECTORY;
1496 er_flags &= ~QR_DIRECTORY;
1499 if (!strcmp(bstr("ulallowed"), "yes")) {
1500 er_flags |= QR_UPLOAD;
1502 er_flags &= ~QR_UPLOAD;
1505 if (!strcmp(bstr("dlallowed"), "yes")) {
1506 er_flags |= QR_DOWNLOAD;
1508 er_flags &= ~QR_DOWNLOAD;
1511 if (!strcmp(bstr("visdir"), "yes")) {
1512 er_flags |= QR_VISDIR;
1514 er_flags &= ~QR_VISDIR;
1517 strcpy(buf, bstr("anon"));
1519 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1520 if (!strcmp(buf, "anononly"))
1521 er_flags |= QR_ANONONLY;
1522 if (!strcmp(buf, "anon2"))
1523 er_flags |= QR_ANONOPT;
1526 if (!strcmp(bstr("bump"), "yes"))
1529 er_floor = atoi(bstr("er_floor"));
1531 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1532 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1535 if (buf[0] != '2') {
1536 strcpy(WC->ImportantMessage, &buf[4]);
1542 if (strlen(er_roomaide) > 0) {
1543 sprintf(buf, "SETA %s", er_roomaide);
1546 if (buf[0] != '2') {
1547 strcpy(WC->ImportantMessage, &buf[4]);
1548 display_main_menu();
1553 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1559 * Invite, Kick, and show Who Knows a room
1561 void display_whok(void)
1563 char buf[SIZ], room[SIZ], username[SIZ];
1568 if (buf[0] != '2') {
1569 strcpy(WC->ImportantMessage, &buf[4]);
1570 display_main_menu();
1573 extract(room, &buf[4], 0);
1575 strcpy(username, bstr("username"));
1577 if(!strcmp(bstr("sc"), "Kick")) {
1578 sprintf(buf, "KICK %s", username);
1582 if (buf[0] != '2') {
1583 strcpy(WC->ImportantMessage, &buf[4]);
1585 sprintf(WC->ImportantMessage,
1586 "<B><I>User %s kicked out of room %s.</I></B>\n",
1589 } else if(!strcmp(bstr("sc"), "Invite")) {
1590 sprintf(buf, "INVT %s", username);
1594 if (buf[0] != '2') {
1595 strcpy(WC->ImportantMessage, &buf[4]);
1597 sprintf(WC->ImportantMessage,
1598 "<B><I>User %s invited to room %s.</I></B>\n",
1603 output_headers(1, 1, 1, 0, 0, 0, 0);
1604 stresc(buf, WC->wc_roomname, 1, 1);
1605 svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
1606 do_template("beginbox");
1608 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1609 "<TD>The users listed below have access to this room. "
1610 "To remove a user from the access list, select the user "
1611 "name from the list and click 'Kick'.<br /><br />");
1613 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1614 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1617 if (buf[0] == '1') {
1618 while (serv_gets(buf), strcmp(buf, "000")) {
1619 extract(username, buf, 0);
1620 wprintf("<OPTION>");
1625 wprintf("</SELECT><br />\n");
1627 wprintf("<input type=submit name=sc value=\"Kick\">");
1628 wprintf("</FORM></CENTER>\n");
1631 "To grant another user access to this room, enter the "
1632 "user name in the box below and click 'Invite'.<br /><br />");
1634 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1635 wprintf("Invite: ");
1636 wprintf("<input type=text name=username><br />\n"
1637 "<input type=hidden name=sc value=\"Invite\">"
1638 "<input type=submit value=\"Invite\">"
1639 "</FORM></CENTER>\n");
1641 wprintf("</TD></TR></TABLE>\n");
1642 do_template("endbox");
1649 * display the form for entering a new room
1651 void display_entroom(void)
1656 serv_puts("CRE8 0");
1659 if (buf[0] != '2') {
1660 strcpy(WC->ImportantMessage, &buf[4]);
1661 display_main_menu();
1664 output_headers(1, 1, 0, 0, 0, 0, 0);
1665 svprintf("BOXTITLE", WCS_STRING, "Create a new room");
1666 do_template("beginbox");
1668 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1670 wprintf("<UL><LI>Name of room: ");
1671 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1673 wprintf("<LI>Resides on floor: ");
1675 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1676 for (i = 0; i < 128; ++i)
1677 if (strlen(floorlist[i]) > 0) {
1678 wprintf("<OPTION ");
1679 wprintf("VALUE=\"%d\">", i);
1680 escputs(floorlist[i]);
1681 wprintf("</OPTION>\n");
1683 wprintf("</SELECT>\n");
1685 wprintf("<LI>Type of room:<UL>\n");
1687 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1688 wprintf("CHECKED > Public room\n");
1690 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1691 wprintf("> Private - guess name\n");
1693 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1694 wprintf("> Private - require password:\n");
1695 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1697 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1698 wprintf("> Private - invitation only\n");
1700 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1701 wprintf("> Personal (mailbox for you only)\n");
1704 wprintf("<LI>Default view for room: "); /* FOO */
1705 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1706 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1707 wprintf("<OPTION %s VALUE=\"%d\">",
1708 ((i == 0) ? "SELECTED" : ""), i );
1709 escputs(viewdefs[i]);
1710 wprintf("</OPTION>\n");
1712 wprintf("</SELECT>\n");
1714 wprintf("<CENTER>\n");
1715 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1717 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1718 wprintf("</CENTER>\n");
1719 wprintf("</FORM>\n<hr />");
1720 serv_printf("MESG roomaccess");
1722 if (buf[0] == '1') {
1723 fmout(NULL, "CENTER");
1725 do_template("endbox");
1733 * support function for entroom() -- sets the default view
1735 void er_set_default_view(int newview) {
1749 if (buf[0] != '2') return;
1751 extract(rm_name, &buf[4], 0);
1752 extract(rm_pass, &buf[4], 1);
1753 extract(rm_dir, &buf[4], 2);
1754 rm_bits1 = extract_int(&buf[4], 3);
1755 rm_floor = extract_int(&buf[4], 4);
1756 rm_listorder = extract_int(&buf[4], 5);
1757 rm_bits2 = extract_int(&buf[4], 7);
1759 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1760 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1761 rm_listorder, newview, rm_bits2
1776 char er_password[SIZ];
1781 if (strcmp(bstr("sc"), "OK")) {
1782 strcpy(WC->ImportantMessage,
1783 "Cancelled. No new room was created.");
1784 display_main_menu();
1787 strcpy(er_name, bstr("er_name"));
1788 strcpy(er_type, bstr("type"));
1789 strcpy(er_password, bstr("er_password"));
1790 er_floor = atoi(bstr("er_floor"));
1791 er_view = atoi(bstr("er_view"));
1794 if (!strcmp(er_type, "guessname"))
1796 if (!strcmp(er_type, "passworded"))
1798 if (!strcmp(er_type, "invonly"))
1800 if (!strcmp(er_type, "personal"))
1803 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1804 er_name, er_num_type, er_password, er_floor, 0, er_view);
1807 if (buf[0] != '2') {
1808 strcpy(WC->ImportantMessage, &buf[4]);
1809 display_main_menu();
1813 do_change_view(er_view); /* Now go there */
1818 * display the screen to enter a private room
1820 void display_private(char *rname, int req_pass)
1823 output_headers(1, 1, 0, 0, 0, 0, 0);
1825 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1826 do_template("beginbox");
1828 wprintf("<CENTER>\n");
1829 wprintf("<br />If you know the name of a hidden (guess-name) or\n");
1830 wprintf("passworded room, you can enter that room by typing\n");
1831 wprintf("its name below. Once you gain access to a private\n");
1832 wprintf("room, it will appear in your regular room listings\n");
1833 wprintf("so you don't have to keep returning here.\n");
1834 wprintf("<br /><br />");
1836 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1838 wprintf("<table border=\"0\" cellspacing=\"5\" "
1839 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1841 "Enter room name:</TD><TD>"
1842 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1843 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1846 wprintf("</TD></TR><TR><TD>");
1847 wprintf("Enter room password:</TD><TD>");
1848 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1850 wprintf("</TD></TR></TABLE><br />\n");
1852 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1854 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1855 wprintf("</FORM>\n");
1856 do_template("endbox");
1861 * goto a private room
1863 void goto_private(void)
1868 if (strcasecmp(bstr("sc"), "OK")) {
1869 display_main_menu();
1872 strcpy(hold_rm, WC->wc_roomname);
1873 strcpy(buf, "GOTO ");
1874 strcat(buf, bstr("gr_name"));
1876 strcat(buf, bstr("gr_pass"));
1880 if (buf[0] == '2') {
1881 smart_goto(bstr("gr_name"));
1884 if (!strncmp(buf, "540", 3)) {
1885 display_private(bstr("gr_name"), 1);
1888 output_headers(1, 1, 1, 0, 0, 0, 0);
1889 wprintf("%s\n", &buf[4]);
1896 * display the screen to zap a room
1898 void display_zap(void)
1900 output_headers(1, 1, 2, 0, 0, 0, 0);
1902 wprintf("<div id=\"banner\">\n");
1903 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1904 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget/unsubscribe) the current room</SPAN>\n");
1905 wprintf("</TD></TR></TABLE>\n");
1906 wprintf("</div>\n<div id=\"content\">\n");
1908 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1909 wprintf("disappear from your room list. Is this what you wish ");
1910 wprintf("to do?<br />\n");
1912 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1913 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1915 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1916 wprintf("</FORM>\n");
1927 char final_destination[SIZ];
1929 /* If the forget-room routine fails for any reason, we fall back
1930 * to the current room; otherwise, we go to the Lobby
1932 strcpy(final_destination, WC->wc_roomname);
1934 if (!strcasecmp(bstr("sc"), "OK")) {
1935 serv_printf("GOTO %s", WC->wc_roomname);
1937 if (buf[0] == '2') {
1940 if (buf[0] == '2') {
1941 strcpy(final_destination, "_BASEROOM_");
1945 smart_goto(final_destination);
1952 * Confirm deletion of the current room
1954 void confirm_delete_room(void)
1958 serv_puts("KILL 0");
1960 if (buf[0] != '2') {
1961 strcpy(WC->ImportantMessage, &buf[4]);
1962 display_main_menu();
1965 output_headers(1, 1, 2, 0, 0, 0, 0);
1966 wprintf("<div id=\"banner\">\n");
1967 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1968 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1969 wprintf("</TD></TR></TABLE>\n");
1970 wprintf("</div>\n<div id=\"content\">\n");
1972 wprintf("<CENTER>");
1973 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1975 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1976 escputs(WC->wc_roomname);
1977 wprintf("</FONT>?<br />\n");
1979 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1980 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1982 wprintf("</FORM></CENTER>\n");
1988 * Delete the current room
1990 void delete_room(void)
1995 strcpy(sc, bstr("sc"));
1997 if (strcasecmp(sc, "Delete")) {
1998 strcpy(WC->ImportantMessage,
1999 "Cancelled. This room was not deleted.");
2000 display_main_menu();
2003 serv_puts("KILL 1");
2005 if (buf[0] != '2') {
2006 strcpy(WC->ImportantMessage, &buf[4]);
2007 display_main_menu();
2010 smart_goto("_BASEROOM_");
2017 * Perform changes to a room's network configuration
2019 void netedit(void) {
2028 if (strlen(bstr("line"))==0) {
2033 strcpy(line, bstr("prefix"));
2034 strcat(line, bstr("line"));
2035 strcat(line, bstr("suffix"));
2045 if (buf[0] != '1') {
2051 /* This loop works for add *or* remove. Spiffy, eh? */
2052 while (serv_gets(buf), strcmp(buf, "000")) {
2053 extract(cmpa0, buf, 0);
2054 extract(cmpa1, buf, 1);
2055 extract(cmpb0, line, 0);
2056 extract(cmpb1, line, 1);
2057 if ( (strcasecmp(cmpa0, cmpb0))
2058 || (strcasecmp(cmpa1, cmpb1)) ) {
2059 fprintf(fp, "%s\n", buf);
2066 if (buf[0] != '4') {
2072 while (fgets(buf, sizeof buf, fp) != NULL) {
2073 buf[strlen(buf)-1] = 0;
2077 if (!strcasecmp(bstr("cmd"), "add")) {
2089 * Convert a room name to a folder-ish-looking name.
2091 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2096 * For mailboxes, just do it straight...
2099 sprintf(folder, "My folders|%s", room);
2103 * Otherwise, prefix the floor name as a "public folders" moniker
2106 sprintf(folder, "%s|%s", floorlist[floor], room);
2110 * Replace "\" characters with "|" for pseudo-folder-delimiting
2112 for (i=0; i<strlen(folder); ++i) {
2113 if (folder[i] == '\\') folder[i] = '|';
2121 * Back end for change_view()
2123 void do_change_view(int newview) {
2126 serv_printf("VIEW %d", newview);
2128 WC->wc_view = newview;
2129 smart_goto(WC->wc_roomname);
2135 * Change the view for this room
2137 void change_view(void) {
2140 view = atol(bstr("view"));
2141 do_change_view(view);
2146 * One big expanded tree list view --- like a folder list
2148 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2150 int levels, oldlevels;
2153 int has_subfolders = 0;
2155 /* Include the menu expanding/collapsing code */
2156 wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
2158 /* BEGIN TREE MENU */
2159 wprintf("<div id=\"mainMenu\">\n");
2160 wprintf("<UL id=\"menuList\">\n");
2164 for (i=0; i<max_folders; ++i) {
2167 if ((i+1) < max_folders) {
2168 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2169 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2174 levels = num_tokens(fold[i].name, '|');
2176 if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
2177 for (t=0; t<(oldlevels-levels); ++t) {
2182 if (has_subfolders) {
2184 if (levels == 1) wprintf(" class=\"menubar\"");
2186 wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
2192 if (fold[i].selectable) {
2193 wprintf("<A HREF=\"/dotgoto?room=");
2194 urlescputs(fold[i].room);
2199 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2201 else if (fold[i].hasnewmsgs) {
2202 wprintf("<SPAN CLASS=\"roomlist_new\">");
2205 wprintf("<SPAN CLASS=\"roomlist_old\">");
2207 extract(buf, fold[i].name, levels-1);
2211 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2212 wprintf(" (INBOX)");
2215 if (fold[i].selectable) {
2220 if (has_subfolders) {
2221 wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
2223 ( (levels == 1) ? "menu" : "submenu")
2229 wprintf("</UL></UL>\n");
2230 wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
2231 for (i=0; i<actnum; ++i) {
2232 wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
2235 wprintf("</DIV>\n");
2240 * Boxes and rooms and lists ... oh my!
2242 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2245 int levels, oldlevels;
2248 static int columns = 3;
2249 int boxes_per_column = 0;
2250 int current_column = 0;
2254 while (nf % columns != 0) ++nf;
2255 boxes_per_column = (nf / columns);
2256 if (boxes_per_column < 1) boxes_per_column = 1;
2258 /* Outer table (for columnization) */
2259 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2260 "<tr><td valign=top>");
2264 for (i=0; i<max_folders; ++i) {
2266 levels = num_tokens(fold[i].name, '|');
2268 if ((levels == 1) && (oldlevels > 1)) {
2271 do_template("endbox");
2274 if ((num_boxes % boxes_per_column) == 0) {
2276 if (current_column < columns) {
2277 wprintf("</td><td valign=top>\n");
2284 /* Begin inner box */
2285 extract(buf, fold[i].name, levels-1);
2286 stresc(boxtitle, buf, 1, 0);
2287 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2288 do_template("beginbox");
2296 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2297 if (fold[i].selectable) {
2298 wprintf("<A HREF=\"/dotgoto?room=");
2299 urlescputs(fold[i].room);
2305 if (fold[i].hasnewmsgs) {
2306 wprintf("<SPAN CLASS=\"roomlist_new\">");
2309 wprintf("<SPAN CLASS=\"roomlist_old\">");
2311 extract(buf, fold[i].name, levels-1);
2314 if (fold[i].selectable) {
2320 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2321 wprintf(" (INBOX)");
2323 wprintf("<br />\n");
2326 /* End the final inner box */
2327 do_template("endbox");
2329 wprintf("</TD></TR></TABLE>\n");
2334 * Show the room list. (only should get called by
2335 * knrooms() because that's where output_headers() is called from)
2338 void list_all_rooms_by_floor(char *viewpref) {
2341 struct folder *fold = NULL;
2343 int max_folders = 0;
2344 int alloc_folders = 0;
2348 int num_floors = 1; /* add an extra one for private folders */
2350 /* Start with the mailboxes */
2353 fold = malloc(sizeof(struct folder));
2354 memset(fold, 0, sizeof(struct folder));
2355 strcpy(fold[0].name, "My folders");
2356 fold[0].is_mailbox = 1;
2358 /* Then add floors */
2361 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2362 if (max_folders >= alloc_folders) {
2363 alloc_folders = max_folders + 100;
2364 fold = realloc(fold,
2365 alloc_folders * sizeof(struct folder));
2367 memset(&fold[max_folders], 0, sizeof(struct folder));
2368 extract(fold[max_folders].name, buf, 1);
2376 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2377 if (max_folders >= alloc_folders) {
2378 alloc_folders = max_folders + 100;
2379 fold = realloc(fold,
2380 alloc_folders * sizeof(struct folder));
2382 memset(&fold[max_folders], 0, sizeof(struct folder));
2383 extract(fold[max_folders].room, buf, 0);
2384 ra_flags = extract_int(buf, 5);
2385 flags = extract_int(buf, 1);
2386 fold[max_folders].floor = extract_int(buf, 2);
2387 fold[max_folders].hasnewmsgs =
2388 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2389 if (flags & QR_MAILBOX) {
2390 fold[max_folders].is_mailbox = 1;
2392 room_to_folder(fold[max_folders].name,
2393 fold[max_folders].room,
2394 fold[max_folders].floor,
2395 fold[max_folders].is_mailbox);
2396 fold[max_folders].selectable = 1;
2400 /* Bubble-sort the folder list */
2401 for (i=0; i<max_folders; ++i) {
2402 for (j=0; j<(max_folders-1)-i; ++j) {
2403 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2404 swap = strcasecmp(fold[j].name, fold[j+1].name);
2407 if ( (fold[j+1].is_mailbox)
2408 && (!fold[j].is_mailbox)) {
2416 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2417 memcpy(&fold[j], &fold[j+1],
2418 sizeof(struct folder));
2419 memcpy(&fold[j+1], &ftmp,
2420 sizeof(struct folder));
2425 /* test only hackish view
2426 wprintf("<table><TR><TD>A Table</TD></TR></table>\n");
2427 for (i=0; i<max_folders; ++i) {
2428 escputs(fold[i].name);
2429 wprintf("<br />\n");
2433 if (!strcasecmp(viewpref, "folders")) {
2434 do_folder_view(fold, max_folders, num_floors);
2437 do_rooms_view(fold, max_folders, num_floors);
2445 /* Do either a known rooms list or a folders list, depending on the
2449 char listviewpref[SIZ];
2451 output_headers(1, 1, 2, 0, 0, 0, 0);
2454 /* Determine whether the user is trying to change views */
2455 if (bstr("view") != NULL) {
2456 if (strlen(bstr("view")) > 0) {
2457 set_preference("roomlistview", bstr("view"));
2461 get_preference("roomlistview", listviewpref);
2463 if ( (strcasecmp(listviewpref, "folders"))
2464 && (strcasecmp(listviewpref, "table")) ) {
2465 strcpy(listviewpref, "rooms");
2469 wprintf("<div id=\"banner\">\n"
2470 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2471 "<SPAN CLASS=\"titlebar\">"
2473 if (!strcasecmp(listviewpref, "rooms")) {
2474 wprintf("Room list");
2476 if (!strcasecmp(listviewpref, "folders")) {
2477 wprintf("Folder list");
2479 if (!strcasecmp(listviewpref, "table")) {
2480 wprintf("Room list");
2482 wprintf("</SPAN></TD>\n");
2484 /* offer the ability to switch views */
2485 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2486 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2487 "OnChange=\"location.href=roomlistomatic.newview.options"
2488 "[selectedIndex].value\">\n");
2490 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2493 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2496 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2497 "View as folder list"
2499 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2502 wprintf("</SELECT><br />");
2504 wprintf("</FORM></TD></TR></TABLE>\n");
2506 "<div id=\"content\">\n");
2508 /* Display the room list in the user's preferred format */
2509 list_all_rooms_by_floor(listviewpref);
2515 * Set the message expire policy for this room and/or floor
2517 void set_room_policy(void) {
2520 if (strcmp(bstr("sc"), "OK")) {
2521 strcpy(WC->ImportantMessage,
2522 "Cancelled. Changes were not saved.");
2527 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2529 strcpy(WC->ImportantMessage, &buf[4]);
2531 if (WC->axlevel >= 6) {
2532 strcat(WC->ImportantMessage, "<br />\n");
2533 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2535 strcat(WC->ImportantMessage, &buf[4]);