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\">"
459 if (navbar_style == navbar_default) {
462 "<A HREF=\"/display_enter\">"
463 "<img align=\"middle\" src=\"/static/enter.gif\" border=\"0\">"
464 "<span class=\"navbar_link\">"
466 switch(WC->wc_view) {
467 case VIEW_ADDRESSBOOK:
468 wprintf("Add new contact");
471 wprintf("Add new event");
474 wprintf("Add new task");
477 wprintf("Add new note");
480 wprintf("Enter a message");
483 wprintf("</span></a></td>\n");
486 if (navbar_style == navbar_default) wprintf(
489 "<span class=\"navbar_link\">Skip this room</span>"
490 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
494 if (navbar_style == navbar_default) wprintf(
496 "<A HREF=\"/gotonext\">"
497 "<span class=\"navbar_link\">Goto next room</span>"
498 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
502 wprintf("</tr></table></div>\n");
512 * back end routine to take the session to a new room
515 void gotoroom(char *gname)
518 static long ls = (-1L);
520 /* store ungoto information */
521 strcpy(WC->ugname, WC->wc_roomname);
524 /* move to the new room */
525 serv_printf("GOTO %s", gname);
528 serv_puts("GOTO _BASEROOM_");
534 extract(WC->wc_roomname, &buf[4], 0);
535 WC->room_flags = extract_int(&buf[4], 4);
536 /* highest_msg_read = extract_int(&buf[4],6);
537 maxmsgnum = extract_int(&buf[4],5);
538 is_mail = (char) extract_int(&buf[4],7); */
539 ls = extract_long(&buf[4], 6);
540 WC->wc_floor = extract_int(&buf[4], 10);
541 WC->wc_view = extract_int(&buf[4], 11);
542 WC->wc_default_view = extract_int(&buf[4], 12);
545 WC->is_room_aide = WC->is_aide;
547 WC->is_room_aide = (char) extract_int(&buf[4], 8);
549 remove_march(WC->wc_roomname);
550 if (!strcasecmp(gname, "_BASEROOM_"))
556 * Locate the room on the march list which we most want to go to. Each room
557 * is measured given a "weight" of preference based on various factors.
559 char *pop_march(int desired_floor)
561 static char TheRoom[128];
563 int TheOrder = 32767;
566 struct march *mptr = NULL;
568 strcpy(TheRoom, "_BASEROOM_");
569 if (WC->march == NULL)
572 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
574 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
575 weight = weight + 10000;
576 if (mptr->march_floor == desired_floor)
577 weight = weight + 5000;
579 weight = weight + ((128 - (mptr->march_floor)) * 128);
580 weight = weight + (128 - (mptr->march_order));
582 if (weight > TheWeight) {
584 strcpy(TheRoom, mptr->march_name);
585 TheFloor = mptr->march_floor;
586 TheOrder = mptr->march_order;
594 /* Goto next room having unread messages.
595 * We want to skip over rooms that the user has already been to, and take the
596 * user back to the lobby when done. The room we end up in is placed in
597 * newroom - which is set to 0 (the lobby) initially.
598 * We start the search in the current room rather than the beginning to prevent
599 * two or more concurrent users from dragging each other back to the same room.
604 struct march *mptr, *mptr2;
607 /* First check to see if the march-mode list is already allocated.
608 * If it is, pop the first room off the list and go there.
611 if (WC->march == NULL) {
615 while (serv_gets(buf), strcmp(buf, "000")) {
616 mptr = (struct march *) malloc(sizeof(struct march));
618 extract(mptr->march_name, buf, 0);
619 mptr->march_floor = extract_int(buf, 2);
620 mptr->march_order = extract_int(buf, 3);
621 if (WC->march == NULL) {
625 while (mptr2->next != NULL)
630 /* add _BASEROOM_ to the end of the march list, so the user will end up
631 * in the system base room (usually the Lobby>) at the end of the loop
633 mptr = (struct march *) malloc(sizeof(struct march));
635 strcpy(mptr->march_name, "_BASEROOM_");
636 if (WC->march == NULL) {
640 while (mptr2->next != NULL)
645 * ...and remove the room we're currently in, so a <G>oto doesn't make us
646 * walk around in circles
648 remove_march(WC->wc_roomname);
650 if (WC->march != NULL) {
651 strcpy(next_room, pop_march(-1));
653 strcpy(next_room, "_BASEROOM_");
657 smart_goto(next_room);
661 void smart_goto(char *next_room) {
669 * mark all messages in current room as having been read
671 void slrp_highest(void)
676 serv_puts("SLRP HIGHEST");
679 wprintf("<EM>%s</EM><br />\n", &buf[4]);
686 * un-goto the previous room
692 if (!strcmp(WC->ugname, "")) {
693 smart_goto(WC->wc_roomname);
696 serv_printf("GOTO %s", WC->ugname);
699 smart_goto(WC->wc_roomname);
702 if (WC->uglsn >= 0L) {
703 serv_printf("SLRP %ld", WC->uglsn);
706 strcpy(buf, WC->ugname);
707 strcpy(WC->ugname, "");
716 * Set/clear/read the "self-service list subscribe" flag for a room
718 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
719 * Always returns the new value.
722 int self_service(int newval) {
723 int current_value = 0;
729 int flags, floor, order, view, flags2;
733 if (buf[0] != '2') return(0);
735 extract(name, &buf[4], 0);
736 extract(password, &buf[4], 1);
737 extract(dirname, &buf[4], 2);
738 flags = extract_int(&buf[4], 3);
739 floor = extract_int(&buf[4], 4);
740 order = extract_int(&buf[4], 5);
741 view = extract_int(&buf[4], 6);
742 flags2 = extract_int(&buf[4], 7);
744 if (flags2 & QR2_SELFLIST) {
752 flags2 = flags2 | QR2_SELFLIST;
754 else if (newval == 0) {
755 flags2 = flags2 & ~QR2_SELFLIST;
758 return(current_value);
761 if (newval != current_value) {
762 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
763 name, password, dirname, flags,
764 floor, order, view, flags2);
778 * display the form for editing a room
780 void display_editroom(void)
785 char remote_room[SIZ];
788 char er_password[10];
790 char er_roomaide[26];
796 char *not_shared_with;
803 if (strlen(tab) == 0) tab = "admin";
810 strcpy(WC->ImportantMessage, &buf[4]);
814 extract(er_name, &buf[4], 0);
815 extract(er_password, &buf[4], 1);
816 extract(er_dirname, &buf[4], 2);
817 er_flags = extract_int(&buf[4], 3);
818 er_floor = extract_int(&buf[4], 4);
820 output_headers(1, 1, 1, 0, 0, 0, 0);
822 /* print the tabbed dialog */
823 wprintf("<br /><TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
825 "<TD> </TD>\n");
827 if (!strcmp(tab, "admin")) {
828 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
831 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
833 wprintf("Administration");
834 if (!strcmp(tab, "admin")) {
835 wprintf("</SPAN></TD>\n");
838 wprintf("</A></TD>\n");
841 wprintf("<TD> </TD>\n");
843 if (!strcmp(tab, "config")) {
844 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
847 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
849 wprintf("Configuration");
850 if (!strcmp(tab, "config")) {
851 wprintf("</SPAN></TD>\n");
854 wprintf("</A></TD>\n");
857 wprintf("<TD> </TD>\n");
859 if (!strcmp(tab, "expire")) {
860 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
863 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
865 wprintf("Message expire policy");
866 if (!strcmp(tab, "expire")) {
867 wprintf("</SPAN></TD>\n");
870 wprintf("</A></TD>\n");
873 wprintf("<TD> </TD>\n");
875 if (!strcmp(tab, "sharing")) {
876 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
879 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
882 if (!strcmp(tab, "sharing")) {
883 wprintf("</SPAN></TD>\n");
886 wprintf("</A></TD>\n");
889 wprintf("<TD> </TD>\n");
891 if (!strcmp(tab, "listserv")) {
892 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
895 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
897 wprintf("Mailing list service");
898 if (!strcmp(tab, "listserv")) {
899 wprintf("</SPAN></TD>\n");
902 wprintf("</A></TD>\n");
905 wprintf("<TD> </TD>\n");
907 wprintf("</TR></TABLE>\n");
908 /* end tabbed dialog */
910 /* begin content of whatever tab is open now */
911 wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
914 if (!strcmp(tab, "admin")) {
916 "<LI><A HREF=\"/confirm_delete_room\">\n"
917 "Delete this room</A>\n"
918 "<LI><A HREF=\"/display_editroompic\">\n"
919 "Set or change the graphic for this room's banner</A>\n"
920 "<LI><A HREF=\"/display_editinfo\">\n"
921 "Edit this room's Info file</A>\n"
925 if (!strcmp(tab, "config")) {
926 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
928 wprintf("<UL><LI>Name of room: ");
929 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
931 wprintf("<LI>Resides on floor: ");
932 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
933 for (i = 0; i < 128; ++i)
934 if (strlen(floorlist[i]) > 0) {
937 wprintf("SELECTED ");
938 wprintf("VALUE=\"%d\">", i);
939 escputs(floorlist[i]);
940 wprintf("</OPTION>\n");
942 wprintf("</SELECT>\n");
944 wprintf("<LI>Type of room:<UL>\n");
946 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
947 if ((er_flags & QR_PRIVATE) == 0)
949 wprintf("> Public room\n");
951 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
952 if ((er_flags & QR_PRIVATE) &&
953 (er_flags & QR_GUESSNAME))
955 wprintf("> Private - guess name\n");
957 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
958 if ((er_flags & QR_PRIVATE) &&
959 (er_flags & QR_PASSWORDED))
961 wprintf("> Private - require password:\n");
962 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
964 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
965 if ((er_flags & QR_PRIVATE)
966 && ((er_flags & QR_GUESSNAME) == 0)
967 && ((er_flags & QR_PASSWORDED) == 0))
969 wprintf("> Private - invitation only\n");
971 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
972 wprintf("> If private, cause current users to forget room\n");
976 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
977 if (er_flags & QR_PREFONLY)
979 wprintf("> Preferred users only\n");
981 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
982 if (er_flags & QR_READONLY)
984 wprintf("> Read-only room\n");
986 /* directory stuff */
987 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
988 if (er_flags & QR_DIRECTORY)
990 wprintf("> File directory room\n");
992 wprintf("<UL><LI>Directory name: ");
993 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
995 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
996 if (er_flags & QR_UPLOAD)
998 wprintf("> Uploading allowed\n");
1000 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1001 if (er_flags & QR_DOWNLOAD)
1002 wprintf("CHECKED ");
1003 wprintf("> Downloading allowed\n");
1005 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1006 if (er_flags & QR_VISDIR)
1007 wprintf("CHECKED ");
1008 wprintf("> Visible directory</UL>\n");
1010 /* end of directory stuff */
1012 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1013 if (er_flags & QR_NETWORK)
1014 wprintf("CHECKED ");
1015 wprintf("> Network shared room\n");
1017 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1018 if (er_flags & QR_PERMANENT)
1019 wprintf("CHECKED ");
1020 wprintf("> Permanent (does not auto-purge)\n");
1022 /* start of anon options */
1024 wprintf("<LI>Anonymous messages<UL>\n");
1026 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1027 if (((er_flags & QR_ANONONLY) == 0)
1028 && ((er_flags & QR_ANONOPT) == 0))
1029 wprintf("CHECKED ");
1030 wprintf("> No anonymous messages\n");
1032 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1033 if (er_flags & QR_ANONONLY)
1034 wprintf("CHECKED ");
1035 wprintf("> All messages are anonymous\n");
1037 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1038 if (er_flags & QR_ANONOPT)
1039 wprintf("CHECKED ");
1040 wprintf("> Prompt user when entering messages</UL>\n");
1042 /* end of anon options */
1044 wprintf("<LI>Room aide: \n");
1047 if (buf[0] != '2') {
1048 wprintf("<EM>%s</EM>\n", &buf[4]);
1050 extract(er_roomaide, &buf[4], 0);
1051 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1054 wprintf("</UL><CENTER>\n");
1055 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1056 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1058 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
1064 /* Sharing the room with other Citadel nodes... */
1065 if (!strcmp(tab, "sharing")) {
1067 shared_with = strdup("");
1068 not_shared_with = strdup("");
1070 /* Learn the current configuration */
1071 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1073 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1074 extract(node, buf, 0);
1075 not_shared_with = realloc(not_shared_with,
1076 strlen(not_shared_with) + 32);
1077 strcat(not_shared_with, node);
1078 strcat(not_shared_with, "\n");
1083 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1084 extract(cmd, buf, 0);
1085 extract(node, buf, 1);
1086 extract(remote_room, buf, 2);
1087 if (!strcasecmp(cmd, "ignet_push_share")) {
1088 shared_with = realloc(shared_with,
1089 strlen(shared_with) + 32);
1090 strcat(shared_with, node);
1091 if (strlen(remote_room) > 0) {
1092 strcat(shared_with, "|");
1093 strcat(shared_with, remote_room);
1095 strcat(shared_with, "\n");
1099 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1100 extract_token(buf, shared_with, i, '\n');
1101 extract_token(node, buf, 0, '|');
1102 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1103 extract_token(cmd, not_shared_with, j, '\n');
1104 if (!strcasecmp(node, cmd)) {
1105 remove_token(not_shared_with, j, '\n');
1110 /* Display the stuff */
1111 wprintf("<CENTER><br />"
1112 "<TABLE border=1 cellpadding=5><TR>"
1113 "<TD><B><I>Shared with</I></B></TD>"
1114 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1115 "<TR><TD VALIGN=TOP>\n");
1117 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1118 "<TD>Remote node name</TD>"
1119 "<TD>Remote room name</TD>"
1124 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1125 extract_token(buf, shared_with, i, '\n');
1126 extract_token(node, buf, 0, '|');
1127 extract_token(remote_room, buf, 1, '|');
1128 if (strlen(node) > 0) {
1129 wprintf("<FORM METHOD=\"POST\" "
1130 "ACTION=\"/netedit\">"
1131 "<TR><TD>%s</TD>\n", node);
1134 if (strlen(remote_room) > 0) {
1135 escputs(remote_room);
1141 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1142 "VALUE=\"ignet_push_share|");
1144 if (strlen(remote_room) > 0) {
1146 urlescputs(remote_room);
1149 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1150 "VALUE=\"sharing\">\n");
1151 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1152 "VALUE=\"remove\">\n");
1153 wprintf("<INPUT TYPE=\"submit\" "
1154 "NAME=\"sc\" VALUE=\"Unshare\">");
1155 wprintf("</TD></TR></FORM>\n");
1159 wprintf("</TABLE>\n");
1160 wprintf("</TD><TD VALIGN=TOP>\n");
1161 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1162 "<TD>Remote node name</TD>"
1163 "<TD>Remote room name</TD>"
1168 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1169 extract_token(node, not_shared_with, i, '\n');
1170 if (strlen(node) > 0) {
1171 wprintf("<FORM METHOD=\"POST\" "
1172 "ACTION=\"/netedit\">"
1176 "<INPUT TYPE=\"INPUT\" "
1180 wprintf("<INPUT TYPE=\"hidden\" "
1182 "VALUE=\"ignet_push_share|");
1185 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1186 "VALUE=\"sharing\">\n");
1187 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1188 "VALUE=\"add\">\n");
1189 wprintf("<INPUT TYPE=\"submit\" "
1190 "NAME=\"sc\" VALUE=\"Share\">");
1191 wprintf("</TD></TR></FORM>\n");
1195 wprintf("</TABLE>\n");
1196 wprintf("</TD></TR>"
1197 "</TABLE></CENTER><br />\n"
1198 "<I><B>Notes:</B><UL><LI>When sharing a room, "
1199 "it must be shared from both ends. Adding a node to "
1200 "the 'shared' list sends messages out, but in order to"
1201 " receive messages, the other nodes must be configured"
1202 " to send messages out to your system as well.\n"
1203 "<LI>If the remote room name is blank, it is assumed "
1204 "that the room name is identical on the remote node."
1205 "<LI>If the remote room name is different, the remote "
1206 "node must also configure the name of the room here."
1212 /* Mailing list management */
1213 if (!strcmp(tab, "listserv")) {
1215 wprintf("<br /><center>"
1216 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1217 "<TR><TD VALIGN=TOP>");
1219 wprintf("<i>The contents of this room are being "
1220 "mailed <b>as individual messages</b> "
1221 "to the following list recipients:"
1222 "</i><br /><br />\n");
1226 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1227 extract(cmd, buf, 0);
1228 if (!strcasecmp(cmd, "listrecp")) {
1229 extract(recp, buf, 1);
1232 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1235 wprintf("&tab=listserv\">(remove)</A><br />");
1239 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1240 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1241 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1242 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1243 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1244 wprintf("</FORM>\n");
1246 wprintf("</TD><TD VALIGN=TOP>\n");
1248 wprintf("<i>The contents of this room are being "
1249 "mailed <b>in digest form</b> "
1250 "to the following list recipients:"
1251 "</i><br /><br />\n");
1255 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1256 extract(cmd, buf, 0);
1257 if (!strcasecmp(cmd, "digestrecp")) {
1258 extract(recp, buf, 1);
1261 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1264 wprintf("&tab=listserv\">(remove)</A><br />");
1268 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1269 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1270 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1271 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1272 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1273 wprintf("</FORM>\n");
1275 wprintf("</TD></TR></TABLE><hr />\n");
1277 if (self_service(999) == 1) {
1278 wprintf("This room is configured to allow "
1279 "self-service subscribe/unsubscribe requests."
1280 " <A HREF=\"/toggle_self_service?newval=0&"
1282 "Click to disable.</A><br />\n"
1283 "The URL for subscribe/unsubscribe is: "
1284 "<TT>http://%s/listsub</TT><br />\n",
1289 wprintf("This room is <i>not</i> configured to allow "
1290 "self-service subscribe/unsubscribe requests."
1291 " <A HREF=\"/toggle_self_service?newval=1&"
1293 "Click to enable.</A><br />\n"
1298 wprintf("</CENTER>\n");
1302 /* Mailing list management */
1303 if (!strcmp(tab, "expire")) {
1305 serv_puts("GPEX room");
1307 if (buf[0] == '2') {
1308 roompolicy = extract_int(&buf[4], 0);
1309 roomvalue = extract_int(&buf[4], 1);
1312 serv_puts("GPEX floor");
1314 if (buf[0] == '2') {
1315 floorpolicy = extract_int(&buf[4], 0);
1316 floorvalue = extract_int(&buf[4], 1);
1319 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1320 wprintf("<TABLE border=0 cellspacing=5>\n");
1321 wprintf("<TR><TD>Message expire policy for this room<br />(");
1322 escputs(WC->wc_roomname);
1323 wprintf(")</TD><TD>");
1324 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1325 ((roompolicy == 0) ? "CHECKED" : "") );
1326 wprintf("Use the default policy for this floor<br />\n");
1327 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1328 ((roompolicy == 1) ? "CHECKED" : "") );
1329 wprintf("Never automatically expire messages<br />\n");
1330 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1331 ((roompolicy == 2) ? "CHECKED" : "") );
1332 wprintf("Expire by message count<br />\n");
1333 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1334 ((roompolicy == 3) ? "CHECKED" : "") );
1335 wprintf("Expire by message age<br />");
1336 wprintf("Number of messages or days: ");
1337 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1338 wprintf("</TD></TR>\n");
1340 if (WC->axlevel >= 6) {
1341 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1342 wprintf("<TR><TD>Message expire policy for this floor<br />(");
1343 escputs(floorlist[WC->wc_floor]);
1344 wprintf(")</TD><TD>");
1345 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1346 ((floorpolicy == 0) ? "CHECKED" : "") );
1347 wprintf("Use the system default<br />\n");
1348 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1349 ((floorpolicy == 1) ? "CHECKED" : "") );
1350 wprintf("Never automatically expire messages<br />\n");
1351 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1352 ((floorpolicy == 2) ? "CHECKED" : "") );
1353 wprintf("Expire by message count<br />\n");
1354 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1355 ((floorpolicy == 3) ? "CHECKED" : "") );
1356 wprintf("Expire by message age<br />");
1357 wprintf("Number of messages or days: ");
1358 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1362 wprintf("<CENTER>\n");
1363 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1364 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1366 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1367 wprintf("</CENTER></TD><TR>\n");
1369 wprintf("</TABLE>\n"
1370 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1377 /* end content of whatever tab is open now */
1378 wprintf("</TD></TR></TABLE>\n");
1385 * Toggle self-service list subscription
1387 void toggle_self_service(void) {
1390 newval = atoi(bstr("newval"));
1391 self_service(newval);
1398 * save new parameters for a room
1404 char er_password[10];
1405 char er_dirname[15];
1406 char er_roomaide[26];
1412 if (strcmp(bstr("sc"), "OK")) {
1413 strcpy(WC->ImportantMessage,
1414 "Cancelled. Changes were not saved.");
1421 if (buf[0] != '2') {
1422 strcpy(WC->ImportantMessage, &buf[4]);
1426 extract(er_name, &buf[4], 0);
1427 extract(er_password, &buf[4], 1);
1428 extract(er_dirname, &buf[4], 2);
1429 er_flags = extract_int(&buf[4], 3);
1431 strcpy(er_roomaide, bstr("er_roomaide"));
1432 if (strlen(er_roomaide) == 0) {
1435 if (buf[0] != '2') {
1436 strcpy(er_roomaide, "");
1438 extract(er_roomaide, &buf[4], 0);
1441 strcpy(buf, bstr("er_name"));
1443 if (strlen(buf) > 0)
1444 strcpy(er_name, buf);
1446 strcpy(buf, bstr("er_password"));
1448 if (strlen(buf) > 0)
1449 strcpy(er_password, buf);
1451 strcpy(buf, bstr("er_dirname"));
1453 if (strlen(buf) > 0)
1454 strcpy(er_dirname, buf);
1456 strcpy(buf, bstr("type"));
1457 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1459 if (!strcmp(buf, "invonly")) {
1460 er_flags |= (QR_PRIVATE);
1462 if (!strcmp(buf, "guessname")) {
1463 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1465 if (!strcmp(buf, "passworded")) {
1466 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1468 if (!strcmp(bstr("prefonly"), "yes")) {
1469 er_flags |= QR_PREFONLY;
1471 er_flags &= ~QR_PREFONLY;
1474 if (!strcmp(bstr("readonly"), "yes")) {
1475 er_flags |= QR_READONLY;
1477 er_flags &= ~QR_READONLY;
1480 if (!strcmp(bstr("permanent"), "yes")) {
1481 er_flags |= QR_PERMANENT;
1483 er_flags &= ~QR_PERMANENT;
1486 if (!strcmp(bstr("network"), "yes")) {
1487 er_flags |= QR_NETWORK;
1489 er_flags &= ~QR_NETWORK;
1492 if (!strcmp(bstr("directory"), "yes")) {
1493 er_flags |= QR_DIRECTORY;
1495 er_flags &= ~QR_DIRECTORY;
1498 if (!strcmp(bstr("ulallowed"), "yes")) {
1499 er_flags |= QR_UPLOAD;
1501 er_flags &= ~QR_UPLOAD;
1504 if (!strcmp(bstr("dlallowed"), "yes")) {
1505 er_flags |= QR_DOWNLOAD;
1507 er_flags &= ~QR_DOWNLOAD;
1510 if (!strcmp(bstr("visdir"), "yes")) {
1511 er_flags |= QR_VISDIR;
1513 er_flags &= ~QR_VISDIR;
1516 strcpy(buf, bstr("anon"));
1518 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1519 if (!strcmp(buf, "anononly"))
1520 er_flags |= QR_ANONONLY;
1521 if (!strcmp(buf, "anon2"))
1522 er_flags |= QR_ANONOPT;
1525 if (!strcmp(bstr("bump"), "yes"))
1528 er_floor = atoi(bstr("er_floor"));
1530 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1531 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1534 if (buf[0] != '2') {
1535 strcpy(WC->ImportantMessage, &buf[4]);
1541 if (strlen(er_roomaide) > 0) {
1542 sprintf(buf, "SETA %s", er_roomaide);
1545 if (buf[0] != '2') {
1546 strcpy(WC->ImportantMessage, &buf[4]);
1547 display_main_menu();
1552 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1558 * Invite, Kick, and show Who Knows a room
1560 void display_whok(void)
1562 char buf[SIZ], room[SIZ], username[SIZ];
1567 if (buf[0] != '2') {
1568 strcpy(WC->ImportantMessage, &buf[4]);
1569 display_main_menu();
1572 extract(room, &buf[4], 0);
1574 strcpy(username, bstr("username"));
1576 if(!strcmp(bstr("sc"), "Kick")) {
1577 sprintf(buf, "KICK %s", username);
1581 if (buf[0] != '2') {
1582 strcpy(WC->ImportantMessage, &buf[4]);
1584 sprintf(WC->ImportantMessage,
1585 "<B><I>User %s kicked out of room %s.</I></B>\n",
1588 } else if(!strcmp(bstr("sc"), "Invite")) {
1589 sprintf(buf, "INVT %s", username);
1593 if (buf[0] != '2') {
1594 strcpy(WC->ImportantMessage, &buf[4]);
1596 sprintf(WC->ImportantMessage,
1597 "<B><I>User %s invited to room %s.</I></B>\n",
1602 output_headers(1, 1, 1, 0, 0, 0, 0);
1603 stresc(buf, WC->wc_roomname, 1, 1);
1604 svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
1605 do_template("beginbox");
1607 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1608 "<TD>The users listed below have access to this room. "
1609 "To remove a user from the access list, select the user "
1610 "name from the list and click 'Kick'.<br /><br />");
1612 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1613 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1616 if (buf[0] == '1') {
1617 while (serv_gets(buf), strcmp(buf, "000")) {
1618 extract(username, buf, 0);
1619 wprintf("<OPTION>");
1624 wprintf("</SELECT><br />\n");
1626 wprintf("<input type=submit name=sc value=\"Kick\">");
1627 wprintf("</FORM></CENTER>\n");
1630 "To grant another user access to this room, enter the "
1631 "user name in the box below and click 'Invite'.<br /><br />");
1633 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1634 wprintf("Invite: ");
1635 wprintf("<input type=text name=username><br />\n"
1636 "<input type=hidden name=sc value=\"Invite\">"
1637 "<input type=submit value=\"Invite\">"
1638 "</FORM></CENTER>\n");
1640 wprintf("</TD></TR></TABLE>\n");
1641 do_template("endbox");
1648 * display the form for entering a new room
1650 void display_entroom(void)
1655 serv_puts("CRE8 0");
1658 if (buf[0] != '2') {
1659 strcpy(WC->ImportantMessage, &buf[4]);
1660 display_main_menu();
1663 output_headers(1, 1, 0, 0, 0, 0, 0);
1664 svprintf("BOXTITLE", WCS_STRING, "Create a new room");
1665 do_template("beginbox");
1667 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1669 wprintf("<UL><LI>Name of room: ");
1670 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1672 wprintf("<LI>Resides on floor: ");
1674 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1675 for (i = 0; i < 128; ++i)
1676 if (strlen(floorlist[i]) > 0) {
1677 wprintf("<OPTION ");
1678 wprintf("VALUE=\"%d\">", i);
1679 escputs(floorlist[i]);
1680 wprintf("</OPTION>\n");
1682 wprintf("</SELECT>\n");
1684 wprintf("<LI>Type of room:<UL>\n");
1686 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1687 wprintf("CHECKED > Public room\n");
1689 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1690 wprintf("> Private - guess name\n");
1692 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1693 wprintf("> Private - require password:\n");
1694 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1696 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1697 wprintf("> Private - invitation only\n");
1699 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1700 wprintf("> Personal (mailbox for you only)\n");
1703 wprintf("<LI>Default view for room: "); /* FOO */
1704 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1705 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1706 wprintf("<OPTION %s VALUE=\"%d\">",
1707 ((i == 0) ? "SELECTED" : ""), i );
1708 escputs(viewdefs[i]);
1709 wprintf("</OPTION>\n");
1711 wprintf("</SELECT>\n");
1713 wprintf("<CENTER>\n");
1714 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1716 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1717 wprintf("</CENTER>\n");
1718 wprintf("</FORM>\n<hr />");
1719 serv_printf("MESG roomaccess");
1721 if (buf[0] == '1') {
1722 fmout(NULL, "CENTER");
1724 do_template("endbox");
1732 * support function for entroom() -- sets the default view
1734 void er_set_default_view(int newview) {
1748 if (buf[0] != '2') return;
1750 extract(rm_name, &buf[4], 0);
1751 extract(rm_pass, &buf[4], 1);
1752 extract(rm_dir, &buf[4], 2);
1753 rm_bits1 = extract_int(&buf[4], 3);
1754 rm_floor = extract_int(&buf[4], 4);
1755 rm_listorder = extract_int(&buf[4], 5);
1756 rm_bits2 = extract_int(&buf[4], 7);
1758 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1759 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1760 rm_listorder, newview, rm_bits2
1775 char er_password[SIZ];
1780 if (strcmp(bstr("sc"), "OK")) {
1781 strcpy(WC->ImportantMessage,
1782 "Cancelled. No new room was created.");
1783 display_main_menu();
1786 strcpy(er_name, bstr("er_name"));
1787 strcpy(er_type, bstr("type"));
1788 strcpy(er_password, bstr("er_password"));
1789 er_floor = atoi(bstr("er_floor"));
1790 er_view = atoi(bstr("er_view"));
1793 if (!strcmp(er_type, "guessname"))
1795 if (!strcmp(er_type, "passworded"))
1797 if (!strcmp(er_type, "invonly"))
1799 if (!strcmp(er_type, "personal"))
1802 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1803 er_name, er_num_type, er_password, er_floor, 0, er_view);
1806 if (buf[0] != '2') {
1807 strcpy(WC->ImportantMessage, &buf[4]);
1808 display_main_menu();
1812 do_change_view(er_view); /* Now go there */
1817 * display the screen to enter a private room
1819 void display_private(char *rname, int req_pass)
1822 output_headers(1, 1, 0, 0, 0, 0, 0);
1824 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1825 do_template("beginbox");
1827 wprintf("<CENTER>\n");
1828 wprintf("<br />If you know the name of a hidden (guess-name) or\n");
1829 wprintf("passworded room, you can enter that room by typing\n");
1830 wprintf("its name below. Once you gain access to a private\n");
1831 wprintf("room, it will appear in your regular room listings\n");
1832 wprintf("so you don't have to keep returning here.\n");
1833 wprintf("<br /><br />");
1835 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1837 wprintf("<table border=\"0\" cellspacing=\"5\" "
1838 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1840 "Enter room name:</TD><TD>"
1841 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1842 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1845 wprintf("</TD></TR><TR><TD>");
1846 wprintf("Enter room password:</TD><TD>");
1847 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1849 wprintf("</TD></TR></TABLE><br />\n");
1851 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1853 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1854 wprintf("</FORM>\n");
1855 do_template("endbox");
1860 * goto a private room
1862 void goto_private(void)
1867 if (strcasecmp(bstr("sc"), "OK")) {
1868 display_main_menu();
1871 strcpy(hold_rm, WC->wc_roomname);
1872 strcpy(buf, "GOTO ");
1873 strcat(buf, bstr("gr_name"));
1875 strcat(buf, bstr("gr_pass"));
1879 if (buf[0] == '2') {
1880 smart_goto(bstr("gr_name"));
1883 if (!strncmp(buf, "540", 3)) {
1884 display_private(bstr("gr_name"), 1);
1887 output_headers(1, 1, 1, 0, 0, 0, 0);
1888 wprintf("%s\n", &buf[4]);
1895 * display the screen to zap a room
1897 void display_zap(void)
1899 output_headers(1, 1, 2, 0, 0, 0, 0);
1901 wprintf("<div id=\"banner\">\n");
1902 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1903 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget/unsubscribe) the current room</SPAN>\n");
1904 wprintf("</TD></TR></TABLE>\n");
1905 wprintf("</div>\n<div id=\"content\">\n");
1907 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1908 wprintf("disappear from your room list. Is this what you wish ");
1909 wprintf("to do?<br />\n");
1911 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1912 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1914 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1915 wprintf("</FORM>\n");
1926 char final_destination[SIZ];
1928 /* If the forget-room routine fails for any reason, we fall back
1929 * to the current room; otherwise, we go to the Lobby
1931 strcpy(final_destination, WC->wc_roomname);
1933 if (!strcasecmp(bstr("sc"), "OK")) {
1934 serv_printf("GOTO %s", WC->wc_roomname);
1936 if (buf[0] == '2') {
1939 if (buf[0] == '2') {
1940 strcpy(final_destination, "_BASEROOM_");
1944 smart_goto(final_destination);
1951 * Confirm deletion of the current room
1953 void confirm_delete_room(void)
1957 serv_puts("KILL 0");
1959 if (buf[0] != '2') {
1960 strcpy(WC->ImportantMessage, &buf[4]);
1961 display_main_menu();
1964 output_headers(1, 1, 2, 0, 0, 0, 0);
1965 wprintf("<div id=\"banner\">\n");
1966 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1967 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1968 wprintf("</TD></TR></TABLE>\n");
1969 wprintf("</div>\n<div id=\"content\">\n");
1971 wprintf("<CENTER>");
1972 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1974 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1975 escputs(WC->wc_roomname);
1976 wprintf("</FONT>?<br />\n");
1978 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1979 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1981 wprintf("</FORM></CENTER>\n");
1987 * Delete the current room
1989 void delete_room(void)
1994 strcpy(sc, bstr("sc"));
1996 if (strcasecmp(sc, "Delete")) {
1997 strcpy(WC->ImportantMessage,
1998 "Cancelled. This room was not deleted.");
1999 display_main_menu();
2002 serv_puts("KILL 1");
2004 if (buf[0] != '2') {
2005 strcpy(WC->ImportantMessage, &buf[4]);
2006 display_main_menu();
2009 smart_goto("_BASEROOM_");
2016 * Perform changes to a room's network configuration
2018 void netedit(void) {
2027 if (strlen(bstr("line"))==0) {
2032 strcpy(line, bstr("prefix"));
2033 strcat(line, bstr("line"));
2034 strcat(line, bstr("suffix"));
2044 if (buf[0] != '1') {
2050 /* This loop works for add *or* remove. Spiffy, eh? */
2051 while (serv_gets(buf), strcmp(buf, "000")) {
2052 extract(cmpa0, buf, 0);
2053 extract(cmpa1, buf, 1);
2054 extract(cmpb0, line, 0);
2055 extract(cmpb1, line, 1);
2056 if ( (strcasecmp(cmpa0, cmpb0))
2057 || (strcasecmp(cmpa1, cmpb1)) ) {
2058 fprintf(fp, "%s\n", buf);
2065 if (buf[0] != '4') {
2071 while (fgets(buf, sizeof buf, fp) != NULL) {
2072 buf[strlen(buf)-1] = 0;
2076 if (!strcasecmp(bstr("cmd"), "add")) {
2088 * Convert a room name to a folder-ish-looking name.
2090 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2095 * For mailboxes, just do it straight...
2098 sprintf(folder, "My folders|%s", room);
2102 * Otherwise, prefix the floor name as a "public folders" moniker
2105 sprintf(folder, "%s|%s", floorlist[floor], room);
2109 * Replace "\" characters with "|" for pseudo-folder-delimiting
2111 for (i=0; i<strlen(folder); ++i) {
2112 if (folder[i] == '\\') folder[i] = '|';
2120 * Back end for change_view()
2122 void do_change_view(int newview) {
2125 serv_printf("VIEW %d", newview);
2127 WC->wc_view = newview;
2128 smart_goto(WC->wc_roomname);
2134 * Change the view for this room
2136 void change_view(void) {
2139 view = atol(bstr("view"));
2140 do_change_view(view);
2145 * One big expanded tree list view --- like a folder list
2147 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2149 int levels, oldlevels;
2152 int has_subfolders = 0;
2154 /* Include the menu expanding/collapsing code */
2155 wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
2157 /* BEGIN TREE MENU */
2158 wprintf("<div id=\"mainMenu\">\n");
2159 wprintf("<UL id=\"menuList\">\n");
2163 for (i=0; i<max_folders; ++i) {
2166 if ((i+1) < max_folders) {
2167 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2168 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2173 levels = num_tokens(fold[i].name, '|');
2175 if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
2176 for (t=0; t<(oldlevels-levels); ++t) {
2181 if (has_subfolders) {
2183 if (levels == 1) wprintf(" class=\"menubar\"");
2185 wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
2191 if (fold[i].selectable) {
2192 wprintf("<A HREF=\"/dotgoto?room=");
2193 urlescputs(fold[i].room);
2198 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2200 else if (fold[i].hasnewmsgs) {
2201 wprintf("<SPAN CLASS=\"roomlist_new\">");
2204 wprintf("<SPAN CLASS=\"roomlist_old\">");
2206 extract(buf, fold[i].name, levels-1);
2210 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2211 wprintf(" (INBOX)");
2214 if (fold[i].selectable) {
2219 if (has_subfolders) {
2220 wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
2222 ( (levels == 1) ? "menu" : "submenu")
2228 wprintf("</UL></UL>\n");
2229 wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
2230 for (i=0; i<actnum; ++i) {
2231 wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
2234 wprintf("</DIV>\n");
2239 * Boxes and rooms and lists ... oh my!
2241 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2244 int levels, oldlevels;
2247 static int columns = 3;
2248 int boxes_per_column = 0;
2249 int current_column = 0;
2253 while (nf % columns != 0) ++nf;
2254 boxes_per_column = (nf / columns);
2255 if (boxes_per_column < 1) boxes_per_column = 1;
2257 /* Outer table (for columnization) */
2258 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2259 "<tr><td valign=top>");
2263 for (i=0; i<max_folders; ++i) {
2265 levels = num_tokens(fold[i].name, '|');
2267 if ((levels == 1) && (oldlevels > 1)) {
2270 do_template("endbox");
2273 if ((num_boxes % boxes_per_column) == 0) {
2275 if (current_column < columns) {
2276 wprintf("</td><td valign=top>\n");
2283 /* Begin inner box */
2284 extract(buf, fold[i].name, levels-1);
2285 stresc(boxtitle, buf, 1, 0);
2286 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2287 do_template("beginbox");
2295 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2296 if (fold[i].selectable) {
2297 wprintf("<A HREF=\"/dotgoto?room=");
2298 urlescputs(fold[i].room);
2304 if (fold[i].hasnewmsgs) {
2305 wprintf("<SPAN CLASS=\"roomlist_new\">");
2308 wprintf("<SPAN CLASS=\"roomlist_old\">");
2310 extract(buf, fold[i].name, levels-1);
2313 if (fold[i].selectable) {
2319 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2320 wprintf(" (INBOX)");
2322 wprintf("<br />\n");
2325 /* End the final inner box */
2326 do_template("endbox");
2328 wprintf("</TD></TR></TABLE>\n");
2333 * Show the room list. (only should get called by
2334 * knrooms() because that's where output_headers() is called from)
2337 void list_all_rooms_by_floor(char *viewpref) {
2340 struct folder *fold = NULL;
2342 int max_folders = 0;
2343 int alloc_folders = 0;
2347 int num_floors = 1; /* add an extra one for private folders */
2349 /* Start with the mailboxes */
2352 fold = malloc(sizeof(struct folder));
2353 memset(fold, 0, sizeof(struct folder));
2354 strcpy(fold[0].name, "My folders");
2355 fold[0].is_mailbox = 1;
2357 /* Then add floors */
2360 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2361 if (max_folders >= alloc_folders) {
2362 alloc_folders = max_folders + 100;
2363 fold = realloc(fold,
2364 alloc_folders * sizeof(struct folder));
2366 memset(&fold[max_folders], 0, sizeof(struct folder));
2367 extract(fold[max_folders].name, buf, 1);
2375 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2376 if (max_folders >= alloc_folders) {
2377 alloc_folders = max_folders + 100;
2378 fold = realloc(fold,
2379 alloc_folders * sizeof(struct folder));
2381 memset(&fold[max_folders], 0, sizeof(struct folder));
2382 extract(fold[max_folders].room, buf, 0);
2383 ra_flags = extract_int(buf, 5);
2384 flags = extract_int(buf, 1);
2385 fold[max_folders].floor = extract_int(buf, 2);
2386 fold[max_folders].hasnewmsgs =
2387 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2388 if (flags & QR_MAILBOX) {
2389 fold[max_folders].is_mailbox = 1;
2391 room_to_folder(fold[max_folders].name,
2392 fold[max_folders].room,
2393 fold[max_folders].floor,
2394 fold[max_folders].is_mailbox);
2395 fold[max_folders].selectable = 1;
2399 /* Bubble-sort the folder list */
2400 for (i=0; i<max_folders; ++i) {
2401 for (j=0; j<(max_folders-1)-i; ++j) {
2402 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2403 swap = strcasecmp(fold[j].name, fold[j+1].name);
2406 if ( (fold[j+1].is_mailbox)
2407 && (!fold[j].is_mailbox)) {
2415 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2416 memcpy(&fold[j], &fold[j+1],
2417 sizeof(struct folder));
2418 memcpy(&fold[j+1], &ftmp,
2419 sizeof(struct folder));
2424 /* test only hackish view
2425 wprintf("<table><TR><TD>A Table</TD></TR></table>\n");
2426 for (i=0; i<max_folders; ++i) {
2427 escputs(fold[i].name);
2428 wprintf("<br />\n");
2432 if (!strcasecmp(viewpref, "folders")) {
2433 do_folder_view(fold, max_folders, num_floors);
2436 do_rooms_view(fold, max_folders, num_floors);
2444 /* Do either a known rooms list or a folders list, depending on the
2448 char listviewpref[SIZ];
2450 output_headers(1, 1, 2, 0, 0, 0, 0);
2453 /* Determine whether the user is trying to change views */
2454 if (bstr("view") != NULL) {
2455 if (strlen(bstr("view")) > 0) {
2456 set_preference("roomlistview", bstr("view"));
2460 get_preference("roomlistview", listviewpref);
2462 if ( (strcasecmp(listviewpref, "folders"))
2463 && (strcasecmp(listviewpref, "table")) ) {
2464 strcpy(listviewpref, "rooms");
2468 wprintf("<div id=\"banner\">\n"
2469 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2470 "<SPAN CLASS=\"titlebar\">"
2472 if (!strcasecmp(listviewpref, "rooms")) {
2473 wprintf("Room list");
2475 if (!strcasecmp(listviewpref, "folders")) {
2476 wprintf("Folder list");
2478 if (!strcasecmp(listviewpref, "table")) {
2479 wprintf("Room list");
2481 wprintf("</SPAN></TD>\n");
2483 /* offer the ability to switch views */
2484 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2485 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2486 "OnChange=\"location.href=roomlistomatic.newview.options"
2487 "[selectedIndex].value\">\n");
2489 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2492 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2495 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2496 "View as folder list"
2498 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2501 wprintf("</SELECT><br />");
2503 wprintf("</FORM></TD></TR></TABLE>\n");
2505 "<div id=\"content\">\n");
2507 /* Display the room list in the user's preferred format */
2508 list_all_rooms_by_floor(listviewpref);
2514 * Set the message expire policy for this room and/or floor
2516 void set_room_policy(void) {
2519 if (strcmp(bstr("sc"), "OK")) {
2520 strcpy(WC->ImportantMessage,
2521 "Cancelled. Changes were not saved.");
2526 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2528 strcpy(WC->ImportantMessage, &buf[4]);
2530 if (WC->axlevel >= 6) {
2531 strcat(WC->ImportantMessage, "<br />\n");
2532 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2534 strcat(WC->ImportantMessage, &buf[4]);