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) {
394 "<A HREF=\"/readfwd\">"
395 "<img align=\"middle\" src=\"/static/readmsgs.gif\" border=\"0\">"
396 "<span class=\"navbar_link\">"
398 switch(WC->wc_view) {
399 case VIEW_ADDRESSBOOK:
400 wprintf("View contacts");
403 wprintf("View calendar");
406 wprintf("View tasks");
409 wprintf("View notes");
412 wprintf("All messages");
415 wprintf("</span></a></td>\n");
418 if (navbar_style == navbar_default) {
421 "<A HREF=\"/display_enter\">"
422 "<img align=\"middle\" src=\"/static/enter.gif\" border=\"0\">"
423 "<span class=\"navbar_link\">"
425 switch(WC->wc_view) {
426 case VIEW_ADDRESSBOOK:
427 wprintf("Add new contact");
430 wprintf("Add new event");
433 wprintf("Add new task");
436 wprintf("Add new note");
439 wprintf("Enter a message");
442 wprintf("</span></a></td>\n");
445 if (navbar_style == navbar_default) wprintf(
448 "<span class=\"navbar_link\">Skip this room</span>"
449 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
453 if (navbar_style == navbar_default) wprintf(
455 "<A HREF=\"/gotonext\">"
456 "<span class=\"navbar_link\">Goto next room</span>"
457 "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
461 wprintf("</tr></table></div>\n");
471 * back end routine to take the session to a new room
474 void gotoroom(char *gname)
477 static long ls = (-1L);
479 /* store ungoto information */
480 strcpy(WC->ugname, WC->wc_roomname);
483 /* move to the new room */
484 serv_printf("GOTO %s", gname);
487 serv_puts("GOTO _BASEROOM_");
493 extract(WC->wc_roomname, &buf[4], 0);
494 WC->room_flags = extract_int(&buf[4], 4);
495 /* highest_msg_read = extract_int(&buf[4],6);
496 maxmsgnum = extract_int(&buf[4],5);
497 is_mail = (char) extract_int(&buf[4],7); */
498 ls = extract_long(&buf[4], 6);
499 WC->wc_floor = extract_int(&buf[4], 10);
500 WC->wc_view = extract_int(&buf[4], 11);
501 WC->wc_default_view = extract_int(&buf[4], 12);
504 WC->is_room_aide = WC->is_aide;
506 WC->is_room_aide = (char) extract_int(&buf[4], 8);
508 remove_march(WC->wc_roomname);
509 if (!strcasecmp(gname, "_BASEROOM_"))
515 * Locate the room on the march list which we most want to go to. Each room
516 * is measured given a "weight" of preference based on various factors.
518 char *pop_march(int desired_floor)
520 static char TheRoom[128];
522 int TheOrder = 32767;
525 struct march *mptr = NULL;
527 strcpy(TheRoom, "_BASEROOM_");
528 if (WC->march == NULL)
531 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
533 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
534 weight = weight + 10000;
535 if (mptr->march_floor == desired_floor)
536 weight = weight + 5000;
538 weight = weight + ((128 - (mptr->march_floor)) * 128);
539 weight = weight + (128 - (mptr->march_order));
541 if (weight > TheWeight) {
543 strcpy(TheRoom, mptr->march_name);
544 TheFloor = mptr->march_floor;
545 TheOrder = mptr->march_order;
553 /* Goto next room having unread messages.
554 * We want to skip over rooms that the user has already been to, and take the
555 * user back to the lobby when done. The room we end up in is placed in
556 * newroom - which is set to 0 (the lobby) initially.
557 * We start the search in the current room rather than the beginning to prevent
558 * two or more concurrent users from dragging each other back to the same room.
563 struct march *mptr, *mptr2;
566 /* First check to see if the march-mode list is already allocated.
567 * If it is, pop the first room off the list and go there.
570 if (WC->march == NULL) {
574 while (serv_gets(buf), strcmp(buf, "000")) {
575 mptr = (struct march *) malloc(sizeof(struct march));
577 extract(mptr->march_name, buf, 0);
578 mptr->march_floor = extract_int(buf, 2);
579 mptr->march_order = extract_int(buf, 3);
580 if (WC->march == NULL) {
584 while (mptr2->next != NULL)
589 /* add _BASEROOM_ to the end of the march list, so the user will end up
590 * in the system base room (usually the Lobby>) at the end of the loop
592 mptr = (struct march *) malloc(sizeof(struct march));
594 strcpy(mptr->march_name, "_BASEROOM_");
595 if (WC->march == NULL) {
599 while (mptr2->next != NULL)
604 * ...and remove the room we're currently in, so a <G>oto doesn't make us
605 * walk around in circles
607 remove_march(WC->wc_roomname);
609 if (WC->march != NULL) {
610 strcpy(next_room, pop_march(-1));
612 strcpy(next_room, "_BASEROOM_");
616 smart_goto(next_room);
620 void smart_goto(char *next_room) {
628 * mark all messages in current room as having been read
630 void slrp_highest(void)
635 serv_puts("SLRP HIGHEST");
638 wprintf("<EM>%s</EM><br />\n", &buf[4]);
645 * un-goto the previous room
651 if (!strcmp(WC->ugname, "")) {
652 smart_goto(WC->wc_roomname);
655 serv_printf("GOTO %s", WC->ugname);
658 smart_goto(WC->wc_roomname);
661 if (WC->uglsn >= 0L) {
662 serv_printf("SLRP %ld", WC->uglsn);
665 strcpy(buf, WC->ugname);
666 strcpy(WC->ugname, "");
675 * Set/clear/read the "self-service list subscribe" flag for a room
677 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
678 * Always returns the new value.
681 int self_service(int newval) {
682 int current_value = 0;
688 int flags, floor, order, view, flags2;
692 if (buf[0] != '2') return(0);
694 extract(name, &buf[4], 0);
695 extract(password, &buf[4], 1);
696 extract(dirname, &buf[4], 2);
697 flags = extract_int(&buf[4], 3);
698 floor = extract_int(&buf[4], 4);
699 order = extract_int(&buf[4], 5);
700 view = extract_int(&buf[4], 6);
701 flags2 = extract_int(&buf[4], 7);
703 if (flags2 & QR2_SELFLIST) {
711 flags2 = flags2 | QR2_SELFLIST;
713 else if (newval == 0) {
714 flags2 = flags2 & ~QR2_SELFLIST;
717 return(current_value);
720 if (newval != current_value) {
721 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
722 name, password, dirname, flags,
723 floor, order, view, flags2);
737 * display the form for editing a room
739 void display_editroom(void)
744 char remote_room[SIZ];
747 char er_password[10];
749 char er_roomaide[26];
755 char *not_shared_with;
762 if (strlen(tab) == 0) tab = "admin";
769 strcpy(WC->ImportantMessage, &buf[4]);
773 extract(er_name, &buf[4], 0);
774 extract(er_password, &buf[4], 1);
775 extract(er_dirname, &buf[4], 2);
776 er_flags = extract_int(&buf[4], 3);
777 er_floor = extract_int(&buf[4], 4);
779 output_headers(1, 1, 1, 0, 0, 0, 0);
781 /* print the tabbed dialog */
782 wprintf("<br /><TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
784 "<TD> </TD>\n");
786 if (!strcmp(tab, "admin")) {
787 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
790 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
792 wprintf("Administration");
793 if (!strcmp(tab, "admin")) {
794 wprintf("</SPAN></TD>\n");
797 wprintf("</A></TD>\n");
800 wprintf("<TD> </TD>\n");
802 if (!strcmp(tab, "config")) {
803 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
806 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
808 wprintf("Configuration");
809 if (!strcmp(tab, "config")) {
810 wprintf("</SPAN></TD>\n");
813 wprintf("</A></TD>\n");
816 wprintf("<TD> </TD>\n");
818 if (!strcmp(tab, "expire")) {
819 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
822 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
824 wprintf("Message expire policy");
825 if (!strcmp(tab, "expire")) {
826 wprintf("</SPAN></TD>\n");
829 wprintf("</A></TD>\n");
832 wprintf("<TD> </TD>\n");
834 if (!strcmp(tab, "sharing")) {
835 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
838 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
841 if (!strcmp(tab, "sharing")) {
842 wprintf("</SPAN></TD>\n");
845 wprintf("</A></TD>\n");
848 wprintf("<TD> </TD>\n");
850 if (!strcmp(tab, "listserv")) {
851 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
854 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
856 wprintf("Mailing list service");
857 if (!strcmp(tab, "listserv")) {
858 wprintf("</SPAN></TD>\n");
861 wprintf("</A></TD>\n");
864 wprintf("<TD> </TD>\n");
866 wprintf("</TR></TABLE>\n");
867 /* end tabbed dialog */
869 /* begin content of whatever tab is open now */
870 wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
873 if (!strcmp(tab, "admin")) {
875 "<LI><A HREF=\"/confirm_delete_room\">\n"
876 "Delete this room</A>\n"
877 "<LI><A HREF=\"/display_editroompic\">\n"
878 "Set or change the graphic for this room's banner</A>\n"
879 "<LI><A HREF=\"/display_editinfo\">\n"
880 "Edit this room's Info file</A>\n"
884 if (!strcmp(tab, "config")) {
885 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
887 wprintf("<UL><LI>Name of room: ");
888 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
890 wprintf("<LI>Resides on floor: ");
891 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
892 for (i = 0; i < 128; ++i)
893 if (strlen(floorlist[i]) > 0) {
896 wprintf("SELECTED ");
897 wprintf("VALUE=\"%d\">", i);
898 escputs(floorlist[i]);
899 wprintf("</OPTION>\n");
901 wprintf("</SELECT>\n");
903 wprintf("<LI>Type of room:<UL>\n");
905 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
906 if ((er_flags & QR_PRIVATE) == 0)
908 wprintf("> Public room\n");
910 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
911 if ((er_flags & QR_PRIVATE) &&
912 (er_flags & QR_GUESSNAME))
914 wprintf("> Private - guess name\n");
916 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
917 if ((er_flags & QR_PRIVATE) &&
918 (er_flags & QR_PASSWORDED))
920 wprintf("> Private - require password:\n");
921 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
923 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
924 if ((er_flags & QR_PRIVATE)
925 && ((er_flags & QR_GUESSNAME) == 0)
926 && ((er_flags & QR_PASSWORDED) == 0))
928 wprintf("> Private - invitation only\n");
930 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
931 wprintf("> If private, cause current users to forget room\n");
935 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
936 if (er_flags & QR_PREFONLY)
938 wprintf("> Preferred users only\n");
940 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
941 if (er_flags & QR_READONLY)
943 wprintf("> Read-only room\n");
945 /* directory stuff */
946 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
947 if (er_flags & QR_DIRECTORY)
949 wprintf("> File directory room\n");
951 wprintf("<UL><LI>Directory name: ");
952 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
954 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
955 if (er_flags & QR_UPLOAD)
957 wprintf("> Uploading allowed\n");
959 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
960 if (er_flags & QR_DOWNLOAD)
962 wprintf("> Downloading allowed\n");
964 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
965 if (er_flags & QR_VISDIR)
967 wprintf("> Visible directory</UL>\n");
969 /* end of directory stuff */
971 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
972 if (er_flags & QR_NETWORK)
974 wprintf("> Network shared room\n");
976 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
977 if (er_flags & QR_PERMANENT)
979 wprintf("> Permanent (does not auto-purge)\n");
981 /* start of anon options */
983 wprintf("<LI>Anonymous messages<UL>\n");
985 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
986 if (((er_flags & QR_ANONONLY) == 0)
987 && ((er_flags & QR_ANONOPT) == 0))
989 wprintf("> No anonymous messages\n");
991 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
992 if (er_flags & QR_ANONONLY)
994 wprintf("> All messages are anonymous\n");
996 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
997 if (er_flags & QR_ANONOPT)
999 wprintf("> Prompt user when entering messages</UL>\n");
1001 /* end of anon options */
1003 wprintf("<LI>Room aide: \n");
1006 if (buf[0] != '2') {
1007 wprintf("<EM>%s</EM>\n", &buf[4]);
1009 extract(er_roomaide, &buf[4], 0);
1010 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1013 wprintf("</UL><CENTER>\n");
1014 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1015 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1017 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
1023 /* Sharing the room with other Citadel nodes... */
1024 if (!strcmp(tab, "sharing")) {
1026 shared_with = strdup("");
1027 not_shared_with = strdup("");
1029 /* Learn the current configuration */
1030 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1032 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1033 extract(node, buf, 0);
1034 not_shared_with = realloc(not_shared_with,
1035 strlen(not_shared_with) + 32);
1036 strcat(not_shared_with, node);
1037 strcat(not_shared_with, "\n");
1042 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1043 extract(cmd, buf, 0);
1044 extract(node, buf, 1);
1045 extract(remote_room, buf, 2);
1046 if (!strcasecmp(cmd, "ignet_push_share")) {
1047 shared_with = realloc(shared_with,
1048 strlen(shared_with) + 32);
1049 strcat(shared_with, node);
1050 if (strlen(remote_room) > 0) {
1051 strcat(shared_with, "|");
1052 strcat(shared_with, remote_room);
1054 strcat(shared_with, "\n");
1058 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1059 extract_token(buf, shared_with, i, '\n');
1060 extract_token(node, buf, 0, '|');
1061 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1062 extract_token(cmd, not_shared_with, j, '\n');
1063 if (!strcasecmp(node, cmd)) {
1064 remove_token(not_shared_with, j, '\n');
1069 /* Display the stuff */
1070 wprintf("<CENTER><br />"
1071 "<TABLE border=1 cellpadding=5><TR>"
1072 "<TD><B><I>Shared with</I></B></TD>"
1073 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1074 "<TR><TD VALIGN=TOP>\n");
1076 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1077 "<TD>Remote node name</TD>"
1078 "<TD>Remote room name</TD>"
1083 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1084 extract_token(buf, shared_with, i, '\n');
1085 extract_token(node, buf, 0, '|');
1086 extract_token(remote_room, buf, 1, '|');
1087 if (strlen(node) > 0) {
1088 wprintf("<FORM METHOD=\"POST\" "
1089 "ACTION=\"/netedit\">"
1090 "<TR><TD>%s</TD>\n", node);
1093 if (strlen(remote_room) > 0) {
1094 escputs(remote_room);
1100 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1101 "VALUE=\"ignet_push_share|");
1103 if (strlen(remote_room) > 0) {
1105 urlescputs(remote_room);
1108 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1109 "VALUE=\"sharing\">\n");
1110 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1111 "VALUE=\"remove\">\n");
1112 wprintf("<INPUT TYPE=\"submit\" "
1113 "NAME=\"sc\" VALUE=\"Unshare\">");
1114 wprintf("</TD></TR></FORM>\n");
1118 wprintf("</TABLE>\n");
1119 wprintf("</TD><TD VALIGN=TOP>\n");
1120 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\">"
1121 "<TD>Remote node name</TD>"
1122 "<TD>Remote room name</TD>"
1127 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1128 extract_token(node, not_shared_with, i, '\n');
1129 if (strlen(node) > 0) {
1130 wprintf("<FORM METHOD=\"POST\" "
1131 "ACTION=\"/netedit\">"
1135 "<INPUT TYPE=\"INPUT\" "
1139 wprintf("<INPUT TYPE=\"hidden\" "
1141 "VALUE=\"ignet_push_share|");
1144 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1145 "VALUE=\"sharing\">\n");
1146 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1147 "VALUE=\"add\">\n");
1148 wprintf("<INPUT TYPE=\"submit\" "
1149 "NAME=\"sc\" VALUE=\"Share\">");
1150 wprintf("</TD></TR></FORM>\n");
1154 wprintf("</TABLE>\n");
1155 wprintf("</TD></TR>"
1156 "</TABLE></CENTER><br />\n"
1157 "<I><B>Notes:</B><UL><LI>When sharing a room, "
1158 "it must be shared from both ends. Adding a node to "
1159 "the 'shared' list sends messages out, but in order to"
1160 " receive messages, the other nodes must be configured"
1161 " to send messages out to your system as well.\n"
1162 "<LI>If the remote room name is blank, it is assumed "
1163 "that the room name is identical on the remote node."
1164 "<LI>If the remote room name is different, the remote "
1165 "node must also configure the name of the room here."
1171 /* Mailing list management */
1172 if (!strcmp(tab, "listserv")) {
1174 wprintf("<br /><center>"
1175 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1176 "<TR><TD VALIGN=TOP>");
1178 wprintf("<i>The contents of this room are being "
1179 "mailed <b>as individual messages</b> "
1180 "to the following list recipients:"
1181 "</i><br /><br />\n");
1185 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1186 extract(cmd, buf, 0);
1187 if (!strcasecmp(cmd, "listrecp")) {
1188 extract(recp, buf, 1);
1191 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1194 wprintf("&tab=listserv\">(remove)</A><br />");
1198 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1199 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1200 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1201 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1202 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1203 wprintf("</FORM>\n");
1205 wprintf("</TD><TD VALIGN=TOP>\n");
1207 wprintf("<i>The contents of this room are being "
1208 "mailed <b>in digest form</b> "
1209 "to the following list recipients:"
1210 "</i><br /><br />\n");
1214 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1215 extract(cmd, buf, 0);
1216 if (!strcasecmp(cmd, "digestrecp")) {
1217 extract(recp, buf, 1);
1220 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1223 wprintf("&tab=listserv\">(remove)</A><br />");
1227 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1228 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1229 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1230 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1231 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1232 wprintf("</FORM>\n");
1234 wprintf("</TD></TR></TABLE><hr />\n");
1236 if (self_service(999) == 1) {
1237 wprintf("This room is configured to allow "
1238 "self-service subscribe/unsubscribe requests."
1239 " <A HREF=\"/toggle_self_service?newval=0&"
1241 "Click to disable.</A><br />\n"
1242 "The URL for subscribe/unsubscribe is: "
1243 "<TT>http://%s/listsub</TT><br />\n",
1248 wprintf("This room is <i>not</i> configured to allow "
1249 "self-service subscribe/unsubscribe requests."
1250 " <A HREF=\"/toggle_self_service?newval=1&"
1252 "Click to enable.</A><br />\n"
1257 wprintf("</CENTER>\n");
1261 /* Mailing list management */
1262 if (!strcmp(tab, "expire")) {
1264 serv_puts("GPEX room");
1266 if (buf[0] == '2') {
1267 roompolicy = extract_int(&buf[4], 0);
1268 roomvalue = extract_int(&buf[4], 1);
1271 serv_puts("GPEX floor");
1273 if (buf[0] == '2') {
1274 floorpolicy = extract_int(&buf[4], 0);
1275 floorvalue = extract_int(&buf[4], 1);
1278 wprintf("<br /><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1279 wprintf("<TABLE border=0 cellspacing=5>\n");
1280 wprintf("<TR><TD>Message expire policy for this room<br />(");
1281 escputs(WC->wc_roomname);
1282 wprintf(")</TD><TD>");
1283 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1284 ((roompolicy == 0) ? "CHECKED" : "") );
1285 wprintf("Use the default policy for this floor<br />\n");
1286 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1287 ((roompolicy == 1) ? "CHECKED" : "") );
1288 wprintf("Never automatically expire messages<br />\n");
1289 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1290 ((roompolicy == 2) ? "CHECKED" : "") );
1291 wprintf("Expire by message count<br />\n");
1292 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1293 ((roompolicy == 3) ? "CHECKED" : "") );
1294 wprintf("Expire by message age<br />");
1295 wprintf("Number of messages or days: ");
1296 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1297 wprintf("</TD></TR>\n");
1299 if (WC->axlevel >= 6) {
1300 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1301 wprintf("<TR><TD>Message expire policy for this floor<br />(");
1302 escputs(floorlist[WC->wc_floor]);
1303 wprintf(")</TD><TD>");
1304 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1305 ((floorpolicy == 0) ? "CHECKED" : "") );
1306 wprintf("Use the system default<br />\n");
1307 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1308 ((floorpolicy == 1) ? "CHECKED" : "") );
1309 wprintf("Never automatically expire messages<br />\n");
1310 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1311 ((floorpolicy == 2) ? "CHECKED" : "") );
1312 wprintf("Expire by message count<br />\n");
1313 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1314 ((floorpolicy == 3) ? "CHECKED" : "") );
1315 wprintf("Expire by message age<br />");
1316 wprintf("Number of messages or days: ");
1317 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1321 wprintf("<CENTER>\n");
1322 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1323 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1325 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1326 wprintf("</CENTER></TD><TR>\n");
1328 wprintf("</TABLE>\n"
1329 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1336 /* end content of whatever tab is open now */
1337 wprintf("</TD></TR></TABLE>\n");
1344 * Toggle self-service list subscription
1346 void toggle_self_service(void) {
1349 newval = atoi(bstr("newval"));
1350 self_service(newval);
1357 * save new parameters for a room
1363 char er_password[10];
1364 char er_dirname[15];
1365 char er_roomaide[26];
1371 if (strcmp(bstr("sc"), "OK")) {
1372 strcpy(WC->ImportantMessage,
1373 "Cancelled. Changes were not saved.");
1380 if (buf[0] != '2') {
1381 strcpy(WC->ImportantMessage, &buf[4]);
1385 extract(er_name, &buf[4], 0);
1386 extract(er_password, &buf[4], 1);
1387 extract(er_dirname, &buf[4], 2);
1388 er_flags = extract_int(&buf[4], 3);
1390 strcpy(er_roomaide, bstr("er_roomaide"));
1391 if (strlen(er_roomaide) == 0) {
1394 if (buf[0] != '2') {
1395 strcpy(er_roomaide, "");
1397 extract(er_roomaide, &buf[4], 0);
1400 strcpy(buf, bstr("er_name"));
1402 if (strlen(buf) > 0)
1403 strcpy(er_name, buf);
1405 strcpy(buf, bstr("er_password"));
1407 if (strlen(buf) > 0)
1408 strcpy(er_password, buf);
1410 strcpy(buf, bstr("er_dirname"));
1412 if (strlen(buf) > 0)
1413 strcpy(er_dirname, buf);
1415 strcpy(buf, bstr("type"));
1416 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1418 if (!strcmp(buf, "invonly")) {
1419 er_flags |= (QR_PRIVATE);
1421 if (!strcmp(buf, "guessname")) {
1422 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1424 if (!strcmp(buf, "passworded")) {
1425 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1427 if (!strcmp(bstr("prefonly"), "yes")) {
1428 er_flags |= QR_PREFONLY;
1430 er_flags &= ~QR_PREFONLY;
1433 if (!strcmp(bstr("readonly"), "yes")) {
1434 er_flags |= QR_READONLY;
1436 er_flags &= ~QR_READONLY;
1439 if (!strcmp(bstr("permanent"), "yes")) {
1440 er_flags |= QR_PERMANENT;
1442 er_flags &= ~QR_PERMANENT;
1445 if (!strcmp(bstr("network"), "yes")) {
1446 er_flags |= QR_NETWORK;
1448 er_flags &= ~QR_NETWORK;
1451 if (!strcmp(bstr("directory"), "yes")) {
1452 er_flags |= QR_DIRECTORY;
1454 er_flags &= ~QR_DIRECTORY;
1457 if (!strcmp(bstr("ulallowed"), "yes")) {
1458 er_flags |= QR_UPLOAD;
1460 er_flags &= ~QR_UPLOAD;
1463 if (!strcmp(bstr("dlallowed"), "yes")) {
1464 er_flags |= QR_DOWNLOAD;
1466 er_flags &= ~QR_DOWNLOAD;
1469 if (!strcmp(bstr("visdir"), "yes")) {
1470 er_flags |= QR_VISDIR;
1472 er_flags &= ~QR_VISDIR;
1475 strcpy(buf, bstr("anon"));
1477 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1478 if (!strcmp(buf, "anononly"))
1479 er_flags |= QR_ANONONLY;
1480 if (!strcmp(buf, "anon2"))
1481 er_flags |= QR_ANONOPT;
1484 if (!strcmp(bstr("bump"), "yes"))
1487 er_floor = atoi(bstr("er_floor"));
1489 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1490 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1493 if (buf[0] != '2') {
1494 strcpy(WC->ImportantMessage, &buf[4]);
1500 if (strlen(er_roomaide) > 0) {
1501 sprintf(buf, "SETA %s", er_roomaide);
1504 if (buf[0] != '2') {
1505 strcpy(WC->ImportantMessage, &buf[4]);
1506 display_main_menu();
1511 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1517 * Invite, Kick, and show Who Knows a room
1519 void display_whok(void)
1521 char buf[SIZ], room[SIZ], username[SIZ];
1526 if (buf[0] != '2') {
1527 strcpy(WC->ImportantMessage, &buf[4]);
1528 display_main_menu();
1531 extract(room, &buf[4], 0);
1533 strcpy(username, bstr("username"));
1535 if(!strcmp(bstr("sc"), "Kick")) {
1536 sprintf(buf, "KICK %s", username);
1540 if (buf[0] != '2') {
1541 strcpy(WC->ImportantMessage, &buf[4]);
1543 sprintf(WC->ImportantMessage,
1544 "<B><I>User %s kicked out of room %s.</I></B>\n",
1547 } else if(!strcmp(bstr("sc"), "Invite")) {
1548 sprintf(buf, "INVT %s", username);
1552 if (buf[0] != '2') {
1553 strcpy(WC->ImportantMessage, &buf[4]);
1555 sprintf(WC->ImportantMessage,
1556 "<B><I>User %s invited to room %s.</I></B>\n",
1561 output_headers(1, 1, 1, 0, 0, 0, 0);
1562 stresc(buf, WC->wc_roomname, 1, 1);
1563 svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
1564 do_template("beginbox");
1566 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1567 "<TD>The users listed below have access to this room. "
1568 "To remove a user from the access list, select the user "
1569 "name from the list and click 'Kick'.<br /><br />");
1571 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1572 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1575 if (buf[0] == '1') {
1576 while (serv_gets(buf), strcmp(buf, "000")) {
1577 extract(username, buf, 0);
1578 wprintf("<OPTION>");
1583 wprintf("</SELECT><br />\n");
1585 wprintf("<input type=submit name=sc value=\"Kick\">");
1586 wprintf("</FORM></CENTER>\n");
1589 "To grant another user access to this room, enter the "
1590 "user name in the box below and click 'Invite'.<br /><br />");
1592 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1593 wprintf("Invite: ");
1594 wprintf("<input type=text name=username><br />\n"
1595 "<input type=hidden name=sc value=\"Invite\">"
1596 "<input type=submit value=\"Invite\">"
1597 "</FORM></CENTER>\n");
1599 wprintf("</TD></TR></TABLE>\n");
1600 do_template("endbox");
1607 * display the form for entering a new room
1609 void display_entroom(void)
1614 serv_puts("CRE8 0");
1617 if (buf[0] != '2') {
1618 strcpy(WC->ImportantMessage, &buf[4]);
1619 display_main_menu();
1622 output_headers(1, 1, 0, 0, 0, 0, 0);
1623 svprintf("BOXTITLE", WCS_STRING, "Create a new room");
1624 do_template("beginbox");
1626 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1628 wprintf("<UL><LI>Name of room: ");
1629 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1631 wprintf("<LI>Resides on floor: ");
1633 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1634 for (i = 0; i < 128; ++i)
1635 if (strlen(floorlist[i]) > 0) {
1636 wprintf("<OPTION ");
1637 wprintf("VALUE=\"%d\">", i);
1638 escputs(floorlist[i]);
1639 wprintf("</OPTION>\n");
1641 wprintf("</SELECT>\n");
1643 wprintf("<LI>Type of room:<UL>\n");
1645 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1646 wprintf("CHECKED > Public room\n");
1648 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1649 wprintf("> Private - guess name\n");
1651 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1652 wprintf("> Private - require password:\n");
1653 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1655 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1656 wprintf("> Private - invitation only\n");
1658 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1659 wprintf("> Personal (mailbox for you only)\n");
1662 wprintf("<LI>Default view for room: "); /* FOO */
1663 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1664 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1665 wprintf("<OPTION %s VALUE=\"%d\">",
1666 ((i == 0) ? "SELECTED" : ""), i );
1667 escputs(viewdefs[i]);
1668 wprintf("</OPTION>\n");
1670 wprintf("</SELECT>\n");
1672 wprintf("<CENTER>\n");
1673 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1675 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1676 wprintf("</CENTER>\n");
1677 wprintf("</FORM>\n<hr />");
1678 serv_printf("MESG roomaccess");
1680 if (buf[0] == '1') {
1681 fmout(NULL, "CENTER");
1683 do_template("endbox");
1691 * support function for entroom() -- sets the default view
1693 void er_set_default_view(int newview) {
1707 if (buf[0] != '2') return;
1709 extract(rm_name, &buf[4], 0);
1710 extract(rm_pass, &buf[4], 1);
1711 extract(rm_dir, &buf[4], 2);
1712 rm_bits1 = extract_int(&buf[4], 3);
1713 rm_floor = extract_int(&buf[4], 4);
1714 rm_listorder = extract_int(&buf[4], 5);
1715 rm_bits2 = extract_int(&buf[4], 7);
1717 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1718 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1719 rm_listorder, newview, rm_bits2
1734 char er_password[SIZ];
1739 if (strcmp(bstr("sc"), "OK")) {
1740 strcpy(WC->ImportantMessage,
1741 "Cancelled. No new room was created.");
1742 display_main_menu();
1745 strcpy(er_name, bstr("er_name"));
1746 strcpy(er_type, bstr("type"));
1747 strcpy(er_password, bstr("er_password"));
1748 er_floor = atoi(bstr("er_floor"));
1749 er_view = atoi(bstr("er_view"));
1752 if (!strcmp(er_type, "guessname"))
1754 if (!strcmp(er_type, "passworded"))
1756 if (!strcmp(er_type, "invonly"))
1758 if (!strcmp(er_type, "personal"))
1761 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1762 er_name, er_num_type, er_password, er_floor, 0, er_view);
1765 if (buf[0] != '2') {
1766 strcpy(WC->ImportantMessage, &buf[4]);
1767 display_main_menu();
1771 do_change_view(er_view); /* Now go there */
1776 * display the screen to enter a private room
1778 void display_private(char *rname, int req_pass)
1781 output_headers(1, 1, 0, 0, 0, 0, 0);
1783 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1784 do_template("beginbox");
1786 wprintf("<CENTER>\n");
1787 wprintf("<br />If you know the name of a hidden (guess-name) or\n");
1788 wprintf("passworded room, you can enter that room by typing\n");
1789 wprintf("its name below. Once you gain access to a private\n");
1790 wprintf("room, it will appear in your regular room listings\n");
1791 wprintf("so you don't have to keep returning here.\n");
1792 wprintf("<br /><br />");
1794 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1796 wprintf("<table border=\"0\" cellspacing=\"5\" "
1797 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1799 "Enter room name:</TD><TD>"
1800 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1801 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1804 wprintf("</TD></TR><TR><TD>");
1805 wprintf("Enter room password:</TD><TD>");
1806 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1808 wprintf("</TD></TR></TABLE><br />\n");
1810 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1812 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1813 wprintf("</FORM>\n");
1814 do_template("endbox");
1819 * goto a private room
1821 void goto_private(void)
1826 if (strcasecmp(bstr("sc"), "OK")) {
1827 display_main_menu();
1830 strcpy(hold_rm, WC->wc_roomname);
1831 strcpy(buf, "GOTO ");
1832 strcat(buf, bstr("gr_name"));
1834 strcat(buf, bstr("gr_pass"));
1838 if (buf[0] == '2') {
1839 smart_goto(bstr("gr_name"));
1842 if (!strncmp(buf, "540", 3)) {
1843 display_private(bstr("gr_name"), 1);
1846 output_headers(1, 1, 1, 0, 0, 0, 0);
1847 wprintf("%s\n", &buf[4]);
1854 * display the screen to zap a room
1856 void display_zap(void)
1858 output_headers(1, 1, 2, 0, 0, 0, 0);
1860 wprintf("<div id=\"banner\">\n");
1861 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1862 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget/unsubscribe) the current room</SPAN>\n");
1863 wprintf("</TD></TR></TABLE>\n");
1864 wprintf("</div>\n<div id=\"content\">\n");
1866 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1867 wprintf("disappear from your room list. Is this what you wish ");
1868 wprintf("to do?<br />\n");
1870 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1871 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1873 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1874 wprintf("</FORM>\n");
1885 char final_destination[SIZ];
1887 /* If the forget-room routine fails for any reason, we fall back
1888 * to the current room; otherwise, we go to the Lobby
1890 strcpy(final_destination, WC->wc_roomname);
1892 if (!strcasecmp(bstr("sc"), "OK")) {
1893 serv_printf("GOTO %s", WC->wc_roomname);
1895 if (buf[0] != '2') {
1896 /* ExpressMessageCat(&buf[4]); */
1900 if (buf[0] != '2') {
1901 /* ExpressMessageCat(&buf[4]); */
1903 strcpy(final_destination, "_BASEROOM_");
1907 smart_goto(final_destination);
1914 * Confirm deletion of the current room
1916 void confirm_delete_room(void)
1920 serv_puts("KILL 0");
1922 if (buf[0] != '2') {
1923 strcpy(WC->ImportantMessage, &buf[4]);
1924 display_main_menu();
1927 output_headers(1, 1, 2, 0, 0, 0, 0);
1928 wprintf("<div id=\"banner\">\n");
1929 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1930 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1931 wprintf("</TD></TR></TABLE>\n");
1932 wprintf("</div>\n<div id=\"content\">\n");
1934 wprintf("<CENTER>");
1935 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1937 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1938 escputs(WC->wc_roomname);
1939 wprintf("</FONT>?<br />\n");
1941 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1942 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1944 wprintf("</FORM></CENTER>\n");
1950 * Delete the current room
1952 void delete_room(void)
1957 strcpy(sc, bstr("sc"));
1959 if (strcasecmp(sc, "Delete")) {
1960 strcpy(WC->ImportantMessage,
1961 "Cancelled. This room was not deleted.");
1962 display_main_menu();
1965 serv_puts("KILL 1");
1967 if (buf[0] != '2') {
1968 strcpy(WC->ImportantMessage, &buf[4]);
1969 display_main_menu();
1972 smart_goto("_BASEROOM_");
1979 * Perform changes to a room's network configuration
1981 void netedit(void) {
1990 if (strlen(bstr("line"))==0) {
1995 strcpy(line, bstr("prefix"));
1996 strcat(line, bstr("line"));
1997 strcat(line, bstr("suffix"));
2007 if (buf[0] != '1') {
2013 /* This loop works for add *or* remove. Spiffy, eh? */
2014 while (serv_gets(buf), strcmp(buf, "000")) {
2015 extract(cmpa0, buf, 0);
2016 extract(cmpa1, buf, 1);
2017 extract(cmpb0, line, 0);
2018 extract(cmpb1, line, 1);
2019 if ( (strcasecmp(cmpa0, cmpb0))
2020 || (strcasecmp(cmpa1, cmpb1)) ) {
2021 fprintf(fp, "%s\n", buf);
2028 if (buf[0] != '4') {
2034 while (fgets(buf, sizeof buf, fp) != NULL) {
2035 buf[strlen(buf)-1] = 0;
2039 if (!strcasecmp(bstr("cmd"), "add")) {
2051 * Convert a room name to a folder-ish-looking name.
2053 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2058 * For mailboxes, just do it straight...
2061 sprintf(folder, "My folders|%s", room);
2065 * Otherwise, prefix the floor name as a "public folders" moniker
2068 sprintf(folder, "%s|%s", floorlist[floor], room);
2072 * Replace "\" characters with "|" for pseudo-folder-delimiting
2074 for (i=0; i<strlen(folder); ++i) {
2075 if (folder[i] == '\\') folder[i] = '|';
2083 * Back end for change_view()
2085 void do_change_view(int newview) {
2088 serv_printf("VIEW %d", newview);
2090 WC->wc_view = newview;
2091 smart_goto(WC->wc_roomname);
2097 * Change the view for this room
2099 void change_view(void) {
2102 view = atol(bstr("view"));
2103 do_change_view(view);
2108 * One big expanded tree list view --- like a folder list
2110 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2112 int levels, oldlevels;
2115 int has_subfolders = 0;
2117 /* Include the menu expanding/collapsing code */
2118 wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
2120 /* BEGIN TREE MENU */
2121 wprintf("<div id=\"mainMenu\">\n");
2122 wprintf("<UL id=\"menuList\">\n");
2126 for (i=0; i<max_folders; ++i) {
2129 if ((i+1) < max_folders) {
2130 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2131 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2136 levels = num_tokens(fold[i].name, '|');
2138 if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
2139 for (t=0; t<(oldlevels-levels); ++t) {
2144 if (has_subfolders) {
2146 if (levels == 1) wprintf(" class=\"menubar\"");
2148 wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
2154 if (fold[i].selectable) {
2155 wprintf("<A HREF=\"/dotgoto?room=");
2156 urlescputs(fold[i].room);
2161 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2163 else if (fold[i].hasnewmsgs) {
2164 wprintf("<SPAN CLASS=\"roomlist_new\">");
2167 wprintf("<SPAN CLASS=\"roomlist_old\">");
2169 extract(buf, fold[i].name, levels-1);
2173 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2174 wprintf(" (INBOX)");
2177 if (fold[i].selectable) {
2182 if (has_subfolders) {
2183 wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
2185 ( (levels == 1) ? "menu" : "submenu")
2191 wprintf("</UL></UL>\n");
2192 wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
2193 for (i=0; i<actnum; ++i) {
2194 wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
2197 wprintf("</DIV>\n");
2202 * Boxes and rooms and lists ... oh my!
2204 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2207 int levels, oldlevels;
2210 static int columns = 3;
2211 int boxes_per_column = 0;
2212 int current_column = 0;
2216 while (nf % columns != 0) ++nf;
2217 boxes_per_column = (nf / columns);
2218 if (boxes_per_column < 1) boxes_per_column = 1;
2220 /* Outer table (for columnization) */
2221 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2222 "<tr><td valign=top>");
2226 for (i=0; i<max_folders; ++i) {
2228 levels = num_tokens(fold[i].name, '|');
2230 if ((levels == 1) && (oldlevels > 1)) {
2233 do_template("endbox");
2236 if ((num_boxes % boxes_per_column) == 0) {
2238 if (current_column < columns) {
2239 wprintf("</td><td valign=top>\n");
2246 /* Begin inner box */
2247 extract(buf, fold[i].name, levels-1);
2248 stresc(boxtitle, buf, 1, 0);
2249 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2250 do_template("beginbox");
2258 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2259 if (fold[i].selectable) {
2260 wprintf("<A HREF=\"/dotgoto?room=");
2261 urlescputs(fold[i].room);
2267 if (fold[i].hasnewmsgs) {
2268 wprintf("<SPAN CLASS=\"roomlist_new\">");
2271 wprintf("<SPAN CLASS=\"roomlist_old\">");
2273 extract(buf, fold[i].name, levels-1);
2276 if (fold[i].selectable) {
2282 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2283 wprintf(" (INBOX)");
2285 wprintf("<br />\n");
2288 /* End the final inner box */
2289 do_template("endbox");
2291 wprintf("</TD></TR></TABLE>\n");
2296 * Show the room list. (only should get called by
2297 * knrooms() because that's where output_headers() is called from)
2300 void list_all_rooms_by_floor(char *viewpref) {
2303 struct folder *fold = NULL;
2305 int max_folders = 0;
2306 int alloc_folders = 0;
2310 int num_floors = 1; /* add an extra one for private folders */
2312 /* Start with the mailboxes */
2315 fold = malloc(sizeof(struct folder));
2316 memset(fold, 0, sizeof(struct folder));
2317 strcpy(fold[0].name, "My folders");
2318 fold[0].is_mailbox = 1;
2320 /* Then add floors */
2323 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2324 if (max_folders >= alloc_folders) {
2325 alloc_folders = max_folders + 100;
2326 fold = realloc(fold,
2327 alloc_folders * sizeof(struct folder));
2329 memset(&fold[max_folders], 0, sizeof(struct folder));
2330 extract(fold[max_folders].name, buf, 1);
2338 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2339 if (max_folders >= alloc_folders) {
2340 alloc_folders = max_folders + 100;
2341 fold = realloc(fold,
2342 alloc_folders * sizeof(struct folder));
2344 memset(&fold[max_folders], 0, sizeof(struct folder));
2345 extract(fold[max_folders].room, buf, 0);
2346 ra_flags = extract_int(buf, 5);
2347 flags = extract_int(buf, 1);
2348 fold[max_folders].floor = extract_int(buf, 2);
2349 fold[max_folders].hasnewmsgs =
2350 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2351 if (flags & QR_MAILBOX) {
2352 fold[max_folders].is_mailbox = 1;
2354 room_to_folder(fold[max_folders].name,
2355 fold[max_folders].room,
2356 fold[max_folders].floor,
2357 fold[max_folders].is_mailbox);
2358 fold[max_folders].selectable = 1;
2362 /* Bubble-sort the folder list */
2363 for (i=0; i<max_folders; ++i) {
2364 for (j=0; j<(max_folders-1)-i; ++j) {
2365 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2366 swap = strcasecmp(fold[j].name, fold[j+1].name);
2369 if ( (fold[j+1].is_mailbox)
2370 && (!fold[j].is_mailbox)) {
2378 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2379 memcpy(&fold[j], &fold[j+1],
2380 sizeof(struct folder));
2381 memcpy(&fold[j+1], &ftmp,
2382 sizeof(struct folder));
2387 /* test only hackish view
2388 wprintf("<table><TR><TD>A Table</TD></TR></table>\n");
2389 for (i=0; i<max_folders; ++i) {
2390 escputs(fold[i].name);
2391 wprintf("<br />\n");
2395 if (!strcasecmp(viewpref, "folders")) {
2396 do_folder_view(fold, max_folders, num_floors);
2399 do_rooms_view(fold, max_folders, num_floors);
2407 /* Do either a known rooms list or a folders list, depending on the
2411 char listviewpref[SIZ];
2413 output_headers(1, 1, 2, 0, 0, 0, 0);
2416 /* Determine whether the user is trying to change views */
2417 if (bstr("view") != NULL) {
2418 if (strlen(bstr("view")) > 0) {
2419 set_preference("roomlistview", bstr("view"));
2423 get_preference("roomlistview", listviewpref);
2425 if ( (strcasecmp(listviewpref, "folders"))
2426 && (strcasecmp(listviewpref, "table")) ) {
2427 strcpy(listviewpref, "rooms");
2431 wprintf("<div id=\"banner\">\n"
2432 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2433 "<SPAN CLASS=\"titlebar\">"
2435 if (!strcasecmp(listviewpref, "rooms")) {
2436 wprintf("Room list");
2438 if (!strcasecmp(listviewpref, "folders")) {
2439 wprintf("Folder list");
2441 if (!strcasecmp(listviewpref, "table")) {
2442 wprintf("Room list");
2444 wprintf("</SPAN></TD>\n");
2446 /* offer the ability to switch views */
2447 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2448 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2449 "OnChange=\"location.href=roomlistomatic.newview.options"
2450 "[selectedIndex].value\">\n");
2452 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2455 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2458 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2459 "View as folder list"
2461 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2464 wprintf("</SELECT><br />");
2466 wprintf("</FORM></TD></TR></TABLE>\n");
2468 "<div id=\"content\">\n");
2470 /* Display the room list in the user's preferred format */
2471 list_all_rooms_by_floor(listviewpref);
2477 * Set the message expire policy for this room and/or floor
2479 void set_room_policy(void) {
2482 if (strcmp(bstr("sc"), "OK")) {
2483 strcpy(WC->ImportantMessage,
2484 "Cancelled. Changes were not saved.");
2489 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2491 strcpy(WC->ImportantMessage, &buf[4]);
2493 if (WC->axlevel >= 6) {
2494 strcat(WC->ImportantMessage, "<br />\n");
2495 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2497 strcat(WC->ImportantMessage, &buf[4]);