4 * Lots of different room-related operations.
9 char floorlist[128][SIZ];
13 void initialize_viewdefs(void) {
14 viewdefs[0] = _("Bulletin Board");
15 viewdefs[1] = _("Mail Folder");
16 viewdefs[2] = _("Address Book");
17 viewdefs[3] = _("Calendar");
18 viewdefs[4] = _("Task List");
19 viewdefs[5] = _("Notes List");
20 viewdefs[6] = _("Wiki");
25 * load the list of floors
27 void load_floorlist(void)
32 for (a = 0; a < 128; ++a)
36 serv_getln(buf, sizeof buf);
38 strcpy(floorlist[0], "Main Floor");
41 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
42 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
48 * remove a room from the march list
50 void remove_march(char *aaa)
52 struct march *mptr, *mptr2;
54 if (WC->march == NULL)
57 if (!strcasecmp(WC->march->march_name, aaa)) {
58 mptr = WC->march->next;
64 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
65 if (!strcasecmp(mptr->march_name, aaa)) {
66 mptr2->next = mptr->next;
79 void room_tree_list(struct roomlisting *rp)
88 room_tree_list(rp->lnext);
90 strcpy(rmname, rp->rlname);
93 wprintf("<a href=\"dotgoto&room=");
97 escputs1(rmname, 1, 1);
98 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
100 else if (f & QR_DIRECTORY)
102 else if (f & QR_NETWORK)
106 wprintf("</A><TT> </TT>\n");
108 room_tree_list(rp->rnext);
114 * Room ordering stuff (compare first by floor, then by order)
116 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
118 if ((r1 == NULL) && (r2 == NULL))
124 if (r1->rlfloor < r2->rlfloor)
126 if (r1->rlfloor > r2->rlfloor)
128 if (r1->rlorder < r2->rlorder)
130 if (r1->rlorder > r2->rlorder)
137 * Common code for all room listings
139 void listrms(char *variety)
144 struct roomlisting *rl = NULL;
145 struct roomlisting *rp;
146 struct roomlisting *rs;
149 /* Ask the server for a room list */
151 serv_getln(buf, sizeof buf);
156 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
158 rp = malloc(sizeof(struct roomlisting));
159 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
160 rp->rlflags = extract_int(buf, 1);
161 rp->rlfloor = extract_int(buf, 2);
162 rp->rlorder = extract_int(buf, 3);
171 if (rordercmp(rp, rs) < 0) {
172 if (rs->lnext == NULL) {
179 if (rs->rnext == NULL) {
191 /* If no rooms were listed, print an nbsp to make the cell
192 * borders show up anyway.
194 if (num_rooms == 0) wprintf(" ");
199 * list all forgotten rooms
201 void zapped_list(void)
203 output_headers(1, 1, 0, 0, 0, 0);
205 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
206 do_template("beginbox");
210 wprintf("<br /><br />\n");
211 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
212 do_template("endbox");
218 * read this room's info file (set v to 1 for verbose mode)
225 serv_getln(buf, sizeof buf);
237 /* Display room banner icon. The server doesn't actually
238 * need the room name, but we supply it in order to
239 * keep the browser from using a cached icon from
242 void embed_room_graphic(void) {
245 serv_puts("OIMG _roompic_");
246 serv_getln(buf, sizeof buf);
248 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
249 urlescputs(WC->wc_roomname);
252 serv_getln(buf, sizeof buf);
254 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
255 wprintf("<img height=48 width=48 src=\""
256 "static/viewcontacts_48x.gif"
260 else if (WC->wc_view == VIEW_CALENDAR) {
261 wprintf("<img height=48 width=48 src=\""
262 "static/calarea_48x.gif"
266 else if (WC->wc_view == VIEW_TASKS) {
267 wprintf("<img height=48 width=48 src=\""
268 "static/taskmanag_48x.gif"
272 else if (WC->wc_view == VIEW_NOTES) {
273 wprintf("<img height=48 width=48 src=\""
274 "static/storenotes_48x.gif"
278 else if (WC->wc_view == VIEW_MAILBOX) {
279 wprintf("<img height=48 width=48 src=\""
280 "static/privatemess_48x.gif"
285 wprintf("<img height=48 width=48 src=\""
286 "static/chatrooms_48x.gif"
296 * Display the current view and offer an option to change it
298 void embed_view_o_matic(void) {
301 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
302 "<span class=\"room_banner_new_messages\">");
303 wprintf(_("View as:"));
305 "<SELECT NAME=\"newview\" SIZE=\"1\" "
306 "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif;"
307 " font-size: 7pt; background: #444455; color: #ddddcc;\" "
308 "OnChange=\"location.href=viewomatic.newview.options"
309 "[selectedIndex].value\">\n");
311 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
313 * Only offer the views that make sense, given the default
314 * view for the room. For example, don't offer a Calendar
315 * view in a non-Calendar room.
319 || (i == WC->wc_default_view)
320 || ( (i == 0) && (WC->wc_default_view == 1) )
321 || ( (i == 1) && (WC->wc_default_view == 0) )
324 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
325 ((i == WC->wc_view) ? "SELECTED" : ""),
327 escputs(viewdefs[i]);
328 wprintf("</OPTION>\n");
331 wprintf("</select></span></form>\n");
336 void embed_room_banner(char *got, int navbar_style) {
339 /* We need to have the information returned by a GOTO server command.
340 * If it isn't supplied, we fake it by issuing our own GOTO.
343 serv_printf("GOTO %s", WC->wc_roomname);
344 serv_getln(fakegot, sizeof fakegot);
348 /* The browser needs some information for its own use */
349 wprintf("<script type=\"text/javascript\"> \n"
350 " room_is_trash = %d; \n"
355 /* If the user happens to select the "make this my start page" link,
356 * we want it to remember the URL as a "/dotskip" one instead of
357 * a "skip" or "gotonext" or something like that.
359 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
362 /* Check for new mail. */
363 WC->new_mail = extract_int(&got[4], 9);
364 WC->wc_view = extract_int(&got[4], 11);
366 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
367 svprintf("NUMMSGS", WCS_STRING,
368 _("%d new of %d messages"),
369 extract_int(&got[4], 1),
370 extract_int(&got[4], 2)
372 svcallback("ROOMPIC", embed_room_graphic);
373 svcallback("ROOMINFO", readinfo);
374 svcallback("VIEWOMATIC", embed_view_o_matic);
375 svcallback("START", offer_start_page);
377 do_template("roombanner");
378 if (navbar_style != navbar_none) {
380 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
381 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
384 if (navbar_style == navbar_default) wprintf(
386 "<a href=\"ungoto\">"
387 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
388 "<span class=\"navbar_link\">%s</span></A>"
389 "</td>\n", _("Ungoto")
392 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
395 "<a href=\"readnew\">"
396 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
397 "<span class=\"navbar_link\">%s</span></A>"
398 "</td>\n", _("Read new messages")
402 if (navbar_style == navbar_default) {
403 switch(WC->wc_view) {
404 case VIEW_ADDRESSBOOK:
407 "<a href=\"readfwd\">"
408 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
410 "<span class=\"navbar_link\">"
412 "</span></a></td>\n", _("View contacts")
418 "<a href=\"readfwd?calview=day\">"
419 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
421 "<span class=\"navbar_link\">"
423 "</span></a></td>\n", _("Day view")
427 "<a href=\"readfwd?calview=month\">"
428 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
430 "<span class=\"navbar_link\">"
432 "</span></a></td>\n", _("Month view")
438 "<a href=\"readfwd\">"
439 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
441 "<span class=\"navbar_link\">"
443 "</span></a></td>\n", _("View tasks")
449 "<a href=\"readfwd\">"
450 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
452 "<span class=\"navbar_link\">"
454 "</span></a></td>\n", _("View notes")
460 "<a href=\"readfwd\">"
461 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
463 "<span class=\"navbar_link\">"
465 "</span></a></td>\n", _("View message list")
471 "<a href=\"readfwd\">"
472 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
474 "<span class=\"navbar_link\">"
476 "</span></a></td>\n", _("Read all messages")
482 if (navbar_style == navbar_default) {
483 switch(WC->wc_view) {
484 case VIEW_ADDRESSBOOK:
486 "<td><a href=\"display_enter\">"
487 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
488 "border=\"0\"><span class=\"navbar_link\">"
490 "</span></a></td>\n", _("Add new contact")
495 "<td><a href=\"display_enter\">"
496 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
497 "border=\"0\"><span class=\"navbar_link\">"
499 "</span></a></td>\n", _("Add new event")
504 "<td><a href=\"display_enter\">"
505 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
506 "border=\"0\"><span class=\"navbar_link\">"
508 "</span></a></td>\n", _("Add new task")
513 "<td><a href=\"display_enter\">"
514 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
515 "border=\"0\"><span class=\"navbar_link\">"
517 "</span></a></td>\n", _("Add new note")
522 "<td><a href=\"display_enter\">"
523 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
524 "border=\"0\"><span class=\"navbar_link\">"
526 "</span></a></td>\n", _("Add new page")
531 "<td><a href=\"display_enter\">"
532 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
533 "border=\"0\"><span class=\"navbar_link\">"
535 "</span></a></td>\n", _("Enter a message")
541 if (navbar_style == navbar_default) wprintf(
545 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
546 "<span class=\"navbar_link\">%s</span></a>"
548 _("Leave all messages marked as unread, go to next room with unread messages"),
552 if (navbar_style == navbar_default) wprintf(
554 "<a href=\"gotonext\" "
556 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
557 "<span class=\"navbar_link\">%s</span></a>"
559 _("Mark all messages as read, go to next room with unread messages"),
563 wprintf("</tr></table></div>\n");
573 * back end routine to take the session to a new room
576 int gotoroom(char *gname)
579 static long ls = (-1L);
582 /* store ungoto information */
583 strcpy(WC->ugname, WC->wc_roomname);
586 /* move to the new room */
587 serv_printf("GOTO %s", gname);
588 serv_getln(buf, sizeof buf);
592 serv_puts("GOTO _BASEROOM_");
593 serv_getln(buf, sizeof buf);
600 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
601 WC->room_flags = extract_int(&buf[4], 4);
602 /* highest_msg_read = extract_int(&buf[4],6);
603 maxmsgnum = extract_int(&buf[4],5);
605 WC->is_mailbox = extract_int(&buf[4],7);
606 ls = extract_long(&buf[4], 6);
607 WC->wc_floor = extract_int(&buf[4], 10);
608 WC->wc_view = extract_int(&buf[4], 11);
609 WC->wc_default_view = extract_int(&buf[4], 12);
610 WC->wc_is_trash = extract_int(&buf[4], 13);
613 WC->is_room_aide = WC->is_aide;
615 WC->is_room_aide = (char) extract_int(&buf[4], 8);
617 remove_march(WC->wc_roomname);
618 if (!strcasecmp(gname, "_BASEROOM_"))
626 * Locate the room on the march list which we most want to go to. Each room
627 * is measured given a "weight" of preference based on various factors.
629 char *pop_march(int desired_floor)
631 static char TheRoom[128];
633 int TheOrder = 32767;
636 struct march *mptr = NULL;
638 strcpy(TheRoom, "_BASEROOM_");
639 if (WC->march == NULL)
642 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
644 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
645 weight = weight + 10000;
646 if (mptr->march_floor == desired_floor)
647 weight = weight + 5000;
649 weight = weight + ((128 - (mptr->march_floor)) * 128);
650 weight = weight + (128 - (mptr->march_order));
652 if (weight > TheWeight) {
654 strcpy(TheRoom, mptr->march_name);
655 TheFloor = mptr->march_floor;
656 TheOrder = mptr->march_order;
664 /* Goto next room having unread messages.
665 * We want to skip over rooms that the user has already been to, and take the
666 * user back to the lobby when done. The room we end up in is placed in
667 * newroom - which is set to 0 (the lobby) initially.
668 * We start the search in the current room rather than the beginning to prevent
669 * two or more concurrent users from dragging each other back to the same room.
674 struct march *mptr, *mptr2;
677 /* First check to see if the march-mode list is already allocated.
678 * If it is, pop the first room off the list and go there.
681 if (WC->march == NULL) {
683 serv_getln(buf, sizeof buf);
685 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
686 mptr = (struct march *) malloc(sizeof(struct march));
688 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
689 mptr->march_floor = extract_int(buf, 2);
690 mptr->march_order = extract_int(buf, 3);
691 if (WC->march == NULL) {
695 while (mptr2->next != NULL)
700 /* add _BASEROOM_ to the end of the march list, so the user will end up
701 * in the system base room (usually the Lobby>) at the end of the loop
703 mptr = (struct march *) malloc(sizeof(struct march));
705 strcpy(mptr->march_name, "_BASEROOM_");
706 if (WC->march == NULL) {
710 while (mptr2->next != NULL)
715 * ...and remove the room we're currently in, so a <G>oto doesn't make us
716 * walk around in circles
718 remove_march(WC->wc_roomname);
720 if (WC->march != NULL) {
721 strcpy(next_room, pop_march(-1));
723 strcpy(next_room, "_BASEROOM_");
727 smart_goto(next_room);
731 void smart_goto(char *next_room) {
739 * mark all messages in current room as having been read
741 void slrp_highest(void)
746 serv_puts("SLRP HIGHEST");
747 serv_getln(buf, sizeof buf);
749 wprintf("<EM>%s</EM><br />\n", &buf[4]);
756 * un-goto the previous room
762 if (!strcmp(WC->ugname, "")) {
763 smart_goto(WC->wc_roomname);
766 serv_printf("GOTO %s", WC->ugname);
767 serv_getln(buf, sizeof buf);
769 smart_goto(WC->wc_roomname);
772 if (WC->uglsn >= 0L) {
773 serv_printf("SLRP %ld", WC->uglsn);
774 serv_getln(buf, sizeof buf);
776 strcpy(buf, WC->ugname);
777 strcpy(WC->ugname, "");
786 * Set/clear/read the "self-service list subscribe" flag for a room
788 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
789 * Always returns the new value.
792 int self_service(int newval) {
793 int current_value = 0;
799 int flags, floor, order, view, flags2;
802 serv_getln(buf, sizeof buf);
803 if (buf[0] != '2') return(0);
805 extract_token(name, &buf[4], 0, '|', sizeof name);
806 extract_token(password, &buf[4], 1, '|', sizeof password);
807 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
808 flags = extract_int(&buf[4], 3);
809 floor = extract_int(&buf[4], 4);
810 order = extract_int(&buf[4], 5);
811 view = extract_int(&buf[4], 6);
812 flags2 = extract_int(&buf[4], 7);
814 if (flags2 & QR2_SELFLIST) {
822 flags2 = flags2 | QR2_SELFLIST;
824 else if (newval == 0) {
825 flags2 = flags2 & ~QR2_SELFLIST;
828 return(current_value);
831 if (newval != current_value) {
832 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
833 name, password, dirname, flags,
834 floor, order, view, flags2);
835 serv_getln(buf, sizeof buf);
848 * display the form for editing a room
850 void display_editroom(void)
855 char remote_room[SIZ];
858 char er_password[10];
860 char er_roomaide[26];
866 char *not_shared_with;
873 if (strlen(tab) == 0) tab = "admin";
877 serv_getln(buf, sizeof buf);
880 strcpy(WC->ImportantMessage, &buf[4]);
884 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
885 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
886 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
887 er_flags = extract_int(&buf[4], 3);
888 er_floor = extract_int(&buf[4], 4);
890 output_headers(1, 1, 1, 0, 0, 0);
892 /* print the tabbed dialog */
894 "<div class=\"fix_scrollbar_bug\">"
895 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
897 "<TD> </TD>\n");
899 if (!strcmp(tab, "admin")) {
900 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
903 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
905 wprintf(_("Administration"));
906 if (!strcmp(tab, "admin")) {
907 wprintf("</SPAN></TD>\n");
910 wprintf("</A></TD>\n");
913 wprintf("<TD> </TD>\n");
915 if (!strcmp(tab, "config")) {
916 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
919 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
921 wprintf(_("Configuration"));
922 if (!strcmp(tab, "config")) {
923 wprintf("</SPAN></TD>\n");
926 wprintf("</A></TD>\n");
929 wprintf("<TD> </TD>\n");
931 if (!strcmp(tab, "expire")) {
932 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
935 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
937 wprintf(_("Message expire policy"));
938 if (!strcmp(tab, "expire")) {
939 wprintf("</SPAN></TD>\n");
942 wprintf("</A></TD>\n");
945 wprintf("<TD> </TD>\n");
947 if (!strcmp(tab, "access")) {
948 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
951 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
953 wprintf(_("Access controls"));
954 if (!strcmp(tab, "access")) {
955 wprintf("</SPAN></TD>\n");
958 wprintf("</A></TD>\n");
961 wprintf("<TD> </TD>\n");
963 if (!strcmp(tab, "sharing")) {
964 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
967 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
969 wprintf(_("Sharing"));
970 if (!strcmp(tab, "sharing")) {
971 wprintf("</SPAN></TD>\n");
974 wprintf("</A></TD>\n");
977 wprintf("<TD> </TD>\n");
979 if (!strcmp(tab, "listserv")) {
980 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
983 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
985 wprintf(_("Mailing list service"));
986 if (!strcmp(tab, "listserv")) {
987 wprintf("</SPAN></TD>\n");
990 wprintf("</A></TD>\n");
993 wprintf("<TD> </TD>\n");
995 wprintf("</TR></TABLE></div>\n");
996 /* end tabbed dialog */
998 /* begin content of whatever tab is open now */
999 wprintf("<div class=\"fix_scrollbar_bug\">"
1000 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
1003 if (!strcmp(tab, "admin")) {
1005 "<LI><a href=\"delete_room\" "
1006 "onClick=\"return confirm('");
1007 wprintf(_("Are you sure you want to delete this room?"));
1008 wprintf("');\">\n");
1009 wprintf(_("Delete this room"));
1011 "<LI><a href=\"display_editroompic\">\n");
1012 wprintf(_("Set or change the icon for this room's banner"));
1014 "<LI><a href=\"display_editinfo\">\n");
1015 wprintf(_("Edit this room's Info file"));
1020 if (!strcmp(tab, "config")) {
1021 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1023 wprintf("<UL><LI>");
1024 wprintf(_("Name of room: "));
1025 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1031 wprintf(_("Resides on floor: "));
1032 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1033 for (i = 0; i < 128; ++i)
1034 if (strlen(floorlist[i]) > 0) {
1035 wprintf("<OPTION ");
1037 wprintf("SELECTED ");
1038 wprintf("VALUE=\"%d\">", i);
1039 escputs(floorlist[i]);
1040 wprintf("</OPTION>\n");
1042 wprintf("</SELECT>\n");
1045 wprintf(_("Type of room:"));
1048 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1049 if ((er_flags & QR_PRIVATE) == 0)
1050 wprintf("CHECKED ");
1052 wprintf(_("Public room"));
1055 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1056 if ((er_flags & QR_PRIVATE) &&
1057 (er_flags & QR_GUESSNAME))
1058 wprintf("CHECKED ");
1060 wprintf(_("Private - guess name"));
1062 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1063 if ((er_flags & QR_PRIVATE) &&
1064 (er_flags & QR_PASSWORDED))
1065 wprintf("CHECKED ");
1067 wprintf(_("Private - require password:"));
1068 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1071 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1072 if ((er_flags & QR_PRIVATE)
1073 && ((er_flags & QR_GUESSNAME) == 0)
1074 && ((er_flags & QR_PASSWORDED) == 0))
1075 wprintf("CHECKED ");
1077 wprintf(_("Private - invitation only"));
1079 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1081 wprintf(_("If private, cause current users to forget room"));
1083 wprintf("\n</UL>\n");
1085 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1086 if (er_flags & QR_PREFONLY)
1087 wprintf("CHECKED ");
1089 wprintf(_("Preferred users only"));
1091 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1092 if (er_flags & QR_READONLY)
1093 wprintf("CHECKED ");
1095 wprintf(_("Read-only room"));
1097 /* directory stuff */
1098 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1099 if (er_flags & QR_DIRECTORY)
1100 wprintf("CHECKED ");
1102 wprintf(_("File directory room"));
1104 wprintf("\n<UL><LI>");
1105 wprintf(_("Directory name: "));
1106 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1109 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1110 if (er_flags & QR_UPLOAD)
1111 wprintf("CHECKED ");
1113 wprintf(_("Uploading allowed"));
1115 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1116 if (er_flags & QR_DOWNLOAD)
1117 wprintf("CHECKED ");
1119 wprintf(_("Downloading allowed"));
1121 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1122 if (er_flags & QR_VISDIR)
1123 wprintf("CHECKED ");
1125 wprintf(_("Visible directory"));
1128 /* end of directory stuff */
1130 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1131 if (er_flags & QR_NETWORK)
1132 wprintf("CHECKED ");
1134 wprintf(_("Network shared room"));
1136 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1137 if (er_flags & QR_PERMANENT)
1138 wprintf("CHECKED ");
1140 wprintf(_("Permanent (does not auto-purge)"));
1142 /* start of anon options */
1145 wprintf(_("Anonymous messages"));
1148 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1149 if (((er_flags & QR_ANONONLY) == 0)
1150 && ((er_flags & QR_ANONOPT) == 0))
1151 wprintf("CHECKED ");
1153 wprintf(_("No anonymous messages"));
1155 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1156 if (er_flags & QR_ANONONLY)
1157 wprintf("CHECKED ");
1159 wprintf(_("All messages are anonymous"));
1161 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1162 if (er_flags & QR_ANONOPT)
1163 wprintf("CHECKED ");
1165 wprintf(_("Prompt user when entering messages"));
1168 /* end of anon options */
1171 wprintf(_("Room aide: "));
1173 serv_getln(buf, sizeof buf);
1174 if (buf[0] != '2') {
1175 wprintf("<EM>%s</EM>\n", &buf[4]);
1177 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1178 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1181 wprintf("</UL><CENTER>\n");
1182 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1183 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1185 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1193 /* Sharing the room with other Citadel nodes... */
1194 if (!strcmp(tab, "sharing")) {
1196 shared_with = strdup("");
1197 not_shared_with = strdup("");
1199 /* Learn the current configuration */
1200 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1201 serv_getln(buf, sizeof buf);
1202 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1203 extract_token(node, buf, 0, '|', sizeof node);
1204 not_shared_with = realloc(not_shared_with,
1205 strlen(not_shared_with) + 32);
1206 strcat(not_shared_with, node);
1207 strcat(not_shared_with, "\n");
1211 serv_getln(buf, sizeof buf);
1212 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1213 extract_token(cmd, buf, 0, '|', sizeof cmd);
1214 extract_token(node, buf, 1, '|', sizeof node);
1215 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1216 if (!strcasecmp(cmd, "ignet_push_share")) {
1217 shared_with = realloc(shared_with,
1218 strlen(shared_with) + 32);
1219 strcat(shared_with, node);
1220 if (strlen(remote_room) > 0) {
1221 strcat(shared_with, "|");
1222 strcat(shared_with, remote_room);
1224 strcat(shared_with, "\n");
1228 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1229 extract_token(buf, shared_with, i, '\n', sizeof buf);
1230 extract_token(node, buf, 0, '|', sizeof node);
1231 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1232 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1233 if (!strcasecmp(node, cmd)) {
1234 remove_token(not_shared_with, j, '\n');
1239 /* Display the stuff */
1240 wprintf("<CENTER><br />"
1241 "<TABLE border=1 cellpadding=5><TR>"
1243 wprintf(_("Shared with"));
1244 wprintf("</I></B></TD>"
1246 wprintf(_("Not shared with"));
1247 wprintf("</I></B></TD></TR>\n"
1248 "<TR><TD VALIGN=TOP>\n");
1250 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1251 wprintf(_("Remote node name"));
1252 wprintf("</TD><TD>");
1253 wprintf(_("Remote room name"));
1254 wprintf("</TD><TD>");
1255 wprintf(_("Actions"));
1256 wprintf("</TD></TR>\n");
1258 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1259 extract_token(buf, shared_with, i, '\n', sizeof buf);
1260 extract_token(node, buf, 0, '|', sizeof node);
1261 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1262 if (strlen(node) > 0) {
1263 wprintf("<FORM METHOD=\"POST\" "
1264 "action=\"netedit\">"
1265 "<TR><TD>%s</TD>\n", node);
1268 if (strlen(remote_room) > 0) {
1269 escputs(remote_room);
1275 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1276 "VALUE=\"ignet_push_share|");
1278 if (strlen(remote_room) > 0) {
1280 urlescputs(remote_room);
1283 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1284 "VALUE=\"sharing\">\n");
1285 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1286 "VALUE=\"remove\">\n");
1287 wprintf("<INPUT TYPE=\"submit\" "
1288 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1289 wprintf("</TD></TR></FORM>\n");
1293 wprintf("</TABLE>\n");
1294 wprintf("</TD><TD VALIGN=TOP>\n");
1295 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1296 wprintf(_("Remote node name"));
1297 wprintf("</TD><TD>");
1298 wprintf(_("Remote room name"));
1299 wprintf("</TD><TD>");
1300 wprintf(_("Actions"));
1301 wprintf("</TD></TR>\n");
1303 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1304 extract_token(node, not_shared_with, i, '\n', sizeof node);
1305 if (strlen(node) > 0) {
1306 wprintf("<FORM METHOD=\"POST\" "
1307 "action=\"netedit\">"
1311 "<INPUT TYPE=\"INPUT\" "
1315 wprintf("<INPUT TYPE=\"hidden\" "
1317 "VALUE=\"ignet_push_share|");
1320 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1321 "VALUE=\"sharing\">\n");
1322 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1323 "VALUE=\"add\">\n");
1324 wprintf("<INPUT TYPE=\"submit\" "
1325 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1326 wprintf("</TD></TR></FORM>\n");
1330 wprintf("</TABLE>\n");
1331 wprintf("</TD></TR>"
1332 "</TABLE></CENTER><br />\n"
1333 "<I><B>%s</B><UL><LI>", _("Notes:"));
1334 wprintf(_("When sharing a room, "
1335 "it must be shared from both ends. Adding a node to "
1336 "the 'shared' list sends messages out, but in order to"
1337 " receive messages, the other nodes must be configured"
1338 " to send messages out to your system as well. "
1339 "<LI>If the remote room name is blank, it is assumed "
1340 "that the room name is identical on the remote node."
1341 "<LI>If the remote room name is different, the remote "
1342 "node must also configure the name of the room here."
1348 /* Mailing list management */
1349 if (!strcmp(tab, "listserv")) {
1351 wprintf("<br /><center>"
1352 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1353 "<TR><TD VALIGN=TOP>");
1355 wprintf(_("<i>The contents of this room are being "
1356 "mailed <b>as individual messages</b> "
1357 "to the following list recipients:"
1358 "</i><br /><br />\n"));
1361 serv_getln(buf, sizeof buf);
1362 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1363 extract_token(cmd, buf, 0, '|', sizeof cmd);
1364 if (!strcasecmp(cmd, "listrecp")) {
1365 extract_token(recp, buf, 1, '|', sizeof recp);
1368 wprintf(" <a href=\"netedit&cmd=remove&line="
1371 wprintf("&tab=listserv\">");
1372 wprintf(_("(remove)"));
1373 wprintf("</A><br />");
1376 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1377 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1378 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1379 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1380 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1381 wprintf("</FORM>\n");
1383 wprintf("</TD><TD VALIGN=TOP>\n");
1385 wprintf(_("<i>The contents of this room are being "
1386 "mailed <b>in digest form</b> "
1387 "to the following list recipients:"
1388 "</i><br /><br />\n"));
1391 serv_getln(buf, sizeof buf);
1392 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1393 extract_token(cmd, buf, 0, '|', sizeof cmd);
1394 if (!strcasecmp(cmd, "digestrecp")) {
1395 extract_token(recp, buf, 1, '|', sizeof recp);
1398 wprintf(" <a href=\"netedit&cmd=remove&line="
1401 wprintf("&tab=listserv\">");
1402 wprintf(_("(remove)"));
1403 wprintf("</A><br />");
1406 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1407 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1408 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1409 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1410 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1411 wprintf("</FORM>\n");
1413 wprintf("</TD></TR></TABLE><hr />\n");
1415 if (self_service(999) == 1) {
1416 wprintf(_("This room is configured to allow "
1417 "self-service subscribe/unsubscribe requests."));
1418 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1419 wprintf(_("Click to disable."));
1420 wprintf("</A><br />\n");
1421 wprintf(_("The URL for subscribe/unsubscribe is: "));
1422 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1423 (is_https ? "https" : "http"),
1427 wprintf(_("This room is <i>not</i> configured to allow "
1428 "self-service subscribe/unsubscribe requests."));
1429 wprintf(" <a href=\"toggle_self_service?newval=1&"
1431 wprintf(_("Click to enable."));
1432 wprintf("</A><br />\n");
1436 wprintf("</CENTER>\n");
1440 /* Mailing list management */
1441 if (!strcmp(tab, "expire")) {
1443 serv_puts("GPEX room");
1444 serv_getln(buf, sizeof buf);
1445 if (buf[0] == '2') {
1446 roompolicy = extract_int(&buf[4], 0);
1447 roomvalue = extract_int(&buf[4], 1);
1450 serv_puts("GPEX floor");
1451 serv_getln(buf, sizeof buf);
1452 if (buf[0] == '2') {
1453 floorpolicy = extract_int(&buf[4], 0);
1454 floorvalue = extract_int(&buf[4], 1);
1457 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1458 wprintf("<TABLE border=0 cellspacing=5>\n");
1459 wprintf("<TR><TD>");
1460 wprintf(_("Message expire policy for this room"));
1462 escputs(WC->wc_roomname);
1463 wprintf(")</TD><TD>");
1464 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1465 ((roompolicy == 0) ? "CHECKED" : "") );
1466 wprintf(_("Use the default policy for this floor"));
1467 wprintf("<br />\n");
1468 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1469 ((roompolicy == 1) ? "CHECKED" : "") );
1470 wprintf(_("Never automatically expire messages"));
1471 wprintf("<br />\n");
1472 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1473 ((roompolicy == 2) ? "CHECKED" : "") );
1474 wprintf(_("Expire by message count"));
1475 wprintf("<br />\n");
1476 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1477 ((roompolicy == 3) ? "CHECKED" : "") );
1478 wprintf(_("Expire by message age"));
1480 wprintf(_("Number of messages or days: "));
1481 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1482 wprintf("</TD></TR>\n");
1484 if (WC->axlevel >= 6) {
1485 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1486 wprintf("<TR><TD>");
1487 wprintf(_("Message expire policy for this floor"));
1489 escputs(floorlist[WC->wc_floor]);
1490 wprintf(")</TD><TD>");
1491 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1492 ((floorpolicy == 0) ? "CHECKED" : "") );
1493 wprintf(_("Use the system default"));
1494 wprintf("<br />\n");
1495 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1496 ((floorpolicy == 1) ? "CHECKED" : "") );
1497 wprintf(_("Never automatically expire messages"));
1498 wprintf("<br />\n");
1499 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1500 ((floorpolicy == 2) ? "CHECKED" : "") );
1501 wprintf(_("Expire by message count"));
1502 wprintf("<br />\n");
1503 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1504 ((floorpolicy == 3) ? "CHECKED" : "") );
1505 wprintf(_("Expire by message age"));
1507 wprintf(_("Number of messages or days: "));
1508 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1512 wprintf("<CENTER>\n");
1513 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1514 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1516 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1517 wprintf("</CENTER></TD><TR>\n");
1519 wprintf("</TABLE>\n"
1520 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1526 /* Mailing list management */
1527 if (!strcmp(tab, "access")) {
1531 /* end content of whatever tab is open now */
1532 wprintf("</TD></TR></TABLE></div>\n");
1539 * Toggle self-service list subscription
1541 void toggle_self_service(void) {
1544 newval = atoi(bstr("newval"));
1545 self_service(newval);
1552 * save new parameters for a room
1558 char er_password[10];
1559 char er_dirname[15];
1560 char er_roomaide[26];
1566 if (strlen(bstr("ok_button")) == 0) {
1567 strcpy(WC->ImportantMessage,
1568 _("Cancelled. Changes were not saved."));
1573 serv_getln(buf, sizeof buf);
1575 if (buf[0] != '2') {
1576 strcpy(WC->ImportantMessage, &buf[4]);
1580 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1581 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1582 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1583 er_flags = extract_int(&buf[4], 3);
1585 strcpy(er_roomaide, bstr("er_roomaide"));
1586 if (strlen(er_roomaide) == 0) {
1588 serv_getln(buf, sizeof buf);
1589 if (buf[0] != '2') {
1590 strcpy(er_roomaide, "");
1592 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1595 strcpy(buf, bstr("er_name"));
1597 if (strlen(buf) > 0) {
1598 strcpy(er_name, buf);
1601 strcpy(buf, bstr("er_password"));
1603 if (strlen(buf) > 0)
1604 strcpy(er_password, buf);
1606 strcpy(buf, bstr("er_dirname"));
1608 if (strlen(buf) > 0)
1609 strcpy(er_dirname, buf);
1611 strcpy(buf, bstr("type"));
1612 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1614 if (!strcmp(buf, "invonly")) {
1615 er_flags |= (QR_PRIVATE);
1617 if (!strcmp(buf, "hidden")) {
1618 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1620 if (!strcmp(buf, "passworded")) {
1621 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1623 if (!strcmp(bstr("prefonly"), "yes")) {
1624 er_flags |= QR_PREFONLY;
1626 er_flags &= ~QR_PREFONLY;
1629 if (!strcmp(bstr("readonly"), "yes")) {
1630 er_flags |= QR_READONLY;
1632 er_flags &= ~QR_READONLY;
1635 if (!strcmp(bstr("permanent"), "yes")) {
1636 er_flags |= QR_PERMANENT;
1638 er_flags &= ~QR_PERMANENT;
1641 if (!strcmp(bstr("network"), "yes")) {
1642 er_flags |= QR_NETWORK;
1644 er_flags &= ~QR_NETWORK;
1647 if (!strcmp(bstr("directory"), "yes")) {
1648 er_flags |= QR_DIRECTORY;
1650 er_flags &= ~QR_DIRECTORY;
1653 if (!strcmp(bstr("ulallowed"), "yes")) {
1654 er_flags |= QR_UPLOAD;
1656 er_flags &= ~QR_UPLOAD;
1659 if (!strcmp(bstr("dlallowed"), "yes")) {
1660 er_flags |= QR_DOWNLOAD;
1662 er_flags &= ~QR_DOWNLOAD;
1665 if (!strcmp(bstr("visdir"), "yes")) {
1666 er_flags |= QR_VISDIR;
1668 er_flags &= ~QR_VISDIR;
1671 strcpy(buf, bstr("anon"));
1673 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1674 if (!strcmp(buf, "anononly"))
1675 er_flags |= QR_ANONONLY;
1676 if (!strcmp(buf, "anon2"))
1677 er_flags |= QR_ANONOPT;
1680 if (!strcmp(bstr("bump"), "yes"))
1683 er_floor = atoi(bstr("er_floor"));
1685 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1686 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1688 serv_getln(buf, sizeof buf);
1689 if (buf[0] != '2') {
1690 strcpy(WC->ImportantMessage, &buf[4]);
1696 if (strlen(er_roomaide) > 0) {
1697 sprintf(buf, "SETA %s", er_roomaide);
1699 serv_getln(buf, sizeof buf);
1700 if (buf[0] != '2') {
1701 strcpy(WC->ImportantMessage, &buf[4]);
1702 display_main_menu();
1707 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1714 * Display form for Invite, Kick, and show Who Knows a room
1716 void do_invt_kick(void) {
1717 char buf[SIZ], room[SIZ], username[SIZ];
1720 serv_getln(buf, sizeof buf);
1722 if (buf[0] != '2') {
1726 extract_token(room, &buf[4], 0, '|', sizeof room);
1728 strcpy(username, bstr("username"));
1730 if (strlen(bstr("kick_button")) > 0) {
1731 sprintf(buf, "KICK %s", username);
1733 serv_getln(buf, sizeof buf);
1735 if (buf[0] != '2') {
1736 strcpy(WC->ImportantMessage, &buf[4]);
1738 sprintf(WC->ImportantMessage,
1739 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1744 if (strlen(bstr("invite_button")) > 0) {
1745 sprintf(buf, "INVT %s", username);
1747 serv_getln(buf, sizeof buf);
1749 if (buf[0] != '2') {
1750 strcpy(WC->ImportantMessage, &buf[4]);
1752 sprintf(WC->ImportantMessage,
1753 _("<B><I>User %s invited to room %s.</I></B>\n"),
1764 * Display form for Invite, Kick, and show Who Knows a room
1766 void display_whok(void)
1768 char buf[SIZ], room[SIZ], username[SIZ];
1771 serv_getln(buf, sizeof buf);
1773 if (buf[0] != '2') {
1777 extract_token(room, &buf[4], 0, '|', sizeof room);
1780 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1781 wprintf(_("The users listed below have access to this room. "
1782 "To remove a user from the access list, select the user "
1783 "name from the list and click 'Kick'."));
1784 wprintf("<br /><br />");
1786 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1787 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1788 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1790 serv_getln(buf, sizeof buf);
1791 if (buf[0] == '1') {
1792 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1793 extract_token(username, buf, 0, '|', sizeof username);
1794 wprintf("<OPTION>");
1799 wprintf("</SELECT><br />\n");
1801 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1802 wprintf("</FORM></CENTER>\n");
1804 wprintf("</TD><TD>");
1805 wprintf(_("To grant another user access to this room, enter the "
1806 "user name in the box below and click 'Invite'."));
1807 wprintf("<br /><br />");
1809 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1810 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1811 wprintf(_("Invite:"));
1813 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1814 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1815 "<input type=\"submit\" value=\"%s\">"
1816 "</FORM></CENTER>\n", _("Invite"));
1818 wprintf("</TD></TR></TABLE>\n");
1825 * display the form for entering a new room
1827 void display_entroom(void)
1832 serv_puts("CRE8 0");
1833 serv_getln(buf, sizeof buf);
1835 if (buf[0] != '2') {
1836 strcpy(WC->ImportantMessage, &buf[4]);
1837 display_main_menu();
1841 output_headers(1, 1, 2, 0, 0, 0);
1842 wprintf("<div id=\"banner\">\n"
1843 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1844 "<SPAN CLASS=\"titlebar\">");
1845 wprintf(_("Create a new room"));
1847 "</TD></TR></TABLE>\n"
1848 "</div>\n<div id=\"content\">\n"
1851 wprintf("<div class=\"fix_scrollbar_bug\">"
1852 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1854 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1856 wprintf("<UL><LI>");
1857 wprintf(_("Name of room: "));
1858 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1861 wprintf(_("Resides on floor: "));
1863 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1864 for (i = 0; i < 128; ++i)
1865 if (strlen(floorlist[i]) > 0) {
1866 wprintf("<OPTION ");
1867 wprintf("VALUE=\"%d\">", i);
1868 escputs(floorlist[i]);
1869 wprintf("</OPTION>\n");
1871 wprintf("</SELECT>\n");
1873 /* Our clever little snippet of JavaScript automatically selects
1874 * a public room if the view is set to Bulletin Board or wiki, and
1875 * it selects a mailbox room otherwise. The user can override this,
1876 * of course. We also disable the floor selector for mailboxes.
1879 wprintf(_("Default view for room: "));
1880 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1881 " if ( (this.form.er_view.value == 0) "
1882 " || (this.form.er_view.value == 6) ) { "
1883 " this.form.type[0].checked=true; "
1884 " this.form.er_floor.disabled = false; "
1887 " this.form.type[4].checked=true; "
1888 " this.form.er_floor.disabled = true; "
1891 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1892 wprintf("<OPTION %s VALUE=\"%d\">",
1893 ((i == 0) ? "SELECTED" : ""), i );
1894 escputs(viewdefs[i]);
1895 wprintf("</OPTION>\n");
1897 wprintf("</SELECT>\n");
1900 wprintf(_("Type of room:"));
1903 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1904 wprintf("CHECKED OnChange=\""
1905 " if (this.form.type[0].checked == true) { "
1906 " this.form.er_floor.disabled = false; "
1909 wprintf(_("Public (automatically appears to everyone)"));
1911 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1912 " if (this.form.type[1].checked == true) { "
1913 " this.form.er_floor.disabled = false; "
1916 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1918 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1919 " if (this.form.type[2].checked == true) { "
1920 " this.form.er_floor.disabled = false; "
1923 wprintf(_("Private - require password: "));
1924 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1926 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1927 " if (this.form.type[3].checked == true) { "
1928 " this.form.er_floor.disabled = false; "
1931 wprintf(_("Private - invitation only"));
1933 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1935 " if (this.form.type[4].checked == true) { "
1936 " this.form.er_floor.disabled = true; "
1939 wprintf(_("Personal (mailbox for you only)"));
1941 wprintf("\n</UL>\n");
1943 wprintf("<CENTER>\n");
1944 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1946 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1947 wprintf("</CENTER>\n");
1948 wprintf("</FORM>\n<hr />");
1949 serv_printf("MESG roomaccess");
1950 serv_getln(buf, sizeof buf);
1951 if (buf[0] == '1') {
1954 wprintf("</td></tr></table></div>\n");
1962 * support function for entroom() -- sets the default view
1964 void er_set_default_view(int newview) {
1977 serv_getln(buf, sizeof buf);
1978 if (buf[0] != '2') return;
1980 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
1981 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
1982 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
1983 rm_bits1 = extract_int(&buf[4], 3);
1984 rm_floor = extract_int(&buf[4], 4);
1985 rm_listorder = extract_int(&buf[4], 5);
1986 rm_bits2 = extract_int(&buf[4], 7);
1988 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1989 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1990 rm_listorder, newview, rm_bits2
1992 serv_getln(buf, sizeof buf);
2005 char er_password[SIZ];
2010 if (strlen(bstr("ok_button")) == 0) {
2011 strcpy(WC->ImportantMessage,
2012 _("Cancelled. No new room was created."));
2013 display_main_menu();
2016 strcpy(er_name, bstr("er_name"));
2017 strcpy(er_type, bstr("type"));
2018 strcpy(er_password, bstr("er_password"));
2019 er_floor = atoi(bstr("er_floor"));
2020 er_view = atoi(bstr("er_view"));
2023 if (!strcmp(er_type, "hidden"))
2025 if (!strcmp(er_type, "passworded"))
2027 if (!strcmp(er_type, "invonly"))
2029 if (!strcmp(er_type, "personal"))
2032 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2033 er_name, er_num_type, er_password, er_floor, 0, er_view);
2035 serv_getln(buf, sizeof buf);
2036 if (buf[0] != '2') {
2037 strcpy(WC->ImportantMessage, &buf[4]);
2038 display_main_menu();
2042 do_change_view(er_view); /* Now go there */
2047 * display the screen to enter a private room
2049 void display_private(char *rname, int req_pass)
2051 output_headers(1, 1, 2, 0, 0, 0);
2052 wprintf("<div id=\"banner\">\n"
2053 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2054 "<SPAN CLASS=\"titlebar\">");
2055 wprintf(_("Go to a hidden room"));
2057 "</TD></TR></TABLE>\n"
2058 "</div>\n<div id=\"content\">\n"
2061 wprintf("<div class=\"fix_scrollbar_bug\">"
2062 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2064 wprintf("<CENTER>\n");
2066 wprintf(_("If you know the name of a hidden (guess-name) or "
2067 "passworded room, you can enter that room by typing "
2068 "its name below. Once you gain access to a private "
2069 "room, it will appear in your regular room listings "
2070 "so you don't have to keep returning here."));
2071 wprintf("\n<br /><br />");
2073 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2075 wprintf("<table border=\"0\" cellspacing=\"5\" "
2076 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2078 wprintf(_("Enter room name:"));
2080 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2081 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2084 wprintf("</TD></TR><TR><TD>");
2085 wprintf(_("Enter room password:"));
2086 wprintf("</TD><TD>");
2087 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2089 wprintf("</TD></TR></TABLE><br />\n");
2091 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2093 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2097 wprintf("</FORM>\n");
2098 wprintf("</td></tr></table></div>\n");
2103 * goto a private room
2105 void goto_private(void)
2110 if (strlen(bstr("ok_button")) == 0) {
2111 display_main_menu();
2114 strcpy(hold_rm, WC->wc_roomname);
2115 strcpy(buf, "GOTO ");
2116 strcat(buf, bstr("gr_name"));
2118 strcat(buf, bstr("gr_pass"));
2120 serv_getln(buf, sizeof buf);
2122 if (buf[0] == '2') {
2123 smart_goto(bstr("gr_name"));
2126 if (!strncmp(buf, "540", 3)) {
2127 display_private(bstr("gr_name"), 1);
2130 output_headers(1, 1, 1, 0, 0, 0);
2131 wprintf("%s\n", &buf[4]);
2138 * display the screen to zap a room
2140 void display_zap(void)
2142 output_headers(1, 1, 2, 0, 0, 0);
2144 wprintf("<div id=\"banner\">\n");
2145 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2146 wprintf("<SPAN CLASS=\"titlebar\">");
2147 wprintf(_("Zap (forget/unsubscribe) the current room"));
2148 wprintf("</SPAN>\n");
2149 wprintf("</TD></TR></TABLE>\n");
2150 wprintf("</div>\n<div id=\"content\">\n");
2152 wprintf(_("If you select this option, <em>%s</em> will "
2153 "disappear from your room list. Is this what you wish "
2154 "to do?<br />\n"), WC->wc_roomname);
2156 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2157 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2159 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2160 wprintf("</FORM>\n");
2171 char final_destination[SIZ];
2173 /* If the forget-room routine fails for any reason, we fall back
2174 * to the current room; otherwise, we go to the Lobby
2176 strcpy(final_destination, WC->wc_roomname);
2178 if (strlen(bstr("ok_button")) > 0) {
2179 serv_printf("GOTO %s", WC->wc_roomname);
2180 serv_getln(buf, sizeof buf);
2181 if (buf[0] == '2') {
2183 serv_getln(buf, sizeof buf);
2184 if (buf[0] == '2') {
2185 strcpy(final_destination, "_BASEROOM_");
2189 smart_goto(final_destination);
2195 * Delete the current room
2197 void delete_room(void)
2201 serv_puts("KILL 1");
2202 serv_getln(buf, sizeof buf);
2203 if (buf[0] != '2') {
2204 strcpy(WC->ImportantMessage, &buf[4]);
2205 display_main_menu();
2208 smart_goto("_BASEROOM_");
2215 * Perform changes to a room's network configuration
2217 void netedit(void) {
2226 if (strlen(bstr("line"))==0) {
2231 strcpy(line, bstr("prefix"));
2232 strcat(line, bstr("line"));
2233 strcat(line, bstr("suffix"));
2242 serv_getln(buf, sizeof buf);
2243 if (buf[0] != '1') {
2249 /* This loop works for add *or* remove. Spiffy, eh? */
2250 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2251 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2252 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2253 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2254 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2255 if ( (strcasecmp(cmpa0, cmpb0))
2256 || (strcasecmp(cmpa1, cmpb1)) ) {
2257 fprintf(fp, "%s\n", buf);
2263 serv_getln(buf, sizeof buf);
2264 if (buf[0] != '4') {
2270 while (fgets(buf, sizeof buf, fp) != NULL) {
2271 buf[strlen(buf)-1] = 0;
2275 if (strlen(bstr("add_button")) > 0) {
2287 * Convert a room name to a folder-ish-looking name.
2289 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2294 * For mailboxes, just do it straight...
2297 sprintf(folder, "My folders|%s", room);
2301 * Otherwise, prefix the floor name as a "public folders" moniker
2304 sprintf(folder, "%s|%s", floorlist[floor], room);
2308 * Replace "\" characters with "|" for pseudo-folder-delimiting
2310 for (i=0; i<strlen(folder); ++i) {
2311 if (folder[i] == '\\') folder[i] = '|';
2319 * Back end for change_view()
2321 void do_change_view(int newview) {
2324 serv_printf("VIEW %d", newview);
2325 serv_getln(buf, sizeof buf);
2326 WC->wc_view = newview;
2327 smart_goto(WC->wc_roomname);
2333 * Change the view for this room
2335 void change_view(void) {
2338 view = atol(bstr("view"));
2339 do_change_view(view);
2344 * One big expanded tree list view --- like a folder list
2346 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2350 int has_subfolders = 0;
2353 parents = malloc(max_folders * sizeof(int));
2355 /* BEGIN TREE MENU */
2356 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2358 /* include NanoTree */
2359 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2361 /* initialize NanoTree */
2362 wprintf("<script type=\"text/javascript\"> \n"
2363 " showRootNode = false; \n"
2364 " sortNodes = false; \n"
2365 " dragable = false; \n"
2367 " function standardClick(treeNode) { \n"
2370 " var closedGif = 'static/folder_closed.gif'; \n"
2371 " var openGif = 'static/folder_open.gif'; \n"
2373 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2377 for (i=0; i<max_folders; ++i) {
2380 if ((i+1) < max_folders) {
2381 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2382 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2387 levels = num_tokens(fold[i].name, '|');
2388 parents[levels] = i;
2390 wprintf("var node%d = new TreeNode(%d, '", i, i);
2392 if (fold[i].selectable) {
2393 wprintf("<a href=\"dotgoto?room=");
2394 urlescputs(fold[i].room);
2399 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2401 else if (fold[i].hasnewmsgs) {
2402 wprintf("<SPAN CLASS=\"roomlist_new\">");
2405 wprintf("<SPAN CLASS=\"roomlist_old\">");
2407 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2412 if (has_subfolders) {
2413 wprintf("new Array(closedGif, openGif)");
2415 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2416 wprintf("'static/viewcontacts_16x.gif'");
2418 else if (fold[i].view == VIEW_CALENDAR) {
2419 wprintf("'static/calarea_16x.gif'");
2421 else if (fold[i].view == VIEW_TASKS) {
2422 wprintf("'static/taskmanag_16x.gif'");
2424 else if (fold[i].view == VIEW_NOTES) {
2425 wprintf("'static/storenotes_16x.gif'");
2427 else if (fold[i].view == VIEW_MAILBOX) {
2428 wprintf("'static/privatemess_16x.gif'");
2431 wprintf("'static/chatrooms_16x.gif'");
2434 urlescputs(fold[i].name);
2438 wprintf("rootNode.addChild(node%d);\n", i);
2441 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2445 wprintf("container = document.getElementById('roomlist_div'); \n"
2455 * Boxes and rooms and lists ... oh my!
2457 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2459 char floor_name[256];
2460 char old_floor_name[256];
2462 int levels, oldlevels;
2465 static int columns = 3;
2466 int boxes_per_column = 0;
2467 int current_column = 0;
2470 strcpy(floor_name, "");
2471 strcpy(old_floor_name, "");
2474 while (nf % columns != 0) ++nf;
2475 boxes_per_column = (nf / columns);
2476 if (boxes_per_column < 1) boxes_per_column = 1;
2478 /* Outer table (for columnization) */
2479 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2480 "<tr><td valign=top>");
2484 for (i=0; i<max_folders; ++i) {
2486 levels = num_tokens(fold[i].name, '|');
2487 extract_token(floor_name, fold[i].name, 0,
2488 '|', sizeof floor_name);
2490 if ( (strcasecmp(floor_name, old_floor_name))
2491 && (strlen(old_floor_name) > 0) ) {
2493 do_template("endbox");
2496 if ((num_boxes % boxes_per_column) == 0) {
2498 if (current_column < columns) {
2499 wprintf("</td><td valign=top>\n");
2503 strcpy(old_floor_name, floor_name);
2506 /* Begin inner box */
2507 stresc(boxtitle, floor_name, 1, 0);
2508 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2509 do_template("beginbox");
2516 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2517 if (fold[i].selectable) {
2518 wprintf("<a href=\"dotgoto?room=");
2519 urlescputs(fold[i].room);
2525 if (fold[i].hasnewmsgs) {
2526 wprintf("<SPAN CLASS=\"roomlist_new\">");
2529 wprintf("<SPAN CLASS=\"roomlist_old\">");
2531 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2534 if (fold[i].selectable) {
2540 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2541 wprintf(" (INBOX)");
2543 wprintf("<br />\n");
2546 /* End the final inner box */
2547 do_template("endbox");
2549 wprintf("</TD></TR></TABLE>\n");
2553 void set_floordiv_expanded(char *which_floordiv) {
2554 begin_ajax_response();
2555 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2556 end_ajax_response();
2562 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2564 char floor_name[256];
2565 char old_floor_name[256];
2566 char floordivtitle[256];
2567 char floordiv_id[32];
2568 int levels, oldlevels;
2570 int num_drop_targets = 0;
2573 strcpy(floor_name, "");
2574 strcpy(old_floor_name, "");
2578 for (i=0; i<max_folders; ++i) {
2580 levels = num_tokens(fold[i].name, '|');
2581 extract_token(floor_name, fold[i].name, 0,
2582 '|', sizeof floor_name);
2584 if ( (strcasecmp(floor_name, old_floor_name))
2585 && (strlen(old_floor_name) > 0) ) {
2588 wprintf("</div>\n"); /* floordiv */
2590 strcpy(old_floor_name, floor_name);
2594 stresc(floordivtitle, floor_name, 0, 0);
2595 sprintf(floordiv_id, "floordiv%d", i);
2596 wprintf("<span class=\"ib_roomlist_floor\" "
2597 "onClick=\"expand_floor('%s')\">"
2598 "%s</span><br>\n", floordiv_id, floordivtitle);
2599 wprintf("<div id=\"%s\" style=\"display:%s\">",
2601 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2608 wprintf("<div id=\"roomdiv%d\">", i);
2610 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2612 /* choose the icon */
2613 if (fold[i].view == VIEW_ADDRESSBOOK) {
2614 icon = "viewcontacts_16x.gif" ;
2616 else if (fold[i].view == VIEW_CALENDAR) {
2617 icon = "calarea_16x.gif" ;
2619 else if (fold[i].view == VIEW_TASKS) {
2620 icon = "taskmanag_16x.gif" ;
2622 else if (fold[i].view == VIEW_NOTES) {
2623 icon = "storenotes_16x.gif" ;
2625 else if (fold[i].view == VIEW_MAILBOX) {
2626 icon = "privatemess_16x.gif" ;
2629 icon = "chatrooms_16x.gif" ;
2632 if (fold[i].selectable) {
2633 wprintf("<a href=\"dotgoto?room=");
2634 urlescputs(fold[i].room);
2636 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2641 if (fold[i].hasnewmsgs) {
2642 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2645 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2647 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2649 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2650 wprintf(" (INBOX)");
2653 if (fold[i].selectable) {
2660 wprintf("</div>\n"); /* roomdiv */
2663 wprintf("</div>\n"); /* floordiv */
2666 /* BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2667 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2669 num_drop_targets = 0;
2671 for (i=0; i<max_folders; ++i) {
2672 levels = num_tokens(fold[i].name, '|');
2674 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2675 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2676 jsescputs(fold[i].room);
2682 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2683 if (strlen(WC->floordiv_expanded) > 1) {
2684 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2688 /* END: The old invisible pixel trick, to get our JavaScript to initialize */
2694 * Show the room list. (only should get called by
2695 * knrooms() because that's where output_headers() is called from)
2698 void list_all_rooms_by_floor(char *viewpref) {
2701 struct folder *fold = NULL;
2703 int max_folders = 0;
2704 int alloc_folders = 0;
2708 int num_floors = 1; /* add an extra one for private folders */
2710 /* If our cached folder list is very old, burn it. */
2711 if (WC->cache_fold != NULL) {
2712 if ((time(NULL) - WC->cache_timestamp) > 300) {
2713 free(WC->cache_fold);
2714 WC->cache_fold = NULL;
2718 /* Can we do the iconbar roomlist from cache? */
2719 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2720 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2724 /* Grab the floor table so we know how to build the list... */
2727 /* Start with the mailboxes */
2730 fold = malloc(sizeof(struct folder));
2731 memset(fold, 0, sizeof(struct folder));
2732 strcpy(fold[0].name, "My folders");
2733 fold[0].is_mailbox = 1;
2735 /* Then add floors */
2737 serv_getln(buf, sizeof buf);
2738 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2739 if (max_folders >= alloc_folders) {
2740 alloc_folders = max_folders + 100;
2741 fold = realloc(fold,
2742 alloc_folders * sizeof(struct folder));
2744 memset(&fold[max_folders], 0, sizeof(struct folder));
2745 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2752 serv_getln(buf, sizeof buf);
2753 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2754 if (max_folders >= alloc_folders) {
2755 alloc_folders = max_folders + 100;
2756 fold = realloc(fold,
2757 alloc_folders * sizeof(struct folder));
2759 memset(&fold[max_folders], 0, sizeof(struct folder));
2760 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2761 ra_flags = extract_int(buf, 5);
2762 flags = extract_int(buf, 1);
2763 fold[max_folders].floor = extract_int(buf, 2);
2764 fold[max_folders].hasnewmsgs =
2765 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2766 if (flags & QR_MAILBOX) {
2767 fold[max_folders].is_mailbox = 1;
2769 fold[max_folders].view = extract_int(buf, 6);
2770 room_to_folder(fold[max_folders].name,
2771 fold[max_folders].room,
2772 fold[max_folders].floor,
2773 fold[max_folders].is_mailbox);
2774 fold[max_folders].selectable = 1;
2778 /* Bubble-sort the folder list */
2779 for (i=0; i<max_folders; ++i) {
2780 for (j=0; j<(max_folders-1)-i; ++j) {
2781 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2782 swap = strcasecmp(fold[j].name, fold[j+1].name);
2785 if ( (fold[j+1].is_mailbox)
2786 && (!fold[j].is_mailbox)) {
2794 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2795 memcpy(&fold[j], &fold[j+1],
2796 sizeof(struct folder));
2797 memcpy(&fold[j+1], &ftmp,
2798 sizeof(struct folder));
2804 if (!strcasecmp(viewpref, "folders")) {
2805 do_folder_view(fold, max_folders, num_floors);
2807 else if (!strcasecmp(viewpref, "hackish_view")) {
2808 for (i=0; i<max_folders; ++i) {
2809 escputs(fold[i].name);
2810 wprintf("<br />\n");
2813 else if (!strcasecmp(viewpref, "iconbar")) {
2814 do_iconbar_view(fold, max_folders, num_floors);
2817 do_rooms_view(fold, max_folders, num_floors);
2820 /* Don't free the folder list ... cache it for future use! */
2821 if (WC->cache_fold != NULL) {
2822 free(WC->cache_fold);
2824 WC->cache_fold = fold;
2825 WC->cache_max_folders = max_folders;
2826 WC->cache_num_floors = num_floors;
2827 WC->cache_timestamp = time(NULL);
2831 /* Do either a known rooms list or a folders list, depending on the
2835 char listviewpref[SIZ];
2837 output_headers(1, 1, 2, 0, 0, 0);
2839 /* Determine whether the user is trying to change views */
2840 if (bstr("view") != NULL) {
2841 if (strlen(bstr("view")) > 0) {
2842 set_preference("roomlistview", bstr("view"), 1);
2846 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2848 if ( (strcasecmp(listviewpref, "folders"))
2849 && (strcasecmp(listviewpref, "table")) ) {
2850 strcpy(listviewpref, "rooms");
2854 wprintf("<div id=\"banner\">\n"
2855 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2856 "<SPAN CLASS=\"titlebar\">"
2858 if (!strcasecmp(listviewpref, "rooms")) {
2859 wprintf(_("Room list"));
2861 if (!strcasecmp(listviewpref, "folders")) {
2862 wprintf(_("Folder list"));
2864 if (!strcasecmp(listviewpref, "table")) {
2865 wprintf(_("Room list"));
2867 wprintf("</SPAN></TD>\n");
2869 /* offer the ability to switch views */
2870 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2871 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2872 "OnChange=\"location.href=roomlistomatic.newview.options"
2873 "[selectedIndex].value\">\n");
2875 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
2878 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2881 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
2882 "View as folder list"
2884 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2887 wprintf("</SELECT><br />");
2889 wprintf("</FORM></TD></TR></TABLE>\n");
2892 "<div id=\"content\">\n");
2894 /* Display the room list in the user's preferred format */
2895 list_all_rooms_by_floor(listviewpref);
2902 * Set the message expire policy for this room and/or floor
2904 void set_room_policy(void) {
2907 if (strlen(bstr("ok_button")) == 0) {
2908 strcpy(WC->ImportantMessage,
2909 _("Cancelled. Changes were not saved."));
2914 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2915 serv_getln(buf, sizeof buf);
2916 strcpy(WC->ImportantMessage, &buf[4]);
2918 if (WC->axlevel >= 6) {
2919 strcat(WC->ImportantMessage, "<br />\n");
2920 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2921 serv_getln(buf, sizeof buf);
2922 strcat(WC->ImportantMessage, &buf[4]);