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 rooms by floor (only should get called from knrooms() because
220 * that's where output_headers() is called from)
222 void tabular_room_list(void)
227 do_template("beginbox_nt");
228 wprintf("<TABLE width=100%% border><TR><TH>Floor</TH>");
229 wprintf("<TH>Rooms with new messages</TH>");
230 wprintf("<TH>Rooms with no new messages</TH></TR>\n");
232 for (a = 0; a < 128; ++a)
233 if (floorlist[a][0] != 0) {
235 /* Floor name column */
238 serv_printf("OIMG _floorpic_|%d", a);
243 wprintf("<IMG SRC=\"/image&name=_floorpic_&parm=%d\" ALT=\"%s\">",
244 a, &floorlist[a][0]);
246 escputs(&floorlist[a][0]);
251 /* Rooms with new messages column */
253 sprintf(buf, "LKRN %d", a);
255 wprintf("</TD>\n<TD>");
257 /* Rooms with old messages column */
258 sprintf(buf, "LKRO %d", a);
260 wprintf("</TD></TR>\n");
262 wprintf("</TABLE>\n");
263 do_template("endbox");
276 * list all forgotten rooms
278 void zapped_list(void)
282 svprintf("BOXTITLE", WCS_STRING, "Zapped (forgotten) rooms");
283 do_template("beginbox");
287 wprintf("<BR><BR>\n");
288 wprintf("Click on any room to un-zap it and goto that room.\n");
289 do_template("endbox");
295 * read this room's info file (set v to 1 for verbose mode)
304 fmout(NULL, "CENTER");
311 /* Display room graphic. The server doesn't actually
312 * need the room name, but we supply it in order to
313 * keep the browser from using a cached graphic from
316 void embed_room_graphic(void) {
319 serv_puts("OIMG _roompic_");
322 wprintf("<TD BGCOLOR=\"#444455\">");
323 wprintf("<IMG HEIGHT=64 SRC=\"/image&name=_roompic_&room=");
324 urlescputs(WC->wc_roomname);
333 /* Let the user know if new mail has arrived
335 void embed_newmail_button(void) {
336 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
338 "<A HREF=\"/dotgoto?room=_MAIL_\">"
339 "<IMG SRC=\"/static/mail.gif\" border=0 "
340 "ALT=\"You have new mail\">"
341 "<BR><SPAN CLASS=\"youhavemail\">"
342 "%d new mail</SPAN></A>", WC->new_mail);
343 WC->remember_new_mail = WC->new_mail;
350 * Display the current view and offer an option to change it
352 void embed_view_o_matic(void) {
355 wprintf("<FORM NAME=\"viewomatic\">\n"
356 "<SELECT NAME=\"newview\" SIZE=\"1\" "
357 "OnChange=\"location.href=viewomatic.newview.options"
358 "[selectedIndex].value\">\n");
360 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
362 * Only offer the views that make sense, given the default
363 * view for the room. For example, don't offer a Calendar
364 * view in a non-Calendar room.
368 || (i == WC->wc_default_view)
369 || ( (i == 0) && (WC->wc_default_view == 1) )
370 || ( (i == 1) && (WC->wc_default_view == 0) )
373 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
374 ((i == WC->wc_view) ? "SELECTED" : ""),
376 escputs(viewdefs[i]);
377 wprintf("</OPTION>\n");
380 wprintf("</SELECT></FORM>\n");
385 void embed_room_banner(char *got) {
388 /* We need to have the information returned by a GOTO server command.
389 * If it isn't supplied, we fake it by issuing our own GOTO.
392 serv_printf("GOTO %s", WC->wc_roomname);
397 /* If the user happens to select the "make this my start page" link,
398 * we want it to remember the URL as a "/dotskip" one instead of
399 * a "skip" or "gotonext" or something like that.
401 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
404 /* Check for new mail. */
405 WC->new_mail = extract_int(&got[4], 9);
406 WC->wc_view = extract_int(&got[4], 11);
408 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
409 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
410 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
411 svcallback("ROOMPIC", embed_room_graphic);
412 svcallback("ROOMINFO", readinfo);
413 svcallback("YOUHAVEMAIL", embed_newmail_button);
414 svcallback("VIEWOMATIC", embed_view_o_matic);
415 svcallback("START", offer_start_page);
417 do_template("roombanner");
418 clear_local_substs();
426 * generic routine to take the session to a new room
428 * display_name values: 0 = goto only
429 * 1 = goto and display
432 void gotoroom(char *gname, int display_name)
435 static long ls = (-1L);
440 wprintf("Pragma: no-cache\n");
441 wprintf("Cache-Control: no-store\n");
443 wprintf("<HTML><HEAD>\n"
444 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
445 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
446 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
447 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
449 do_template("background");
451 if (display_name != 2) {
452 /* store ungoto information */
453 strcpy(WC->ugname, WC->wc_roomname);
456 /* move to the new room */
457 serv_printf("GOTO %s", gname);
460 serv_puts("GOTO _BASEROOM_");
465 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
470 extract(WC->wc_roomname, &buf[4], 0);
471 WC->room_flags = extract_int(&buf[4], 4);
472 /* highest_msg_read = extract_int(&buf[4],6);
473 maxmsgnum = extract_int(&buf[4],5);
474 is_mail = (char) extract_int(&buf[4],7); */
475 ls = extract_long(&buf[4], 6);
478 WC->is_room_aide = WC->is_aide;
480 WC->is_room_aide = (char) extract_int(&buf[4], 8);
482 remove_march(WC->wc_roomname);
483 if (!strcasecmp(gname, "_BASEROOM_"))
486 /* Display the room banner */
488 embed_room_banner(buf);
491 strcpy(WC->wc_roomname, WC->wc_roomname);
492 WC->wc_view = extract_int(&buf[4], 11);
493 WC->wc_default_view = extract_int(&buf[4], 12);
498 * Locate the room on the march list which we most want to go to. Each room
499 * is measured given a "weight" of preference based on various factors.
501 char *pop_march(int desired_floor)
503 static char TheRoom[128];
505 int TheOrder = 32767;
508 struct march *mptr = NULL;
510 strcpy(TheRoom, "_BASEROOM_");
511 if (WC->march == NULL)
514 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
516 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
517 weight = weight + 10000;
518 if (mptr->march_floor == desired_floor)
519 weight = weight + 5000;
521 weight = weight + ((128 - (mptr->march_floor)) * 128);
522 weight = weight + (128 - (mptr->march_order));
524 if (weight > TheWeight) {
526 strcpy(TheRoom, mptr->march_name);
527 TheFloor = mptr->march_floor;
528 TheOrder = mptr->march_order;
536 /* Goto next room having unread messages.
537 * We want to skip over rooms that the user has already been to, and take the
538 * user back to the lobby when done. The room we end up in is placed in
539 * newroom - which is set to 0 (the lobby) initially.
540 * We start the search in the current room rather than the beginning to prevent
541 * two or more concurrent users from dragging each other back to the same room.
546 struct march *mptr, *mptr2;
549 /* First check to see if the march-mode list is already allocated.
550 * If it is, pop the first room off the list and go there.
553 if (WC->march == NULL) {
557 while (serv_gets(buf), strcmp(buf, "000")) {
558 mptr = (struct march *) malloc(sizeof(struct march));
560 extract(mptr->march_name, buf, 0);
561 mptr->march_floor = extract_int(buf, 2);
562 mptr->march_order = extract_int(buf, 3);
563 if (WC->march == NULL) {
567 while (mptr2->next != NULL)
572 /* add _BASEROOM_ to the end of the march list, so the user will end up
573 * in the system base room (usually the Lobby>) at the end of the loop
575 mptr = (struct march *) malloc(sizeof(struct march));
577 strcpy(mptr->march_name, "_BASEROOM_");
578 if (WC->march == NULL) {
582 while (mptr2->next != NULL)
587 * ...and remove the room we're currently in, so a <G>oto doesn't make us
588 * walk around in circles
590 remove_march(WC->wc_roomname);
592 if (WC->march != NULL) {
593 strcpy(next_room, pop_march(-1));
595 strcpy(next_room, "_BASEROOM_");
599 smart_goto(next_room);
603 void smart_goto(char *next_room) {
604 gotoroom(next_room, 0);
611 * mark all messages in current room as having been read
613 void slrp_highest(void)
618 serv_puts("SLRP HIGHEST");
621 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
628 * un-goto the previous room
634 if (!strcmp(WC->ugname, "")) {
635 smart_goto(WC->wc_roomname);
638 serv_printf("GOTO %s", WC->ugname);
641 smart_goto(WC->wc_roomname);
644 if (WC->uglsn >= 0L) {
645 serv_printf("SLRP %ld", WC->uglsn);
648 strcpy(buf, WC->ugname);
649 strcpy(WC->ugname, "");
658 * Set/clear/read the "self-service list subscribe" flag for a room
660 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
661 * Always returns the new value.
664 int self_service(int newval) {
665 int current_value = 0;
671 int flags, floor, order, view, flags2;
675 if (buf[0] != '2') return(0);
677 extract(name, &buf[4], 0);
678 extract(password, &buf[4], 1);
679 extract(dirname, &buf[4], 2);
680 flags = extract_int(&buf[4], 3);
681 floor = extract_int(&buf[4], 4);
682 order = extract_int(&buf[4], 5);
683 view = extract_int(&buf[4], 6);
684 flags2 = extract_int(&buf[4], 7);
686 if (flags2 & QR2_SELFLIST) {
694 flags2 = flags2 | QR2_SELFLIST;
696 else if (newval == 0) {
697 flags2 = flags2 & ~QR2_SELFLIST;
700 return(current_value);
703 if (newval != current_value) {
704 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
705 name, password, dirname, flags,
706 floor, order, view, flags2);
720 * display the form for editing a room
722 void display_editroom(void)
729 char er_password[10];
731 char er_roomaide[26];
737 char *not_shared_with;
740 if (strlen(tab) == 0) tab = "admin";
746 strcpy(WC->ImportantMessage, &buf[4]);
750 extract(er_name, &buf[4], 0);
751 extract(er_password, &buf[4], 1);
752 extract(er_dirname, &buf[4], 2);
753 er_flags = extract_int(&buf[4], 3);
754 er_floor = extract_int(&buf[4], 4);
758 /* print the tabbed dialog */
759 wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
761 "<TD> </TD>\n");
763 if (!strcmp(tab, "admin")) {
764 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
767 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=admin\">");
769 wprintf("Room administration");
770 if (!strcmp(tab, "admin")) {
771 wprintf("</SPAN></TD>\n");
774 wprintf("</A></TD>\n");
777 wprintf("<TD> </TD>\n");
779 if (!strcmp(tab, "config")) {
780 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
783 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=config\">");
785 wprintf("Room configuration");
786 if (!strcmp(tab, "config")) {
787 wprintf("</SPAN></TD>\n");
790 wprintf("</A></TD>\n");
793 wprintf("<TD> </TD>\n");
795 if (!strcmp(tab, "sharing")) {
796 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
799 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=sharing\">");
802 if (!strcmp(tab, "sharing")) {
803 wprintf("</SPAN></TD>\n");
806 wprintf("</A></TD>\n");
809 wprintf("<TD> </TD>\n");
811 if (!strcmp(tab, "listserv")) {
812 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
815 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=listserv\">");
817 wprintf("Mailing list service");
818 if (!strcmp(tab, "listserv")) {
819 wprintf("</SPAN></TD>\n");
822 wprintf("</A></TD>\n");
825 wprintf("</TR></TABLE>\n");
826 /* end tabbed dialog */
828 /* begin content of whatever tab is open now */
829 wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
832 if (!strcmp(tab, "admin")) {
834 "<LI><A HREF=\"/confirm_delete_room\">\n"
835 "Delete this room</A>\n"
836 "<LI><A HREF=\"/display_editroompic\">\n"
837 "Set or change the graphic for this room's banner</A>\n"
838 "<LI><A HREF=\"/display_editinfo\">\n"
839 "Edit this room's Info file</A>\n"
843 if (!strcmp(tab, "config")) {
844 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
846 wprintf("<UL><LI>Name of room: ");
847 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
849 wprintf("<LI>Resides on floor: ");
851 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
852 for (i = 0; i < 128; ++i)
853 if (strlen(floorlist[i]) > 0) {
856 wprintf("SELECTED ");
857 wprintf("VALUE=\"%d\">", i);
858 escputs(floorlist[i]);
859 wprintf("</OPTION>\n");
861 wprintf("</SELECT>\n");
863 wprintf("<LI>Type of room:<UL>\n");
865 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
866 if ((er_flags & QR_PRIVATE) == 0)
868 wprintf("> Public room\n");
870 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
871 if ((er_flags & QR_PRIVATE) &&
872 (er_flags & QR_GUESSNAME))
874 wprintf("> Private - guess name\n");
876 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
877 if ((er_flags & QR_PRIVATE) &&
878 (er_flags & QR_PASSWORDED))
880 wprintf("> Private - require password:\n");
881 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
883 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
884 if ((er_flags & QR_PRIVATE)
885 && ((er_flags & QR_GUESSNAME) == 0)
886 && ((er_flags & QR_PASSWORDED) == 0))
888 wprintf("> Private - invitation only\n");
890 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
891 wprintf("> If private, cause current users to forget room\n");
895 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
896 if (er_flags & QR_PREFONLY)
898 wprintf("> Preferred users only\n");
900 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
901 if (er_flags & QR_READONLY)
903 wprintf("> Read-only room\n");
905 /* directory stuff */
906 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
907 if (er_flags & QR_DIRECTORY)
909 wprintf("> File directory room\n");
911 wprintf("<UL><LI>Directory name: ");
912 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
914 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
915 if (er_flags & QR_UPLOAD)
917 wprintf("> Uploading allowed\n");
919 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
920 if (er_flags & QR_DOWNLOAD)
922 wprintf("> Downloading allowed\n");
924 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
925 if (er_flags & QR_VISDIR)
927 wprintf("> Visible directory</UL>\n");
929 /* end of directory stuff */
931 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
932 if (er_flags & QR_NETWORK)
934 wprintf("> Network shared room\n");
936 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
937 if (er_flags & QR_PERMANENT)
939 wprintf("> Permanent (does not auto-purge)\n");
941 /* start of anon options */
943 wprintf("<LI>Anonymous messages<UL>\n");
945 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
946 if (((er_flags & QR_ANONONLY) == 0)
947 && ((er_flags & QR_ANONOPT) == 0))
949 wprintf("> No anonymous messages\n");
951 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
952 if (er_flags & QR_ANONONLY)
954 wprintf("> All messages are anonymous\n");
956 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
957 if (er_flags & QR_ANONOPT)
959 wprintf("> Prompt user when entering messages</UL>\n");
961 /* end of anon options */
963 wprintf("<LI>Room aide: \n");
967 wprintf("<EM>%s</EM>\n", &buf[4]);
969 extract(er_roomaide, &buf[4], 0);
970 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
973 wprintf("</UL><CENTER>\n");
974 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
975 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
976 wprintf("</CENTER>\n");
980 /* Sharing the room with other Citadel nodes... */
981 if (!strcmp(tab, "sharing")) {
983 shared_with = strdup("");
984 not_shared_with = strdup("");
986 /* Learn the current configuration */
987 serv_puts("CONF getsys|application/x-citadel-ignet-config");
989 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
990 extract(node, buf, 0);
991 not_shared_with = realloc(not_shared_with,
992 strlen(not_shared_with) + 32);
993 strcat(not_shared_with, node);
994 strcat(not_shared_with, "|");
999 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1000 extract(cmd, buf, 0);
1001 extract(node, buf, 1);
1002 if (!strcasecmp(cmd, "ignet_push_share")) {
1003 shared_with = realloc(shared_with,
1004 strlen(shared_with) + 32);
1005 strcat(shared_with, node);
1006 strcat(shared_with, "|");
1010 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
1011 extract(node, shared_with, i);
1012 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
1013 extract(cmd, not_shared_with, j);
1014 if (!strcasecmp(node, cmd)) {
1015 remove_token(not_shared_with, j, '|');
1020 /* Display the stuff */
1021 wprintf("<CENTER><BR>"
1022 "<TABLE border=1 cellpadding=5><TR>"
1023 "<TD><B><I>Shared with</I></B></TD>"
1024 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1027 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
1028 extract(node, shared_with, i);
1029 if (strlen(node) > 0) {
1030 wprintf("%s ", node);
1031 wprintf("<A HREF=\"/netedit&cmd=remove&line="
1032 "ignet_push_share|");
1034 wprintf("&tab=sharing\">(unshare)</A><BR>");
1038 wprintf("</TD><TD>\n");
1040 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
1041 extract(node, not_shared_with, i);
1042 if (strlen(node) > 0) {
1043 wprintf("%s ", node);
1044 wprintf("<A HREF=\"/netedit&cmd=add&line="
1045 "ignet_push_share|");
1047 wprintf("&tab=sharing\">(share)</A><BR>");
1051 wprintf("</TD></TR>"
1053 "<I><B>Reminder:</B> When sharing a room, "
1054 "it must be shared from both ends. Adding a node to "
1055 "the 'shared' list sends messages out, but in order to"
1056 " receive messages, the other nodes must be configured"
1057 " to send messages out to your system as well.</I><BR>"
1062 /* Mailing list management */
1063 if (!strcmp(tab, "listserv")) {
1065 wprintf("<BR><center>"
1066 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1067 "<TR><TD VALIGN=TOP>");
1069 wprintf("<i>The contents of this room are being "
1070 "mailed <b>as individual messages</b> "
1071 "to the following list recipients:"
1076 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1077 extract(cmd, buf, 0);
1078 if (!strcasecmp(cmd, "listrecp")) {
1079 extract(recp, buf, 1);
1082 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1085 wprintf("&tab=listserv\">(remove)</A><BR>");
1089 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1090 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1091 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1092 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1093 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1094 wprintf("</FORM>\n");
1096 wprintf("</TD><TD VALIGN=TOP>\n");
1098 wprintf("<i>The contents of this room are being "
1099 "mailed <b>in digest form</b> "
1100 "to the following list recipients:"
1105 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1106 extract(cmd, buf, 0);
1107 if (!strcasecmp(cmd, "digestrecp")) {
1108 extract(recp, buf, 1);
1111 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1114 wprintf("&tab=listserv\">(remove)</A><BR>");
1118 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1119 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1120 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1121 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1122 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1123 wprintf("</FORM>\n");
1125 wprintf("</TD></TR></TABLE><HR>\n");
1127 if (self_service(999) == 1) {
1128 wprintf("This room is configured to allow "
1129 "self-service subscribe/unsubscribe requests."
1130 " <A HREF=\"/toggle_self_service?newval=0&"
1132 "Click to disable.</A><BR>\n"
1133 "The URL for subscribe/unsubscribe is: "
1134 "<TT>http://%s/listsub</TT><BR>\n",
1139 wprintf("This room is <i>not</i> configured to allow "
1140 "self-service subscribe/unsubscribe requests."
1141 " <A HREF=\"/toggle_self_service?newval=1&"
1143 "Click to enable.</A><BR>\n"
1148 wprintf("</CENTER>\n");
1151 /* end content of whatever tab is open now */
1152 wprintf("</TD></TR></TABLE>\n");
1159 * Toggle self-service list subscription
1161 void toggle_self_service(void) {
1164 newval = atoi(bstr("newval"));
1165 self_service(newval);
1172 * save new parameters for a room
1178 char er_password[10];
1179 char er_dirname[15];
1180 char er_roomaide[26];
1186 if (strcmp(bstr("sc"), "OK")) {
1187 strcpy(WC->ImportantMessage,
1188 "Cancelled. Changes were not saved.");
1189 display_main_menu();
1195 if (buf[0] != '2') {
1196 strcpy(WC->ImportantMessage, &buf[4]);
1197 display_main_menu();
1200 extract(er_name, &buf[4], 0);
1201 extract(er_password, &buf[4], 1);
1202 extract(er_dirname, &buf[4], 2);
1203 er_flags = extract_int(&buf[4], 3);
1205 strcpy(er_roomaide, bstr("er_roomaide"));
1206 if (strlen(er_roomaide) == 0) {
1209 if (buf[0] != '2') {
1210 strcpy(er_roomaide, "");
1212 extract(er_roomaide, &buf[4], 0);
1215 strcpy(buf, bstr("er_name"));
1217 if (strlen(buf) > 0)
1218 strcpy(er_name, buf);
1220 strcpy(buf, bstr("er_password"));
1222 if (strlen(buf) > 0)
1223 strcpy(er_password, buf);
1225 strcpy(buf, bstr("er_dirname"));
1227 if (strlen(buf) > 0)
1228 strcpy(er_dirname, buf);
1230 strcpy(buf, bstr("type"));
1231 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1233 if (!strcmp(buf, "invonly")) {
1234 er_flags |= (QR_PRIVATE);
1236 if (!strcmp(buf, "guessname")) {
1237 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1239 if (!strcmp(buf, "passworded")) {
1240 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1242 if (!strcmp(bstr("prefonly"), "yes")) {
1243 er_flags |= QR_PREFONLY;
1245 er_flags &= ~QR_PREFONLY;
1248 if (!strcmp(bstr("readonly"), "yes")) {
1249 er_flags |= QR_READONLY;
1251 er_flags &= ~QR_READONLY;
1254 if (!strcmp(bstr("permanent"), "yes")) {
1255 er_flags |= QR_PERMANENT;
1257 er_flags &= ~QR_PERMANENT;
1260 if (!strcmp(bstr("network"), "yes")) {
1261 er_flags |= QR_NETWORK;
1263 er_flags &= ~QR_NETWORK;
1266 if (!strcmp(bstr("directory"), "yes")) {
1267 er_flags |= QR_DIRECTORY;
1269 er_flags &= ~QR_DIRECTORY;
1272 if (!strcmp(bstr("ulallowed"), "yes")) {
1273 er_flags |= QR_UPLOAD;
1275 er_flags &= ~QR_UPLOAD;
1278 if (!strcmp(bstr("dlallowed"), "yes")) {
1279 er_flags |= QR_DOWNLOAD;
1281 er_flags &= ~QR_DOWNLOAD;
1284 if (!strcmp(bstr("visdir"), "yes")) {
1285 er_flags |= QR_VISDIR;
1287 er_flags &= ~QR_VISDIR;
1290 strcpy(buf, bstr("anon"));
1292 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1293 if (!strcmp(buf, "anononly"))
1294 er_flags |= QR_ANONONLY;
1295 if (!strcmp(buf, "anon2"))
1296 er_flags |= QR_ANONOPT;
1299 if (!strcmp(bstr("bump"), "yes"))
1302 er_floor = atoi(bstr("er_floor"));
1304 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1305 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1308 if (buf[0] != '2') {
1309 strcpy(WC->ImportantMessage, &buf[4]);
1310 display_main_menu();
1313 gotoroom(er_name, 0);
1315 if (strlen(er_roomaide) > 0) {
1316 sprintf(buf, "SETA %s", er_roomaide);
1319 if (buf[0] != '2') {
1320 strcpy(WC->ImportantMessage, &buf[4]);
1321 display_main_menu();
1325 smart_goto(er_name);
1329 * Invite, Kick, and show Who Knows a room
1331 void display_whok(void)
1333 char buf[SIZ], room[SIZ], username[SIZ];
1338 if (buf[0] != '2') {
1339 strcpy(WC->ImportantMessage, &buf[4]);
1340 display_main_menu();
1343 extract(room, &buf[4], 0);
1345 strcpy(username, bstr("username"));
1347 if(!strcmp(bstr("sc"), "Kick")) {
1348 sprintf(buf, "KICK %s", username);
1352 if (buf[0] != '2') {
1353 strcpy(WC->ImportantMessage, &buf[4]);
1355 sprintf(WC->ImportantMessage,
1356 "<B><I>User %s kicked out of room %s.</I></B>\n",
1359 } else if(!strcmp(bstr("sc"), "Invite")) {
1360 sprintf(buf, "INVT %s", username);
1364 if (buf[0] != '2') {
1365 strcpy(WC->ImportantMessage, &buf[4]);
1367 sprintf(WC->ImportantMessage,
1368 "<B><I>User %s invited to room %s.</I></B>\n",
1374 stresc(buf, WC->wc_roomname, 1, 1);
1375 svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
1376 do_template("beginbox");
1378 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1379 "<TD>The users listed below have access to this room. "
1380 "To remove a user from the access list, select the user "
1381 "name from the list and click 'Kick'.<BR><BR>");
1383 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1384 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1387 if (buf[0] == '1') {
1388 while (serv_gets(buf), strcmp(buf, "000")) {
1389 extract(username, buf, 0);
1390 wprintf("<OPTION>");
1395 wprintf("</SELECT><BR>\n");
1397 wprintf("<input type=submit name=sc value=\"Kick\">");
1398 wprintf("</FORM></CENTER>\n");
1401 "To grant another user access to this room, enter the "
1402 "user name in the box below and click 'Invite'.<BR><BR>");
1404 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1405 wprintf("Invite: ");
1406 wprintf("<input type=text name=username><BR>\n"
1407 "<input type=hidden name=sc value=\"Invite\">"
1408 "<input type=submit value=\"Invite\">"
1409 "</FORM></CENTER>\n");
1411 wprintf("</TD></TR></TABLE>\n");
1412 do_template("endbox");
1419 * display the form for entering a new room
1421 void display_entroom(void)
1426 serv_puts("CRE8 0");
1429 if (buf[0] != '2') {
1430 strcpy(WC->ImportantMessage, &buf[4]);
1431 display_main_menu();
1435 svprintf("BOXTITLE", WCS_STRING, "Create a new room");
1436 do_template("beginbox");
1438 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1440 wprintf("<UL><LI>Name of room: ");
1441 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1443 wprintf("<LI>Resides on floor: ");
1445 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1446 for (i = 0; i < 128; ++i)
1447 if (strlen(floorlist[i]) > 0) {
1448 wprintf("<OPTION ");
1449 wprintf("VALUE=\"%d\">", i);
1450 escputs(floorlist[i]);
1451 wprintf("</OPTION>\n");
1453 wprintf("</SELECT>\n");
1455 wprintf("<LI>Type of room:<UL>\n");
1457 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1458 wprintf("CHECKED > Public room\n");
1460 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1461 wprintf("> Private - guess name\n");
1463 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1464 wprintf("> Private - require password:\n");
1465 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1467 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1468 wprintf("> Private - invitation only\n");
1470 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1471 wprintf("> Personal (mailbox for you only)\n");
1474 wprintf("<LI>Default view for room: "); /* FOO */
1475 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
1476 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1477 wprintf("<OPTION %s VALUE=\"%d\">",
1478 ((i == 0) ? "SELECTED" : ""), i );
1479 escputs(viewdefs[i]);
1480 wprintf("</OPTION>\n");
1482 wprintf("</SELECT>\n");
1484 wprintf("<CENTER>\n");
1485 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1486 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1487 wprintf("</CENTER>\n");
1488 wprintf("</FORM>\n<HR>");
1489 serv_printf("MESG roomaccess");
1491 if (buf[0] == '1') {
1492 fmout(NULL, "CENTER");
1494 do_template("endbox");
1502 * support function for entroom() -- sets the default view
1504 void er_set_default_view(int newview) {
1518 if (buf[0] != '2') return;
1520 extract(rm_name, &buf[4], 0);
1521 extract(rm_pass, &buf[4], 1);
1522 extract(rm_dir, &buf[4], 2);
1523 rm_bits1 = extract_int(&buf[4], 3);
1524 rm_floor = extract_int(&buf[4], 4);
1525 rm_listorder = extract_int(&buf[4], 5);
1526 rm_bits2 = extract_int(&buf[4], 7);
1528 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1529 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1530 rm_listorder, newview, rm_bits2
1545 char er_password[SIZ];
1549 if (strcmp(bstr("sc"), "OK")) {
1550 strcpy(WC->ImportantMessage,
1551 "Cancelled. No new room was created.");
1552 display_main_menu();
1555 strcpy(er_name, bstr("er_name"));
1556 strcpy(er_type, bstr("type"));
1557 strcpy(er_password, bstr("er_password"));
1558 er_floor = atoi(bstr("er_floor"));
1561 if (!strcmp(er_type, "guessname"))
1563 if (!strcmp(er_type, "passworded"))
1565 if (!strcmp(er_type, "invonly"))
1567 if (!strcmp(er_type, "personal"))
1570 sprintf(buf, "CRE8 1|%s|%d|%s|%d",
1571 er_name, er_num_type, er_password, er_floor);
1574 if (buf[0] != '2') {
1575 strcpy(WC->ImportantMessage, &buf[4]);
1576 display_main_menu();
1579 gotoroom(er_name, 0);
1580 er_set_default_view(atoi(bstr("er_view"))); /* Set default view */
1581 do_change_view(atoi(bstr("er_view"))); /* Now go there */
1586 * display the screen to enter a private room
1588 void display_private(char *rname, int req_pass)
1593 svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
1594 do_template("beginbox");
1596 wprintf("<CENTER>\n");
1597 wprintf("<BR>If you know the name of a hidden (guess-name) or\n");
1598 wprintf("passworded room, you can enter that room by typing\n");
1599 wprintf("its name below. Once you gain access to a private\n");
1600 wprintf("room, it will appear in your regular room listings\n");
1601 wprintf("so you don't have to keep returning here.\n");
1602 wprintf("<BR><BR>");
1604 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1606 wprintf("<table border=\"0\" cellspacing=\"5\" "
1607 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
1609 "Enter room name:</TD><TD>"
1610 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
1611 "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1614 wprintf("</TD></TR><TR><TD>");
1615 wprintf("Enter room password:</TD><TD>");
1616 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1618 wprintf("</TD></TR></TABLE><BR>\n");
1620 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
1622 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1623 wprintf("</FORM>\n");
1624 do_template("endbox");
1629 * goto a private room
1631 void goto_private(void)
1636 if (strcasecmp(bstr("sc"), "OK")) {
1637 display_main_menu();
1640 strcpy(hold_rm, WC->wc_roomname);
1641 strcpy(buf, "GOTO ");
1642 strcat(buf, bstr("gr_name"));
1644 strcat(buf, bstr("gr_pass"));
1648 if (buf[0] == '2') {
1649 smart_goto(bstr("gr_name"));
1652 if (!strncmp(buf, "540", 3)) {
1653 display_private(bstr("gr_name"), 1);
1657 wprintf("%s\n", &buf[4]);
1664 * display the screen to zap a room
1666 void display_zap(void)
1670 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1671 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget) the current room</SPAN>\n");
1672 wprintf("</TD></TR></TABLE>\n");
1674 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1675 wprintf("disappear from your room list. Is this what you wish ");
1676 wprintf("to do?<BR>\n");
1678 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1679 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1680 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1681 wprintf("</FORM>\n");
1692 char final_destination[SIZ];
1694 /* If the forget-room routine fails for any reason, we fall back
1695 * to the current room; otherwise, we go to the Lobby
1697 strcpy(final_destination, WC->wc_roomname);
1699 if (!strcasecmp(bstr("sc"), "OK")) {
1700 serv_printf("GOTO %s", WC->wc_roomname);
1702 if (buf[0] != '2') {
1703 /* ExpressMessageCat(&buf[4]); */
1707 if (buf[0] != '2') {
1708 /* ExpressMessageCat(&buf[4]); */
1710 strcpy(final_destination, "_BASEROOM_");
1714 smart_goto(final_destination);
1721 * Confirm deletion of the current room
1723 void confirm_delete_room(void)
1727 serv_puts("KILL 0");
1729 if (buf[0] != '2') {
1730 strcpy(WC->ImportantMessage, &buf[4]);
1731 display_main_menu();
1735 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1736 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1737 wprintf("</TD></TR></TABLE>\n");
1739 wprintf("<CENTER>");
1740 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1742 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1743 escputs(WC->wc_roomname);
1744 wprintf("</FONT>?<BR>\n");
1746 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1747 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1749 wprintf("</FORM></CENTER>\n");
1755 * Delete the current room
1757 void delete_room(void)
1762 strcpy(sc, bstr("sc"));
1764 if (strcasecmp(sc, "Delete")) {
1765 strcpy(WC->ImportantMessage,
1766 "Cancelled. This room was not deleted.");
1767 display_main_menu();
1770 serv_puts("KILL 1");
1772 if (buf[0] != '2') {
1773 strcpy(WC->ImportantMessage, &buf[4]);
1774 display_main_menu();
1777 smart_goto("_BASEROOM_");
1784 * Perform changes to a room's network configuration
1786 void netedit(void) {
1791 if (strlen(bstr("line"))==0) {
1796 strcpy(line, bstr("prefix"));
1797 strcat(line, bstr("line"));
1798 strcat(line, bstr("suffix"));
1808 if (buf[0] != '1') {
1814 /* This loop works for add *or* remove. Spiffy, eh? */
1815 while (serv_gets(buf), strcmp(buf, "000")) {
1816 if (strcasecmp(buf, line)) {
1817 fprintf(fp, "%s\n", buf);
1824 if (buf[0] != '4') {
1830 while (fgets(buf, sizeof buf, fp) != NULL) {
1831 buf[strlen(buf)-1] = 0;
1835 if (!strcasecmp(bstr("cmd"), "add")) {
1847 * Convert a room name to a folder-ish-looking name.
1849 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
1854 * For mailboxes, just do it straight...
1857 sprintf(folder, "My folders|%s", room);
1861 * Otherwise, prefix the floor name as a "public folders" moniker
1864 sprintf(folder, "%s|%s", floorlist[floor], room);
1868 * Replace "\" characters with "|" for pseudo-folder-delimiting
1870 for (i=0; i<strlen(folder); ++i) {
1871 if (folder[i] == '\\') folder[i] = '|';
1879 * Back end for change_view()
1881 void do_change_view(int newview) {
1884 serv_printf("VIEW %d", newview);
1886 smart_goto(WC->wc_roomname);
1892 * Change the view for this room
1894 void change_view(void) {
1897 view = atol(bstr("view"));
1898 do_change_view(view);
1903 * One big expanded tree list view --- like a folder list
1905 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
1907 int levels, oldlevels;
1910 do_template("beginbox_nt");
1913 for (i=0; i<max_folders; ++i) {
1915 levels = num_tokens(fold[i].name, '|');
1918 for (t=0; t<levels; ++t) wprintf(" ");
1919 if (fold[i].selectable) {
1920 wprintf("<A HREF=\"/dotgoto?room=");
1921 urlescputs(fold[i].room);
1928 wprintf("<SPAN CLASS=\"roomlist_floor\">");
1930 else if (fold[i].hasnewmsgs) {
1931 wprintf("<SPAN CLASS=\"roomlist_new\">");
1934 wprintf("<SPAN CLASS=\"roomlist_old\">");
1936 extract(buf, fold[i].name, levels-1);
1939 if (fold[i].selectable) {
1945 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
1946 wprintf(" (INBOX)");
1950 do_template("endbox");
1954 * Boxes and rooms and lists ... oh my!
1956 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
1959 int levels, oldlevels;
1962 static int columns = 3;
1963 int boxes_per_column = 0;
1964 int current_column = 0;
1968 while (nf % columns != 0) ++nf;
1969 boxes_per_column = (nf / columns);
1970 if (boxes_per_column < 1) boxes_per_column = 1;
1972 /* Outer table (for columnization) */
1973 wprintf("<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1974 "<TR><TD VALIGN=TOP>");
1978 for (i=0; i<max_folders; ++i) {
1980 levels = num_tokens(fold[i].name, '|');
1982 if ((levels == 1) && (oldlevels == 2)) {
1985 do_template("endbox");
1988 if ((num_boxes % boxes_per_column) == 0) {
1990 if (current_column < columns) {
1991 wprintf("</TD><TD VALIGN=TOP>\n");
1998 /* Begin inner box */
1999 extract(buf, fold[i].name, levels-1);
2000 stresc(boxtitle, buf, 1, 0);
2001 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2002 do_template("beginbox");
2010 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2011 if (fold[i].selectable) {
2012 wprintf("<A HREF=\"/dotgoto?room=");
2013 urlescputs(fold[i].room);
2019 if (fold[i].hasnewmsgs) {
2020 wprintf("<SPAN CLASS=\"roomlist_new\">");
2023 wprintf("<SPAN CLASS=\"roomlist_old\">");
2025 extract(buf, fold[i].name, levels-1);
2028 if (fold[i].selectable) {
2034 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2035 wprintf(" (INBOX)");
2040 /* End the final inner box */
2041 do_template("endbox");
2043 wprintf("</TD></TR></TABLE>\n");
2048 * Show the room list. (only should get called by
2049 * knrooms() because that's where output_headers() is called from)
2052 void list_all_rooms_by_floor(char *viewpref) {
2055 struct folder *fold = NULL;
2057 int max_folders = 0;
2058 int alloc_folders = 0;
2062 int num_floors = 1; /* add an extra one for private folders */
2064 /* Start with the mailboxes */
2067 fold = malloc(sizeof(struct folder));
2068 memset(fold, 0, sizeof(struct folder));
2069 strcpy(fold[0].name, "My folders");
2070 fold[0].is_mailbox = 1;
2072 /* Then add floors */
2075 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2076 if (max_folders >= alloc_folders) {
2077 alloc_folders = max_folders + 100;
2078 fold = realloc(fold,
2079 alloc_folders * sizeof(struct folder));
2081 memset(&fold[max_folders], 0, sizeof(struct folder));
2082 extract(fold[max_folders].name, buf, 1);
2090 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
2091 if (max_folders >= alloc_folders) {
2092 alloc_folders = max_folders + 100;
2093 fold = realloc(fold,
2094 alloc_folders * sizeof(struct folder));
2096 memset(&fold[max_folders], 0, sizeof(struct folder));
2097 extract(fold[max_folders].room, buf, 0);
2098 ra_flags = extract_int(buf, 5);
2099 flags = extract_int(buf, 1);
2100 fold[max_folders].floor = extract_int(buf, 2);
2101 fold[max_folders].hasnewmsgs =
2102 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2103 if (flags & QR_MAILBOX) {
2104 fold[max_folders].is_mailbox = 1;
2106 room_to_folder(fold[max_folders].name,
2107 fold[max_folders].room,
2108 fold[max_folders].floor,
2109 fold[max_folders].is_mailbox);
2110 fold[max_folders].selectable = 1;
2114 /* Bubble-sort the folder list */
2115 for (i=0; i<max_folders; ++i) {
2116 for (j=0; j<(max_folders-1)-i; ++j) {
2117 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2118 swap = strcasecmp(fold[j].name, fold[j+1].name);
2121 if ( (fold[j+1].is_mailbox)
2122 && (!fold[j].is_mailbox)) {
2130 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2131 memcpy(&fold[j], &fold[j+1],
2132 sizeof(struct folder));
2133 memcpy(&fold[j+1], &ftmp,
2134 sizeof(struct folder));
2139 if (!strcasecmp(viewpref, "folders")) {
2140 do_folder_view(fold, max_folders, num_floors);
2143 do_rooms_view(fold, max_folders, num_floors);
2151 /* Do either a known rooms list or a folders list, depending on the
2155 char listviewpref[SIZ];
2160 /* Determine whether the user is trying to change views */
2161 if (bstr("view") != NULL) {
2162 if (strlen(bstr("view")) > 0) {
2163 set_preference("roomlistview", bstr("view"));
2167 get_preference("roomlistview", listviewpref);
2169 if ( (strcasecmp(listviewpref, "folders"))
2170 && (strcasecmp(listviewpref, "table")) ) {
2171 strcpy(listviewpref, "rooms");
2175 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#000077\"><TR><TD>"
2176 "<SPAN CLASS=\"titlebar\">"
2178 if (!strcasecmp(listviewpref, "rooms")) {
2179 wprintf("Room list");
2181 if (!strcasecmp(listviewpref, "folders")) {
2182 wprintf("Folder list");
2184 if (!strcasecmp(listviewpref, "table")) {
2185 wprintf("Room list");
2187 wprintf("</SPAN></TD>\n");
2190 /* offer the ability to switch views */
2191 wprintf("<TD><FORM NAME=\"roomlistomatic\">\n"
2192 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2193 "OnChange=\"location.href=roomlistomatic.newview.options"
2194 "[selectedIndex].value\">\n");
2196 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2199 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2202 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2203 "View as folder list"
2205 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2208 wprintf("<OPTION %s VALUE=\"/knrooms&view=table\">"
2209 "Classic table view"
2211 ( !strcasecmp(listviewpref, "table") ? "SELECTED" : "" )
2214 wprintf("</SELECT></FORM></TD><TD>\n");
2216 wprintf("</TD></TR></TABLE>\n");
2218 /* Display the room list in the user's preferred format */
2219 if (!strcasecmp(listviewpref, "table")) {
2220 tabular_room_list();
2223 list_all_rooms_by_floor(listviewpref);