10 #include <sys/types.h>
12 #include <sys/socket.h>
15 #include <netinet/in.h>
42 char floorlist[128][SIZ];
45 * load the list of floors
47 void load_floorlist(void)
52 for (a = 0; a < 128; ++a)
58 strcpy(floorlist[0], "Main Floor");
61 while (serv_gets(buf), strcmp(buf, "000")) {
62 extract(floorlist[extract_int(buf, 0)], buf, 1);
68 * remove a room from the march list
70 void remove_march(char *aaa)
72 struct march *mptr, *mptr2;
74 if (WC->march == NULL)
77 if (!strcasecmp(WC->march->march_name, aaa)) {
78 mptr = WC->march->next;
84 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
85 if (!strcasecmp(mptr->march_name, aaa)) {
86 mptr2->next = mptr->next;
99 void room_tree_list(struct roomlisting *rp)
108 room_tree_list(rp->lnext);
110 strcpy(rmname, rp->rlname);
113 wprintf("<A HREF=\"/dotgoto&room=");
117 escputs1(rmname, 1, 1);
118 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
120 else if (f & QR_DIRECTORY)
122 else if (f & QR_NETWORK)
126 wprintf("</A><TT> </TT>\n");
128 room_tree_list(rp->rnext);
134 * Room ordering stuff (compare first by floor, then by order)
136 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
138 if ((r1 == NULL) && (r2 == NULL))
144 if (r1->rlfloor < r2->rlfloor)
146 if (r1->rlfloor > r2->rlfloor)
148 if (r1->rlorder < r2->rlorder)
150 if (r1->rlorder > r2->rlorder)
157 * Common code for all room listings
159 void listrms(char *variety)
164 struct roomlisting *rl = NULL;
165 struct roomlisting *rp;
166 struct roomlisting *rs;
169 /* Ask the server for a room list */
176 while (serv_gets(buf), strcmp(buf, "000")) {
178 rp = malloc(sizeof(struct roomlisting));
179 extract(rp->rlname, buf, 0);
180 rp->rlflags = extract_int(buf, 1);
181 rp->rlfloor = extract_int(buf, 2);
182 rp->rlorder = extract_int(buf, 3);
191 if (rordercmp(rp, rs) < 0) {
192 if (rs->lnext == NULL) {
199 if (rs->rnext == NULL) {
211 /* If no rooms were listed, print an nbsp to make the cell
212 * borders show up anyway.
214 if (num_rooms == 0) wprintf(" ");
219 * list all forgotten rooms
221 void zapped_list(void)
225 svprintf("BOXTITLE", WCS_STRING, "Zapped (forgotten) rooms");
226 do_template("beginbox");
230 wprintf("<BR><BR>\n");
231 wprintf("Click on any room to un-zap it and goto that room.\n");
232 do_template("endbox");
238 * read this room's info file (set v to 1 for verbose mode)
247 fmout(NULL, "CENTER");
254 /* Display room graphic. The server doesn't actually
255 * need the room name, but we supply it in order to
256 * keep the browser from using a cached graphic from
259 void embed_room_graphic(void) {
262 serv_puts("OIMG _roompic_");
265 wprintf("<TD BGCOLOR=\"#444455\">");
266 wprintf("<IMG HEIGHT=64 SRC=\"/image&name=_roompic_&room=");
267 urlescputs(WC->wc_roomname);
276 /* Let the user know if new mail has arrived
278 void embed_newmail_button(void) {
279 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
281 "<A HREF=\"/dotgoto?room=_MAIL_\">"
282 "<IMG SRC=\"/static/mail.gif\" border=0 "
283 "ALT=\"You have new mail\">"
284 "<BR><SPAN CLASS=\"youhavemail\">"
285 "%d new mail</SPAN></A>", WC->new_mail);
286 WC->remember_new_mail = WC->new_mail;
293 * Display the current view and offer an option to change it
295 void embed_view_o_matic(void) {
298 wprintf("<FORM NAME=\"viewomatic\">\n"
299 "<SELECT NAME=\"newview\" SIZE=\"1\" "
300 "OnChange=\"location.href=viewomatic.newview.options"
301 "[selectedIndex].value\">\n");
303 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
305 * Only offer the views that make sense, given the default
306 * view for the room. For example, don't offer a Calendar
307 * view in a non-Calendar room.
311 || (i == WC->wc_default_view)
312 || ( (i == 0) && (WC->wc_default_view == 1) )
313 || ( (i == 1) && (WC->wc_default_view == 0) )
316 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
317 ((i == WC->wc_view) ? "SELECTED" : ""),
319 escputs(viewdefs[i]);
320 wprintf("</OPTION>\n");
323 wprintf("</SELECT></FORM>\n");
328 void embed_room_banner(char *got) {
331 /* We need to have the information returned by a GOTO server command.
332 * If it isn't supplied, we fake it by issuing our own GOTO.
335 serv_printf("GOTO %s", WC->wc_roomname);
340 /* If the user happens to select the "make this my start page" link,
341 * we want it to remember the URL as a "/dotskip" one instead of
342 * a "skip" or "gotonext" or something like that.
344 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
347 /* Check for new mail. */
348 WC->new_mail = extract_int(&got[4], 9);
349 WC->wc_view = extract_int(&got[4], 11);
351 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
352 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
353 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
354 svcallback("ROOMPIC", embed_room_graphic);
355 svcallback("ROOMINFO", readinfo);
356 svcallback("YOUHAVEMAIL", embed_newmail_button);
357 svcallback("VIEWOMATIC", embed_view_o_matic);
358 svcallback("START", offer_start_page);
360 do_template("roombanner");
361 clear_local_substs();
369 * back end routine to take the session to a new room
372 void gotoroom(char *gname)
375 static long ls = (-1L);
377 /* store ungoto information */
378 strcpy(WC->ugname, WC->wc_roomname);
381 /* move to the new room */
382 serv_printf("GOTO %s", gname);
385 serv_puts("GOTO _BASEROOM_");
391 extract(WC->wc_roomname, &buf[4], 0);
392 WC->room_flags = extract_int(&buf[4], 4);
393 /* highest_msg_read = extract_int(&buf[4],6);
394 maxmsgnum = extract_int(&buf[4],5);
395 is_mail = (char) extract_int(&buf[4],7); */
396 ls = extract_long(&buf[4], 6);
397 WC->wc_floor = extract_int(&buf[4], 10);
398 WC->wc_view = extract_int(&buf[4], 11);
399 WC->wc_default_view = extract_int(&buf[4], 12);
402 WC->is_room_aide = WC->is_aide;
404 WC->is_room_aide = (char) extract_int(&buf[4], 8);
406 remove_march(WC->wc_roomname);
407 if (!strcasecmp(gname, "_BASEROOM_"))
413 * Locate the room on the march list which we most want to go to. Each room
414 * is measured given a "weight" of preference based on various factors.
416 char *pop_march(int desired_floor)
418 static char TheRoom[128];
420 int TheOrder = 32767;
423 struct march *mptr = NULL;
425 strcpy(TheRoom, "_BASEROOM_");
426 if (WC->march == NULL)
429 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
431 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
432 weight = weight + 10000;
433 if (mptr->march_floor == desired_floor)
434 weight = weight + 5000;
436 weight = weight + ((128 - (mptr->march_floor)) * 128);
437 weight = weight + (128 - (mptr->march_order));
439 if (weight > TheWeight) {
441 strcpy(TheRoom, mptr->march_name);
442 TheFloor = mptr->march_floor;
443 TheOrder = mptr->march_order;
451 /* Goto next room having unread messages.
452 * We want to skip over rooms that the user has already been to, and take the
453 * user back to the lobby when done. The room we end up in is placed in
454 * newroom - which is set to 0 (the lobby) initially.
455 * We start the search in the current room rather than the beginning to prevent
456 * two or more concurrent users from dragging each other back to the same room.
461 struct march *mptr, *mptr2;
464 /* First check to see if the march-mode list is already allocated.
465 * If it is, pop the first room off the list and go there.
468 if (WC->march == NULL) {
472 while (serv_gets(buf), strcmp(buf, "000")) {
473 mptr = (struct march *) malloc(sizeof(struct march));
475 extract(mptr->march_name, buf, 0);
476 mptr->march_floor = extract_int(buf, 2);
477 mptr->march_order = extract_int(buf, 3);
478 if (WC->march == NULL) {
482 while (mptr2->next != NULL)
487 /* add _BASEROOM_ to the end of the march list, so the user will end up
488 * in the system base room (usually the Lobby>) at the end of the loop
490 mptr = (struct march *) malloc(sizeof(struct march));
492 strcpy(mptr->march_name, "_BASEROOM_");
493 if (WC->march == NULL) {
497 while (mptr2->next != NULL)
502 * ...and remove the room we're currently in, so a <G>oto doesn't make us
503 * walk around in circles
505 remove_march(WC->wc_roomname);
507 if (WC->march != NULL) {
508 strcpy(next_room, pop_march(-1));
510 strcpy(next_room, "_BASEROOM_");
514 smart_goto(next_room);
518 void smart_goto(char *next_room) {
526 * mark all messages in current room as having been read
528 void slrp_highest(void)
533 serv_puts("SLRP HIGHEST");
536 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
543 * un-goto the previous room
549 if (!strcmp(WC->ugname, "")) {
550 smart_goto(WC->wc_roomname);
553 serv_printf("GOTO %s", WC->ugname);
556 smart_goto(WC->wc_roomname);
559 if (WC->uglsn >= 0L) {
560 serv_printf("SLRP %ld", WC->uglsn);
563 strcpy(buf, WC->ugname);
564 strcpy(WC->ugname, "");
573 * Set/clear/read the "self-service list subscribe" flag for a room
575 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
576 * Always returns the new value.
579 int self_service(int newval) {
580 int current_value = 0;
586 int flags, floor, order, view, flags2;
590 if (buf[0] != '2') return(0);
592 extract(name, &buf[4], 0);
593 extract(password, &buf[4], 1);
594 extract(dirname, &buf[4], 2);
595 flags = extract_int(&buf[4], 3);
596 floor = extract_int(&buf[4], 4);
597 order = extract_int(&buf[4], 5);
598 view = extract_int(&buf[4], 6);
599 flags2 = extract_int(&buf[4], 7);
601 if (flags2 & QR2_SELFLIST) {
609 flags2 = flags2 | QR2_SELFLIST;
611 else if (newval == 0) {
612 flags2 = flags2 & ~QR2_SELFLIST;
615 return(current_value);
618 if (newval != current_value) {
619 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
620 name, password, dirname, flags,
621 floor, order, view, flags2);
635 * display the form for editing a room
637 void display_editroom(void)
644 char er_password[10];
646 char er_roomaide[26];
652 char *not_shared_with;
659 if (strlen(tab) == 0) tab = "admin";
666 strcpy(WC->ImportantMessage, &buf[4]);
670 extract(er_name, &buf[4], 0);
671 extract(er_password, &buf[4], 1);
672 extract(er_dirname, &buf[4], 2);
673 er_flags = extract_int(&buf[4], 3);
674 er_floor = extract_int(&buf[4], 4);
678 /* print the tabbed dialog */
679 wprintf("<BR><TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
681 "<TD> </TD>\n");
683 if (!strcmp(tab, "admin")) {
684 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
687 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
689 wprintf("Administration");
690 if (!strcmp(tab, "admin")) {
691 wprintf("</SPAN></TD>\n");
694 wprintf("</A></TD>\n");
697 wprintf("<TD> </TD>\n");
699 if (!strcmp(tab, "config")) {
700 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
703 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
705 wprintf("Configuration");
706 if (!strcmp(tab, "config")) {
707 wprintf("</SPAN></TD>\n");
710 wprintf("</A></TD>\n");
713 wprintf("<TD> </TD>\n");
715 if (!strcmp(tab, "expire")) {
716 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
719 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
721 wprintf("Message expire policy");
722 if (!strcmp(tab, "expire")) {
723 wprintf("</SPAN></TD>\n");
726 wprintf("</A></TD>\n");
729 wprintf("<TD> </TD>\n");
731 if (!strcmp(tab, "sharing")) {
732 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
735 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
738 if (!strcmp(tab, "sharing")) {
739 wprintf("</SPAN></TD>\n");
742 wprintf("</A></TD>\n");
745 wprintf("<TD> </TD>\n");
747 if (!strcmp(tab, "listserv")) {
748 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
751 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
753 wprintf("Mailing list service");
754 if (!strcmp(tab, "listserv")) {
755 wprintf("</SPAN></TD>\n");
758 wprintf("</A></TD>\n");
761 wprintf("<TD> </TD>\n");
763 wprintf("</TR></TABLE>\n");
764 /* end tabbed dialog */
766 /* begin content of whatever tab is open now */
767 wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
770 if (!strcmp(tab, "admin")) {
772 "<LI><A HREF=\"/confirm_delete_room\">\n"
773 "Delete this room</A>\n"
774 "<LI><A HREF=\"/display_editroompic\">\n"
775 "Set or change the graphic for this room's banner</A>\n"
776 "<LI><A HREF=\"/display_editinfo\">\n"
777 "Edit this room's Info file</A>\n"
781 if (!strcmp(tab, "config")) {
782 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
784 wprintf("<UL><LI>Name of room: ");
785 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
787 wprintf("<LI>Resides on floor: ");
788 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
789 for (i = 0; i < 128; ++i)
790 if (strlen(floorlist[i]) > 0) {
793 wprintf("SELECTED ");
794 wprintf("VALUE=\"%d\">", i);
795 escputs(floorlist[i]);
796 wprintf("</OPTION>\n");
798 wprintf("</SELECT>\n");
800 wprintf("<LI>Type of room:<UL>\n");
802 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
803 if ((er_flags & QR_PRIVATE) == 0)
805 wprintf("> Public room\n");
807 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
808 if ((er_flags & QR_PRIVATE) &&
809 (er_flags & QR_GUESSNAME))
811 wprintf("> Private - guess name\n");
813 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
814 if ((er_flags & QR_PRIVATE) &&
815 (er_flags & QR_PASSWORDED))
817 wprintf("> Private - require password:\n");
818 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
820 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
821 if ((er_flags & QR_PRIVATE)
822 && ((er_flags & QR_GUESSNAME) == 0)
823 && ((er_flags & QR_PASSWORDED) == 0))
825 wprintf("> Private - invitation only\n");
827 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
828 wprintf("> If private, cause current users to forget room\n");
832 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
833 if (er_flags & QR_PREFONLY)
835 wprintf("> Preferred users only\n");
837 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
838 if (er_flags & QR_READONLY)
840 wprintf("> Read-only room\n");
842 /* directory stuff */
843 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
844 if (er_flags & QR_DIRECTORY)
846 wprintf("> File directory room\n");
848 wprintf("<UL><LI>Directory name: ");
849 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
851 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
852 if (er_flags & QR_UPLOAD)
854 wprintf("> Uploading allowed\n");
856 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
857 if (er_flags & QR_DOWNLOAD)
859 wprintf("> Downloading allowed\n");
861 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
862 if (er_flags & QR_VISDIR)
864 wprintf("> Visible directory</UL>\n");
866 /* end of directory stuff */
868 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
869 if (er_flags & QR_NETWORK)
871 wprintf("> Network shared room\n");
873 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
874 if (er_flags & QR_PERMANENT)
876 wprintf("> Permanent (does not auto-purge)\n");
878 /* start of anon options */
880 wprintf("<LI>Anonymous messages<UL>\n");
882 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
883 if (((er_flags & QR_ANONONLY) == 0)
884 && ((er_flags & QR_ANONOPT) == 0))
886 wprintf("> No anonymous messages\n");
888 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
889 if (er_flags & QR_ANONONLY)
891 wprintf("> All messages are anonymous\n");
893 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
894 if (er_flags & QR_ANONOPT)
896 wprintf("> Prompt user when entering messages</UL>\n");
898 /* end of anon options */
900 wprintf("<LI>Room aide: \n");
904 wprintf("<EM>%s</EM>\n", &buf[4]);
906 extract(er_roomaide, &buf[4], 0);
907 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
910 wprintf("</UL><CENTER>\n");
911 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
912 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
914 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
920 /* Sharing the room with other Citadel nodes... */
921 if (!strcmp(tab, "sharing")) {
923 shared_with = strdup("");
924 not_shared_with = strdup("");
926 /* Learn the current configuration */
927 serv_puts("CONF getsys|application/x-citadel-ignet-config");
929 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
930 extract(node, buf, 0);
931 not_shared_with = realloc(not_shared_with,
932 strlen(not_shared_with) + 32);
933 strcat(not_shared_with, node);
934 strcat(not_shared_with, "|");
939 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
940 extract(cmd, buf, 0);
941 extract(node, buf, 1);
942 if (!strcasecmp(cmd, "ignet_push_share")) {
943 shared_with = realloc(shared_with,
944 strlen(shared_with) + 32);
945 strcat(shared_with, node);
946 strcat(shared_with, "|");
950 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
951 extract(node, shared_with, i);
952 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
953 extract(cmd, not_shared_with, j);
954 if (!strcasecmp(node, cmd)) {
955 remove_token(not_shared_with, j, '|');
960 /* Display the stuff */
961 wprintf("<CENTER><BR>"
962 "<TABLE border=1 cellpadding=5><TR>"
963 "<TD><B><I>Shared with</I></B></TD>"
964 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
967 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
968 extract(node, shared_with, i);
969 if (strlen(node) > 0) {
970 wprintf("%s ", node);
971 wprintf("<A HREF=\"/netedit&cmd=remove&line="
972 "ignet_push_share|");
974 wprintf("&tab=sharing\">(unshare)</A><BR>");
978 wprintf("</TD><TD>\n");
980 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
981 extract(node, not_shared_with, i);
982 if (strlen(node) > 0) {
983 wprintf("%s ", node);
984 wprintf("<A HREF=\"/netedit&cmd=add&line="
985 "ignet_push_share|");
987 wprintf("&tab=sharing\">(share)</A><BR>");
993 "<I><B>Reminder:</B> When sharing a room, "
994 "it must be shared from both ends. Adding a node to "
995 "the 'shared' list sends messages out, but in order to"
996 " receive messages, the other nodes must be configured"
997 " to send messages out to your system as well.</I><BR>"
1002 /* Mailing list management */
1003 if (!strcmp(tab, "listserv")) {
1005 wprintf("<BR><center>"
1006 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1007 "<TR><TD VALIGN=TOP>");
1009 wprintf("<i>The contents of this room are being "
1010 "mailed <b>as individual messages</b> "
1011 "to the following list recipients:"
1016 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1017 extract(cmd, buf, 0);
1018 if (!strcasecmp(cmd, "listrecp")) {
1019 extract(recp, buf, 1);
1022 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1025 wprintf("&tab=listserv\">(remove)</A><BR>");
1029 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1030 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1031 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1032 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1033 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1034 wprintf("</FORM>\n");
1036 wprintf("</TD><TD VALIGN=TOP>\n");
1038 wprintf("<i>The contents of this room are being "
1039 "mailed <b>in digest form</b> "
1040 "to the following list recipients:"
1045 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1046 extract(cmd, buf, 0);
1047 if (!strcasecmp(cmd, "digestrecp")) {
1048 extract(recp, buf, 1);
1051 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1054 wprintf("&tab=listserv\">(remove)</A><BR>");
1058 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1059 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1060 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1061 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1062 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1063 wprintf("</FORM>\n");
1065 wprintf("</TD></TR></TABLE><HR>\n");
1067 if (self_service(999) == 1) {
1068 wprintf("This room is configured to allow "
1069 "self-service subscribe/unsubscribe requests."
1070 " <A HREF=\"/toggle_self_service?newval=0&"
1072 "Click to disable.</A><BR>\n"
1073 "The URL for subscribe/unsubscribe is: "
1074 "<TT>http://%s/listsub</TT><BR>\n",
1079 wprintf("This room is <i>not</i> configured to allow "
1080 "self-service subscribe/unsubscribe requests."
1081 " <A HREF=\"/toggle_self_service?newval=1&"
1083 "Click to enable.</A><BR>\n"
1088 wprintf("</CENTER>\n");
1092 /* Mailing list management */
1093 if (!strcmp(tab, "expire")) {
1095 serv_puts("GPEX room");
1097 if (buf[0] == '2') {
1098 roompolicy = extract_int(&buf[4], 0);
1099 roomvalue = extract_int(&buf[4], 1);
1102 serv_puts("GPEX floor");
1104 if (buf[0] == '2') {
1105 floorpolicy = extract_int(&buf[4], 0);
1106 floorvalue = extract_int(&buf[4], 1);
1109 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
1110 wprintf("<TABLE border=0 cellspacing=5>\n");
1111 wprintf("<TR><TD>Message expire policy for this room<BR>(");
1112 escputs(WC->wc_roomname);
1113 wprintf(")</TD><TD>");
1114 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1115 ((roompolicy == 0) ? "CHECKED" : "") );
1116 wprintf("Use the default policy for this floor<BR>\n");
1117 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1118 ((roompolicy == 1) ? "CHECKED" : "") );
1119 wprintf("Never automatically expire messages<BR>\n");
1120 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1121 ((roompolicy == 2) ? "CHECKED" : "") );
1122 wprintf("Expire by message count<BR>\n");
1123 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1124 ((roompolicy == 3) ? "CHECKED" : "") );
1125 wprintf("Expire by message age<BR>");
1126 wprintf("Number of messages or days: ");
1127 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1128 wprintf("</TD></TR>\n");
1130 if (WC->axlevel >= 6) {
1131 wprintf("<TR><TD COLSPAN=2><HR></TD></TR>\n");
1132 wprintf("<TR><TD>Message expire policy for this floor<BR>(");
1133 escputs(floorlist[WC->wc_floor]);
1134 wprintf(")</TD><TD>");
1135 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1136 ((floorpolicy == 0) ? "CHECKED" : "") );
1137 wprintf("Use the system default<BR>\n");
1138 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1139 ((floorpolicy == 1) ? "CHECKED" : "") );
1140 wprintf("Never automatically expire messages<BR>\n");
1141 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1142 ((floorpolicy == 2) ? "CHECKED" : "") );
1143 wprintf("Expire by message count<BR>\n");
1144 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1145 ((floorpolicy == 3) ? "CHECKED" : "") );
1146 wprintf("Expire by message age<BR>");
1147 wprintf("Number of messages or days: ");
1148 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1152 wprintf("<CENTER>\n");
1153 wprintf("<TR><TD COLSPAN=2><HR><CENTER>\n");
1154 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1156 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1157 wprintf("</CENTER></TD><TR>\n");
1159 wprintf("</TABLE>\n"
1160 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1167 /* end content of whatever tab is open now */
1168 wprintf("</TD></TR></TABLE>\n");
1175 * Toggle self-service list subscription
1177 void toggle_self_service(void) {
1180 newval = atoi(bstr("newval"));
1181 self_service(newval);
1188 * save new parameters for a room
1194 char er_password[10];
1195 char er_dirname[15];
1196 char er_roomaide[26];
1202 if (strcmp(bstr("sc"), "OK")) {
1203 strcpy(WC->ImportantMessage,
1204 "Cancelled. Changes were not saved.");
1211 if (buf[0] != '2') {
1212 strcpy(WC->ImportantMessage, &buf[4]);
1216 extract(er_name, &buf[4], 0);
1217 extract(er_password, &buf[4], 1);
1218 extract(er_dirname, &buf[4], 2);
1219 er_flags = extract_int(&buf[4], 3);
1221 strcpy(er_roomaide, bstr("er_roomaide"));
1222 if (strlen(er_roomaide) == 0) {
1225 if (buf[0] != '2') {
1226 strcpy(er_roomaide, "");
1228 extract(er_roomaide, &buf[4], 0);
1231 strcpy(buf, bstr("er_name"));
1233 if (strlen(buf) > 0)
1234 strcpy(er_name, buf);
1236 strcpy(buf, bstr("er_password"));
1238 if (strlen(buf) > 0)
1239 strcpy(er_password, buf);
1241 strcpy(buf, bstr("er_dirname"));
1243 if (strlen(buf) > 0)
1244 strcpy(er_dirname, buf);
1246 strcpy(buf, bstr("type"));
1247 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1249 if (!strcmp(buf, "invonly")) {
1250 er_flags |= (QR_PRIVATE);
1252 if (!strcmp(buf, "guessname")) {
1253 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1255 if (!strcmp(buf, "passworded")) {
1256 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1258 if (!strcmp(bstr("prefonly"), "yes")) {
1259 er_flags |= QR_PREFONLY;
1261 er_flags &= ~QR_PREFONLY;
1264 if (!strcmp(bstr("readonly"), "yes")) {
1265 er_flags |= QR_READONLY;
1267 er_flags &= ~QR_READONLY;
1270 if (!strcmp(bstr("permanent"), "yes")) {
1271 er_flags |= QR_PERMANENT;
1273 er_flags &= ~QR_PERMANENT;
1276 if (!strcmp(bstr("network"), "yes")) {
1277 er_flags |= QR_NETWORK;
1279 er_flags &= ~QR_NETWORK;
1282 if (!strcmp(bstr("directory"), "yes")) {
1283 er_flags |= QR_DIRECTORY;
1285 er_flags &= ~QR_DIRECTORY;
1288 if (!strcmp(bstr("ulallowed"), "yes")) {
1289 er_flags |= QR_UPLOAD;
1291 er_flags &= ~QR_UPLOAD;
1294 if (!strcmp(bstr("dlallowed"), "yes")) {
1295 er_flags |= QR_DOWNLOAD;
1297 er_flags &= ~QR_DOWNLOAD;
1300 if (!strcmp(bstr("visdir"), "yes")) {
1301 er_flags |= QR_VISDIR;
1303 er_flags &= ~QR_VISDIR;
1306 strcpy(buf, bstr("anon"));
1308 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1309 if (!strcmp(buf, "anononly"))
1310 er_flags |= QR_ANONONLY;
1311 if (!strcmp(buf, "anon2"))
1312 er_flags |= QR_ANONOPT;
1315 if (!strcmp(bstr("bump"), "yes"))
1318 er_floor = atoi(bstr("er_floor"));
1320 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1321 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1324 if (buf[0] != '2') {
1325 strcpy(WC->ImportantMessage, &buf[4]);
1331 if (strlen(er_roomaide) > 0) {
1332 sprintf(buf, "SETA %s", er_roomaide);
1335 if (buf[0] != '2') {
1336 strcpy(WC->ImportantMessage, &buf[4]);
1337 display_main_menu();
1342 strcpy(WC->ImportantMessage, "Your changes have been saved.");
1348 * Invite, Kick, and show Who Knows a room
1350 void display_whok(void)
1352 char buf[SIZ], room[SIZ], username[SIZ];
1357 if (buf[0] != '2') {
1358 strcpy(WC->ImportantMessage, &buf[4]);
1359 display_main_menu();
1362 extract(room, &buf[4], 0);
1364 strcpy(username, bstr("username"));
1366 if(!strcmp(bstr("sc"), "Kick")) {
1367 sprintf(buf, "KICK %s", username);
1371 if (buf[0] != '2') {
1372 strcpy(WC->ImportantMessage, &buf[4]);
1374 sprintf(WC->ImportantMessage,
1375 "<B><I>User %s kicked out of room %s.</I></B>\n",
1378 } else if(!strcmp(bstr("sc"), "Invite")) {
1379 sprintf(buf, "INVT %s", username);
1383 if (buf[0] != '2') {
1384 strcpy(WC->ImportantMessage, &buf[4]);
1386 sprintf(WC->ImportantMessage,
1387 "<B><I>User %s invited to room %s.</I></B>\n",
1393 stresc(buf, WC->wc_roomname, 1, 1);
1394 svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
1395 do_template("beginbox");
1397 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1398 "<TD>The users listed below have access to this room. "
1399 "To remove a user from the access list, select the user "
1400 "name from the list and click 'Kick'.<BR><BR>");
1402 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1403 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1406 if (buf[0] == '1') {
1407 while (serv_gets(buf), strcmp(buf, "000")) {
1408 extract(username, buf, 0);
1409 wprintf("<OPTION>");
1414 wprintf("</SELECT><BR>\n");
1416 wprintf("<input type=submit name=sc value=\"Kick\">");
1417 wprintf("</FORM></CENTER>\n");
1420 "To grant another user access to this room, enter the "
1421 "user name in the box below and click 'Invite'.<BR><BR>");
1423 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1424 wprintf("Invite: ");
1425 wprintf("<input type=text name=username><BR>\n"
1426 "<input type=hidden name=sc value=\"Invite\">"
1427 "<input type=submit value=\"Invite\">"
1428 "</FORM></CENTER>\n");
1430 wprintf("</TD></TR></TABLE>\n");
1431 do_template("endbox");
1438 * display the form for entering a new room
1440 void display_entroom(void)
1445 serv_puts("CRE8 0");
1448 if (buf[0] != '2') {
1449 strcpy(WC->ImportantMessage, &buf[4]);
1450 display_main_menu();
1454 svprintf("BOXTITLE", WCS_STRING, "Create a new room");
1455 do_template("beginbox");
1457 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1459 wprintf("<UL><LI>Name of room: ");
1460 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1462 wprintf("<LI>Resides on floor: ");
1464 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1465 for (i = 0; i < 128; ++i)
1466 if (strlen(floorlist[i]) > 0) {
1467 wprintf("<OPTION ");
1468 wprintf("VALUE=\"%d\">", i);
1469 escputs(floorlist[i]);
1470 wprintf("</OPTION>\n");
1472 wprintf("</SELECT>\n");
1474 wprintf("<LI>Type of room:<UL>\n");
1476 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1477 wprintf("CHECKED > Public room\n");
1479 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1480 wprintf("> Private - guess name\n");
1482 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1483 wprintf("> Private - require password:\n");
1484 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1486 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1487 wprintf("> Private - invitation only\n");
1489 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1490 wprintf("> Personal (mailbox for you only)\n");
1493 wprintf("<LI>Default view for room: "); /* FOO */
1494 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1495 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1496 wprintf("<OPTION %s VALUE=\"%d\">",
1497 ((i == 0) ? "SELECTED" : ""), i );
1498 escputs(viewdefs[i]);
1499 wprintf("</OPTION>\n");
1501 wprintf("</SELECT>\n");
1503 wprintf("<CENTER>\n");
1504 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1506 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1507 wprintf("</CENTER>\n");
1508 wprintf("</FORM>\n<HR>");
1509 serv_printf("MESG roomaccess");
1511 if (buf[0] == '1') {
1512 fmout(NULL, "CENTER");
1514 do_template("endbox");
1522 * support function for entroom() -- sets the default view
1524 void er_set_default_view(int newview) {
1538 if (buf[0] != '2') return;
1540 extract(rm_name, &buf[4], 0);
1541 extract(rm_pass, &buf[4], 1);
1542 extract(rm_dir, &buf[4], 2);
1543 rm_bits1 = extract_int(&buf[4], 3);
1544 rm_floor = extract_int(&buf[4], 4);
1545 rm_listorder = extract_int(&buf[4], 5);
1546 rm_bits2 = extract_int(&buf[4], 7);
1548 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1549 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1550 rm_listorder, newview, rm_bits2
1565 char er_password[SIZ];
1570 if (strcmp(bstr("sc"), "OK")) {
1571 strcpy(WC->ImportantMessage,
1572 "Cancelled. No new room was created.");
1573 display_main_menu();
1576 strcpy(er_name, bstr("er_name"));
1577 strcpy(er_type, bstr("type"));
1578 strcpy(er_password, bstr("er_password"));
1579 er_floor = atoi(bstr("er_floor"));
1580 er_view = atoi(bstr("er_view"));
1583 if (!strcmp(er_type, "guessname"))
1585 if (!strcmp(er_type, "passworded"))
1587 if (!strcmp(er_type, "invonly"))
1589 if (!strcmp(er_type, "personal"))
1592 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
1593 er_name, er_num_type, er_password, er_floor, 0, er_view);
1596 if (buf[0] != '2') {
1597 strcpy(WC->ImportantMessage, &buf[4]);
1598 display_main_menu();
1602 do_change_view(er_view); /* Now go there */
1607 * display the screen to enter a private room
1609 void display_private(char *rname, int req_pass)
1614 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1615 do_template("beginbox");
1617 wprintf("<CENTER>\n");
1618 wprintf("<BR>If you know the name of a hidden (guess-name) or\n");
1619 wprintf("passworded room, you can enter that room by typing\n");
1620 wprintf("its name below. Once you gain access to a private\n");
1621 wprintf("room, it will appear in your regular room listings\n");
1622 wprintf("so you don't have to keep returning here.\n");
1623 wprintf("<BR><BR>");
1625 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1627 wprintf("<table border=\"0\" cellspacing=\"5\" "
1628 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1630 "Enter room name:</TD><TD>"
1631 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1632 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1635 wprintf("</TD></TR><TR><TD>");
1636 wprintf("Enter room password:</TD><TD>");
1637 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1639 wprintf("</TD></TR></TABLE><BR>\n");
1641 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1643 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1644 wprintf("</FORM>\n");
1645 do_template("endbox");
1650 * goto a private room
1652 void goto_private(void)
1657 if (strcasecmp(bstr("sc"), "OK")) {
1658 display_main_menu();
1661 strcpy(hold_rm, WC->wc_roomname);
1662 strcpy(buf, "GOTO ");
1663 strcat(buf, bstr("gr_name"));
1665 strcat(buf, bstr("gr_pass"));
1669 if (buf[0] == '2') {
1670 smart_goto(bstr("gr_name"));
1673 if (!strncmp(buf, "540", 3)) {
1674 display_private(bstr("gr_name"), 1);
1678 wprintf("%s\n", &buf[4]);
1685 * display the screen to zap a room
1687 void display_zap(void)
1691 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1692 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget) the current room</SPAN>\n");
1693 wprintf("</TD></TR></TABLE>\n");
1695 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1696 wprintf("disappear from your room list. Is this what you wish ");
1697 wprintf("to do?<BR>\n");
1699 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1700 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1702 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1703 wprintf("</FORM>\n");
1714 char final_destination[SIZ];
1716 /* If the forget-room routine fails for any reason, we fall back
1717 * to the current room; otherwise, we go to the Lobby
1719 strcpy(final_destination, WC->wc_roomname);
1721 if (!strcasecmp(bstr("sc"), "OK")) {
1722 serv_printf("GOTO %s", WC->wc_roomname);
1724 if (buf[0] != '2') {
1725 /* ExpressMessageCat(&buf[4]); */
1729 if (buf[0] != '2') {
1730 /* ExpressMessageCat(&buf[4]); */
1732 strcpy(final_destination, "_BASEROOM_");
1736 smart_goto(final_destination);
1743 * Confirm deletion of the current room
1745 void confirm_delete_room(void)
1749 serv_puts("KILL 0");
1751 if (buf[0] != '2') {
1752 strcpy(WC->ImportantMessage, &buf[4]);
1753 display_main_menu();
1757 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1758 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1759 wprintf("</TD></TR></TABLE>\n");
1761 wprintf("<CENTER>");
1762 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1764 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1765 escputs(WC->wc_roomname);
1766 wprintf("</FONT>?<BR>\n");
1768 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1769 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1771 wprintf("</FORM></CENTER>\n");
1777 * Delete the current room
1779 void delete_room(void)
1784 strcpy(sc, bstr("sc"));
1786 if (strcasecmp(sc, "Delete")) {
1787 strcpy(WC->ImportantMessage,
1788 "Cancelled. This room was not deleted.");
1789 display_main_menu();
1792 serv_puts("KILL 1");
1794 if (buf[0] != '2') {
1795 strcpy(WC->ImportantMessage, &buf[4]);
1796 display_main_menu();
1799 smart_goto("_BASEROOM_");
1806 * Perform changes to a room's network configuration
1808 void netedit(void) {
1813 if (strlen(bstr("line"))==0) {
1818 strcpy(line, bstr("prefix"));
1819 strcat(line, bstr("line"));
1820 strcat(line, bstr("suffix"));
1830 if (buf[0] != '1') {
1836 /* This loop works for add *or* remove. Spiffy, eh? */
1837 while (serv_gets(buf), strcmp(buf, "000")) {
1838 if (strcasecmp(buf, line)) {
1839 fprintf(fp, "%s\n", buf);
1846 if (buf[0] != '4') {
1852 while (fgets(buf, sizeof buf, fp) != NULL) {
1853 buf[strlen(buf)-1] = 0;
1857 if (!strcasecmp(bstr("cmd"), "add")) {
1869 * Convert a room name to a folder-ish-looking name.
1871 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
1876 * For mailboxes, just do it straight...
1879 sprintf(folder, "My folders|%s", room);
1883 * Otherwise, prefix the floor name as a "public folders" moniker
1886 sprintf(folder, "%s|%s", floorlist[floor], room);
1890 * Replace "\" characters with "|" for pseudo-folder-delimiting
1892 for (i=0; i<strlen(folder); ++i) {
1893 if (folder[i] == '\\') folder[i] = '|';
1901 * Back end for change_view()
1903 void do_change_view(int newview) {
1906 serv_printf("VIEW %d", newview);
1908 WC->wc_view = newview;
1909 smart_goto(WC->wc_roomname);
1915 * Change the view for this room
1917 void change_view(void) {
1920 view = atol(bstr("view"));
1921 do_change_view(view);
1926 * One big expanded tree list view --- like a folder list
1928 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
1930 int levels, oldlevels;
1933 do_template("beginbox_nt");
1937 for (i=0; i<max_folders; ++i) {
1939 levels = num_tokens(fold[i].name, '|');
1941 if (levels > oldlevels) for (t=0; t<(levels-oldlevels); ++t) {
1944 if (levels < oldlevels) for (t=0; t<(oldlevels-levels); ++t) {
1951 if (fold[i].selectable) {
1952 wprintf("<A HREF=\"/dotgoto?room=");
1953 urlescputs(fold[i].room);
1960 wprintf("<SPAN CLASS=\"roomlist_floor\">");
1962 else if (fold[i].hasnewmsgs) {
1963 wprintf("<SPAN CLASS=\"roomlist_new\">");
1966 wprintf("<SPAN CLASS=\"roomlist_old\">");
1968 extract(buf, fold[i].name, levels-1);
1971 if (fold[i].selectable) {
1977 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
1978 wprintf(" (INBOX)");
1982 do_template("endbox");
1986 * Boxes and rooms and lists ... oh my!
1988 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
1991 int levels, oldlevels;
1994 static int columns = 3;
1995 int boxes_per_column = 0;
1996 int current_column = 0;
2000 while (nf % columns != 0) ++nf;
2001 boxes_per_column = (nf / columns);
2002 if (boxes_per_column < 1) boxes_per_column = 1;
2004 /* Outer table (for columnization) */
2005 wprintf("<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
2006 "<TR><TD VALIGN=TOP>");
2010 for (i=0; i<max_folders; ++i) {
2012 levels = num_tokens(fold[i].name, '|');
2014 if ((levels == 1) && (oldlevels == 2)) {
2017 do_template("endbox");
2020 if ((num_boxes % boxes_per_column) == 0) {
2022 if (current_column < columns) {
2023 wprintf("</TD><TD VALIGN=TOP>\n");
2030 /* Begin inner box */
2031 extract(buf, fold[i].name, levels-1);
2032 stresc(boxtitle, buf, 1, 0);
2033 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2034 do_template("beginbox");
2042 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2043 if (fold[i].selectable) {
2044 wprintf("<A HREF=\"/dotgoto?room=");
2045 urlescputs(fold[i].room);
2051 if (fold[i].hasnewmsgs) {
2052 wprintf("<SPAN CLASS=\"roomlist_new\">");
2055 wprintf("<SPAN CLASS=\"roomlist_old\">");
2057 extract(buf, fold[i].name, levels-1);
2060 if (fold[i].selectable) {
2066 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2067 wprintf(" (INBOX)");
2072 /* End the final inner box */
2073 do_template("endbox");
2075 wprintf("</TD></TR></TABLE>\n");
2080 * Show the room list. (only should get called by
2081 * knrooms() because that's where output_headers() is called from)
2084 void list_all_rooms_by_floor(char *viewpref) {
2087 struct folder *fold = NULL;
2089 int max_folders = 0;
2090 int alloc_folders = 0;
2094 int num_floors = 1; /* add an extra one for private folders */
2096 /* Start with the mailboxes */
2099 fold = malloc(sizeof(struct folder));
2100 memset(fold, 0, sizeof(struct folder));
2101 strcpy(fold[0].name, "My folders");
2102 fold[0].is_mailbox = 1;
2104 /* Then add floors */
2107 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2108 if (max_folders >= alloc_folders) {
2109 alloc_folders = max_folders + 100;
2110 fold = realloc(fold,
2111 alloc_folders * sizeof(struct folder));
2113 memset(&fold[max_folders], 0, sizeof(struct folder));
2114 extract(fold[max_folders].name, buf, 1);
2122 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2123 if (max_folders >= alloc_folders) {
2124 alloc_folders = max_folders + 100;
2125 fold = realloc(fold,
2126 alloc_folders * sizeof(struct folder));
2128 memset(&fold[max_folders], 0, sizeof(struct folder));
2129 extract(fold[max_folders].room, buf, 0);
2130 ra_flags = extract_int(buf, 5);
2131 flags = extract_int(buf, 1);
2132 fold[max_folders].floor = extract_int(buf, 2);
2133 fold[max_folders].hasnewmsgs =
2134 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2135 if (flags & QR_MAILBOX) {
2136 fold[max_folders].is_mailbox = 1;
2138 room_to_folder(fold[max_folders].name,
2139 fold[max_folders].room,
2140 fold[max_folders].floor,
2141 fold[max_folders].is_mailbox);
2142 fold[max_folders].selectable = 1;
2146 /* Bubble-sort the folder list */
2147 for (i=0; i<max_folders; ++i) {
2148 for (j=0; j<(max_folders-1)-i; ++j) {
2149 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2150 swap = strcasecmp(fold[j].name, fold[j+1].name);
2153 if ( (fold[j+1].is_mailbox)
2154 && (!fold[j].is_mailbox)) {
2162 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2163 memcpy(&fold[j], &fold[j+1],
2164 sizeof(struct folder));
2165 memcpy(&fold[j+1], &ftmp,
2166 sizeof(struct folder));
2171 if (!strcasecmp(viewpref, "folders")) {
2172 do_folder_view(fold, max_folders, num_floors);
2175 do_rooms_view(fold, max_folders, num_floors);
2183 /* Do either a known rooms list or a folders list, depending on the
2187 char listviewpref[SIZ];
2192 /* Determine whether the user is trying to change views */
2193 if (bstr("view") != NULL) {
2194 if (strlen(bstr("view")) > 0) {
2195 set_preference("roomlistview", bstr("view"));
2199 get_preference("roomlistview", listviewpref);
2201 if ( (strcasecmp(listviewpref, "folders"))
2202 && (strcasecmp(listviewpref, "table")) ) {
2203 strcpy(listviewpref, "rooms");
2207 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2208 "<SPAN CLASS=\"titlebar\">"
2210 if (!strcasecmp(listviewpref, "rooms")) {
2211 wprintf("Room list");
2213 if (!strcasecmp(listviewpref, "folders")) {
2214 wprintf("Folder list");
2216 if (!strcasecmp(listviewpref, "table")) {
2217 wprintf("Room list");
2219 wprintf("</SPAN></TD>\n");
2222 /* offer the ability to switch views */
2223 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2224 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2225 "OnChange=\"location.href=roomlistomatic.newview.options"
2226 "[selectedIndex].value\">\n");
2228 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2231 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2234 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2235 "View as folder list"
2237 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2240 wprintf("</SELECT><BR>");
2242 wprintf("</FORM></TD></TR></TABLE>\n");
2244 /* Display the room list in the user's preferred format */
2245 list_all_rooms_by_floor(listviewpref);
2251 * Set the message expire policy for this room and/or floor
2253 void set_room_policy(void) {
2256 if (strcmp(bstr("sc"), "OK")) {
2257 strcpy(WC->ImportantMessage,
2258 "Cancelled. Changes were not saved.");
2263 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2265 strcpy(WC->ImportantMessage, &buf[4]);
2267 if (WC->axlevel >= 6) {
2268 strcat(WC->ImportantMessage, "<BR>\n");
2269 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2271 strcat(WC->ImportantMessage, &buf[4]);