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)
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) {
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 clear_local_substs();
370 * back end routine to take the session to a new room
373 void gotoroom(char *gname)
376 static long ls = (-1L);
378 /* store ungoto information */
379 strcpy(WC->ugname, WC->wc_roomname);
382 /* move to the new room */
383 serv_printf("GOTO %s", gname);
386 serv_puts("GOTO _BASEROOM_");
392 extract(WC->wc_roomname, &buf[4], 0);
393 WC->room_flags = extract_int(&buf[4], 4);
394 /* highest_msg_read = extract_int(&buf[4],6);
395 maxmsgnum = extract_int(&buf[4],5);
396 is_mail = (char) extract_int(&buf[4],7); */
397 ls = extract_long(&buf[4], 6);
398 WC->wc_floor = extract_int(&buf[4], 10);
399 WC->wc_view = extract_int(&buf[4], 11);
400 WC->wc_default_view = extract_int(&buf[4], 12);
403 WC->is_room_aide = WC->is_aide;
405 WC->is_room_aide = (char) extract_int(&buf[4], 8);
407 remove_march(WC->wc_roomname);
408 if (!strcasecmp(gname, "_BASEROOM_"))
414 * Locate the room on the march list which we most want to go to. Each room
415 * is measured given a "weight" of preference based on various factors.
417 char *pop_march(int desired_floor)
419 static char TheRoom[128];
421 int TheOrder = 32767;
424 struct march *mptr = NULL;
426 strcpy(TheRoom, "_BASEROOM_");
427 if (WC->march == NULL)
430 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
432 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
433 weight = weight + 10000;
434 if (mptr->march_floor == desired_floor)
435 weight = weight + 5000;
437 weight = weight + ((128 - (mptr->march_floor)) * 128);
438 weight = weight + (128 - (mptr->march_order));
440 if (weight > TheWeight) {
442 strcpy(TheRoom, mptr->march_name);
443 TheFloor = mptr->march_floor;
444 TheOrder = mptr->march_order;
452 /* Goto next room having unread messages.
453 * We want to skip over rooms that the user has already been to, and take the
454 * user back to the lobby when done. The room we end up in is placed in
455 * newroom - which is set to 0 (the lobby) initially.
456 * We start the search in the current room rather than the beginning to prevent
457 * two or more concurrent users from dragging each other back to the same room.
462 struct march *mptr, *mptr2;
465 /* First check to see if the march-mode list is already allocated.
466 * If it is, pop the first room off the list and go there.
469 if (WC->march == NULL) {
473 while (serv_gets(buf), strcmp(buf, "000")) {
474 mptr = (struct march *) malloc(sizeof(struct march));
476 extract(mptr->march_name, buf, 0);
477 mptr->march_floor = extract_int(buf, 2);
478 mptr->march_order = extract_int(buf, 3);
479 if (WC->march == NULL) {
483 while (mptr2->next != NULL)
488 /* add _BASEROOM_ to the end of the march list, so the user will end up
489 * in the system base room (usually the Lobby>) at the end of the loop
491 mptr = (struct march *) malloc(sizeof(struct march));
493 strcpy(mptr->march_name, "_BASEROOM_");
494 if (WC->march == NULL) {
498 while (mptr2->next != NULL)
503 * ...and remove the room we're currently in, so a <G>oto doesn't make us
504 * walk around in circles
506 remove_march(WC->wc_roomname);
508 if (WC->march != NULL) {
509 strcpy(next_room, pop_march(-1));
511 strcpy(next_room, "_BASEROOM_");
515 smart_goto(next_room);
519 void smart_goto(char *next_room) {
527 * mark all messages in current room as having been read
529 void slrp_highest(void)
534 serv_puts("SLRP HIGHEST");
537 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
544 * un-goto the previous room
550 if (!strcmp(WC->ugname, "")) {
551 smart_goto(WC->wc_roomname);
554 serv_printf("GOTO %s", WC->ugname);
557 smart_goto(WC->wc_roomname);
560 if (WC->uglsn >= 0L) {
561 serv_printf("SLRP %ld", WC->uglsn);
564 strcpy(buf, WC->ugname);
565 strcpy(WC->ugname, "");
574 * Set/clear/read the "self-service list subscribe" flag for a room
576 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
577 * Always returns the new value.
580 int self_service(int newval) {
581 int current_value = 0;
587 int flags, floor, order, view, flags2;
591 if (buf[0] != '2') return(0);
593 extract(name, &buf[4], 0);
594 extract(password, &buf[4], 1);
595 extract(dirname, &buf[4], 2);
596 flags = extract_int(&buf[4], 3);
597 floor = extract_int(&buf[4], 4);
598 order = extract_int(&buf[4], 5);
599 view = extract_int(&buf[4], 6);
600 flags2 = extract_int(&buf[4], 7);
602 if (flags2 & QR2_SELFLIST) {
610 flags2 = flags2 | QR2_SELFLIST;
612 else if (newval == 0) {
613 flags2 = flags2 & ~QR2_SELFLIST;
616 return(current_value);
619 if (newval != current_value) {
620 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
621 name, password, dirname, flags,
622 floor, order, view, flags2);
636 * display the form for editing a room
638 void display_editroom(void)
645 char er_password[10];
647 char er_roomaide[26];
653 char *not_shared_with;
660 if (strlen(tab) == 0) tab = "admin";
667 strcpy(WC->ImportantMessage, &buf[4]);
671 extract(er_name, &buf[4], 0);
672 extract(er_password, &buf[4], 1);
673 extract(er_dirname, &buf[4], 2);
674 er_flags = extract_int(&buf[4], 3);
675 er_floor = extract_int(&buf[4], 4);
679 /* print the tabbed dialog */
680 wprintf("<BR><TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
682 "<TD> </TD>\n");
684 if (!strcmp(tab, "admin")) {
685 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
688 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
690 wprintf("Administration");
691 if (!strcmp(tab, "admin")) {
692 wprintf("</SPAN></TD>\n");
695 wprintf("</A></TD>\n");
698 wprintf("<TD> </TD>\n");
700 if (!strcmp(tab, "config")) {
701 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
704 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
706 wprintf("Configuration");
707 if (!strcmp(tab, "config")) {
708 wprintf("</SPAN></TD>\n");
711 wprintf("</A></TD>\n");
714 wprintf("<TD> </TD>\n");
716 if (!strcmp(tab, "expire")) {
717 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
720 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
722 wprintf("Message expire policy");
723 if (!strcmp(tab, "expire")) {
724 wprintf("</SPAN></TD>\n");
727 wprintf("</A></TD>\n");
730 wprintf("<TD> </TD>\n");
732 if (!strcmp(tab, "sharing")) {
733 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
736 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
739 if (!strcmp(tab, "sharing")) {
740 wprintf("</SPAN></TD>\n");
743 wprintf("</A></TD>\n");
746 wprintf("<TD> </TD>\n");
748 if (!strcmp(tab, "listserv")) {
749 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
752 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
754 wprintf("Mailing list service");
755 if (!strcmp(tab, "listserv")) {
756 wprintf("</SPAN></TD>\n");
759 wprintf("</A></TD>\n");
762 wprintf("<TD> </TD>\n");
764 wprintf("</TR></TABLE>\n");
765 /* end tabbed dialog */
767 /* begin content of whatever tab is open now */
768 wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
771 if (!strcmp(tab, "admin")) {
773 "<LI><A HREF=\"/confirm_delete_room\">\n"
774 "Delete this room</A>\n"
775 "<LI><A HREF=\"/display_editroompic\">\n"
776 "Set or change the graphic for this room's banner</A>\n"
777 "<LI><A HREF=\"/display_editinfo\">\n"
778 "Edit this room's Info file</A>\n"
782 if (!strcmp(tab, "config")) {
783 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
785 wprintf("<UL><LI>Name of room: ");
786 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
788 wprintf("<LI>Resides on floor: ");
789 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
790 for (i = 0; i < 128; ++i)
791 if (strlen(floorlist[i]) > 0) {
794 wprintf("SELECTED ");
795 wprintf("VALUE=\"%d\">", i);
796 escputs(floorlist[i]);
797 wprintf("</OPTION>\n");
799 wprintf("</SELECT>\n");
801 wprintf("<LI>Type of room:<UL>\n");
803 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
804 if ((er_flags & QR_PRIVATE) == 0)
806 wprintf("> Public room\n");
808 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
809 if ((er_flags & QR_PRIVATE) &&
810 (er_flags & QR_GUESSNAME))
812 wprintf("> Private - guess name\n");
814 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
815 if ((er_flags & QR_PRIVATE) &&
816 (er_flags & QR_PASSWORDED))
818 wprintf("> Private - require password:\n");
819 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
821 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
822 if ((er_flags & QR_PRIVATE)
823 && ((er_flags & QR_GUESSNAME) == 0)
824 && ((er_flags & QR_PASSWORDED) == 0))
826 wprintf("> Private - invitation only\n");
828 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
829 wprintf("> If private, cause current users to forget room\n");
833 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
834 if (er_flags & QR_PREFONLY)
836 wprintf("> Preferred users only\n");
838 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
839 if (er_flags & QR_READONLY)
841 wprintf("> Read-only room\n");
843 /* directory stuff */
844 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
845 if (er_flags & QR_DIRECTORY)
847 wprintf("> File directory room\n");
849 wprintf("<UL><LI>Directory name: ");
850 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
852 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
853 if (er_flags & QR_UPLOAD)
855 wprintf("> Uploading allowed\n");
857 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
858 if (er_flags & QR_DOWNLOAD)
860 wprintf("> Downloading allowed\n");
862 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
863 if (er_flags & QR_VISDIR)
865 wprintf("> Visible directory</UL>\n");
867 /* end of directory stuff */
869 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
870 if (er_flags & QR_NETWORK)
872 wprintf("> Network shared room\n");
874 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
875 if (er_flags & QR_PERMANENT)
877 wprintf("> Permanent (does not auto-purge)\n");
879 /* start of anon options */
881 wprintf("<LI>Anonymous messages<UL>\n");
883 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
884 if (((er_flags & QR_ANONONLY) == 0)
885 && ((er_flags & QR_ANONOPT) == 0))
887 wprintf("> No anonymous messages\n");
889 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
890 if (er_flags & QR_ANONONLY)
892 wprintf("> All messages are anonymous\n");
894 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
895 if (er_flags & QR_ANONOPT)
897 wprintf("> Prompt user when entering messages</UL>\n");
899 /* end of anon options */
901 wprintf("<LI>Room aide: \n");
905 wprintf("<EM>%s</EM>\n", &buf[4]);
907 extract(er_roomaide, &buf[4], 0);
908 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
911 wprintf("</UL><CENTER>\n");
912 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
913 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
915 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
921 /* Sharing the room with other Citadel nodes... */
922 if (!strcmp(tab, "sharing")) {
924 shared_with = strdup("");
925 not_shared_with = strdup("");
927 /* Learn the current configuration */
928 serv_puts("CONF getsys|application/x-citadel-ignet-config");
930 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
931 extract(node, buf, 0);
932 not_shared_with = realloc(not_shared_with,
933 strlen(not_shared_with) + 32);
934 strcat(not_shared_with, node);
935 strcat(not_shared_with, "|");
940 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
941 extract(cmd, buf, 0);
942 extract(node, buf, 1);
943 if (!strcasecmp(cmd, "ignet_push_share")) {
944 shared_with = realloc(shared_with,
945 strlen(shared_with) + 32);
946 strcat(shared_with, node);
947 strcat(shared_with, "|");
951 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
952 extract(node, shared_with, i);
953 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
954 extract(cmd, not_shared_with, j);
955 if (!strcasecmp(node, cmd)) {
956 remove_token(not_shared_with, j, '|');
961 /* Display the stuff */
962 wprintf("<CENTER><BR>"
963 "<TABLE border=1 cellpadding=5><TR>"
964 "<TD><B><I>Shared with</I></B></TD>"
965 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
968 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
969 extract(node, shared_with, i);
970 if (strlen(node) > 0) {
971 wprintf("%s ", node);
972 wprintf("<A HREF=\"/netedit&cmd=remove&line="
973 "ignet_push_share|");
975 wprintf("&tab=sharing\">(unshare)</A><BR>");
979 wprintf("</TD><TD>\n");
981 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
982 extract(node, not_shared_with, i);
983 if (strlen(node) > 0) {
984 wprintf("%s ", node);
985 wprintf("<A HREF=\"/netedit&cmd=add&line="
986 "ignet_push_share|");
988 wprintf("&tab=sharing\">(share)</A><BR>");
994 "<I><B>Reminder:</B> When sharing a room, "
995 "it must be shared from both ends. Adding a node to "
996 "the 'shared' list sends messages out, but in order to"
997 " receive messages, the other nodes must be configured"
998 " to send messages out to your system as well.</I><BR>"
1003 /* Mailing list management */
1004 if (!strcmp(tab, "listserv")) {
1006 wprintf("<BR><center>"
1007 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1008 "<TR><TD VALIGN=TOP>");
1010 wprintf("<i>The contents of this room are being "
1011 "mailed <b>as individual messages</b> "
1012 "to the following list recipients:"
1017 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1018 extract(cmd, buf, 0);
1019 if (!strcasecmp(cmd, "listrecp")) {
1020 extract(recp, buf, 1);
1023 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1026 wprintf("&tab=listserv\">(remove)</A><BR>");
1030 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1031 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1032 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1033 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1034 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1035 wprintf("</FORM>\n");
1037 wprintf("</TD><TD VALIGN=TOP>\n");
1039 wprintf("<i>The contents of this room are being "
1040 "mailed <b>in digest form</b> "
1041 "to the following list recipients:"
1046 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1047 extract(cmd, buf, 0);
1048 if (!strcasecmp(cmd, "digestrecp")) {
1049 extract(recp, buf, 1);
1052 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1055 wprintf("&tab=listserv\">(remove)</A><BR>");
1059 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1060 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1061 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1062 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1063 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1064 wprintf("</FORM>\n");
1066 wprintf("</TD></TR></TABLE><HR>\n");
1068 if (self_service(999) == 1) {
1069 wprintf("This room is configured to allow "
1070 "self-service subscribe/unsubscribe requests."
1071 " <A HREF=\"/toggle_self_service?newval=0&"
1073 "Click to disable.</A><BR>\n"
1074 "The URL for subscribe/unsubscribe is: "
1075 "<TT>http://%s/listsub</TT><BR>\n",
1080 wprintf("This room is <i>not</i> configured to allow "
1081 "self-service subscribe/unsubscribe requests."
1082 " <A HREF=\"/toggle_self_service?newval=1&"
1084 "Click to enable.</A><BR>\n"
1089 wprintf("</CENTER>\n");
1093 /* Mailing list management */
1094 if (!strcmp(tab, "expire")) {
1096 serv_puts("GPEX room");
1098 if (buf[0] == '2') {
1099 roompolicy = extract_int(&buf[4], 0);
1100 roomvalue = extract_int(&buf[4], 1);
1103 serv_puts("GPEX floor");
1105 if (buf[0] == '2') {
1106 floorpolicy = extract_int(&buf[4], 0);
1107 floorvalue = extract_int(&buf[4], 1);
1110 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1111 wprintf("<TABLE border=0 cellspacing=5>\n");
1112 wprintf("<TR><TD>Message expire policy for this room<BR>(");
1113 escputs(WC->wc_roomname);
1114 wprintf(")</TD><TD>");
1115 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1116 ((roompolicy == 0) ? "CHECKED" : "") );
1117 wprintf("Use the default policy for this floor<BR>\n");
1118 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1119 ((roompolicy == 1) ? "CHECKED" : "") );
1120 wprintf("Never automatically expire messages<BR>\n");
1121 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1122 ((roompolicy == 2) ? "CHECKED" : "") );
1123 wprintf("Expire by message count<BR>\n");
1124 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1125 ((roompolicy == 3) ? "CHECKED" : "") );
1126 wprintf("Expire by message age<BR>");
1127 wprintf("Number of messages or days: ");
1128 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1129 wprintf("</TD></TR>\n");
1131 if (WC->axlevel >= 6) {
1132 wprintf("<TR><TD COLSPAN=2><HR></TD></TR>\n");
1133 wprintf("<TR><TD>Message expire policy for this floor<BR>(");
1134 escputs(floorlist[WC->wc_floor]);
1135 wprintf(")</TD><TD>");
1136 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1137 ((floorpolicy == 0) ? "CHECKED" : "") );
1138 wprintf("Use the system default<BR>\n");
1139 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1140 ((floorpolicy == 1) ? "CHECKED" : "") );
1141 wprintf("Never automatically expire messages<BR>\n");
1142 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1143 ((floorpolicy == 2) ? "CHECKED" : "") );
1144 wprintf("Expire by message count<BR>\n");
1145 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1146 ((floorpolicy == 3) ? "CHECKED" : "") );
1147 wprintf("Expire by message age<BR>");
1148 wprintf("Number of messages or days: ");
1149 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1153 wprintf("<CENTER>\n");
1154 wprintf("<TR><TD COLSPAN=2><HR><CENTER>\n");
1155 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1157 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1158 wprintf("</CENTER></TD><TR>\n");
1160 wprintf("</TABLE>\n"
1161 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1168 /* end content of whatever tab is open now */
1169 wprintf("</TD></TR></TABLE>\n");
1176 * Toggle self-service list subscription
1178 void toggle_self_service(void) {
1181 newval = atoi(bstr("newval"));
1182 self_service(newval);
1189 * save new parameters for a room
1195 char er_password[10];
1196 char er_dirname[15];
1197 char er_roomaide[26];
1203 if (strcmp(bstr("sc"), "OK")) {
1204 strcpy(WC->ImportantMessage,
1205 "Cancelled. Changes were not saved.");
1212 if (buf[0] != '2') {
1213 strcpy(WC->ImportantMessage, &buf[4]);
1217 extract(er_name, &buf[4], 0);
1218 extract(er_password, &buf[4], 1);
1219 extract(er_dirname, &buf[4], 2);
1220 er_flags = extract_int(&buf[4], 3);
1222 strcpy(er_roomaide, bstr("er_roomaide"));
1223 if (strlen(er_roomaide) == 0) {
1226 if (buf[0] != '2') {
1227 strcpy(er_roomaide, "");
1229 extract(er_roomaide, &buf[4], 0);
1232 strcpy(buf, bstr("er_name"));
1234 if (strlen(buf) > 0)
1235 strcpy(er_name, buf);
1237 strcpy(buf, bstr("er_password"));
1239 if (strlen(buf) > 0)
1240 strcpy(er_password, buf);
1242 strcpy(buf, bstr("er_dirname"));
1244 if (strlen(buf) > 0)
1245 strcpy(er_dirname, buf);
1247 strcpy(buf, bstr("type"));
1248 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1250 if (!strcmp(buf, "invonly")) {
1251 er_flags |= (QR_PRIVATE);
1253 if (!strcmp(buf, "guessname")) {
1254 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1256 if (!strcmp(buf, "passworded")) {
1257 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1259 if (!strcmp(bstr("prefonly"), "yes")) {
1260 er_flags |= QR_PREFONLY;
1262 er_flags &= ~QR_PREFONLY;
1265 if (!strcmp(bstr("readonly"), "yes")) {
1266 er_flags |= QR_READONLY;
1268 er_flags &= ~QR_READONLY;
1271 if (!strcmp(bstr("permanent"), "yes")) {
1272 er_flags |= QR_PERMANENT;
1274 er_flags &= ~QR_PERMANENT;
1277 if (!strcmp(bstr("network"), "yes")) {
1278 er_flags |= QR_NETWORK;
1280 er_flags &= ~QR_NETWORK;
1283 if (!strcmp(bstr("directory"), "yes")) {
1284 er_flags |= QR_DIRECTORY;
1286 er_flags &= ~QR_DIRECTORY;
1289 if (!strcmp(bstr("ulallowed"), "yes")) {
1290 er_flags |= QR_UPLOAD;
1292 er_flags &= ~QR_UPLOAD;
1295 if (!strcmp(bstr("dlallowed"), "yes")) {
1296 er_flags |= QR_DOWNLOAD;
1298 er_flags &= ~QR_DOWNLOAD;
1301 if (!strcmp(bstr("visdir"), "yes")) {
1302 er_flags |= QR_VISDIR;
1304 er_flags &= ~QR_VISDIR;
1307 strcpy(buf, bstr("anon"));
1309 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1310 if (!strcmp(buf, "anononly"))
1311 er_flags |= QR_ANONONLY;
1312 if (!strcmp(buf, "anon2"))
1313 er_flags |= QR_ANONOPT;
1316 if (!strcmp(bstr("bump"), "yes"))
1319 er_floor = atoi(bstr("er_floor"));
1321 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1322 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1325 if (buf[0] != '2') {
1326 strcpy(WC->ImportantMessage, &buf[4]);
1332 if (strlen(er_roomaide) > 0) {
1333 sprintf(buf, "SETA %s", er_roomaide);
1336 if (buf[0] != '2') {
1337 strcpy(WC->ImportantMessage, &buf[4]);
1338 display_main_menu();
1343 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1349 * Invite, Kick, and show Who Knows a room
1351 void display_whok(void)
1353 char buf[SIZ], room[SIZ], username[SIZ];
1358 if (buf[0] != '2') {
1359 strcpy(WC->ImportantMessage, &buf[4]);
1360 display_main_menu();
1363 extract(room, &buf[4], 0);
1365 strcpy(username, bstr("username"));
1367 if(!strcmp(bstr("sc"), "Kick")) {
1368 sprintf(buf, "KICK %s", username);
1372 if (buf[0] != '2') {
1373 strcpy(WC->ImportantMessage, &buf[4]);
1375 sprintf(WC->ImportantMessage,
1376 "<B><I>User %s kicked out of room %s.</I></B>\n",
1379 } else if(!strcmp(bstr("sc"), "Invite")) {
1380 sprintf(buf, "INVT %s", username);
1384 if (buf[0] != '2') {
1385 strcpy(WC->ImportantMessage, &buf[4]);
1387 sprintf(WC->ImportantMessage,
1388 "<B><I>User %s invited to room %s.</I></B>\n",
1394 stresc(buf, WC->wc_roomname, 1, 1);
1395 svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
1396 do_template("beginbox");
1398 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1399 "<TD>The users listed below have access to this room. "
1400 "To remove a user from the access list, select the user "
1401 "name from the list and click 'Kick'.<BR><BR>");
1403 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1404 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1407 if (buf[0] == '1') {
1408 while (serv_gets(buf), strcmp(buf, "000")) {
1409 extract(username, buf, 0);
1410 wprintf("<OPTION>");
1415 wprintf("</SELECT><BR>\n");
1417 wprintf("<input type=submit name=sc value=\"Kick\">");
1418 wprintf("</FORM></CENTER>\n");
1421 "To grant another user access to this room, enter the "
1422 "user name in the box below and click 'Invite'.<BR><BR>");
1424 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1425 wprintf("Invite: ");
1426 wprintf("<input type=text name=username><BR>\n"
1427 "<input type=hidden name=sc value=\"Invite\">"
1428 "<input type=submit value=\"Invite\">"
1429 "</FORM></CENTER>\n");
1431 wprintf("</TD></TR></TABLE>\n");
1432 do_template("endbox");
1439 * display the form for entering a new room
1441 void display_entroom(void)
1446 serv_puts("CRE8 0");
1449 if (buf[0] != '2') {
1450 strcpy(WC->ImportantMessage, &buf[4]);
1451 display_main_menu();
1455 svprintf("BOXTITLE", WCS_STRING, "Create a new room");
1456 do_template("beginbox");
1458 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1460 wprintf("<UL><LI>Name of room: ");
1461 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1463 wprintf("<LI>Resides on floor: ");
1465 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1466 for (i = 0; i < 128; ++i)
1467 if (strlen(floorlist[i]) > 0) {
1468 wprintf("<OPTION ");
1469 wprintf("VALUE=\"%d\">", i);
1470 escputs(floorlist[i]);
1471 wprintf("</OPTION>\n");
1473 wprintf("</SELECT>\n");
1475 wprintf("<LI>Type of room:<UL>\n");
1477 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1478 wprintf("CHECKED > Public room\n");
1480 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1481 wprintf("> Private - guess name\n");
1483 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1484 wprintf("> Private - require password:\n");
1485 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1487 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1488 wprintf("> Private - invitation only\n");
1490 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1491 wprintf("> Personal (mailbox for you only)\n");
1494 wprintf("<LI>Default view for room: "); /* FOO */
1495 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1496 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1497 wprintf("<OPTION %s VALUE=\"%d\">",
1498 ((i == 0) ? "SELECTED" : ""), i );
1499 escputs(viewdefs[i]);
1500 wprintf("</OPTION>\n");
1502 wprintf("</SELECT>\n");
1504 wprintf("<CENTER>\n");
1505 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1507 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1508 wprintf("</CENTER>\n");
1509 wprintf("</FORM>\n<HR>");
1510 serv_printf("MESG roomaccess");
1512 if (buf[0] == '1') {
1513 fmout(NULL, "CENTER");
1515 do_template("endbox");
1523 * support function for entroom() -- sets the default view
1525 void er_set_default_view(int newview) {
1539 if (buf[0] != '2') return;
1541 extract(rm_name, &buf[4], 0);
1542 extract(rm_pass, &buf[4], 1);
1543 extract(rm_dir, &buf[4], 2);
1544 rm_bits1 = extract_int(&buf[4], 3);
1545 rm_floor = extract_int(&buf[4], 4);
1546 rm_listorder = extract_int(&buf[4], 5);
1547 rm_bits2 = extract_int(&buf[4], 7);
1549 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1550 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1551 rm_listorder, newview, rm_bits2
1566 char er_password[SIZ];
1571 if (strcmp(bstr("sc"), "OK")) {
1572 strcpy(WC->ImportantMessage,
1573 "Cancelled. No new room was created.");
1574 display_main_menu();
1577 strcpy(er_name, bstr("er_name"));
1578 strcpy(er_type, bstr("type"));
1579 strcpy(er_password, bstr("er_password"));
1580 er_floor = atoi(bstr("er_floor"));
1581 er_view = atoi(bstr("er_view"));
1584 if (!strcmp(er_type, "guessname"))
1586 if (!strcmp(er_type, "passworded"))
1588 if (!strcmp(er_type, "invonly"))
1590 if (!strcmp(er_type, "personal"))
1593 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1594 er_name, er_num_type, er_password, er_floor, 0, er_view);
1597 if (buf[0] != '2') {
1598 strcpy(WC->ImportantMessage, &buf[4]);
1599 display_main_menu();
1603 do_change_view(er_view); /* Now go there */
1608 * display the screen to enter a private room
1610 void display_private(char *rname, int req_pass)
1615 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1616 do_template("beginbox");
1618 wprintf("<CENTER>\n");
1619 wprintf("<BR>If you know the name of a hidden (guess-name) or\n");
1620 wprintf("passworded room, you can enter that room by typing\n");
1621 wprintf("its name below. Once you gain access to a private\n");
1622 wprintf("room, it will appear in your regular room listings\n");
1623 wprintf("so you don't have to keep returning here.\n");
1624 wprintf("<BR><BR>");
1626 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1628 wprintf("<table border=\"0\" cellspacing=\"5\" "
1629 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1631 "Enter room name:</TD><TD>"
1632 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1633 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1636 wprintf("</TD></TR><TR><TD>");
1637 wprintf("Enter room password:</TD><TD>");
1638 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1640 wprintf("</TD></TR></TABLE><BR>\n");
1642 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1644 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1645 wprintf("</FORM>\n");
1646 do_template("endbox");
1651 * goto a private room
1653 void goto_private(void)
1658 if (strcasecmp(bstr("sc"), "OK")) {
1659 display_main_menu();
1662 strcpy(hold_rm, WC->wc_roomname);
1663 strcpy(buf, "GOTO ");
1664 strcat(buf, bstr("gr_name"));
1666 strcat(buf, bstr("gr_pass"));
1670 if (buf[0] == '2') {
1671 smart_goto(bstr("gr_name"));
1674 if (!strncmp(buf, "540", 3)) {
1675 display_private(bstr("gr_name"), 1);
1679 wprintf("%s\n", &buf[4]);
1686 * display the screen to zap a room
1688 void display_zap(void)
1692 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1693 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget) the current room</SPAN>\n");
1694 wprintf("</TD></TR></TABLE>\n");
1696 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1697 wprintf("disappear from your room list. Is this what you wish ");
1698 wprintf("to do?<BR>\n");
1700 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1701 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1703 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1704 wprintf("</FORM>\n");
1715 char final_destination[SIZ];
1717 /* If the forget-room routine fails for any reason, we fall back
1718 * to the current room; otherwise, we go to the Lobby
1720 strcpy(final_destination, WC->wc_roomname);
1722 if (!strcasecmp(bstr("sc"), "OK")) {
1723 serv_printf("GOTO %s", WC->wc_roomname);
1725 if (buf[0] != '2') {
1726 /* ExpressMessageCat(&buf[4]); */
1730 if (buf[0] != '2') {
1731 /* ExpressMessageCat(&buf[4]); */
1733 strcpy(final_destination, "_BASEROOM_");
1737 smart_goto(final_destination);
1744 * Confirm deletion of the current room
1746 void confirm_delete_room(void)
1750 serv_puts("KILL 0");
1752 if (buf[0] != '2') {
1753 strcpy(WC->ImportantMessage, &buf[4]);
1754 display_main_menu();
1758 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1759 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1760 wprintf("</TD></TR></TABLE>\n");
1762 wprintf("<CENTER>");
1763 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1765 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1766 escputs(WC->wc_roomname);
1767 wprintf("</FONT>?<BR>\n");
1769 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1770 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1772 wprintf("</FORM></CENTER>\n");
1778 * Delete the current room
1780 void delete_room(void)
1785 strcpy(sc, bstr("sc"));
1787 if (strcasecmp(sc, "Delete")) {
1788 strcpy(WC->ImportantMessage,
1789 "Cancelled. This room was not deleted.");
1790 display_main_menu();
1793 serv_puts("KILL 1");
1795 if (buf[0] != '2') {
1796 strcpy(WC->ImportantMessage, &buf[4]);
1797 display_main_menu();
1800 smart_goto("_BASEROOM_");
1807 * Perform changes to a room's network configuration
1809 void netedit(void) {
1814 if (strlen(bstr("line"))==0) {
1819 strcpy(line, bstr("prefix"));
1820 strcat(line, bstr("line"));
1821 strcat(line, bstr("suffix"));
1831 if (buf[0] != '1') {
1837 /* This loop works for add *or* remove. Spiffy, eh? */
1838 while (serv_gets(buf), strcmp(buf, "000")) {
1839 if (strcasecmp(buf, line)) {
1840 fprintf(fp, "%s\n", buf);
1847 if (buf[0] != '4') {
1853 while (fgets(buf, sizeof buf, fp) != NULL) {
1854 buf[strlen(buf)-1] = 0;
1858 if (!strcasecmp(bstr("cmd"), "add")) {
1870 * Convert a room name to a folder-ish-looking name.
1872 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
1877 * For mailboxes, just do it straight...
1880 sprintf(folder, "My folders|%s", room);
1884 * Otherwise, prefix the floor name as a "public folders" moniker
1887 sprintf(folder, "%s|%s", floorlist[floor], room);
1891 * Replace "\" characters with "|" for pseudo-folder-delimiting
1893 for (i=0; i<strlen(folder); ++i) {
1894 if (folder[i] == '\\') folder[i] = '|';
1902 * Back end for change_view()
1904 void do_change_view(int newview) {
1907 serv_printf("VIEW %d", newview);
1909 WC->wc_view = newview;
1910 smart_goto(WC->wc_roomname);
1916 * Change the view for this room
1918 void change_view(void) {
1921 view = atol(bstr("view"));
1922 do_change_view(view);
1927 * One big expanded tree list view --- like a folder list
1929 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
1931 int levels, oldlevels;
1934 int has_subfolders = 0;
1936 /* Include the menu expanding/collapsing code */
1937 wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
1939 do_template("beginbox_nt");
1940 wprintf("<div id=\"mainMenu\">\n");
1941 wprintf("<UL id=\"menuList\">\n");
1945 for (i=0; i<max_folders; ++i) {
1948 if ((i+1) < max_folders) {
1949 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
1950 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
1955 levels = num_tokens(fold[i].name, '|');
1957 if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
1958 for (t=0; t<(oldlevels-levels); ++t) {
1963 if (has_subfolders) {
1965 if (levels == 1) wprintf(" class=\"menubar\"");
1967 wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
1973 if (fold[i].selectable) {
1974 wprintf("<A HREF=\"/dotgoto?room=");
1975 urlescputs(fold[i].room);
1980 wprintf("<SPAN CLASS=\"roomlist_floor\">");
1982 else if (fold[i].hasnewmsgs) {
1983 wprintf("<SPAN CLASS=\"roomlist_new\">");
1986 wprintf("<SPAN CLASS=\"roomlist_old\">");
1988 extract(buf, fold[i].name, levels-1);
1992 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
1993 wprintf(" (INBOX)");
1996 if (fold[i].selectable) {
2001 if (has_subfolders) {
2002 wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
2004 ( (levels == 1) ? "menu" : "submenu")
2010 wprintf("</UL></UL>\n");
2011 wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
2012 for (i=0; i<actnum; ++i) {
2013 wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
2016 wprintf("</DIV>\n");
2017 do_template("endbox");
2021 * Boxes and rooms and lists ... oh my!
2023 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2026 int levels, oldlevels;
2029 static int columns = 3;
2030 int boxes_per_column = 0;
2031 int current_column = 0;
2035 while (nf % columns != 0) ++nf;
2036 boxes_per_column = (nf / columns);
2037 if (boxes_per_column < 1) boxes_per_column = 1;
2039 /* Outer table (for columnization) */
2040 wprintf("<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
2041 "<TR><TD VALIGN=TOP>");
2045 for (i=0; i<max_folders; ++i) {
2047 levels = num_tokens(fold[i].name, '|');
2049 if ((levels == 1) && (oldlevels > 1)) {
2052 do_template("endbox");
2055 if ((num_boxes % boxes_per_column) == 0) {
2057 if (current_column < columns) {
2058 wprintf("</TD><TD VALIGN=TOP>\n");
2065 /* Begin inner box */
2066 extract(buf, fold[i].name, levels-1);
2067 stresc(boxtitle, buf, 1, 0);
2068 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2069 do_template("beginbox");
2077 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2078 if (fold[i].selectable) {
2079 wprintf("<A HREF=\"/dotgoto?room=");
2080 urlescputs(fold[i].room);
2086 if (fold[i].hasnewmsgs) {
2087 wprintf("<SPAN CLASS=\"roomlist_new\">");
2090 wprintf("<SPAN CLASS=\"roomlist_old\">");
2092 extract(buf, fold[i].name, levels-1);
2095 if (fold[i].selectable) {
2101 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2102 wprintf(" (INBOX)");
2107 /* End the final inner box */
2108 do_template("endbox");
2110 wprintf("</TD></TR></TABLE>\n");
2115 * Show the room list. (only should get called by
2116 * knrooms() because that's where output_headers() is called from)
2119 void list_all_rooms_by_floor(char *viewpref) {
2122 struct folder *fold = NULL;
2124 int max_folders = 0;
2125 int alloc_folders = 0;
2129 int num_floors = 1; /* add an extra one for private folders */
2131 /* Start with the mailboxes */
2134 fold = malloc(sizeof(struct folder));
2135 memset(fold, 0, sizeof(struct folder));
2136 strcpy(fold[0].name, "My folders");
2137 fold[0].is_mailbox = 1;
2139 /* Then add floors */
2142 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2143 if (max_folders >= alloc_folders) {
2144 alloc_folders = max_folders + 100;
2145 fold = realloc(fold,
2146 alloc_folders * sizeof(struct folder));
2148 memset(&fold[max_folders], 0, sizeof(struct folder));
2149 extract(fold[max_folders].name, buf, 1);
2157 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2158 if (max_folders >= alloc_folders) {
2159 alloc_folders = max_folders + 100;
2160 fold = realloc(fold,
2161 alloc_folders * sizeof(struct folder));
2163 memset(&fold[max_folders], 0, sizeof(struct folder));
2164 extract(fold[max_folders].room, buf, 0);
2165 ra_flags = extract_int(buf, 5);
2166 flags = extract_int(buf, 1);
2167 fold[max_folders].floor = extract_int(buf, 2);
2168 fold[max_folders].hasnewmsgs =
2169 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2170 if (flags & QR_MAILBOX) {
2171 fold[max_folders].is_mailbox = 1;
2173 room_to_folder(fold[max_folders].name,
2174 fold[max_folders].room,
2175 fold[max_folders].floor,
2176 fold[max_folders].is_mailbox);
2177 fold[max_folders].selectable = 1;
2181 /* Bubble-sort the folder list */
2182 for (i=0; i<max_folders; ++i) {
2183 for (j=0; j<(max_folders-1)-i; ++j) {
2184 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2185 swap = strcasecmp(fold[j].name, fold[j+1].name);
2188 if ( (fold[j+1].is_mailbox)
2189 && (!fold[j].is_mailbox)) {
2197 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2198 memcpy(&fold[j], &fold[j+1],
2199 sizeof(struct folder));
2200 memcpy(&fold[j+1], &ftmp,
2201 sizeof(struct folder));
2206 if (!strcasecmp(viewpref, "folders")) {
2207 do_folder_view(fold, max_folders, num_floors);
2210 do_rooms_view(fold, max_folders, num_floors);
2218 /* Do either a known rooms list or a folders list, depending on the
2222 char listviewpref[SIZ];
2227 /* Determine whether the user is trying to change views */
2228 if (bstr("view") != NULL) {
2229 if (strlen(bstr("view")) > 0) {
2230 set_preference("roomlistview", bstr("view"));
2234 get_preference("roomlistview", listviewpref);
2236 if ( (strcasecmp(listviewpref, "folders"))
2237 && (strcasecmp(listviewpref, "table")) ) {
2238 strcpy(listviewpref, "rooms");
2242 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2243 "<SPAN CLASS=\"titlebar\">"
2245 if (!strcasecmp(listviewpref, "rooms")) {
2246 wprintf("Room list");
2248 if (!strcasecmp(listviewpref, "folders")) {
2249 wprintf("Folder list");
2251 if (!strcasecmp(listviewpref, "table")) {
2252 wprintf("Room list");
2254 wprintf("</SPAN></TD>\n");
2257 /* offer the ability to switch views */
2258 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2259 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2260 "OnChange=\"location.href=roomlistomatic.newview.options"
2261 "[selectedIndex].value\">\n");
2263 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2266 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2269 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2270 "View as folder list"
2272 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2275 wprintf("</SELECT><BR>");
2277 wprintf("</FORM></TD></TR></TABLE>\n");
2279 /* Display the room list in the user's preferred format */
2280 list_all_rooms_by_floor(listviewpref);
2286 * Set the message expire policy for this room and/or floor
2288 void set_room_policy(void) {
2291 if (strcmp(bstr("sc"), "OK")) {
2292 strcpy(WC->ImportantMessage,
2293 "Cancelled. Changes were not saved.");
2298 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2300 strcpy(WC->ImportantMessage, &buf[4]);
2302 if (WC->axlevel >= 6) {
2303 strcat(WC->ImportantMessage, "<BR>\n");
2304 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2306 strcat(WC->ImportantMessage, &buf[4]);