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 * generic routine to take the session to a new room
371 * display_name values: 0 = goto only
372 * 1 = goto and display
375 void gotoroom(char *gname, int display_name)
378 static long ls = (-1L);
383 wprintf("Pragma: no-cache\n");
384 wprintf("Cache-Control: no-store\n");
386 wprintf("<HTML><HEAD>\n"
387 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
388 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
389 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
390 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
392 do_template("background");
394 if (display_name != 2) {
395 /* store ungoto information */
396 strcpy(WC->ugname, WC->wc_roomname);
399 /* move to the new room */
400 serv_printf("GOTO %s", gname);
403 serv_puts("GOTO _BASEROOM_");
408 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
413 extract(WC->wc_roomname, &buf[4], 0);
414 WC->room_flags = extract_int(&buf[4], 4);
415 /* highest_msg_read = extract_int(&buf[4],6);
416 maxmsgnum = extract_int(&buf[4],5);
417 is_mail = (char) extract_int(&buf[4],7); */
418 ls = extract_long(&buf[4], 6);
421 WC->is_room_aide = WC->is_aide;
423 WC->is_room_aide = (char) extract_int(&buf[4], 8);
425 remove_march(WC->wc_roomname);
426 if (!strcasecmp(gname, "_BASEROOM_"))
429 /* Display the room banner */
431 embed_room_banner(buf);
434 strcpy(WC->wc_roomname, WC->wc_roomname);
435 WC->wc_view = extract_int(&buf[4], 11);
436 WC->wc_default_view = extract_int(&buf[4], 12);
441 * Locate the room on the march list which we most want to go to. Each room
442 * is measured given a "weight" of preference based on various factors.
444 char *pop_march(int desired_floor)
446 static char TheRoom[128];
448 int TheOrder = 32767;
451 struct march *mptr = NULL;
453 strcpy(TheRoom, "_BASEROOM_");
454 if (WC->march == NULL)
457 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
459 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
460 weight = weight + 10000;
461 if (mptr->march_floor == desired_floor)
462 weight = weight + 5000;
464 weight = weight + ((128 - (mptr->march_floor)) * 128);
465 weight = weight + (128 - (mptr->march_order));
467 if (weight > TheWeight) {
469 strcpy(TheRoom, mptr->march_name);
470 TheFloor = mptr->march_floor;
471 TheOrder = mptr->march_order;
479 /* Goto next room having unread messages.
480 * We want to skip over rooms that the user has already been to, and take the
481 * user back to the lobby when done. The room we end up in is placed in
482 * newroom - which is set to 0 (the lobby) initially.
483 * We start the search in the current room rather than the beginning to prevent
484 * two or more concurrent users from dragging each other back to the same room.
489 struct march *mptr, *mptr2;
492 /* First check to see if the march-mode list is already allocated.
493 * If it is, pop the first room off the list and go there.
496 if (WC->march == NULL) {
500 while (serv_gets(buf), strcmp(buf, "000")) {
501 mptr = (struct march *) malloc(sizeof(struct march));
503 extract(mptr->march_name, buf, 0);
504 mptr->march_floor = extract_int(buf, 2);
505 mptr->march_order = extract_int(buf, 3);
506 if (WC->march == NULL) {
510 while (mptr2->next != NULL)
515 /* add _BASEROOM_ to the end of the march list, so the user will end up
516 * in the system base room (usually the Lobby>) at the end of the loop
518 mptr = (struct march *) malloc(sizeof(struct march));
520 strcpy(mptr->march_name, "_BASEROOM_");
521 if (WC->march == NULL) {
525 while (mptr2->next != NULL)
530 * ...and remove the room we're currently in, so a <G>oto doesn't make us
531 * walk around in circles
533 remove_march(WC->wc_roomname);
535 if (WC->march != NULL) {
536 strcpy(next_room, pop_march(-1));
538 strcpy(next_room, "_BASEROOM_");
542 smart_goto(next_room);
546 void smart_goto(char *next_room) {
547 gotoroom(next_room, 0);
554 * mark all messages in current room as having been read
556 void slrp_highest(void)
561 serv_puts("SLRP HIGHEST");
564 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
571 * un-goto the previous room
577 if (!strcmp(WC->ugname, "")) {
578 smart_goto(WC->wc_roomname);
581 serv_printf("GOTO %s", WC->ugname);
584 smart_goto(WC->wc_roomname);
587 if (WC->uglsn >= 0L) {
588 serv_printf("SLRP %ld", WC->uglsn);
591 strcpy(buf, WC->ugname);
592 strcpy(WC->ugname, "");
601 * Set/clear/read the "self-service list subscribe" flag for a room
603 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
604 * Always returns the new value.
607 int self_service(int newval) {
608 int current_value = 0;
614 int flags, floor, order, view, flags2;
618 if (buf[0] != '2') return(0);
620 extract(name, &buf[4], 0);
621 extract(password, &buf[4], 1);
622 extract(dirname, &buf[4], 2);
623 flags = extract_int(&buf[4], 3);
624 floor = extract_int(&buf[4], 4);
625 order = extract_int(&buf[4], 5);
626 view = extract_int(&buf[4], 6);
627 flags2 = extract_int(&buf[4], 7);
629 if (flags2 & QR2_SELFLIST) {
637 flags2 = flags2 | QR2_SELFLIST;
639 else if (newval == 0) {
640 flags2 = flags2 & ~QR2_SELFLIST;
643 return(current_value);
646 if (newval != current_value) {
647 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
648 name, password, dirname, flags,
649 floor, order, view, flags2);
663 * display the form for editing a room
665 void display_editroom(void)
672 char er_password[10];
674 char er_roomaide[26];
680 char *not_shared_with;
683 if (strlen(tab) == 0) tab = "admin";
689 strcpy(WC->ImportantMessage, &buf[4]);
693 extract(er_name, &buf[4], 0);
694 extract(er_password, &buf[4], 1);
695 extract(er_dirname, &buf[4], 2);
696 er_flags = extract_int(&buf[4], 3);
697 er_floor = extract_int(&buf[4], 4);
701 /* print the tabbed dialog */
702 wprintf("<BR><TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
704 "<TD> </TD>\n");
706 if (!strcmp(tab, "admin")) {
707 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
710 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
712 wprintf("Administration");
713 if (!strcmp(tab, "admin")) {
714 wprintf("</SPAN></TD>\n");
717 wprintf("</A></TD>\n");
720 wprintf("<TD> </TD>\n");
722 if (!strcmp(tab, "config")) {
723 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
726 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
728 wprintf("Configuration");
729 if (!strcmp(tab, "config")) {
730 wprintf("</SPAN></TD>\n");
733 wprintf("</A></TD>\n");
736 wprintf("<TD> </TD>\n");
738 if (!strcmp(tab, "sharing")) {
739 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
742 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
745 if (!strcmp(tab, "sharing")) {
746 wprintf("</SPAN></TD>\n");
749 wprintf("</A></TD>\n");
752 wprintf("<TD> </TD>\n");
754 if (!strcmp(tab, "listserv")) {
755 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
758 wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
760 wprintf("Mailing list service");
761 if (!strcmp(tab, "listserv")) {
762 wprintf("</SPAN></TD>\n");
765 wprintf("</A></TD>\n");
768 wprintf("<TD> </TD>\n");
770 wprintf("</TR></TABLE>\n");
771 /* end tabbed dialog */
773 /* begin content of whatever tab is open now */
774 wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
777 if (!strcmp(tab, "admin")) {
779 "<LI><A HREF=\"/confirm_delete_room\">\n"
780 "Delete this room</A>\n"
781 "<LI><A HREF=\"/display_editroompic\">\n"
782 "Set or change the graphic for this room's banner</A>\n"
783 "<LI><A HREF=\"/display_editinfo\">\n"
784 "Edit this room's Info file</A>\n"
788 if (!strcmp(tab, "config")) {
789 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
791 wprintf("<UL><LI>Name of room: ");
792 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
794 wprintf("<LI>Resides on floor: ");
796 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
797 for (i = 0; i < 128; ++i)
798 if (strlen(floorlist[i]) > 0) {
801 wprintf("SELECTED ");
802 wprintf("VALUE=\"%d\">", i);
803 escputs(floorlist[i]);
804 wprintf("</OPTION>\n");
806 wprintf("</SELECT>\n");
808 wprintf("<LI>Type of room:<UL>\n");
810 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
811 if ((er_flags & QR_PRIVATE) == 0)
813 wprintf("> Public room\n");
815 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
816 if ((er_flags & QR_PRIVATE) &&
817 (er_flags & QR_GUESSNAME))
819 wprintf("> Private - guess name\n");
821 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
822 if ((er_flags & QR_PRIVATE) &&
823 (er_flags & QR_PASSWORDED))
825 wprintf("> Private - require password:\n");
826 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
828 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
829 if ((er_flags & QR_PRIVATE)
830 && ((er_flags & QR_GUESSNAME) == 0)
831 && ((er_flags & QR_PASSWORDED) == 0))
833 wprintf("> Private - invitation only\n");
835 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
836 wprintf("> If private, cause current users to forget room\n");
840 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
841 if (er_flags & QR_PREFONLY)
843 wprintf("> Preferred users only\n");
845 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
846 if (er_flags & QR_READONLY)
848 wprintf("> Read-only room\n");
850 /* directory stuff */
851 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
852 if (er_flags & QR_DIRECTORY)
854 wprintf("> File directory room\n");
856 wprintf("<UL><LI>Directory name: ");
857 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
859 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
860 if (er_flags & QR_UPLOAD)
862 wprintf("> Uploading allowed\n");
864 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
865 if (er_flags & QR_DOWNLOAD)
867 wprintf("> Downloading allowed\n");
869 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
870 if (er_flags & QR_VISDIR)
872 wprintf("> Visible directory</UL>\n");
874 /* end of directory stuff */
876 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
877 if (er_flags & QR_NETWORK)
879 wprintf("> Network shared room\n");
881 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
882 if (er_flags & QR_PERMANENT)
884 wprintf("> Permanent (does not auto-purge)\n");
886 /* start of anon options */
888 wprintf("<LI>Anonymous messages<UL>\n");
890 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
891 if (((er_flags & QR_ANONONLY) == 0)
892 && ((er_flags & QR_ANONOPT) == 0))
894 wprintf("> No anonymous messages\n");
896 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
897 if (er_flags & QR_ANONONLY)
899 wprintf("> All messages are anonymous\n");
901 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
902 if (er_flags & QR_ANONOPT)
904 wprintf("> Prompt user when entering messages</UL>\n");
906 /* end of anon options */
908 wprintf("<LI>Room aide: \n");
912 wprintf("<EM>%s</EM>\n", &buf[4]);
914 extract(er_roomaide, &buf[4], 0);
915 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
918 wprintf("</UL><CENTER>\n");
919 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
920 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
921 wprintf("</CENTER>\n");
925 /* Sharing the room with other Citadel nodes... */
926 if (!strcmp(tab, "sharing")) {
928 shared_with = strdup("");
929 not_shared_with = strdup("");
931 /* Learn the current configuration */
932 serv_puts("CONF getsys|application/x-citadel-ignet-config");
934 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
935 extract(node, buf, 0);
936 not_shared_with = realloc(not_shared_with,
937 strlen(not_shared_with) + 32);
938 strcat(not_shared_with, node);
939 strcat(not_shared_with, "|");
944 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
945 extract(cmd, buf, 0);
946 extract(node, buf, 1);
947 if (!strcasecmp(cmd, "ignet_push_share")) {
948 shared_with = realloc(shared_with,
949 strlen(shared_with) + 32);
950 strcat(shared_with, node);
951 strcat(shared_with, "|");
955 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
956 extract(node, shared_with, i);
957 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
958 extract(cmd, not_shared_with, j);
959 if (!strcasecmp(node, cmd)) {
960 remove_token(not_shared_with, j, '|');
965 /* Display the stuff */
966 wprintf("<CENTER><BR>"
967 "<TABLE border=1 cellpadding=5><TR>"
968 "<TD><B><I>Shared with</I></B></TD>"
969 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
972 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
973 extract(node, shared_with, i);
974 if (strlen(node) > 0) {
975 wprintf("%s ", node);
976 wprintf("<A HREF=\"/netedit&cmd=remove&line="
977 "ignet_push_share|");
979 wprintf("&tab=sharing\">(unshare)</A><BR>");
983 wprintf("</TD><TD>\n");
985 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
986 extract(node, not_shared_with, i);
987 if (strlen(node) > 0) {
988 wprintf("%s ", node);
989 wprintf("<A HREF=\"/netedit&cmd=add&line="
990 "ignet_push_share|");
992 wprintf("&tab=sharing\">(share)</A><BR>");
998 "<I><B>Reminder:</B> When sharing a room, "
999 "it must be shared from both ends. Adding a node to "
1000 "the 'shared' list sends messages out, but in order to"
1001 " receive messages, the other nodes must be configured"
1002 " to send messages out to your system as well.</I><BR>"
1007 /* Mailing list management */
1008 if (!strcmp(tab, "listserv")) {
1010 wprintf("<BR><center>"
1011 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1012 "<TR><TD VALIGN=TOP>");
1014 wprintf("<i>The contents of this room are being "
1015 "mailed <b>as individual messages</b> "
1016 "to the following list recipients:"
1021 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1022 extract(cmd, buf, 0);
1023 if (!strcasecmp(cmd, "listrecp")) {
1024 extract(recp, buf, 1);
1027 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1030 wprintf("&tab=listserv\">(remove)</A><BR>");
1034 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1035 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1036 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1037 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1038 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1039 wprintf("</FORM>\n");
1041 wprintf("</TD><TD VALIGN=TOP>\n");
1043 wprintf("<i>The contents of this room are being "
1044 "mailed <b>in digest form</b> "
1045 "to the following list recipients:"
1050 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1051 extract(cmd, buf, 0);
1052 if (!strcasecmp(cmd, "digestrecp")) {
1053 extract(recp, buf, 1);
1056 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1059 wprintf("&tab=listserv\">(remove)</A><BR>");
1063 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1064 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1065 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1066 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1067 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1068 wprintf("</FORM>\n");
1070 wprintf("</TD></TR></TABLE><HR>\n");
1072 if (self_service(999) == 1) {
1073 wprintf("This room is configured to allow "
1074 "self-service subscribe/unsubscribe requests."
1075 " <A HREF=\"/toggle_self_service?newval=0&"
1077 "Click to disable.</A><BR>\n"
1078 "The URL for subscribe/unsubscribe is: "
1079 "<TT>http://%s/listsub</TT><BR>\n",
1084 wprintf("This room is <i>not</i> configured to allow "
1085 "self-service subscribe/unsubscribe requests."
1086 " <A HREF=\"/toggle_self_service?newval=1&"
1088 "Click to enable.</A><BR>\n"
1093 wprintf("</CENTER>\n");
1096 /* end content of whatever tab is open now */
1097 wprintf("</TD></TR></TABLE>\n");
1104 * Toggle self-service list subscription
1106 void toggle_self_service(void) {
1109 newval = atoi(bstr("newval"));
1110 self_service(newval);
1117 * save new parameters for a room
1123 char er_password[10];
1124 char er_dirname[15];
1125 char er_roomaide[26];
1131 if (strcmp(bstr("sc"), "OK")) {
1132 strcpy(WC->ImportantMessage,
1133 "Cancelled. Changes were not saved.");
1134 display_main_menu();
1140 if (buf[0] != '2') {
1141 strcpy(WC->ImportantMessage, &buf[4]);
1142 display_main_menu();
1145 extract(er_name, &buf[4], 0);
1146 extract(er_password, &buf[4], 1);
1147 extract(er_dirname, &buf[4], 2);
1148 er_flags = extract_int(&buf[4], 3);
1150 strcpy(er_roomaide, bstr("er_roomaide"));
1151 if (strlen(er_roomaide) == 0) {
1154 if (buf[0] != '2') {
1155 strcpy(er_roomaide, "");
1157 extract(er_roomaide, &buf[4], 0);
1160 strcpy(buf, bstr("er_name"));
1162 if (strlen(buf) > 0)
1163 strcpy(er_name, buf);
1165 strcpy(buf, bstr("er_password"));
1167 if (strlen(buf) > 0)
1168 strcpy(er_password, buf);
1170 strcpy(buf, bstr("er_dirname"));
1172 if (strlen(buf) > 0)
1173 strcpy(er_dirname, buf);
1175 strcpy(buf, bstr("type"));
1176 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1178 if (!strcmp(buf, "invonly")) {
1179 er_flags |= (QR_PRIVATE);
1181 if (!strcmp(buf, "guessname")) {
1182 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1184 if (!strcmp(buf, "passworded")) {
1185 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1187 if (!strcmp(bstr("prefonly"), "yes")) {
1188 er_flags |= QR_PREFONLY;
1190 er_flags &= ~QR_PREFONLY;
1193 if (!strcmp(bstr("readonly"), "yes")) {
1194 er_flags |= QR_READONLY;
1196 er_flags &= ~QR_READONLY;
1199 if (!strcmp(bstr("permanent"), "yes")) {
1200 er_flags |= QR_PERMANENT;
1202 er_flags &= ~QR_PERMANENT;
1205 if (!strcmp(bstr("network"), "yes")) {
1206 er_flags |= QR_NETWORK;
1208 er_flags &= ~QR_NETWORK;
1211 if (!strcmp(bstr("directory"), "yes")) {
1212 er_flags |= QR_DIRECTORY;
1214 er_flags &= ~QR_DIRECTORY;
1217 if (!strcmp(bstr("ulallowed"), "yes")) {
1218 er_flags |= QR_UPLOAD;
1220 er_flags &= ~QR_UPLOAD;
1223 if (!strcmp(bstr("dlallowed"), "yes")) {
1224 er_flags |= QR_DOWNLOAD;
1226 er_flags &= ~QR_DOWNLOAD;
1229 if (!strcmp(bstr("visdir"), "yes")) {
1230 er_flags |= QR_VISDIR;
1232 er_flags &= ~QR_VISDIR;
1235 strcpy(buf, bstr("anon"));
1237 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1238 if (!strcmp(buf, "anononly"))
1239 er_flags |= QR_ANONONLY;
1240 if (!strcmp(buf, "anon2"))
1241 er_flags |= QR_ANONOPT;
1244 if (!strcmp(bstr("bump"), "yes"))
1247 er_floor = atoi(bstr("er_floor"));
1249 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1250 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1253 if (buf[0] != '2') {
1254 strcpy(WC->ImportantMessage, &buf[4]);
1255 display_main_menu();
1258 gotoroom(er_name, 0);
1260 if (strlen(er_roomaide) > 0) {
1261 sprintf(buf, "SETA %s", er_roomaide);
1264 if (buf[0] != '2') {
1265 strcpy(WC->ImportantMessage, &buf[4]);
1266 display_main_menu();
1270 gotoroom(er_name, 0);
1271 display_main_menu();
1276 * Invite, Kick, and show Who Knows a room
1278 void display_whok(void)
1280 char buf[SIZ], room[SIZ], username[SIZ];
1285 if (buf[0] != '2') {
1286 strcpy(WC->ImportantMessage, &buf[4]);
1287 display_main_menu();
1290 extract(room, &buf[4], 0);
1292 strcpy(username, bstr("username"));
1294 if(!strcmp(bstr("sc"), "Kick")) {
1295 sprintf(buf, "KICK %s", username);
1299 if (buf[0] != '2') {
1300 strcpy(WC->ImportantMessage, &buf[4]);
1302 sprintf(WC->ImportantMessage,
1303 "<B><I>User %s kicked out of room %s.</I></B>\n",
1306 } else if(!strcmp(bstr("sc"), "Invite")) {
1307 sprintf(buf, "INVT %s", username);
1311 if (buf[0] != '2') {
1312 strcpy(WC->ImportantMessage, &buf[4]);
1314 sprintf(WC->ImportantMessage,
1315 "<B><I>User %s invited to room %s.</I></B>\n",
1321 stresc(buf, WC->wc_roomname, 1, 1);
1322 svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
1323 do_template("beginbox");
1325 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1326 "<TD>The users listed below have access to this room. "
1327 "To remove a user from the access list, select the user "
1328 "name from the list and click 'Kick'.<BR><BR>");
1330 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1331 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1334 if (buf[0] == '1') {
1335 while (serv_gets(buf), strcmp(buf, "000")) {
1336 extract(username, buf, 0);
1337 wprintf("<OPTION>");
1342 wprintf("</SELECT><BR>\n");
1344 wprintf("<input type=submit name=sc value=\"Kick\">");
1345 wprintf("</FORM></CENTER>\n");
1348 "To grant another user access to this room, enter the "
1349 "user name in the box below and click 'Invite'.<BR><BR>");
1351 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1352 wprintf("Invite: ");
1353 wprintf("<input type=text name=username><BR>\n"
1354 "<input type=hidden name=sc value=\"Invite\">"
1355 "<input type=submit value=\"Invite\">"
1356 "</FORM></CENTER>\n");
1358 wprintf("</TD></TR></TABLE>\n");
1359 do_template("endbox");
1366 * display the form for entering a new room
1368 void display_entroom(void)
1373 serv_puts("CRE8 0");
1376 if (buf[0] != '2') {
1377 strcpy(WC->ImportantMessage, &buf[4]);
1378 display_main_menu();
1382 svprintf("BOXTITLE", WCS_STRING, "Create a new room");
1383 do_template("beginbox");
1385 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1387 wprintf("<UL><LI>Name of room: ");
1388 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1390 wprintf("<LI>Resides on floor: ");
1392 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1393 for (i = 0; i < 128; ++i)
1394 if (strlen(floorlist[i]) > 0) {
1395 wprintf("<OPTION ");
1396 wprintf("VALUE=\"%d\">", i);
1397 escputs(floorlist[i]);
1398 wprintf("</OPTION>\n");
1400 wprintf("</SELECT>\n");
1402 wprintf("<LI>Type of room:<UL>\n");
1404 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1405 wprintf("CHECKED > Public room\n");
1407 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1408 wprintf("> Private - guess name\n");
1410 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1411 wprintf("> Private - require password:\n");
1412 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1414 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1415 wprintf("> Private - invitation only\n");
1417 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1418 wprintf("> Personal (mailbox for you only)\n");
1421 wprintf("<LI>Default view for room: "); /* FOO */
1422 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1423 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1424 wprintf("<OPTION %s VALUE=\"%d\">",
1425 ((i == 0) ? "SELECTED" : ""), i );
1426 escputs(viewdefs[i]);
1427 wprintf("</OPTION>\n");
1429 wprintf("</SELECT>\n");
1431 wprintf("<CENTER>\n");
1432 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1433 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1434 wprintf("</CENTER>\n");
1435 wprintf("</FORM>\n<HR>");
1436 serv_printf("MESG roomaccess");
1438 if (buf[0] == '1') {
1439 fmout(NULL, "CENTER");
1441 do_template("endbox");
1449 * support function for entroom() -- sets the default view
1451 void er_set_default_view(int newview) {
1465 if (buf[0] != '2') return;
1467 extract(rm_name, &buf[4], 0);
1468 extract(rm_pass, &buf[4], 1);
1469 extract(rm_dir, &buf[4], 2);
1470 rm_bits1 = extract_int(&buf[4], 3);
1471 rm_floor = extract_int(&buf[4], 4);
1472 rm_listorder = extract_int(&buf[4], 5);
1473 rm_bits2 = extract_int(&buf[4], 7);
1475 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1476 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1477 rm_listorder, newview, rm_bits2
1492 char er_password[SIZ];
1496 if (strcmp(bstr("sc"), "OK")) {
1497 strcpy(WC->ImportantMessage,
1498 "Cancelled. No new room was created.");
1499 display_main_menu();
1502 strcpy(er_name, bstr("er_name"));
1503 strcpy(er_type, bstr("type"));
1504 strcpy(er_password, bstr("er_password"));
1505 er_floor = atoi(bstr("er_floor"));
1508 if (!strcmp(er_type, "guessname"))
1510 if (!strcmp(er_type, "passworded"))
1512 if (!strcmp(er_type, "invonly"))
1514 if (!strcmp(er_type, "personal"))
1517 sprintf(buf, "CRE8 1|%s|%d|%s|%d",
1518 er_name, er_num_type, er_password, er_floor);
1521 if (buf[0] != '2') {
1522 strcpy(WC->ImportantMessage, &buf[4]);
1523 display_main_menu();
1526 gotoroom(er_name, 0);
1527 er_set_default_view(atoi(bstr("er_view"))); /* Set default view */
1528 do_change_view(atoi(bstr("er_view"))); /* Now go there */
1533 * display the screen to enter a private room
1535 void display_private(char *rname, int req_pass)
1540 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1541 do_template("beginbox");
1543 wprintf("<CENTER>\n");
1544 wprintf("<BR>If you know the name of a hidden (guess-name) or\n");
1545 wprintf("passworded room, you can enter that room by typing\n");
1546 wprintf("its name below. Once you gain access to a private\n");
1547 wprintf("room, it will appear in your regular room listings\n");
1548 wprintf("so you don't have to keep returning here.\n");
1549 wprintf("<BR><BR>");
1551 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1553 wprintf("<table border=\"0\" cellspacing=\"5\" "
1554 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1556 "Enter room name:</TD><TD>"
1557 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1558 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1561 wprintf("</TD></TR><TR><TD>");
1562 wprintf("Enter room password:</TD><TD>");
1563 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1565 wprintf("</TD></TR></TABLE><BR>\n");
1567 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1569 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1570 wprintf("</FORM>\n");
1571 do_template("endbox");
1576 * goto a private room
1578 void goto_private(void)
1583 if (strcasecmp(bstr("sc"), "OK")) {
1584 display_main_menu();
1587 strcpy(hold_rm, WC->wc_roomname);
1588 strcpy(buf, "GOTO ");
1589 strcat(buf, bstr("gr_name"));
1591 strcat(buf, bstr("gr_pass"));
1595 if (buf[0] == '2') {
1596 smart_goto(bstr("gr_name"));
1599 if (!strncmp(buf, "540", 3)) {
1600 display_private(bstr("gr_name"), 1);
1604 wprintf("%s\n", &buf[4]);
1611 * display the screen to zap a room
1613 void display_zap(void)
1617 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1618 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget) the current room</SPAN>\n");
1619 wprintf("</TD></TR></TABLE>\n");
1621 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1622 wprintf("disappear from your room list. Is this what you wish ");
1623 wprintf("to do?<BR>\n");
1625 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1626 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1627 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1628 wprintf("</FORM>\n");
1639 char final_destination[SIZ];
1641 /* If the forget-room routine fails for any reason, we fall back
1642 * to the current room; otherwise, we go to the Lobby
1644 strcpy(final_destination, WC->wc_roomname);
1646 if (!strcasecmp(bstr("sc"), "OK")) {
1647 serv_printf("GOTO %s", WC->wc_roomname);
1649 if (buf[0] != '2') {
1650 /* ExpressMessageCat(&buf[4]); */
1654 if (buf[0] != '2') {
1655 /* ExpressMessageCat(&buf[4]); */
1657 strcpy(final_destination, "_BASEROOM_");
1661 smart_goto(final_destination);
1668 * Confirm deletion of the current room
1670 void confirm_delete_room(void)
1674 serv_puts("KILL 0");
1676 if (buf[0] != '2') {
1677 strcpy(WC->ImportantMessage, &buf[4]);
1678 display_main_menu();
1682 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1683 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1684 wprintf("</TD></TR></TABLE>\n");
1686 wprintf("<CENTER>");
1687 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1689 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1690 escputs(WC->wc_roomname);
1691 wprintf("</FONT>?<BR>\n");
1693 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1694 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1696 wprintf("</FORM></CENTER>\n");
1702 * Delete the current room
1704 void delete_room(void)
1709 strcpy(sc, bstr("sc"));
1711 if (strcasecmp(sc, "Delete")) {
1712 strcpy(WC->ImportantMessage,
1713 "Cancelled. This room was not deleted.");
1714 display_main_menu();
1717 serv_puts("KILL 1");
1719 if (buf[0] != '2') {
1720 strcpy(WC->ImportantMessage, &buf[4]);
1721 display_main_menu();
1724 smart_goto("_BASEROOM_");
1731 * Perform changes to a room's network configuration
1733 void netedit(void) {
1738 if (strlen(bstr("line"))==0) {
1743 strcpy(line, bstr("prefix"));
1744 strcat(line, bstr("line"));
1745 strcat(line, bstr("suffix"));
1755 if (buf[0] != '1') {
1761 /* This loop works for add *or* remove. Spiffy, eh? */
1762 while (serv_gets(buf), strcmp(buf, "000")) {
1763 if (strcasecmp(buf, line)) {
1764 fprintf(fp, "%s\n", buf);
1771 if (buf[0] != '4') {
1777 while (fgets(buf, sizeof buf, fp) != NULL) {
1778 buf[strlen(buf)-1] = 0;
1782 if (!strcasecmp(bstr("cmd"), "add")) {
1794 * Convert a room name to a folder-ish-looking name.
1796 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
1801 * For mailboxes, just do it straight...
1804 sprintf(folder, "My folders|%s", room);
1808 * Otherwise, prefix the floor name as a "public folders" moniker
1811 sprintf(folder, "%s|%s", floorlist[floor], room);
1815 * Replace "\" characters with "|" for pseudo-folder-delimiting
1817 for (i=0; i<strlen(folder); ++i) {
1818 if (folder[i] == '\\') folder[i] = '|';
1826 * Back end for change_view()
1828 void do_change_view(int newview) {
1831 serv_printf("VIEW %d", newview);
1833 smart_goto(WC->wc_roomname);
1839 * Change the view for this room
1841 void change_view(void) {
1844 view = atol(bstr("view"));
1845 do_change_view(view);
1850 * One big expanded tree list view --- like a folder list
1852 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
1854 int levels, oldlevels;
1857 do_template("beginbox_nt");
1860 for (i=0; i<max_folders; ++i) {
1862 levels = num_tokens(fold[i].name, '|');
1865 for (t=0; t<levels; ++t) wprintf(" ");
1866 if (fold[i].selectable) {
1867 wprintf("<A HREF=\"/dotgoto?room=");
1868 urlescputs(fold[i].room);
1875 wprintf("<SPAN CLASS=\"roomlist_floor\">");
1877 else if (fold[i].hasnewmsgs) {
1878 wprintf("<SPAN CLASS=\"roomlist_new\">");
1881 wprintf("<SPAN CLASS=\"roomlist_old\">");
1883 extract(buf, fold[i].name, levels-1);
1886 if (fold[i].selectable) {
1892 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
1893 wprintf(" (INBOX)");
1897 do_template("endbox");
1901 * Boxes and rooms and lists ... oh my!
1903 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
1906 int levels, oldlevels;
1909 static int columns = 3;
1910 int boxes_per_column = 0;
1911 int current_column = 0;
1915 while (nf % columns != 0) ++nf;
1916 boxes_per_column = (nf / columns);
1917 if (boxes_per_column < 1) boxes_per_column = 1;
1919 /* Outer table (for columnization) */
1920 wprintf("<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1921 "<TR><TD VALIGN=TOP>");
1925 for (i=0; i<max_folders; ++i) {
1927 levels = num_tokens(fold[i].name, '|');
1929 if ((levels == 1) && (oldlevels == 2)) {
1932 do_template("endbox");
1935 if ((num_boxes % boxes_per_column) == 0) {
1937 if (current_column < columns) {
1938 wprintf("</TD><TD VALIGN=TOP>\n");
1945 /* Begin inner box */
1946 extract(buf, fold[i].name, levels-1);
1947 stresc(boxtitle, buf, 1, 0);
1948 svprintf("BOXTITLE", WCS_STRING, boxtitle);
1949 do_template("beginbox");
1957 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
1958 if (fold[i].selectable) {
1959 wprintf("<A HREF=\"/dotgoto?room=");
1960 urlescputs(fold[i].room);
1966 if (fold[i].hasnewmsgs) {
1967 wprintf("<SPAN CLASS=\"roomlist_new\">");
1970 wprintf("<SPAN CLASS=\"roomlist_old\">");
1972 extract(buf, fold[i].name, levels-1);
1975 if (fold[i].selectable) {
1981 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
1982 wprintf(" (INBOX)");
1987 /* End the final inner box */
1988 do_template("endbox");
1990 wprintf("</TD></TR></TABLE>\n");
1995 * Show the room list. (only should get called by
1996 * knrooms() because that's where output_headers() is called from)
1999 void list_all_rooms_by_floor(char *viewpref) {
2002 struct folder *fold = NULL;
2004 int max_folders = 0;
2005 int alloc_folders = 0;
2009 int num_floors = 1; /* add an extra one for private folders */
2011 /* Start with the mailboxes */
2014 fold = malloc(sizeof(struct folder));
2015 memset(fold, 0, sizeof(struct folder));
2016 strcpy(fold[0].name, "My folders");
2017 fold[0].is_mailbox = 1;
2019 /* Then add floors */
2022 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2023 if (max_folders >= alloc_folders) {
2024 alloc_folders = max_folders + 100;
2025 fold = realloc(fold,
2026 alloc_folders * sizeof(struct folder));
2028 memset(&fold[max_folders], 0, sizeof(struct folder));
2029 extract(fold[max_folders].name, buf, 1);
2037 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2038 if (max_folders >= alloc_folders) {
2039 alloc_folders = max_folders + 100;
2040 fold = realloc(fold,
2041 alloc_folders * sizeof(struct folder));
2043 memset(&fold[max_folders], 0, sizeof(struct folder));
2044 extract(fold[max_folders].room, buf, 0);
2045 ra_flags = extract_int(buf, 5);
2046 flags = extract_int(buf, 1);
2047 fold[max_folders].floor = extract_int(buf, 2);
2048 fold[max_folders].hasnewmsgs =
2049 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2050 if (flags & QR_MAILBOX) {
2051 fold[max_folders].is_mailbox = 1;
2053 room_to_folder(fold[max_folders].name,
2054 fold[max_folders].room,
2055 fold[max_folders].floor,
2056 fold[max_folders].is_mailbox);
2057 fold[max_folders].selectable = 1;
2061 /* Bubble-sort the folder list */
2062 for (i=0; i<max_folders; ++i) {
2063 for (j=0; j<(max_folders-1)-i; ++j) {
2064 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2065 swap = strcasecmp(fold[j].name, fold[j+1].name);
2068 if ( (fold[j+1].is_mailbox)
2069 && (!fold[j].is_mailbox)) {
2077 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2078 memcpy(&fold[j], &fold[j+1],
2079 sizeof(struct folder));
2080 memcpy(&fold[j+1], &ftmp,
2081 sizeof(struct folder));
2086 if (!strcasecmp(viewpref, "folders")) {
2087 do_folder_view(fold, max_folders, num_floors);
2090 do_rooms_view(fold, max_folders, num_floors);
2098 /* Do either a known rooms list or a folders list, depending on the
2102 char listviewpref[SIZ];
2107 /* Determine whether the user is trying to change views */
2108 if (bstr("view") != NULL) {
2109 if (strlen(bstr("view")) > 0) {
2110 set_preference("roomlistview", bstr("view"));
2114 get_preference("roomlistview", listviewpref);
2116 if ( (strcasecmp(listviewpref, "folders"))
2117 && (strcasecmp(listviewpref, "table")) ) {
2118 strcpy(listviewpref, "rooms");
2122 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2123 "<SPAN CLASS=\"titlebar\">"
2125 if (!strcasecmp(listviewpref, "rooms")) {
2126 wprintf("Room list");
2128 if (!strcasecmp(listviewpref, "folders")) {
2129 wprintf("Folder list");
2131 if (!strcasecmp(listviewpref, "table")) {
2132 wprintf("Room list");
2134 wprintf("</SPAN></TD>\n");
2137 /* offer the ability to switch views */
2138 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2139 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2140 "OnChange=\"location.href=roomlistomatic.newview.options"
2141 "[selectedIndex].value\">\n");
2143 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2146 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2149 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2150 "View as folder list"
2152 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2155 wprintf("</SELECT><BR>");
2157 wprintf("</FORM></TD></TR></TABLE>\n");
2159 /* Display the room list in the user's preferred format */
2160 list_all_rooms_by_floor(listviewpref);