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=");
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)
281 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
282 wprintf("<SPAN CLASS=\"titlebar\">Zapped (forgotten) rooms</SPAN>\n");
283 wprintf("</TD></TR></TABLE><BR>\n");
285 wprintf("<BR><BR>\n");
286 wprintf("Click on any room to un-zap it and goto that room.\n");
292 * read this room's info file (set v to 1 for verbose mode)
308 /* Display room graphic. The server doesn't actually
309 * need the room name, but we supply it in order to
310 * keep the browser from using a cached graphic from
313 void embed_room_graphic(void) {
316 serv_puts("OIMG _roompic_");
319 wprintf("<TD BGCOLOR=\"#444455\">");
320 wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
321 urlescputs(WC->wc_roomname);
330 /* Let the user know if new mail has arrived
332 void embed_newmail_button(void) {
333 if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) {
335 "<A HREF=\"/dotgoto?room=_MAIL_\">"
336 "<IMG SRC=\"/static/mail.gif\" border=0 "
337 "ALT=\"You have new mail\">"
338 "<BR><SPAN CLASS=\"youhavemail\">"
339 "%d new mail</SPAN></A>", WC->new_mail);
340 WC->remember_new_mail = WC->new_mail;
347 * Display the current view and offer an option to change it
349 void embed_view_o_matic(void) {
352 wprintf("<FORM NAME=\"viewomatic\">\n"
353 "<SELECT NAME=\"newview\" SIZE=\"1\" "
354 "OnChange=\"location.href=viewomatic.newview.options"
355 "[selectedIndex].value\">\n");
357 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
359 * Only offer the views that make sense, given the default
360 * view for the room. For example, don't offer a Calendar
361 * view in a non-Calendar room.
365 || (i == WC->wc_default_view)
366 || ( (i == 0) && (WC->wc_default_view == 1) )
367 || ( (i == 1) && (WC->wc_default_view == 0) )
370 wprintf("<OPTION %s VALUE=\"/changeview?view=%d\">",
371 ((i == WC->wc_view) ? "SELECTED" : ""),
373 escputs(viewdefs[i]);
374 wprintf("</OPTION>\n");
377 wprintf("</SELECT></FORM>\n");
382 void embed_room_banner(char *got) {
385 /* We need to have the information returned by a GOTO server command.
386 * If it isn't supplied, we fake it by issuing our own GOTO.
389 serv_printf("GOTO %s", WC->wc_roomname);
394 /* If the user happens to select the "make this my start page" link,
395 * we want it to remember the URL as a "/dotskip" one instead of
396 * a "skip" or "gotonext" or something like that.
398 snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s",
401 /* Check for new mail. */
402 WC->new_mail = extract_int(&got[4], 9);
403 WC->wc_view = extract_int(&got[4], 11);
405 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
406 svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1));
407 svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2));
408 svcallback("ROOMPIC", embed_room_graphic);
409 svcallback("ROOMINFO", readinfo);
410 svcallback("YOUHAVEMAIL", embed_newmail_button);
411 svcallback("VIEWOMATIC", embed_view_o_matic);
412 svcallback("START", offer_start_page);
414 do_template("roombanner");
415 clear_local_substs();
423 * generic routine to take the session to a new room
425 * display_name values: 0 = goto only
426 * 1 = goto and display
429 void gotoroom(char *gname, int display_name)
432 static long ls = (-1L);
437 wprintf("Pragma: no-cache\n");
438 wprintf("Cache-Control: no-store\n");
440 wprintf("<HTML><HEAD>\n"
441 "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
442 "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
443 "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
444 "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
446 do_template("background");
448 if (display_name != 2) {
449 /* store ungoto information */
450 strcpy(WC->ugname, WC->wc_roomname);
453 /* move to the new room */
454 serv_printf("GOTO %s", gname);
457 serv_puts("GOTO _BASEROOM_");
462 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
467 extract(WC->wc_roomname, &buf[4], 0);
468 WC->room_flags = extract_int(&buf[4], 4);
469 /* highest_msg_read = extract_int(&buf[4],6);
470 maxmsgnum = extract_int(&buf[4],5);
471 is_mail = (char) extract_int(&buf[4],7); */
472 ls = extract_long(&buf[4], 6);
475 WC->is_room_aide = WC->is_aide;
477 WC->is_room_aide = (char) extract_int(&buf[4], 8);
479 remove_march(WC->wc_roomname);
480 if (!strcasecmp(gname, "_BASEROOM_"))
483 /* Display the room banner */
485 embed_room_banner(buf);
488 strcpy(WC->wc_roomname, WC->wc_roomname);
489 WC->wc_view = extract_int(&buf[4], 11);
490 WC->wc_default_view = extract_int(&buf[4], 12);
495 * Locate the room on the march list which we most want to go to. Each room
496 * is measured given a "weight" of preference based on various factors.
498 char *pop_march(int desired_floor)
500 static char TheRoom[128];
502 int TheOrder = 32767;
505 struct march *mptr = NULL;
507 strcpy(TheRoom, "_BASEROOM_");
508 if (WC->march == NULL)
511 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
513 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
514 weight = weight + 10000;
515 if (mptr->march_floor == desired_floor)
516 weight = weight + 5000;
518 weight = weight + ((128 - (mptr->march_floor)) * 128);
519 weight = weight + (128 - (mptr->march_order));
521 if (weight > TheWeight) {
523 strcpy(TheRoom, mptr->march_name);
524 TheFloor = mptr->march_floor;
525 TheOrder = mptr->march_order;
533 /* Goto next room having unread messages.
534 * We want to skip over rooms that the user has already been to, and take the
535 * user back to the lobby when done. The room we end up in is placed in
536 * newroom - which is set to 0 (the lobby) initially.
537 * We start the search in the current room rather than the beginning to prevent
538 * two or more concurrent users from dragging each other back to the same room.
543 struct march *mptr, *mptr2;
546 /* First check to see if the march-mode list is already allocated.
547 * If it is, pop the first room off the list and go there.
550 if (WC->march == NULL) {
554 while (serv_gets(buf), strcmp(buf, "000")) {
555 mptr = (struct march *) malloc(sizeof(struct march));
557 extract(mptr->march_name, buf, 0);
558 mptr->march_floor = extract_int(buf, 2);
559 mptr->march_order = extract_int(buf, 3);
560 if (WC->march == NULL) {
564 while (mptr2->next != NULL)
569 /* add _BASEROOM_ to the end of the march list, so the user will end up
570 * in the system base room (usually the Lobby>) at the end of the loop
572 mptr = (struct march *) malloc(sizeof(struct march));
574 strcpy(mptr->march_name, "_BASEROOM_");
575 if (WC->march == NULL) {
579 while (mptr2->next != NULL)
584 * ...and remove the room we're currently in, so a <G>oto doesn't make us
585 * walk around in circles
587 remove_march(WC->wc_roomname);
589 if (WC->march != NULL) {
590 strcpy(next_room, pop_march(-1));
592 strcpy(next_room, "_BASEROOM_");
596 smart_goto(next_room);
600 void smart_goto(char *next_room) {
601 gotoroom(next_room, 0);
608 * mark all messages in current room as having been read
610 void slrp_highest(void)
615 serv_puts("SLRP HIGHEST");
618 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
625 * un-goto the previous room
631 if (!strcmp(WC->ugname, "")) {
632 smart_goto(WC->wc_roomname);
635 serv_printf("GOTO %s", WC->ugname);
638 smart_goto(WC->wc_roomname);
641 if (WC->uglsn >= 0L) {
642 serv_printf("SLRP %ld", WC->uglsn);
645 strcpy(buf, WC->ugname);
646 strcpy(WC->ugname, "");
655 * Set/clear/read the "self-service list subscribe" flag for a room
657 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
658 * Always returns the new value.
661 int self_service(int newval) {
662 int current_value = 0;
668 int flags, floor, order, view, flags2;
672 if (buf[0] != '2') return(0);
674 extract(name, &buf[4], 0);
675 extract(password, &buf[4], 1);
676 extract(dirname, &buf[4], 2);
677 flags = extract_int(&buf[4], 3);
678 floor = extract_int(&buf[4], 4);
679 order = extract_int(&buf[4], 5);
680 view = extract_int(&buf[4], 6);
681 flags2 = extract_int(&buf[4], 7);
683 if (flags2 & QR2_SELFLIST) {
691 flags2 = flags2 | QR2_SELFLIST;
693 else if (newval == 0) {
694 flags2 = flags2 & ~QR2_SELFLIST;
697 return(current_value);
700 if (newval != current_value) {
701 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
702 name, password, dirname, flags,
703 floor, order, view, flags2);
717 * display the form for editing a room
719 void display_editroom(void)
726 char er_password[10];
728 char er_roomaide[26];
734 char *not_shared_with;
737 if (strlen(tab) == 0) tab = "admin";
743 display_error(&buf[4]);
746 extract(er_name, &buf[4], 0);
747 extract(er_password, &buf[4], 1);
748 extract(er_dirname, &buf[4], 2);
749 er_flags = extract_int(&buf[4], 3);
750 er_floor = extract_int(&buf[4], 4);
754 /* print the tabbed dialog */
755 wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
756 "<TR ALIGN=CENTER BGCOLOR=\"#FFFFFF\">"
757 "<TD> </TD>\n");
759 if (!strcmp(tab, "admin")) {
760 wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
763 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=admin\">");
765 wprintf("Room administration");
766 if (!strcmp(tab, "admin")) {
767 wprintf("</SPAN></TD>\n");
770 wprintf("</A></TD>\n");
773 wprintf("<TD> </TD>\n");
775 if (!strcmp(tab, "config")) {
776 wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
779 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=config\">");
781 wprintf("Room configuration");
782 if (!strcmp(tab, "config")) {
783 wprintf("</SPAN></TD>\n");
786 wprintf("</A></TD>\n");
789 wprintf("<TD> </TD>\n");
791 if (!strcmp(tab, "sharing")) {
792 wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
795 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=sharing\">");
798 if (!strcmp(tab, "sharing")) {
799 wprintf("</SPAN></TD>\n");
802 wprintf("</A></TD>\n");
805 wprintf("<TD> </TD>\n");
807 if (!strcmp(tab, "listserv")) {
808 wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
811 wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=listserv\">");
813 wprintf("Mailing list service");
814 if (!strcmp(tab, "listserv")) {
815 wprintf("</SPAN></TD>\n");
818 wprintf("</A></TD>\n");
821 wprintf("<TD> </TD></TR>"
822 "<TR><TD BGCOLOR=\"#000077\" COLSPAN=9 HEIGHT=5> </TD></TR>"
825 /* end tabbed dialog */
828 if (!strcmp(tab, "admin")) {
830 "<LI><A HREF=\"/confirm_delete_room\">\n"
831 "Delete this room</A>\n"
832 "<LI><A HREF=\"/display_editroompic\">\n"
833 "Set or change the graphic for this room's banner</A>\n"
834 "<LI><A HREF=\"/display_editinfo\">\n"
835 "Edit this room's Info file</A>\n"
839 if (!strcmp(tab, "config")) {
840 wprintf("<FORM METHOD=\"POST\" ACTION=\"/editroom\">\n");
842 wprintf("<UL><LI>Name of room: ");
843 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
845 wprintf("<LI>Resides on floor: ");
847 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
848 for (i = 0; i < 128; ++i)
849 if (strlen(floorlist[i]) > 0) {
852 wprintf("SELECTED ");
853 wprintf("VALUE=\"%d\">", i);
854 escputs(floorlist[i]);
855 wprintf("</OPTION>\n");
857 wprintf("</SELECT>\n");
859 wprintf("<LI>Type of room:<UL>\n");
861 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
862 if ((er_flags & QR_PRIVATE) == 0)
864 wprintf("> Public room\n");
866 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
867 if ((er_flags & QR_PRIVATE) &&
868 (er_flags & QR_GUESSNAME))
870 wprintf("> Private - guess name\n");
872 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
873 if ((er_flags & QR_PRIVATE) &&
874 (er_flags & QR_PASSWORDED))
876 wprintf("> Private - require password:\n");
877 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n", er_password);
879 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
880 if ((er_flags & QR_PRIVATE)
881 && ((er_flags & QR_GUESSNAME) == 0)
882 && ((er_flags & QR_PASSWORDED) == 0))
884 wprintf("> Private - invitation only\n");
886 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
887 wprintf("> If private, cause current users to forget room\n");
891 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
892 if (er_flags & QR_PREFONLY)
894 wprintf("> Preferred users only\n");
896 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
897 if (er_flags & QR_READONLY)
899 wprintf("> Read-only room\n");
901 /* directory stuff */
902 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
903 if (er_flags & QR_DIRECTORY)
905 wprintf("> File directory room\n");
907 wprintf("<UL><LI>Directory name: ");
908 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n", er_dirname);
910 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
911 if (er_flags & QR_UPLOAD)
913 wprintf("> Uploading allowed\n");
915 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
916 if (er_flags & QR_DOWNLOAD)
918 wprintf("> Downloading allowed\n");
920 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
921 if (er_flags & QR_VISDIR)
923 wprintf("> Visible directory</UL>\n");
925 /* end of directory stuff */
927 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
928 if (er_flags & QR_NETWORK)
930 wprintf("> Network shared room\n");
932 /* start of anon options */
934 wprintf("<LI>Anonymous messages<UL>\n");
936 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
937 if (((er_flags & QR_ANONONLY) == 0)
938 && ((er_flags & QR_ANONOPT) == 0))
940 wprintf("> No anonymous messages\n");
942 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
943 if (er_flags & QR_ANONONLY)
945 wprintf("> All messages are anonymous\n");
947 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
948 if (er_flags & QR_ANONOPT)
950 wprintf("> Prompt user when entering messages</UL>\n");
952 /* end of anon options */
954 wprintf("<LI>Room aide: \n");
958 wprintf("<EM>%s</EM>\n", &buf[4]);
960 extract(er_roomaide, &buf[4], 0);
961 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
964 wprintf("</UL><CENTER>\n");
965 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
966 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
967 wprintf("</CENTER>\n");
971 /* Sharing the room with other Citadel nodes... */
972 if (!strcmp(tab, "sharing")) {
974 shared_with = strdup("");
975 not_shared_with = strdup("");
977 /* Learn the current configuration */
978 serv_puts("CONF getsys|application/x-citadel-ignet-config");
980 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
981 extract(node, buf, 0);
982 not_shared_with = realloc(not_shared_with,
983 strlen(not_shared_with) + 32);
984 strcat(not_shared_with, node);
985 strcat(not_shared_with, "|");
990 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
991 extract(cmd, buf, 0);
992 extract(node, buf, 1);
993 if (!strcasecmp(cmd, "ignet_push_share")) {
994 shared_with = realloc(shared_with,
995 strlen(shared_with) + 32);
996 strcat(shared_with, node);
997 strcat(shared_with, "|");
1001 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
1002 extract(node, shared_with, i);
1003 for (j=0; j<num_tokens(not_shared_with, '|'); ++j) {
1004 extract(cmd, not_shared_with, j);
1005 if (!strcasecmp(node, cmd)) {
1006 remove_token(not_shared_with, j, '|');
1011 /* Display the stuff */
1012 wprintf("<CENTER><BR>"
1013 "<TABLE border=1 cellpadding=5><TR>"
1014 "<TD><B><I>Shared with</I></B></TD>"
1015 "<TD><B><I>Not shared with</I></B></TD></TR>\n"
1018 for (i=0; i<num_tokens(shared_with, '|'); ++i) {
1019 extract(node, shared_with, i);
1020 if (strlen(node) > 0) {
1021 wprintf("%s ", node);
1022 wprintf("<A HREF=\"/netedit&cmd=remove&line="
1023 "ignet_push_share|");
1025 wprintf("&tab=sharing\">(unshare)</A><BR>");
1029 wprintf("</TD><TD>\n");
1031 for (i=0; i<num_tokens(not_shared_with, '|'); ++i) {
1032 extract(node, not_shared_with, i);
1033 if (strlen(node) > 0) {
1034 wprintf("%s ", node);
1035 wprintf("<A HREF=\"/netedit&cmd=add&line="
1036 "ignet_push_share|");
1038 wprintf("&tab=sharing\">(share)</A><BR>");
1042 wprintf("</TD></TR>"
1044 "<I><B>Reminder:</B> When sharing a room, "
1045 "it must be shared from both ends. Adding a node to "
1046 "the 'shared' list sends messages out, but in order to"
1047 " receive messages, the other nodes must be configured"
1048 " to send messages out to your system as well.</I><BR>"
1053 /* Mailing list management */
1054 if (!strcmp(tab, "listserv")) {
1056 wprintf("<BR><center>"
1057 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1058 "<TR><TD VALIGN=TOP>");
1060 wprintf("<i>The contents of this room are being "
1061 "mailed <b>as individual messages</b> "
1062 "to the following list recipients:"
1067 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1068 extract(cmd, buf, 0);
1069 if (!strcasecmp(cmd, "listrecp")) {
1070 extract(recp, buf, 1);
1073 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1076 wprintf("&tab=listserv\">(remove)</A><BR>");
1080 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1081 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1082 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1083 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1084 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1085 wprintf("</FORM>\n");
1087 wprintf("</TD><TD VALIGN=TOP>\n");
1089 wprintf("<i>The contents of this room are being "
1090 "mailed <b>in digest form</b> "
1091 "to the following list recipients:"
1096 if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
1097 extract(cmd, buf, 0);
1098 if (!strcasecmp(cmd, "digestrecp")) {
1099 extract(recp, buf, 1);
1102 wprintf(" <A HREF=\"/netedit&cmd=remove&line="
1105 wprintf("&tab=listserv\">(remove)</A><BR>");
1109 wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
1110 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1111 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1112 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1113 wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
1114 wprintf("</FORM>\n");
1116 wprintf("</TD></TR></TABLE><HR>\n");
1118 if (self_service(999) == 1) {
1119 wprintf("This room is configured to allow "
1120 "self-service subscribe/unsubscribe requests."
1121 " <A HREF=\"/toggle_self_service?newval=0&"
1123 "Click to disable.</A><BR>\n"
1124 "The URL for subscribe/unsubscribe is: "
1125 "<TT>http://%s/listsub</TT><BR>\n",
1130 wprintf("This room is <i>not</i> configured to allow "
1131 "self-service subscribe/unsubscribe requests."
1132 " <A HREF=\"/toggle_self_service?newval=1&"
1134 "Click to enable.</A><BR>\n"
1139 wprintf("</CENTER>\n");
1147 * Toggle self-service list subscription
1149 void toggle_self_service(void) {
1152 newval = atoi(bstr("newval"));
1153 self_service(newval);
1160 * save new parameters for a room
1166 char er_password[10];
1167 char er_dirname[15];
1168 char er_roomaide[26];
1174 if (strcmp(bstr("sc"), "OK")) {
1175 display_error("Cancelled. Changes were not saved.");
1181 if (buf[0] != '2') {
1182 display_error(&buf[4]);
1185 extract(er_name, &buf[4], 0);
1186 extract(er_password, &buf[4], 1);
1187 extract(er_dirname, &buf[4], 2);
1188 er_flags = extract_int(&buf[4], 3);
1190 strcpy(er_roomaide, bstr("er_roomaide"));
1191 if (strlen(er_roomaide) == 0) {
1194 if (buf[0] != '2') {
1195 strcpy(er_roomaide, "");
1197 extract(er_roomaide, &buf[4], 0);
1200 strcpy(buf, bstr("er_name"));
1202 if (strlen(buf) > 0)
1203 strcpy(er_name, buf);
1205 strcpy(buf, bstr("er_password"));
1207 if (strlen(buf) > 0)
1208 strcpy(er_password, buf);
1210 strcpy(buf, bstr("er_dirname"));
1212 if (strlen(buf) > 0)
1213 strcpy(er_dirname, buf);
1215 strcpy(buf, bstr("type"));
1216 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1218 if (!strcmp(buf, "invonly")) {
1219 er_flags |= (QR_PRIVATE);
1221 if (!strcmp(buf, "guessname")) {
1222 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1224 if (!strcmp(buf, "passworded")) {
1225 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1227 if (!strcmp(bstr("prefonly"), "yes")) {
1228 er_flags |= QR_PREFONLY;
1230 er_flags &= ~QR_PREFONLY;
1233 if (!strcmp(bstr("readonly"), "yes")) {
1234 er_flags |= QR_READONLY;
1236 er_flags &= ~QR_READONLY;
1239 if (!strcmp(bstr("network"), "yes")) {
1240 er_flags |= QR_NETWORK;
1242 er_flags &= ~QR_NETWORK;
1245 if (!strcmp(bstr("directory"), "yes")) {
1246 er_flags |= QR_DIRECTORY;
1248 er_flags &= ~QR_DIRECTORY;
1251 if (!strcmp(bstr("ulallowed"), "yes")) {
1252 er_flags |= QR_UPLOAD;
1254 er_flags &= ~QR_UPLOAD;
1257 if (!strcmp(bstr("dlallowed"), "yes")) {
1258 er_flags |= QR_DOWNLOAD;
1260 er_flags &= ~QR_DOWNLOAD;
1263 if (!strcmp(bstr("visdir"), "yes")) {
1264 er_flags |= QR_VISDIR;
1266 er_flags &= ~QR_VISDIR;
1269 strcpy(buf, bstr("anon"));
1271 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1272 if (!strcmp(buf, "anononly"))
1273 er_flags |= QR_ANONONLY;
1274 if (!strcmp(buf, "anon2"))
1275 er_flags |= QR_ANONOPT;
1278 if (!strcmp(bstr("bump"), "yes"))
1281 er_floor = atoi(bstr("er_floor"));
1283 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1284 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1287 if (buf[0] != '2') {
1288 display_error(&buf[4]);
1291 gotoroom(er_name, 0);
1293 if (strlen(er_roomaide) > 0) {
1294 sprintf(buf, "SETA %s", er_roomaide);
1297 if (buf[0] != '2') {
1298 display_error(&buf[4]);
1302 smart_goto(er_name);
1306 * Invite, Kick, and show Who Knows a room
1308 void display_whok(void)
1310 char buf[SIZ], room[SIZ], username[SIZ];
1315 if (buf[0] != '2') {
1316 display_error(&buf[4]);
1319 extract(room, &buf[4], 0);
1321 strcpy(username, bstr("username"));
1325 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#007700\"><TR><TD>");
1326 wprintf("<SPAN CLASS=\"titlebar\">Access control list for ");
1327 escputs(WC->wc_roomname);
1328 wprintf("</SPAN></TD></TR></TABLE>\n");
1330 if(!strcmp(bstr("sc"), "Kick")) {
1331 sprintf(buf, "KICK %s", username);
1335 if (buf[0] != '2') {
1336 display_error(&buf[4]);
1339 wprintf("<B><I>User %s kicked out of room %s.</I></B>\n",
1342 } else if(!strcmp(bstr("sc"), "Invite")) {
1343 sprintf(buf, "INVT %s", username);
1347 if (buf[0] != '2') {
1348 display_error(&buf[4]);
1351 wprintf("<B><I>User %s invited to room %s.</I></B>\n",
1358 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
1359 "<TD>The users listed below have access to this room. "
1360 "To remove a user from the access list, select the user "
1361 "name from the list and click 'Kick'.<BR><BR>");
1363 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1364 wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
1367 if (buf[0] == '1') {
1368 while (serv_gets(buf), strcmp(buf, "000")) {
1369 extract(username, buf, 0);
1370 wprintf("<OPTION>");
1375 wprintf("</SELECT><BR>\n");
1377 wprintf("<input type=submit name=sc value=\"Kick\">");
1378 wprintf("</FORM></CENTER>\n");
1381 "To grant another user access to this room, enter the "
1382 "user name in the box below and click 'Invite'.<BR><BR>");
1384 wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
1385 wprintf("Invite: ");
1386 wprintf("<input type=text name=username><BR>\n"
1387 "<input type=hidden name=sc value=\"Invite\">"
1388 "<input type=submit value=\"Invite\">"
1389 "</FORM></CENTER>\n");
1391 wprintf("</TD></TR></TABLE>\n");
1398 * display the form for entering a new room
1400 void display_entroom(void)
1405 serv_puts("CRE8 0");
1408 if (buf[0] != '2') {
1409 display_error(&buf[4]);
1414 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#000077\"><TR><TD>");
1415 wprintf("<SPAN CLASS=\"titlebar\">Enter (create) a new room</SPAN>\n");
1416 wprintf("</TD></TR></TABLE>\n");
1418 wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
1420 wprintf("<UL><LI>Name of room: ");
1421 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
1423 wprintf("<LI>Type of room:<UL>\n");
1425 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1426 wprintf("CHECKED > Public room\n");
1428 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"guessname\" ");
1429 wprintf("> Private - guess name\n");
1431 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1432 wprintf("> Private - require password:\n");
1433 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1435 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1436 wprintf("> Private - invitation only\n");
1439 wprintf("<LI>Resides on floor: ");
1441 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1442 for (i = 0; i < 128; ++i)
1443 if (strlen(floorlist[i]) > 0) {
1444 wprintf("<OPTION ");
1445 wprintf("VALUE=\"%d\">", i);
1446 escputs(floorlist[i]);
1447 wprintf("</OPTION>\n");
1449 wprintf("</SELECT>\n");
1453 wprintf("<CENTER>\n");
1454 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1455 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1456 wprintf("</CENTER>\n");
1457 wprintf("</FORM>\n<HR>");
1458 serv_printf("MESG roomaccess");
1460 if (buf[0] == '1') {
1476 char er_password[10];
1480 if (strcmp(bstr("sc"), "OK")) {
1481 display_error("Cancelled. No new room was created.");
1484 strcpy(er_name, bstr("er_name"));
1485 strcpy(er_type, bstr("type"));
1486 strcpy(er_password, bstr("er_password"));
1487 er_floor = atoi(bstr("er_floor"));
1490 if (!strcmp(er_type, "guessname"))
1492 if (!strcmp(er_type, "passworded"))
1494 if (!strcmp(er_type, "invonly"))
1497 sprintf(buf, "CRE8 1|%s|%d|%s|%d",
1498 er_name, er_num_type, er_password, er_floor);
1501 if (buf[0] != '2') {
1502 display_error(&buf[4]);
1505 smart_goto(er_name);
1510 * display the screen to enter a private room
1512 void display_private(char *rname, int req_pass)
1517 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1518 wprintf("<SPAN CLASS=\"titlebar\">Goto a private room</SPAN>\n");
1519 wprintf("</TD></TR></TABLE>\n");
1521 wprintf("<CENTER>\n");
1522 wprintf("If you know the name of a hidden (guess-name) or\n");
1523 wprintf("passworded room, you can enter that room by typing\n");
1524 wprintf("its name below. Once you gain access to a private\n");
1525 wprintf("room, it will appear in your regular room listings\n");
1526 wprintf("so you don't have to keep returning here.\n");
1527 wprintf("<BR><BR>");
1529 wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
1531 wprintf("<TABLE border><TR><TD>");
1532 wprintf("Enter room name:</TD><TD>");
1533 wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
1536 wprintf("</TD></TR><TR><TD>");
1537 wprintf("Enter room password:</TD><TD>");
1538 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
1540 wprintf("</TD></TR></TABLE>\n");
1542 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1543 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1544 wprintf("</FORM>\n");
1549 * goto a private room
1551 void goto_private(void)
1556 if (strcasecmp(bstr("sc"), "OK")) {
1557 display_main_menu();
1560 strcpy(hold_rm, WC->wc_roomname);
1561 strcpy(buf, "GOTO ");
1562 strcat(buf, bstr("gr_name"));
1564 strcat(buf, bstr("gr_pass"));
1568 if (buf[0] == '2') {
1569 smart_goto(bstr("gr_name"));
1572 if (!strncmp(buf, "540", 3)) {
1573 display_private(bstr("gr_name"), 1);
1577 wprintf("%s\n", &buf[4]);
1584 * display the screen to zap a room
1586 void display_zap(void)
1590 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1591 wprintf("<SPAN CLASS=\"titlebar\">Zap (forget) the current room</SPAN>\n");
1592 wprintf("</TD></TR></TABLE>\n");
1594 wprintf("If you select this option, <em>%s</em> will ", WC->wc_roomname);
1595 wprintf("disappear from your room list. Is this what you wish ");
1596 wprintf("to do?<BR>\n");
1598 wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
1599 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
1600 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1601 wprintf("</FORM>\n");
1612 char final_destination[SIZ];
1614 /* If the forget-room routine fails for any reason, we fall back
1615 * to the current room; otherwise, we go to the Lobby
1617 strcpy(final_destination, WC->wc_roomname);
1619 if (!strcasecmp(bstr("sc"), "OK")) {
1620 serv_printf("GOTO %s", WC->wc_roomname);
1622 if (buf[0] != '2') {
1623 /* ExpressMessageCat(&buf[4]); */
1627 if (buf[0] != '2') {
1628 /* ExpressMessageCat(&buf[4]); */
1630 strcpy(final_destination, "_BASEROOM_");
1634 smart_goto(final_destination);
1641 * Confirm deletion of the current room
1643 void confirm_delete_room(void)
1647 serv_puts("KILL 0");
1649 if (buf[0] != '2') {
1650 display_error(&buf[4]);
1654 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1655 wprintf("<SPAN CLASS=\"titlebar\">Confirm deletion of room</SPAN>\n");
1656 wprintf("</TD></TR></TABLE>\n");
1658 wprintf("<CENTER>");
1659 wprintf("<FORM METHOD=\"GET\" ACTION=\"/delete_room\">\n");
1661 wprintf("Are you sure you want to delete <FONT SIZE=+1>");
1662 escputs(WC->wc_roomname);
1663 wprintf("</FONT>?<BR>\n");
1665 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">");
1666 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
1668 wprintf("</FORM></CENTER>\n");
1674 * Delete the current room
1676 void delete_room(void)
1681 strcpy(sc, bstr("sc"));
1683 if (strcasecmp(sc, "Delete")) {
1684 display_error("Cancelled. This room was not deleted.");
1687 serv_puts("KILL 1");
1689 if (buf[0] != '2') {
1690 display_error(&buf[4]);
1692 smart_goto("_BASEROOM_");
1699 * Perform changes to a room's network configuration
1701 void netedit(void) {
1706 if (strlen(bstr("line"))==0) {
1711 strcpy(line, bstr("prefix"));
1712 strcat(line, bstr("line"));
1713 strcat(line, bstr("suffix"));
1723 if (buf[0] != '1') {
1729 /* This loop works for add *or* remove. Spiffy, eh? */
1730 while (serv_gets(buf), strcmp(buf, "000")) {
1731 if (strcasecmp(buf, line)) {
1732 fprintf(fp, "%s\n", buf);
1739 if (buf[0] != '4') {
1745 while (fgets(buf, sizeof buf, fp) != NULL) {
1746 buf[strlen(buf)-1] = 0;
1750 if (!strcasecmp(bstr("cmd"), "add")) {
1762 * Convert a room name to a folder-ish-looking name.
1764 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
1769 * For mailboxes, just do it straight...
1772 sprintf(folder, "My folders|%s", room);
1776 * Otherwise, prefix the floor name as a "public folders" moniker
1779 sprintf(folder, "%s|%s", floorlist[floor], room);
1783 * Replace "\" characters with "|" for pseudo-folder-delimiting
1785 for (i=0; i<strlen(folder); ++i) {
1786 if (folder[i] == '\\') folder[i] = '|';
1797 * Change the view for this room
1799 void change_view(void) {
1803 view = atol(bstr("view"));
1805 serv_printf("VIEW %d", view);
1807 smart_goto(WC->wc_roomname);
1812 * One big expanded tree list view --- like a folder list
1814 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
1816 int levels, oldlevels;
1819 do_template("beginbox_nt");
1822 for (i=0; i<max_folders; ++i) {
1824 levels = num_tokens(fold[i].name, '|');
1827 for (t=0; t<levels; ++t) wprintf(" ");
1828 if (fold[i].selectable) {
1829 wprintf("<A HREF=\"/dotgoto?room=");
1830 urlescputs(fold[i].room);
1836 if (fold[i].hasnewmsgs) wprintf("<B>");
1837 extract(buf, fold[i].name, levels-1);
1839 if (fold[i].hasnewmsgs) wprintf("</B>");
1840 if (fold[i].selectable) {
1846 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
1847 wprintf(" (INBOX)");
1851 do_template("endbox");
1855 * Boxes and rooms and lists ... oh my!
1857 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
1860 int levels, oldlevels;
1863 static int columns = 3;
1864 int boxes_per_column = 0;
1865 int current_column = 0;
1867 boxes_per_column = (num_floors / columns);
1868 if (boxes_per_column < 1) boxes_per_column = 1;
1870 /* Outer table (for columnization) */
1871 wprintf("<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1872 "<TR><TD VALIGN=TOP>");
1876 for (i=0; i<max_folders; ++i) {
1878 levels = num_tokens(fold[i].name, '|');
1880 if ((levels == 1) && (oldlevels == 2)) {
1883 do_template("endbox");
1886 if ((num_boxes % boxes_per_column) == 0) {
1888 if (current_column < columns) {
1889 wprintf("</TD><TD VALIGN=TOP>\n");
1896 /* Begin inner box */
1897 extract(buf, fold[i].name, levels-1);
1898 stresc(boxtitle, buf, 1);
1899 svprintf("BOXTITLE", WCS_STRING, boxtitle);
1900 do_template("beginbox");
1908 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
1909 if (fold[i].selectable) {
1910 wprintf("<A HREF=\"/dotgoto?room=");
1911 urlescputs(fold[i].room);
1917 if (fold[i].hasnewmsgs) wprintf("<B>");
1918 extract(buf, fold[i].name, levels-1);
1920 if (fold[i].hasnewmsgs) wprintf("</B>");
1921 if (fold[i].selectable) {
1927 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
1928 wprintf(" (INBOX)");
1933 /* End the final inner box */
1934 do_template("endbox");
1936 wprintf("</TD></TR></TABLE>\n");
1941 * Show the room list. (only should get called by
1942 * knrooms() because that's where output_headers() is called from)
1945 void list_all_rooms_by_floor(char *viewpref) {
1948 struct folder *fold = NULL;
1950 int max_folders = 0;
1951 int alloc_folders = 0;
1955 int num_floors = 1; /* add an extra one for private folders */
1957 /* Start with the mailboxes */
1960 fold = malloc(sizeof(struct folder));
1961 memset(fold, 0, sizeof(struct folder));
1962 strcpy(fold[0].name, "My folders");
1963 fold[0].is_mailbox = 1;
1965 /* Then add floors */
1968 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
1969 if (max_folders >= alloc_folders) {
1970 alloc_folders = max_folders + 100;
1971 fold = realloc(fold,
1972 alloc_folders * sizeof(struct folder));
1974 memset(&fold[max_folders], 0, sizeof(struct folder));
1975 extract(fold[max_folders].name, buf, 1);
1983 if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) {
1984 if (max_folders >= alloc_folders) {
1985 alloc_folders = max_folders + 100;
1986 fold = realloc(fold,
1987 alloc_folders * sizeof(struct folder));
1989 memset(&fold[max_folders], 0, sizeof(struct folder));
1990 extract(fold[max_folders].room, buf, 0);
1991 ra_flags = extract_int(buf, 5);
1992 flags = extract_int(buf, 1);
1993 fold[max_folders].floor = extract_int(buf, 2);
1994 fold[max_folders].hasnewmsgs =
1995 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
1996 if (flags & QR_MAILBOX) {
1997 fold[max_folders].is_mailbox = 1;
1999 room_to_folder(fold[max_folders].name,
2000 fold[max_folders].room,
2001 fold[max_folders].floor,
2002 fold[max_folders].is_mailbox);
2003 fold[max_folders].selectable = 1;
2007 /* Bubble-sort the folder list */
2008 for (i=0; i<max_folders; ++i) {
2009 for (j=0; j<(max_folders-1)-i; ++j) {
2010 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2011 swap = strcasecmp(fold[j].name, fold[j+1].name);
2014 if ( (fold[j+1].is_mailbox)
2015 && (!fold[j].is_mailbox)) {
2023 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2024 memcpy(&fold[j], &fold[j+1],
2025 sizeof(struct folder));
2026 memcpy(&fold[j+1], &ftmp,
2027 sizeof(struct folder));
2032 if (!strcasecmp(viewpref, "folders")) {
2033 do_folder_view(fold, max_folders, num_floors);
2036 do_rooms_view(fold, max_folders, num_floors);
2044 /* Do either a known rooms list or a folders list, depending on the
2048 char listviewpref[SIZ];
2053 /* Determine whether the user is trying to change views */
2054 if (bstr("view") != NULL) {
2055 if (strlen(bstr("view")) > 0) {
2056 set_preference("roomlistview", bstr("view"));
2060 get_preference("roomlistview", listviewpref);
2062 if ( (strcasecmp(listviewpref, "folders"))
2063 && (strcasecmp(listviewpref, "table")) ) {
2064 strcpy(listviewpref, "rooms");
2068 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#000077\"><TR><TD>"
2069 "<SPAN CLASS=\"titlebar\">"
2071 if (!strcasecmp(listviewpref, "rooms")) {
2072 wprintf("Room list");
2074 if (!strcasecmp(listviewpref, "folders")) {
2075 wprintf("Folder list");
2077 if (!strcasecmp(listviewpref, "table")) {
2078 wprintf("Room list");
2080 wprintf("</SPAN></TD>\n");
2083 /* offer the ability to switch views */
2084 wprintf("<TD><FORM NAME=\"roomlistomatic\">\n"
2085 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2086 "OnChange=\"location.href=roomlistomatic.newview.options"
2087 "[selectedIndex].value\">\n");
2089 wprintf("<OPTION %s VALUE=\"/knrooms&view=rooms\">"
2092 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2095 wprintf("<OPTION %s VALUE=\"/knrooms&view=folders\">"
2096 "View as folder list"
2098 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2101 wprintf("<OPTION %s VALUE=\"/knrooms&view=table\">"
2102 "Classic table view"
2104 ( !strcasecmp(listviewpref, "table") ? "SELECTED" : "" )
2107 wprintf("</SELECT></FORM></TD><TD>\n");
2109 wprintf("</TD></TR></TABLE><BR>\n");
2111 /* Display the room list in the user's preferred format */
2112 if (!strcasecmp(listviewpref, "table")) {
2113 tabular_room_list();
2116 list_all_rooms_by_floor(listviewpref);