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")
521 /* Don't let users create unlinked pages. */
525 "<td><a href=\"display_enter\">"
526 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
527 "border=\"0\"><span class=\"navbar_link\">"
529 "</span></a></td>\n", _("Enter a message")
535 if (navbar_style == navbar_default) wprintf(
539 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
540 "<span class=\"navbar_link\">%s</span></a>"
542 _("Leave all messages marked as unread, go to next room with unread messages"),
546 if (navbar_style == navbar_default) wprintf(
548 "<a href=\"gotonext\" "
550 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
551 "<span class=\"navbar_link\">%s</span></a>"
553 _("Mark all messages as read, go to next room with unread messages"),
557 wprintf("</tr></table></div>\n");
567 * back end routine to take the session to a new room
570 int gotoroom(char *gname)
573 static long ls = (-1L);
576 /* store ungoto information */
577 strcpy(WC->ugname, WC->wc_roomname);
580 /* move to the new room */
581 serv_printf("GOTO %s", gname);
582 serv_getln(buf, sizeof buf);
586 serv_puts("GOTO _BASEROOM_");
587 serv_getln(buf, sizeof buf);
594 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
595 WC->room_flags = extract_int(&buf[4], 4);
596 /* highest_msg_read = extract_int(&buf[4],6);
597 maxmsgnum = extract_int(&buf[4],5);
599 WC->is_mailbox = extract_int(&buf[4],7);
600 ls = extract_long(&buf[4], 6);
601 WC->wc_floor = extract_int(&buf[4], 10);
602 WC->wc_view = extract_int(&buf[4], 11);
603 WC->wc_default_view = extract_int(&buf[4], 12);
604 WC->wc_is_trash = extract_int(&buf[4], 13);
607 WC->is_room_aide = WC->is_aide;
609 WC->is_room_aide = (char) extract_int(&buf[4], 8);
611 remove_march(WC->wc_roomname);
612 if (!strcasecmp(gname, "_BASEROOM_"))
620 * Locate the room on the march list which we most want to go to. Each room
621 * is measured given a "weight" of preference based on various factors.
623 char *pop_march(int desired_floor)
625 static char TheRoom[128];
627 int TheOrder = 32767;
630 struct march *mptr = NULL;
632 strcpy(TheRoom, "_BASEROOM_");
633 if (WC->march == NULL)
636 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
638 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
639 weight = weight + 10000;
640 if (mptr->march_floor == desired_floor)
641 weight = weight + 5000;
643 weight = weight + ((128 - (mptr->march_floor)) * 128);
644 weight = weight + (128 - (mptr->march_order));
646 if (weight > TheWeight) {
648 strcpy(TheRoom, mptr->march_name);
649 TheFloor = mptr->march_floor;
650 TheOrder = mptr->march_order;
658 /* Goto next room having unread messages.
659 * We want to skip over rooms that the user has already been to, and take the
660 * user back to the lobby when done. The room we end up in is placed in
661 * newroom - which is set to 0 (the lobby) initially.
662 * We start the search in the current room rather than the beginning to prevent
663 * two or more concurrent users from dragging each other back to the same room.
668 struct march *mptr, *mptr2;
671 /* First check to see if the march-mode list is already allocated.
672 * If it is, pop the first room off the list and go there.
675 if (WC->march == NULL) {
677 serv_getln(buf, sizeof buf);
679 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
680 mptr = (struct march *) malloc(sizeof(struct march));
682 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
683 mptr->march_floor = extract_int(buf, 2);
684 mptr->march_order = extract_int(buf, 3);
685 if (WC->march == NULL) {
689 while (mptr2->next != NULL)
694 /* add _BASEROOM_ to the end of the march list, so the user will end up
695 * in the system base room (usually the Lobby>) at the end of the loop
697 mptr = (struct march *) malloc(sizeof(struct march));
699 strcpy(mptr->march_name, "_BASEROOM_");
700 if (WC->march == NULL) {
704 while (mptr2->next != NULL)
709 * ...and remove the room we're currently in, so a <G>oto doesn't make us
710 * walk around in circles
712 remove_march(WC->wc_roomname);
714 if (WC->march != NULL) {
715 strcpy(next_room, pop_march(-1));
717 strcpy(next_room, "_BASEROOM_");
721 smart_goto(next_room);
725 void smart_goto(char *next_room) {
733 * mark all messages in current room as having been read
735 void slrp_highest(void)
740 serv_puts("SLRP HIGHEST");
741 serv_getln(buf, sizeof buf);
743 wprintf("<EM>%s</EM><br />\n", &buf[4]);
750 * un-goto the previous room
756 if (!strcmp(WC->ugname, "")) {
757 smart_goto(WC->wc_roomname);
760 serv_printf("GOTO %s", WC->ugname);
761 serv_getln(buf, sizeof buf);
763 smart_goto(WC->wc_roomname);
766 if (WC->uglsn >= 0L) {
767 serv_printf("SLRP %ld", WC->uglsn);
768 serv_getln(buf, sizeof buf);
770 strcpy(buf, WC->ugname);
771 strcpy(WC->ugname, "");
780 * Set/clear/read the "self-service list subscribe" flag for a room
782 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
783 * Always returns the new value.
786 int self_service(int newval) {
787 int current_value = 0;
793 int flags, floor, order, view, flags2;
796 serv_getln(buf, sizeof buf);
797 if (buf[0] != '2') return(0);
799 extract_token(name, &buf[4], 0, '|', sizeof name);
800 extract_token(password, &buf[4], 1, '|', sizeof password);
801 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
802 flags = extract_int(&buf[4], 3);
803 floor = extract_int(&buf[4], 4);
804 order = extract_int(&buf[4], 5);
805 view = extract_int(&buf[4], 6);
806 flags2 = extract_int(&buf[4], 7);
808 if (flags2 & QR2_SELFLIST) {
816 flags2 = flags2 | QR2_SELFLIST;
818 else if (newval == 0) {
819 flags2 = flags2 & ~QR2_SELFLIST;
822 return(current_value);
825 if (newval != current_value) {
826 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
827 name, password, dirname, flags,
828 floor, order, view, flags2);
829 serv_getln(buf, sizeof buf);
842 * display the form for editing a room
844 void display_editroom(void)
849 char remote_room[SIZ];
852 char er_password[10];
854 char er_roomaide[26];
860 char *not_shared_with;
867 if (strlen(tab) == 0) tab = "admin";
871 serv_getln(buf, sizeof buf);
874 strcpy(WC->ImportantMessage, &buf[4]);
878 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
879 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
880 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
881 er_flags = extract_int(&buf[4], 3);
882 er_floor = extract_int(&buf[4], 4);
884 output_headers(1, 1, 1, 0, 0, 0);
886 /* print the tabbed dialog */
888 "<div class=\"fix_scrollbar_bug\">"
889 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
891 "<TD> </TD>\n");
893 if (!strcmp(tab, "admin")) {
894 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
897 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
899 wprintf(_("Administration"));
900 if (!strcmp(tab, "admin")) {
901 wprintf("</SPAN></TD>\n");
904 wprintf("</A></TD>\n");
907 wprintf("<TD> </TD>\n");
909 if (!strcmp(tab, "config")) {
910 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
913 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
915 wprintf(_("Configuration"));
916 if (!strcmp(tab, "config")) {
917 wprintf("</SPAN></TD>\n");
920 wprintf("</A></TD>\n");
923 wprintf("<TD> </TD>\n");
925 if (!strcmp(tab, "expire")) {
926 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
929 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
931 wprintf(_("Message expire policy"));
932 if (!strcmp(tab, "expire")) {
933 wprintf("</SPAN></TD>\n");
936 wprintf("</A></TD>\n");
939 wprintf("<TD> </TD>\n");
941 if (!strcmp(tab, "access")) {
942 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
945 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
947 wprintf(_("Access controls"));
948 if (!strcmp(tab, "access")) {
949 wprintf("</SPAN></TD>\n");
952 wprintf("</A></TD>\n");
955 wprintf("<TD> </TD>\n");
957 if (!strcmp(tab, "sharing")) {
958 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
961 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
963 wprintf(_("Sharing"));
964 if (!strcmp(tab, "sharing")) {
965 wprintf("</SPAN></TD>\n");
968 wprintf("</A></TD>\n");
971 wprintf("<TD> </TD>\n");
973 if (!strcmp(tab, "listserv")) {
974 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
977 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
979 wprintf(_("Mailing list service"));
980 if (!strcmp(tab, "listserv")) {
981 wprintf("</SPAN></TD>\n");
984 wprintf("</A></TD>\n");
987 wprintf("<TD> </TD>\n");
989 wprintf("</TR></TABLE></div>\n");
990 /* end tabbed dialog */
992 /* begin content of whatever tab is open now */
993 wprintf("<div class=\"fix_scrollbar_bug\">"
994 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
997 if (!strcmp(tab, "admin")) {
999 "<LI><a href=\"delete_room\" "
1000 "onClick=\"return confirm('");
1001 wprintf(_("Are you sure you want to delete this room?"));
1002 wprintf("');\">\n");
1003 wprintf(_("Delete this room"));
1005 "<LI><a href=\"display_editroompic\">\n");
1006 wprintf(_("Set or change the icon for this room's banner"));
1008 "<LI><a href=\"display_editinfo\">\n");
1009 wprintf(_("Edit this room's Info file"));
1014 if (!strcmp(tab, "config")) {
1015 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1017 wprintf("<UL><LI>");
1018 wprintf(_("Name of room: "));
1019 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1025 wprintf(_("Resides on floor: "));
1026 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1027 for (i = 0; i < 128; ++i)
1028 if (strlen(floorlist[i]) > 0) {
1029 wprintf("<OPTION ");
1031 wprintf("SELECTED ");
1032 wprintf("VALUE=\"%d\">", i);
1033 escputs(floorlist[i]);
1034 wprintf("</OPTION>\n");
1036 wprintf("</SELECT>\n");
1039 wprintf(_("Type of room:"));
1042 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1043 if ((er_flags & QR_PRIVATE) == 0)
1044 wprintf("CHECKED ");
1046 wprintf(_("Public room"));
1049 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1050 if ((er_flags & QR_PRIVATE) &&
1051 (er_flags & QR_GUESSNAME))
1052 wprintf("CHECKED ");
1054 wprintf(_("Private - guess name"));
1056 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1057 if ((er_flags & QR_PRIVATE) &&
1058 (er_flags & QR_PASSWORDED))
1059 wprintf("CHECKED ");
1061 wprintf(_("Private - require password:"));
1062 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1065 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1066 if ((er_flags & QR_PRIVATE)
1067 && ((er_flags & QR_GUESSNAME) == 0)
1068 && ((er_flags & QR_PASSWORDED) == 0))
1069 wprintf("CHECKED ");
1071 wprintf(_("Private - invitation only"));
1073 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1075 wprintf(_("If private, cause current users to forget room"));
1077 wprintf("\n</UL>\n");
1079 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1080 if (er_flags & QR_PREFONLY)
1081 wprintf("CHECKED ");
1083 wprintf(_("Preferred users only"));
1085 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1086 if (er_flags & QR_READONLY)
1087 wprintf("CHECKED ");
1089 wprintf(_("Read-only room"));
1091 /* directory stuff */
1092 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1093 if (er_flags & QR_DIRECTORY)
1094 wprintf("CHECKED ");
1096 wprintf(_("File directory room"));
1098 wprintf("\n<UL><LI>");
1099 wprintf(_("Directory name: "));
1100 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1103 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1104 if (er_flags & QR_UPLOAD)
1105 wprintf("CHECKED ");
1107 wprintf(_("Uploading allowed"));
1109 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1110 if (er_flags & QR_DOWNLOAD)
1111 wprintf("CHECKED ");
1113 wprintf(_("Downloading allowed"));
1115 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1116 if (er_flags & QR_VISDIR)
1117 wprintf("CHECKED ");
1119 wprintf(_("Visible directory"));
1122 /* end of directory stuff */
1124 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1125 if (er_flags & QR_NETWORK)
1126 wprintf("CHECKED ");
1128 wprintf(_("Network shared room"));
1130 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1131 if (er_flags & QR_PERMANENT)
1132 wprintf("CHECKED ");
1134 wprintf(_("Permanent (does not auto-purge)"));
1136 /* start of anon options */
1139 wprintf(_("Anonymous messages"));
1142 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1143 if (((er_flags & QR_ANONONLY) == 0)
1144 && ((er_flags & QR_ANONOPT) == 0))
1145 wprintf("CHECKED ");
1147 wprintf(_("No anonymous messages"));
1149 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1150 if (er_flags & QR_ANONONLY)
1151 wprintf("CHECKED ");
1153 wprintf(_("All messages are anonymous"));
1155 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1156 if (er_flags & QR_ANONOPT)
1157 wprintf("CHECKED ");
1159 wprintf(_("Prompt user when entering messages"));
1162 /* end of anon options */
1165 wprintf(_("Room aide: "));
1167 serv_getln(buf, sizeof buf);
1168 if (buf[0] != '2') {
1169 wprintf("<EM>%s</EM>\n", &buf[4]);
1171 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1172 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1175 wprintf("</UL><CENTER>\n");
1176 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1177 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1179 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1187 /* Sharing the room with other Citadel nodes... */
1188 if (!strcmp(tab, "sharing")) {
1190 shared_with = strdup("");
1191 not_shared_with = strdup("");
1193 /* Learn the current configuration */
1194 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1195 serv_getln(buf, sizeof buf);
1196 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1197 extract_token(node, buf, 0, '|', sizeof node);
1198 not_shared_with = realloc(not_shared_with,
1199 strlen(not_shared_with) + 32);
1200 strcat(not_shared_with, node);
1201 strcat(not_shared_with, "\n");
1205 serv_getln(buf, sizeof buf);
1206 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1207 extract_token(cmd, buf, 0, '|', sizeof cmd);
1208 extract_token(node, buf, 1, '|', sizeof node);
1209 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1210 if (!strcasecmp(cmd, "ignet_push_share")) {
1211 shared_with = realloc(shared_with,
1212 strlen(shared_with) + 32);
1213 strcat(shared_with, node);
1214 if (strlen(remote_room) > 0) {
1215 strcat(shared_with, "|");
1216 strcat(shared_with, remote_room);
1218 strcat(shared_with, "\n");
1222 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1223 extract_token(buf, shared_with, i, '\n', sizeof buf);
1224 extract_token(node, buf, 0, '|', sizeof node);
1225 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1226 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1227 if (!strcasecmp(node, cmd)) {
1228 remove_token(not_shared_with, j, '\n');
1233 /* Display the stuff */
1234 wprintf("<CENTER><br />"
1235 "<TABLE border=1 cellpadding=5><TR>"
1237 wprintf(_("Shared with"));
1238 wprintf("</I></B></TD>"
1240 wprintf(_("Not shared with"));
1241 wprintf("</I></B></TD></TR>\n"
1242 "<TR><TD VALIGN=TOP>\n");
1244 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1245 wprintf(_("Remote node name"));
1246 wprintf("</TD><TD>");
1247 wprintf(_("Remote room name"));
1248 wprintf("</TD><TD>");
1249 wprintf(_("Actions"));
1250 wprintf("</TD></TR>\n");
1252 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1253 extract_token(buf, shared_with, i, '\n', sizeof buf);
1254 extract_token(node, buf, 0, '|', sizeof node);
1255 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1256 if (strlen(node) > 0) {
1257 wprintf("<FORM METHOD=\"POST\" "
1258 "action=\"netedit\">"
1259 "<TR><TD>%s</TD>\n", node);
1262 if (strlen(remote_room) > 0) {
1263 escputs(remote_room);
1269 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1270 "VALUE=\"ignet_push_share|");
1272 if (strlen(remote_room) > 0) {
1274 urlescputs(remote_room);
1277 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1278 "VALUE=\"sharing\">\n");
1279 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1280 "VALUE=\"remove\">\n");
1281 wprintf("<INPUT TYPE=\"submit\" "
1282 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1283 wprintf("</TD></TR></FORM>\n");
1287 wprintf("</TABLE>\n");
1288 wprintf("</TD><TD VALIGN=TOP>\n");
1289 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1290 wprintf(_("Remote node name"));
1291 wprintf("</TD><TD>");
1292 wprintf(_("Remote room name"));
1293 wprintf("</TD><TD>");
1294 wprintf(_("Actions"));
1295 wprintf("</TD></TR>\n");
1297 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1298 extract_token(node, not_shared_with, i, '\n', sizeof node);
1299 if (strlen(node) > 0) {
1300 wprintf("<FORM METHOD=\"POST\" "
1301 "action=\"netedit\">"
1305 "<INPUT TYPE=\"INPUT\" "
1309 wprintf("<INPUT TYPE=\"hidden\" "
1311 "VALUE=\"ignet_push_share|");
1314 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1315 "VALUE=\"sharing\">\n");
1316 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1317 "VALUE=\"add\">\n");
1318 wprintf("<INPUT TYPE=\"submit\" "
1319 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1320 wprintf("</TD></TR></FORM>\n");
1324 wprintf("</TABLE>\n");
1325 wprintf("</TD></TR>"
1326 "</TABLE></CENTER><br />\n"
1327 "<I><B>%s</B><UL><LI>", _("Notes:"));
1328 wprintf(_("When sharing a room, "
1329 "it must be shared from both ends. Adding a node to "
1330 "the 'shared' list sends messages out, but in order to"
1331 " receive messages, the other nodes must be configured"
1332 " to send messages out to your system as well. "
1333 "<LI>If the remote room name is blank, it is assumed "
1334 "that the room name is identical on the remote node."
1335 "<LI>If the remote room name is different, the remote "
1336 "node must also configure the name of the room here."
1342 /* Mailing list management */
1343 if (!strcmp(tab, "listserv")) {
1345 wprintf("<br /><center>"
1346 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1347 "<TR><TD VALIGN=TOP>");
1349 wprintf(_("<i>The contents of this room are being "
1350 "mailed <b>as individual messages</b> "
1351 "to the following list recipients:"
1352 "</i><br /><br />\n"));
1355 serv_getln(buf, sizeof buf);
1356 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1357 extract_token(cmd, buf, 0, '|', sizeof cmd);
1358 if (!strcasecmp(cmd, "listrecp")) {
1359 extract_token(recp, buf, 1, '|', sizeof recp);
1362 wprintf(" <a href=\"netedit&cmd=remove&line="
1365 wprintf("&tab=listserv\">");
1366 wprintf(_("(remove)"));
1367 wprintf("</A><br />");
1370 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1371 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1372 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1373 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1374 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1375 wprintf("</FORM>\n");
1377 wprintf("</TD><TD VALIGN=TOP>\n");
1379 wprintf(_("<i>The contents of this room are being "
1380 "mailed <b>in digest form</b> "
1381 "to the following list recipients:"
1382 "</i><br /><br />\n"));
1385 serv_getln(buf, sizeof buf);
1386 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1387 extract_token(cmd, buf, 0, '|', sizeof cmd);
1388 if (!strcasecmp(cmd, "digestrecp")) {
1389 extract_token(recp, buf, 1, '|', sizeof recp);
1392 wprintf(" <a href=\"netedit&cmd=remove&line="
1395 wprintf("&tab=listserv\">");
1396 wprintf(_("(remove)"));
1397 wprintf("</A><br />");
1400 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1401 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1402 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1403 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1404 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1405 wprintf("</FORM>\n");
1407 wprintf("</TD></TR></TABLE><hr />\n");
1409 if (self_service(999) == 1) {
1410 wprintf(_("This room is configured to allow "
1411 "self-service subscribe/unsubscribe requests."));
1412 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1413 wprintf(_("Click to disable."));
1414 wprintf("</A><br />\n");
1415 wprintf(_("The URL for subscribe/unsubscribe is: "));
1416 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1417 (is_https ? "https" : "http"),
1421 wprintf(_("This room is <i>not</i> configured to allow "
1422 "self-service subscribe/unsubscribe requests."));
1423 wprintf(" <a href=\"toggle_self_service?newval=1&"
1425 wprintf(_("Click to enable."));
1426 wprintf("</A><br />\n");
1430 wprintf("</CENTER>\n");
1434 /* Mailing list management */
1435 if (!strcmp(tab, "expire")) {
1437 serv_puts("GPEX room");
1438 serv_getln(buf, sizeof buf);
1439 if (buf[0] == '2') {
1440 roompolicy = extract_int(&buf[4], 0);
1441 roomvalue = extract_int(&buf[4], 1);
1444 serv_puts("GPEX floor");
1445 serv_getln(buf, sizeof buf);
1446 if (buf[0] == '2') {
1447 floorpolicy = extract_int(&buf[4], 0);
1448 floorvalue = extract_int(&buf[4], 1);
1451 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1452 wprintf("<TABLE border=0 cellspacing=5>\n");
1453 wprintf("<TR><TD>");
1454 wprintf(_("Message expire policy for this room"));
1456 escputs(WC->wc_roomname);
1457 wprintf(")</TD><TD>");
1458 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1459 ((roompolicy == 0) ? "CHECKED" : "") );
1460 wprintf(_("Use the default policy for this floor"));
1461 wprintf("<br />\n");
1462 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1463 ((roompolicy == 1) ? "CHECKED" : "") );
1464 wprintf(_("Never automatically expire messages"));
1465 wprintf("<br />\n");
1466 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1467 ((roompolicy == 2) ? "CHECKED" : "") );
1468 wprintf(_("Expire by message count"));
1469 wprintf("<br />\n");
1470 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1471 ((roompolicy == 3) ? "CHECKED" : "") );
1472 wprintf(_("Expire by message age"));
1474 wprintf(_("Number of messages or days: "));
1475 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1476 wprintf("</TD></TR>\n");
1478 if (WC->axlevel >= 6) {
1479 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1480 wprintf("<TR><TD>");
1481 wprintf(_("Message expire policy for this floor"));
1483 escputs(floorlist[WC->wc_floor]);
1484 wprintf(")</TD><TD>");
1485 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1486 ((floorpolicy == 0) ? "CHECKED" : "") );
1487 wprintf(_("Use the system default"));
1488 wprintf("<br />\n");
1489 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1490 ((floorpolicy == 1) ? "CHECKED" : "") );
1491 wprintf(_("Never automatically expire messages"));
1492 wprintf("<br />\n");
1493 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1494 ((floorpolicy == 2) ? "CHECKED" : "") );
1495 wprintf(_("Expire by message count"));
1496 wprintf("<br />\n");
1497 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1498 ((floorpolicy == 3) ? "CHECKED" : "") );
1499 wprintf(_("Expire by message age"));
1501 wprintf(_("Number of messages or days: "));
1502 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1506 wprintf("<CENTER>\n");
1507 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1508 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1510 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1511 wprintf("</CENTER></TD><TR>\n");
1513 wprintf("</TABLE>\n"
1514 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1520 /* Mailing list management */
1521 if (!strcmp(tab, "access")) {
1525 /* end content of whatever tab is open now */
1526 wprintf("</TD></TR></TABLE></div>\n");
1533 * Toggle self-service list subscription
1535 void toggle_self_service(void) {
1538 newval = atoi(bstr("newval"));
1539 self_service(newval);
1546 * save new parameters for a room
1552 char er_password[10];
1553 char er_dirname[15];
1554 char er_roomaide[26];
1560 if (strlen(bstr("ok_button")) == 0) {
1561 strcpy(WC->ImportantMessage,
1562 _("Cancelled. Changes were not saved."));
1567 serv_getln(buf, sizeof buf);
1569 if (buf[0] != '2') {
1570 strcpy(WC->ImportantMessage, &buf[4]);
1574 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1575 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1576 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1577 er_flags = extract_int(&buf[4], 3);
1579 strcpy(er_roomaide, bstr("er_roomaide"));
1580 if (strlen(er_roomaide) == 0) {
1582 serv_getln(buf, sizeof buf);
1583 if (buf[0] != '2') {
1584 strcpy(er_roomaide, "");
1586 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1589 strcpy(buf, bstr("er_name"));
1591 if (strlen(buf) > 0) {
1592 strcpy(er_name, buf);
1595 strcpy(buf, bstr("er_password"));
1597 if (strlen(buf) > 0)
1598 strcpy(er_password, buf);
1600 strcpy(buf, bstr("er_dirname"));
1602 if (strlen(buf) > 0)
1603 strcpy(er_dirname, buf);
1605 strcpy(buf, bstr("type"));
1606 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1608 if (!strcmp(buf, "invonly")) {
1609 er_flags |= (QR_PRIVATE);
1611 if (!strcmp(buf, "hidden")) {
1612 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1614 if (!strcmp(buf, "passworded")) {
1615 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1617 if (!strcmp(bstr("prefonly"), "yes")) {
1618 er_flags |= QR_PREFONLY;
1620 er_flags &= ~QR_PREFONLY;
1623 if (!strcmp(bstr("readonly"), "yes")) {
1624 er_flags |= QR_READONLY;
1626 er_flags &= ~QR_READONLY;
1629 if (!strcmp(bstr("permanent"), "yes")) {
1630 er_flags |= QR_PERMANENT;
1632 er_flags &= ~QR_PERMANENT;
1635 if (!strcmp(bstr("network"), "yes")) {
1636 er_flags |= QR_NETWORK;
1638 er_flags &= ~QR_NETWORK;
1641 if (!strcmp(bstr("directory"), "yes")) {
1642 er_flags |= QR_DIRECTORY;
1644 er_flags &= ~QR_DIRECTORY;
1647 if (!strcmp(bstr("ulallowed"), "yes")) {
1648 er_flags |= QR_UPLOAD;
1650 er_flags &= ~QR_UPLOAD;
1653 if (!strcmp(bstr("dlallowed"), "yes")) {
1654 er_flags |= QR_DOWNLOAD;
1656 er_flags &= ~QR_DOWNLOAD;
1659 if (!strcmp(bstr("visdir"), "yes")) {
1660 er_flags |= QR_VISDIR;
1662 er_flags &= ~QR_VISDIR;
1665 strcpy(buf, bstr("anon"));
1667 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1668 if (!strcmp(buf, "anononly"))
1669 er_flags |= QR_ANONONLY;
1670 if (!strcmp(buf, "anon2"))
1671 er_flags |= QR_ANONOPT;
1674 if (!strcmp(bstr("bump"), "yes"))
1677 er_floor = atoi(bstr("er_floor"));
1679 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1680 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1682 serv_getln(buf, sizeof buf);
1683 if (buf[0] != '2') {
1684 strcpy(WC->ImportantMessage, &buf[4]);
1690 if (strlen(er_roomaide) > 0) {
1691 sprintf(buf, "SETA %s", er_roomaide);
1693 serv_getln(buf, sizeof buf);
1694 if (buf[0] != '2') {
1695 strcpy(WC->ImportantMessage, &buf[4]);
1696 display_main_menu();
1701 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1708 * Display form for Invite, Kick, and show Who Knows a room
1710 void do_invt_kick(void) {
1711 char buf[SIZ], room[SIZ], username[SIZ];
1714 serv_getln(buf, sizeof buf);
1716 if (buf[0] != '2') {
1720 extract_token(room, &buf[4], 0, '|', sizeof room);
1722 strcpy(username, bstr("username"));
1724 if (strlen(bstr("kick_button")) > 0) {
1725 sprintf(buf, "KICK %s", username);
1727 serv_getln(buf, sizeof buf);
1729 if (buf[0] != '2') {
1730 strcpy(WC->ImportantMessage, &buf[4]);
1732 sprintf(WC->ImportantMessage,
1733 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1738 if (strlen(bstr("invite_button")) > 0) {
1739 sprintf(buf, "INVT %s", username);
1741 serv_getln(buf, sizeof buf);
1743 if (buf[0] != '2') {
1744 strcpy(WC->ImportantMessage, &buf[4]);
1746 sprintf(WC->ImportantMessage,
1747 _("<B><I>User %s invited to room %s.</I></B>\n"),
1758 * Display form for Invite, Kick, and show Who Knows a room
1760 void display_whok(void)
1762 char buf[SIZ], room[SIZ], username[SIZ];
1765 serv_getln(buf, sizeof buf);
1767 if (buf[0] != '2') {
1771 extract_token(room, &buf[4], 0, '|', sizeof room);
1774 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1775 wprintf(_("The users listed below have access to this room. "
1776 "To remove a user from the access list, select the user "
1777 "name from the list and click 'Kick'."));
1778 wprintf("<br /><br />");
1780 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1781 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1782 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1784 serv_getln(buf, sizeof buf);
1785 if (buf[0] == '1') {
1786 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1787 extract_token(username, buf, 0, '|', sizeof username);
1788 wprintf("<OPTION>");
1793 wprintf("</SELECT><br />\n");
1795 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1796 wprintf("</FORM></CENTER>\n");
1798 wprintf("</TD><TD>");
1799 wprintf(_("To grant another user access to this room, enter the "
1800 "user name in the box below and click 'Invite'."));
1801 wprintf("<br /><br />");
1803 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1804 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1805 wprintf(_("Invite:"));
1807 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1808 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1809 "<input type=\"submit\" value=\"%s\">"
1810 "</FORM></CENTER>\n", _("Invite"));
1812 wprintf("</TD></TR></TABLE>\n");
1819 * display the form for entering a new room
1821 void display_entroom(void)
1826 serv_puts("CRE8 0");
1827 serv_getln(buf, sizeof buf);
1829 if (buf[0] != '2') {
1830 strcpy(WC->ImportantMessage, &buf[4]);
1831 display_main_menu();
1835 output_headers(1, 1, 2, 0, 0, 0);
1836 wprintf("<div id=\"banner\">\n"
1837 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1838 "<SPAN CLASS=\"titlebar\">");
1839 wprintf(_("Create a new room"));
1841 "</TD></TR></TABLE>\n"
1842 "</div>\n<div id=\"content\">\n"
1845 wprintf("<div class=\"fix_scrollbar_bug\">"
1846 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1848 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1850 wprintf("<UL><LI>");
1851 wprintf(_("Name of room: "));
1852 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1855 wprintf(_("Resides on floor: "));
1857 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1858 for (i = 0; i < 128; ++i)
1859 if (strlen(floorlist[i]) > 0) {
1860 wprintf("<OPTION ");
1861 wprintf("VALUE=\"%d\">", i);
1862 escputs(floorlist[i]);
1863 wprintf("</OPTION>\n");
1865 wprintf("</SELECT>\n");
1867 /* Our clever little snippet of JavaScript automatically selects
1868 * a public room if the view is set to Bulletin Board or wiki, and
1869 * it selects a mailbox room otherwise. The user can override this,
1870 * of course. We also disable the floor selector for mailboxes.
1873 wprintf(_("Default view for room: "));
1874 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1875 " if ( (this.form.er_view.value == 0) "
1876 " || (this.form.er_view.value == 6) ) { "
1877 " this.form.type[0].checked=true; "
1878 " this.form.er_floor.disabled = false; "
1881 " this.form.type[4].checked=true; "
1882 " this.form.er_floor.disabled = true; "
1885 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1886 wprintf("<OPTION %s VALUE=\"%d\">",
1887 ((i == 0) ? "SELECTED" : ""), i );
1888 escputs(viewdefs[i]);
1889 wprintf("</OPTION>\n");
1891 wprintf("</SELECT>\n");
1894 wprintf(_("Type of room:"));
1897 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1898 wprintf("CHECKED OnChange=\""
1899 " if (this.form.type[0].checked == true) { "
1900 " this.form.er_floor.disabled = false; "
1903 wprintf(_("Public (automatically appears to everyone)"));
1905 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1906 " if (this.form.type[1].checked == true) { "
1907 " this.form.er_floor.disabled = false; "
1910 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1912 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1913 " if (this.form.type[2].checked == true) { "
1914 " this.form.er_floor.disabled = false; "
1917 wprintf(_("Private - require password: "));
1918 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1920 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1921 " if (this.form.type[3].checked == true) { "
1922 " this.form.er_floor.disabled = false; "
1925 wprintf(_("Private - invitation only"));
1927 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1929 " if (this.form.type[4].checked == true) { "
1930 " this.form.er_floor.disabled = true; "
1933 wprintf(_("Personal (mailbox for you only)"));
1935 wprintf("\n</UL>\n");
1937 wprintf("<CENTER>\n");
1938 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1940 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1941 wprintf("</CENTER>\n");
1942 wprintf("</FORM>\n<hr />");
1943 serv_printf("MESG roomaccess");
1944 serv_getln(buf, sizeof buf);
1945 if (buf[0] == '1') {
1948 wprintf("</td></tr></table></div>\n");
1956 * support function for entroom() -- sets the default view
1958 void er_set_default_view(int newview) {
1971 serv_getln(buf, sizeof buf);
1972 if (buf[0] != '2') return;
1974 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
1975 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
1976 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
1977 rm_bits1 = extract_int(&buf[4], 3);
1978 rm_floor = extract_int(&buf[4], 4);
1979 rm_listorder = extract_int(&buf[4], 5);
1980 rm_bits2 = extract_int(&buf[4], 7);
1982 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1983 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1984 rm_listorder, newview, rm_bits2
1986 serv_getln(buf, sizeof buf);
1999 char er_password[SIZ];
2004 if (strlen(bstr("ok_button")) == 0) {
2005 strcpy(WC->ImportantMessage,
2006 _("Cancelled. No new room was created."));
2007 display_main_menu();
2010 strcpy(er_name, bstr("er_name"));
2011 strcpy(er_type, bstr("type"));
2012 strcpy(er_password, bstr("er_password"));
2013 er_floor = atoi(bstr("er_floor"));
2014 er_view = atoi(bstr("er_view"));
2017 if (!strcmp(er_type, "hidden"))
2019 if (!strcmp(er_type, "passworded"))
2021 if (!strcmp(er_type, "invonly"))
2023 if (!strcmp(er_type, "personal"))
2026 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2027 er_name, er_num_type, er_password, er_floor, 0, er_view);
2029 serv_getln(buf, sizeof buf);
2030 if (buf[0] != '2') {
2031 strcpy(WC->ImportantMessage, &buf[4]);
2032 display_main_menu();
2036 do_change_view(er_view); /* Now go there */
2041 * display the screen to enter a private room
2043 void display_private(char *rname, int req_pass)
2045 output_headers(1, 1, 2, 0, 0, 0);
2046 wprintf("<div id=\"banner\">\n"
2047 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2048 "<SPAN CLASS=\"titlebar\">");
2049 wprintf(_("Go to a hidden room"));
2051 "</TD></TR></TABLE>\n"
2052 "</div>\n<div id=\"content\">\n"
2055 wprintf("<div class=\"fix_scrollbar_bug\">"
2056 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2058 wprintf("<CENTER>\n");
2060 wprintf(_("If you know the name of a hidden (guess-name) or "
2061 "passworded room, you can enter that room by typing "
2062 "its name below. Once you gain access to a private "
2063 "room, it will appear in your regular room listings "
2064 "so you don't have to keep returning here."));
2065 wprintf("\n<br /><br />");
2067 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2069 wprintf("<table border=\"0\" cellspacing=\"5\" "
2070 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2072 wprintf(_("Enter room name:"));
2074 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2075 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2078 wprintf("</TD></TR><TR><TD>");
2079 wprintf(_("Enter room password:"));
2080 wprintf("</TD><TD>");
2081 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2083 wprintf("</TD></TR></TABLE><br />\n");
2085 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2087 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2091 wprintf("</FORM>\n");
2092 wprintf("</td></tr></table></div>\n");
2097 * goto a private room
2099 void goto_private(void)
2104 if (strlen(bstr("ok_button")) == 0) {
2105 display_main_menu();
2108 strcpy(hold_rm, WC->wc_roomname);
2109 strcpy(buf, "GOTO ");
2110 strcat(buf, bstr("gr_name"));
2112 strcat(buf, bstr("gr_pass"));
2114 serv_getln(buf, sizeof buf);
2116 if (buf[0] == '2') {
2117 smart_goto(bstr("gr_name"));
2120 if (!strncmp(buf, "540", 3)) {
2121 display_private(bstr("gr_name"), 1);
2124 output_headers(1, 1, 1, 0, 0, 0);
2125 wprintf("%s\n", &buf[4]);
2132 * display the screen to zap a room
2134 void display_zap(void)
2136 output_headers(1, 1, 2, 0, 0, 0);
2138 wprintf("<div id=\"banner\">\n");
2139 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2140 wprintf("<SPAN CLASS=\"titlebar\">");
2141 wprintf(_("Zap (forget/unsubscribe) the current room"));
2142 wprintf("</SPAN>\n");
2143 wprintf("</TD></TR></TABLE>\n");
2144 wprintf("</div>\n<div id=\"content\">\n");
2146 wprintf(_("If you select this option, <em>%s</em> will "
2147 "disappear from your room list. Is this what you wish "
2148 "to do?<br />\n"), WC->wc_roomname);
2150 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2151 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2153 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2154 wprintf("</FORM>\n");
2165 char final_destination[SIZ];
2167 /* If the forget-room routine fails for any reason, we fall back
2168 * to the current room; otherwise, we go to the Lobby
2170 strcpy(final_destination, WC->wc_roomname);
2172 if (strlen(bstr("ok_button")) > 0) {
2173 serv_printf("GOTO %s", WC->wc_roomname);
2174 serv_getln(buf, sizeof buf);
2175 if (buf[0] == '2') {
2177 serv_getln(buf, sizeof buf);
2178 if (buf[0] == '2') {
2179 strcpy(final_destination, "_BASEROOM_");
2183 smart_goto(final_destination);
2189 * Delete the current room
2191 void delete_room(void)
2195 serv_puts("KILL 1");
2196 serv_getln(buf, sizeof buf);
2197 if (buf[0] != '2') {
2198 strcpy(WC->ImportantMessage, &buf[4]);
2199 display_main_menu();
2202 smart_goto("_BASEROOM_");
2209 * Perform changes to a room's network configuration
2211 void netedit(void) {
2220 if (strlen(bstr("line"))==0) {
2225 strcpy(line, bstr("prefix"));
2226 strcat(line, bstr("line"));
2227 strcat(line, bstr("suffix"));
2236 serv_getln(buf, sizeof buf);
2237 if (buf[0] != '1') {
2243 /* This loop works for add *or* remove. Spiffy, eh? */
2244 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2245 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2246 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2247 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2248 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2249 if ( (strcasecmp(cmpa0, cmpb0))
2250 || (strcasecmp(cmpa1, cmpb1)) ) {
2251 fprintf(fp, "%s\n", buf);
2257 serv_getln(buf, sizeof buf);
2258 if (buf[0] != '4') {
2264 while (fgets(buf, sizeof buf, fp) != NULL) {
2265 buf[strlen(buf)-1] = 0;
2269 if (strlen(bstr("add_button")) > 0) {
2281 * Convert a room name to a folder-ish-looking name.
2283 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2288 * For mailboxes, just do it straight...
2291 sprintf(folder, "My folders|%s", room);
2295 * Otherwise, prefix the floor name as a "public folders" moniker
2298 sprintf(folder, "%s|%s", floorlist[floor], room);
2302 * Replace "\" characters with "|" for pseudo-folder-delimiting
2304 for (i=0; i<strlen(folder); ++i) {
2305 if (folder[i] == '\\') folder[i] = '|';
2313 * Back end for change_view()
2315 void do_change_view(int newview) {
2318 serv_printf("VIEW %d", newview);
2319 serv_getln(buf, sizeof buf);
2320 WC->wc_view = newview;
2321 smart_goto(WC->wc_roomname);
2327 * Change the view for this room
2329 void change_view(void) {
2332 view = atol(bstr("view"));
2333 do_change_view(view);
2338 * One big expanded tree list view --- like a folder list
2340 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2344 int has_subfolders = 0;
2347 parents = malloc(max_folders * sizeof(int));
2349 /* BEGIN TREE MENU */
2350 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2352 /* include NanoTree */
2353 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2355 /* initialize NanoTree */
2356 wprintf("<script type=\"text/javascript\"> \n"
2357 " showRootNode = false; \n"
2358 " sortNodes = false; \n"
2359 " dragable = false; \n"
2361 " function standardClick(treeNode) { \n"
2364 " var closedGif = 'static/folder_closed.gif'; \n"
2365 " var openGif = 'static/folder_open.gif'; \n"
2367 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2371 for (i=0; i<max_folders; ++i) {
2374 if ((i+1) < max_folders) {
2375 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2376 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2381 levels = num_tokens(fold[i].name, '|');
2382 parents[levels] = i;
2384 wprintf("var node%d = new TreeNode(%d, '", i, i);
2386 if (fold[i].selectable) {
2387 wprintf("<a href=\"dotgoto?room=");
2388 urlescputs(fold[i].room);
2393 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2395 else if (fold[i].hasnewmsgs) {
2396 wprintf("<SPAN CLASS=\"roomlist_new\">");
2399 wprintf("<SPAN CLASS=\"roomlist_old\">");
2401 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2406 if (has_subfolders) {
2407 wprintf("new Array(closedGif, openGif)");
2409 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2410 wprintf("'static/viewcontacts_16x.gif'");
2412 else if (fold[i].view == VIEW_CALENDAR) {
2413 wprintf("'static/calarea_16x.gif'");
2415 else if (fold[i].view == VIEW_TASKS) {
2416 wprintf("'static/taskmanag_16x.gif'");
2418 else if (fold[i].view == VIEW_NOTES) {
2419 wprintf("'static/storenotes_16x.gif'");
2421 else if (fold[i].view == VIEW_MAILBOX) {
2422 wprintf("'static/privatemess_16x.gif'");
2425 wprintf("'static/chatrooms_16x.gif'");
2428 urlescputs(fold[i].name);
2432 wprintf("rootNode.addChild(node%d);\n", i);
2435 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2439 wprintf("container = document.getElementById('roomlist_div'); \n"
2449 * Boxes and rooms and lists ... oh my!
2451 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2453 char floor_name[256];
2454 char old_floor_name[256];
2456 int levels, oldlevels;
2459 static int columns = 3;
2460 int boxes_per_column = 0;
2461 int current_column = 0;
2464 strcpy(floor_name, "");
2465 strcpy(old_floor_name, "");
2468 while (nf % columns != 0) ++nf;
2469 boxes_per_column = (nf / columns);
2470 if (boxes_per_column < 1) boxes_per_column = 1;
2472 /* Outer table (for columnization) */
2473 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2474 "<tr><td valign=top>");
2478 for (i=0; i<max_folders; ++i) {
2480 levels = num_tokens(fold[i].name, '|');
2481 extract_token(floor_name, fold[i].name, 0,
2482 '|', sizeof floor_name);
2484 if ( (strcasecmp(floor_name, old_floor_name))
2485 && (strlen(old_floor_name) > 0) ) {
2487 do_template("endbox");
2490 if ((num_boxes % boxes_per_column) == 0) {
2492 if (current_column < columns) {
2493 wprintf("</td><td valign=top>\n");
2497 strcpy(old_floor_name, floor_name);
2500 /* Begin inner box */
2501 stresc(boxtitle, floor_name, 1, 0);
2502 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2503 do_template("beginbox");
2510 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2511 if (fold[i].selectable) {
2512 wprintf("<a href=\"dotgoto?room=");
2513 urlescputs(fold[i].room);
2519 if (fold[i].hasnewmsgs) {
2520 wprintf("<SPAN CLASS=\"roomlist_new\">");
2523 wprintf("<SPAN CLASS=\"roomlist_old\">");
2525 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2528 if (fold[i].selectable) {
2534 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2535 wprintf(" (INBOX)");
2537 wprintf("<br />\n");
2540 /* End the final inner box */
2541 do_template("endbox");
2543 wprintf("</TD></TR></TABLE>\n");
2547 void set_floordiv_expanded(char *which_floordiv) {
2548 begin_ajax_response();
2549 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2550 end_ajax_response();
2556 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2558 char floor_name[256];
2559 char old_floor_name[256];
2560 char floordivtitle[256];
2561 char floordiv_id[32];
2562 int levels, oldlevels;
2564 int num_drop_targets = 0;
2567 strcpy(floor_name, "");
2568 strcpy(old_floor_name, "");
2572 for (i=0; i<max_folders; ++i) {
2574 levels = num_tokens(fold[i].name, '|');
2575 extract_token(floor_name, fold[i].name, 0,
2576 '|', sizeof floor_name);
2578 if ( (strcasecmp(floor_name, old_floor_name))
2579 && (strlen(old_floor_name) > 0) ) {
2582 wprintf("</div>\n"); /* floordiv */
2584 strcpy(old_floor_name, floor_name);
2588 stresc(floordivtitle, floor_name, 0, 0);
2589 sprintf(floordiv_id, "floordiv%d", i);
2590 wprintf("<span class=\"ib_roomlist_floor\" "
2591 "onClick=\"expand_floor('%s')\">"
2592 "%s</span><br>\n", floordiv_id, floordivtitle);
2593 wprintf("<div id=\"%s\" style=\"display:%s\">",
2595 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2602 wprintf("<div id=\"roomdiv%d\">", i);
2604 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2606 /* choose the icon */
2607 if (fold[i].view == VIEW_ADDRESSBOOK) {
2608 icon = "viewcontacts_16x.gif" ;
2610 else if (fold[i].view == VIEW_CALENDAR) {
2611 icon = "calarea_16x.gif" ;
2613 else if (fold[i].view == VIEW_TASKS) {
2614 icon = "taskmanag_16x.gif" ;
2616 else if (fold[i].view == VIEW_NOTES) {
2617 icon = "storenotes_16x.gif" ;
2619 else if (fold[i].view == VIEW_MAILBOX) {
2620 icon = "privatemess_16x.gif" ;
2623 icon = "chatrooms_16x.gif" ;
2626 if (fold[i].selectable) {
2627 wprintf("<a href=\"dotgoto?room=");
2628 urlescputs(fold[i].room);
2630 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2635 if (fold[i].hasnewmsgs) {
2636 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2639 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2641 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2643 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2644 wprintf(" (INBOX)");
2647 if (fold[i].selectable) {
2654 wprintf("</div>\n"); /* roomdiv */
2657 wprintf("</div>\n"); /* floordiv */
2660 /* BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2661 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2663 num_drop_targets = 0;
2665 for (i=0; i<max_folders; ++i) {
2666 levels = num_tokens(fold[i].name, '|');
2668 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2669 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2670 jsescputs(fold[i].room);
2676 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2677 if (strlen(WC->floordiv_expanded) > 1) {
2678 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2682 /* END: The old invisible pixel trick, to get our JavaScript to initialize */
2688 * Show the room list. (only should get called by
2689 * knrooms() because that's where output_headers() is called from)
2692 void list_all_rooms_by_floor(char *viewpref) {
2695 struct folder *fold = NULL;
2697 int max_folders = 0;
2698 int alloc_folders = 0;
2702 int num_floors = 1; /* add an extra one for private folders */
2704 /* If our cached folder list is very old, burn it. */
2705 if (WC->cache_fold != NULL) {
2706 if ((time(NULL) - WC->cache_timestamp) > 300) {
2707 free(WC->cache_fold);
2708 WC->cache_fold = NULL;
2712 /* Can we do the iconbar roomlist from cache? */
2713 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2714 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2718 /* Grab the floor table so we know how to build the list... */
2721 /* Start with the mailboxes */
2724 fold = malloc(sizeof(struct folder));
2725 memset(fold, 0, sizeof(struct folder));
2726 strcpy(fold[0].name, "My folders");
2727 fold[0].is_mailbox = 1;
2729 /* Then add floors */
2731 serv_getln(buf, sizeof buf);
2732 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2733 if (max_folders >= alloc_folders) {
2734 alloc_folders = max_folders + 100;
2735 fold = realloc(fold,
2736 alloc_folders * sizeof(struct folder));
2738 memset(&fold[max_folders], 0, sizeof(struct folder));
2739 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2746 serv_getln(buf, sizeof buf);
2747 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2748 if (max_folders >= alloc_folders) {
2749 alloc_folders = max_folders + 100;
2750 fold = realloc(fold,
2751 alloc_folders * sizeof(struct folder));
2753 memset(&fold[max_folders], 0, sizeof(struct folder));
2754 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2755 ra_flags = extract_int(buf, 5);
2756 flags = extract_int(buf, 1);
2757 fold[max_folders].floor = extract_int(buf, 2);
2758 fold[max_folders].hasnewmsgs =
2759 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2760 if (flags & QR_MAILBOX) {
2761 fold[max_folders].is_mailbox = 1;
2763 fold[max_folders].view = extract_int(buf, 6);
2764 room_to_folder(fold[max_folders].name,
2765 fold[max_folders].room,
2766 fold[max_folders].floor,
2767 fold[max_folders].is_mailbox);
2768 fold[max_folders].selectable = 1;
2772 /* Bubble-sort the folder list */
2773 for (i=0; i<max_folders; ++i) {
2774 for (j=0; j<(max_folders-1)-i; ++j) {
2775 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2776 swap = strcasecmp(fold[j].name, fold[j+1].name);
2779 if ( (fold[j+1].is_mailbox)
2780 && (!fold[j].is_mailbox)) {
2788 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2789 memcpy(&fold[j], &fold[j+1],
2790 sizeof(struct folder));
2791 memcpy(&fold[j+1], &ftmp,
2792 sizeof(struct folder));
2798 if (!strcasecmp(viewpref, "folders")) {
2799 do_folder_view(fold, max_folders, num_floors);
2801 else if (!strcasecmp(viewpref, "hackish_view")) {
2802 for (i=0; i<max_folders; ++i) {
2803 escputs(fold[i].name);
2804 wprintf("<br />\n");
2807 else if (!strcasecmp(viewpref, "iconbar")) {
2808 do_iconbar_view(fold, max_folders, num_floors);
2811 do_rooms_view(fold, max_folders, num_floors);
2814 /* Don't free the folder list ... cache it for future use! */
2815 if (WC->cache_fold != NULL) {
2816 free(WC->cache_fold);
2818 WC->cache_fold = fold;
2819 WC->cache_max_folders = max_folders;
2820 WC->cache_num_floors = num_floors;
2821 WC->cache_timestamp = time(NULL);
2825 /* Do either a known rooms list or a folders list, depending on the
2829 char listviewpref[SIZ];
2831 output_headers(1, 1, 2, 0, 0, 0);
2833 /* Determine whether the user is trying to change views */
2834 if (bstr("view") != NULL) {
2835 if (strlen(bstr("view")) > 0) {
2836 set_preference("roomlistview", bstr("view"), 1);
2840 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2842 if ( (strcasecmp(listviewpref, "folders"))
2843 && (strcasecmp(listviewpref, "table")) ) {
2844 strcpy(listviewpref, "rooms");
2848 wprintf("<div id=\"banner\">\n"
2849 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2850 "<SPAN CLASS=\"titlebar\">"
2852 if (!strcasecmp(listviewpref, "rooms")) {
2853 wprintf(_("Room list"));
2855 if (!strcasecmp(listviewpref, "folders")) {
2856 wprintf(_("Folder list"));
2858 if (!strcasecmp(listviewpref, "table")) {
2859 wprintf(_("Room list"));
2861 wprintf("</SPAN></TD>\n");
2863 /* offer the ability to switch views */
2864 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2865 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2866 "OnChange=\"location.href=roomlistomatic.newview.options"
2867 "[selectedIndex].value\">\n");
2869 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
2872 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2875 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
2876 "View as folder list"
2878 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2881 wprintf("</SELECT><br />");
2883 wprintf("</FORM></TD></TR></TABLE>\n");
2886 "<div id=\"content\">\n");
2888 /* Display the room list in the user's preferred format */
2889 list_all_rooms_by_floor(listviewpref);
2896 * Set the message expire policy for this room and/or floor
2898 void set_room_policy(void) {
2901 if (strlen(bstr("ok_button")) == 0) {
2902 strcpy(WC->ImportantMessage,
2903 _("Cancelled. Changes were not saved."));
2908 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2909 serv_getln(buf, sizeof buf);
2910 strcpy(WC->ImportantMessage, &buf[4]);
2912 if (WC->axlevel >= 6) {
2913 strcat(WC->ImportantMessage, "<br />\n");
2914 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2915 serv_getln(buf, sizeof buf);
2916 strcat(WC->ImportantMessage, &buf[4]);