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");
24 * load the list of floors
26 void load_floorlist(void)
31 for (a = 0; a < 128; ++a)
35 serv_getln(buf, sizeof buf);
37 strcpy(floorlist[0], "Main Floor");
40 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
41 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
47 * remove a room from the march list
49 void remove_march(char *aaa)
51 struct march *mptr, *mptr2;
53 if (WC->march == NULL)
56 if (!strcasecmp(WC->march->march_name, aaa)) {
57 mptr = WC->march->next;
63 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
64 if (!strcasecmp(mptr->march_name, aaa)) {
65 mptr2->next = mptr->next;
78 void room_tree_list(struct roomlisting *rp)
87 room_tree_list(rp->lnext);
89 strcpy(rmname, rp->rlname);
92 wprintf("<a href=\"dotgoto&room=");
96 escputs1(rmname, 1, 1);
97 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
99 else if (f & QR_DIRECTORY)
101 else if (f & QR_NETWORK)
105 wprintf("</A><TT> </TT>\n");
107 room_tree_list(rp->rnext);
113 * Room ordering stuff (compare first by floor, then by order)
115 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
117 if ((r1 == NULL) && (r2 == NULL))
123 if (r1->rlfloor < r2->rlfloor)
125 if (r1->rlfloor > r2->rlfloor)
127 if (r1->rlorder < r2->rlorder)
129 if (r1->rlorder > r2->rlorder)
136 * Common code for all room listings
138 void listrms(char *variety)
143 struct roomlisting *rl = NULL;
144 struct roomlisting *rp;
145 struct roomlisting *rs;
148 /* Ask the server for a room list */
150 serv_getln(buf, sizeof buf);
155 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
157 rp = malloc(sizeof(struct roomlisting));
158 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
159 rp->rlflags = extract_int(buf, 1);
160 rp->rlfloor = extract_int(buf, 2);
161 rp->rlorder = extract_int(buf, 3);
170 if (rordercmp(rp, rs) < 0) {
171 if (rs->lnext == NULL) {
178 if (rs->rnext == NULL) {
190 /* If no rooms were listed, print an nbsp to make the cell
191 * borders show up anyway.
193 if (num_rooms == 0) wprintf(" ");
198 * list all forgotten rooms
200 void zapped_list(void)
202 output_headers(1, 1, 0, 0, 0, 0);
204 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
205 do_template("beginbox");
209 wprintf("<br /><br />\n");
210 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
211 do_template("endbox");
217 * read this room's info file (set v to 1 for verbose mode)
224 serv_getln(buf, sizeof buf);
236 /* Display room banner icon. The server doesn't actually
237 * need the room name, but we supply it in order to
238 * keep the browser from using a cached icon from
241 void embed_room_graphic(void) {
244 serv_puts("OIMG _roompic_");
245 serv_getln(buf, sizeof buf);
247 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
248 urlescputs(WC->wc_roomname);
251 serv_getln(buf, sizeof buf);
253 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
254 wprintf("<img height=48 width=48 src=\""
255 "static/viewcontacts_48x.gif"
259 else if (WC->wc_view == VIEW_CALENDAR) {
260 wprintf("<img height=48 width=48 src=\""
261 "static/calarea_48x.gif"
265 else if (WC->wc_view == VIEW_TASKS) {
266 wprintf("<img height=48 width=48 src=\""
267 "static/taskmanag_48x.gif"
271 else if (WC->wc_view == VIEW_NOTES) {
272 wprintf("<img height=48 width=48 src=\""
273 "static/storenotes_48x.gif"
277 else if (WC->wc_view == VIEW_MAILBOX) {
278 wprintf("<img height=48 width=48 src=\""
279 "static/privatemess_48x.gif"
284 wprintf("<img height=48 width=48 src=\""
285 "static/chatrooms_48x.gif"
295 * Display the current view and offer an option to change it
297 void embed_view_o_matic(void) {
300 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
301 "<span class=\"room_banner_new_messages\">");
302 wprintf(_("View as:"));
304 "<SELECT NAME=\"newview\" SIZE=\"1\" "
305 "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif;"
306 " font-size: 7pt; background: #444455; color: #ddddcc;\" "
307 "OnChange=\"location.href=viewomatic.newview.options"
308 "[selectedIndex].value\">\n");
310 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
312 * Only offer the views that make sense, given the default
313 * view for the room. For example, don't offer a Calendar
314 * view in a non-Calendar room.
318 || (i == WC->wc_default_view)
319 || ( (i == 0) && (WC->wc_default_view == 1) )
320 || ( (i == 1) && (WC->wc_default_view == 0) )
323 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
324 ((i == WC->wc_view) ? "SELECTED" : ""),
326 escputs(viewdefs[i]);
327 wprintf("</OPTION>\n");
330 wprintf("</select></span></form>\n");
335 void embed_room_banner(char *got, int navbar_style) {
338 /* We need to have the information returned by a GOTO server command.
339 * If it isn't supplied, we fake it by issuing our own GOTO.
342 serv_printf("GOTO %s", WC->wc_roomname);
343 serv_getln(fakegot, sizeof fakegot);
347 /* The browser needs some information for its own use */
348 wprintf("<script type=\"text/javascript\"> \n"
349 " room_is_trash = %d; \n"
354 /* If the user happens to select the "make this my start page" link,
355 * we want it to remember the URL as a "/dotskip" one instead of
356 * a "skip" or "gotonext" or something like that.
358 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
361 /* Check for new mail. */
362 WC->new_mail = extract_int(&got[4], 9);
363 WC->wc_view = extract_int(&got[4], 11);
365 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
366 svprintf("NUMMSGS", WCS_STRING,
367 _("%d new of %d messages"),
368 extract_int(&got[4], 1),
369 extract_int(&got[4], 2)
371 svcallback("ROOMPIC", embed_room_graphic);
372 svcallback("ROOMINFO", readinfo);
373 svcallback("VIEWOMATIC", embed_view_o_matic);
374 svcallback("START", offer_start_page);
376 do_template("roombanner");
377 if (navbar_style != navbar_none) {
379 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
380 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
383 if (navbar_style == navbar_default) wprintf(
385 "<a href=\"ungoto\">"
386 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
387 "<span class=\"navbar_link\">%s</span></A>"
388 "</td>\n", _("Ungoto")
391 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
394 "<a href=\"readnew\">"
395 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
396 "<span class=\"navbar_link\">%s</span></A>"
397 "</td>\n", _("Read new messages")
401 if (navbar_style == navbar_default) {
402 switch(WC->wc_view) {
403 case VIEW_ADDRESSBOOK:
406 "<a href=\"readfwd\">"
407 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
409 "<span class=\"navbar_link\">"
411 "</span></a></td>\n", _("View contacts")
417 "<a href=\"readfwd?calview=day\">"
418 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
420 "<span class=\"navbar_link\">"
422 "</span></a></td>\n", _("Day view")
426 "<a href=\"readfwd?calview=month\">"
427 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
429 "<span class=\"navbar_link\">"
431 "</span></a></td>\n", _("Month view")
437 "<a href=\"readfwd\">"
438 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
440 "<span class=\"navbar_link\">"
442 "</span></a></td>\n", _("View tasks")
448 "<a href=\"readfwd\">"
449 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
451 "<span class=\"navbar_link\">"
453 "</span></a></td>\n", _("View notes")
459 "<a href=\"readfwd\">"
460 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
462 "<span class=\"navbar_link\">"
464 "</span></a></td>\n", _("View message list")
470 "<a href=\"readfwd\">"
471 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
473 "<span class=\"navbar_link\">"
475 "</span></a></td>\n", _("Read all messages")
481 if (navbar_style == navbar_default) {
482 switch(WC->wc_view) {
483 case VIEW_ADDRESSBOOK:
485 "<td><a href=\"display_enter\">"
486 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
487 "border=\"0\"><span class=\"navbar_link\">"
489 "</span></a></td>\n", _("Add new contact")
494 "<td><a href=\"display_enter\">"
495 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
496 "border=\"0\"><span class=\"navbar_link\">"
498 "</span></a></td>\n", _("Add new event")
503 "<td><a href=\"display_enter\">"
504 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
505 "border=\"0\"><span class=\"navbar_link\">"
507 "</span></a></td>\n", _("Add new task")
512 "<td><a href=\"display_enter\">"
513 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
514 "border=\"0\"><span class=\"navbar_link\">"
516 "</span></a></td>\n", _("Add new note")
521 "<td><a href=\"display_enter\">"
522 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
523 "border=\"0\"><span class=\"navbar_link\">"
525 "</span></a></td>\n", _("Enter a message")
531 if (navbar_style == navbar_default) wprintf(
535 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
536 "<span class=\"navbar_link\">%s</span></a>"
538 _("Leave all messages marked as unread, go to next room with unread messages"),
542 if (navbar_style == navbar_default) wprintf(
544 "<a href=\"gotonext\" "
546 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
547 "<span class=\"navbar_link\">%s</span></a>"
549 _("Mark all messages as read, go to next room with unread messages"),
553 wprintf("</tr></table></div>\n");
563 * back end routine to take the session to a new room
566 int gotoroom(char *gname)
569 static long ls = (-1L);
572 /* store ungoto information */
573 strcpy(WC->ugname, WC->wc_roomname);
576 /* move to the new room */
577 serv_printf("GOTO %s", gname);
578 serv_getln(buf, sizeof buf);
582 serv_puts("GOTO _BASEROOM_");
583 serv_getln(buf, sizeof buf);
590 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
591 WC->room_flags = extract_int(&buf[4], 4);
592 /* highest_msg_read = extract_int(&buf[4],6);
593 maxmsgnum = extract_int(&buf[4],5);
595 WC->is_mailbox = extract_int(&buf[4],7);
596 ls = extract_long(&buf[4], 6);
597 WC->wc_floor = extract_int(&buf[4], 10);
598 WC->wc_view = extract_int(&buf[4], 11);
599 WC->wc_default_view = extract_int(&buf[4], 12);
600 WC->wc_is_trash = extract_int(&buf[4], 13);
603 WC->is_room_aide = WC->is_aide;
605 WC->is_room_aide = (char) extract_int(&buf[4], 8);
607 remove_march(WC->wc_roomname);
608 if (!strcasecmp(gname, "_BASEROOM_"))
616 * Locate the room on the march list which we most want to go to. Each room
617 * is measured given a "weight" of preference based on various factors.
619 char *pop_march(int desired_floor)
621 static char TheRoom[128];
623 int TheOrder = 32767;
626 struct march *mptr = NULL;
628 strcpy(TheRoom, "_BASEROOM_");
629 if (WC->march == NULL)
632 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
634 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
635 weight = weight + 10000;
636 if (mptr->march_floor == desired_floor)
637 weight = weight + 5000;
639 weight = weight + ((128 - (mptr->march_floor)) * 128);
640 weight = weight + (128 - (mptr->march_order));
642 if (weight > TheWeight) {
644 strcpy(TheRoom, mptr->march_name);
645 TheFloor = mptr->march_floor;
646 TheOrder = mptr->march_order;
654 /* Goto next room having unread messages.
655 * We want to skip over rooms that the user has already been to, and take the
656 * user back to the lobby when done. The room we end up in is placed in
657 * newroom - which is set to 0 (the lobby) initially.
658 * We start the search in the current room rather than the beginning to prevent
659 * two or more concurrent users from dragging each other back to the same room.
664 struct march *mptr, *mptr2;
667 /* First check to see if the march-mode list is already allocated.
668 * If it is, pop the first room off the list and go there.
671 if (WC->march == NULL) {
673 serv_getln(buf, sizeof buf);
675 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
676 mptr = (struct march *) malloc(sizeof(struct march));
678 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
679 mptr->march_floor = extract_int(buf, 2);
680 mptr->march_order = extract_int(buf, 3);
681 if (WC->march == NULL) {
685 while (mptr2->next != NULL)
690 /* add _BASEROOM_ to the end of the march list, so the user will end up
691 * in the system base room (usually the Lobby>) at the end of the loop
693 mptr = (struct march *) malloc(sizeof(struct march));
695 strcpy(mptr->march_name, "_BASEROOM_");
696 if (WC->march == NULL) {
700 while (mptr2->next != NULL)
705 * ...and remove the room we're currently in, so a <G>oto doesn't make us
706 * walk around in circles
708 remove_march(WC->wc_roomname);
710 if (WC->march != NULL) {
711 strcpy(next_room, pop_march(-1));
713 strcpy(next_room, "_BASEROOM_");
717 smart_goto(next_room);
721 void smart_goto(char *next_room) {
729 * mark all messages in current room as having been read
731 void slrp_highest(void)
736 serv_puts("SLRP HIGHEST");
737 serv_getln(buf, sizeof buf);
739 wprintf("<EM>%s</EM><br />\n", &buf[4]);
746 * un-goto the previous room
752 if (!strcmp(WC->ugname, "")) {
753 smart_goto(WC->wc_roomname);
756 serv_printf("GOTO %s", WC->ugname);
757 serv_getln(buf, sizeof buf);
759 smart_goto(WC->wc_roomname);
762 if (WC->uglsn >= 0L) {
763 serv_printf("SLRP %ld", WC->uglsn);
764 serv_getln(buf, sizeof buf);
766 strcpy(buf, WC->ugname);
767 strcpy(WC->ugname, "");
776 * Set/clear/read the "self-service list subscribe" flag for a room
778 * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
779 * Always returns the new value.
782 int self_service(int newval) {
783 int current_value = 0;
789 int flags, floor, order, view, flags2;
792 serv_getln(buf, sizeof buf);
793 if (buf[0] != '2') return(0);
795 extract_token(name, &buf[4], 0, '|', sizeof name);
796 extract_token(password, &buf[4], 1, '|', sizeof password);
797 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
798 flags = extract_int(&buf[4], 3);
799 floor = extract_int(&buf[4], 4);
800 order = extract_int(&buf[4], 5);
801 view = extract_int(&buf[4], 6);
802 flags2 = extract_int(&buf[4], 7);
804 if (flags2 & QR2_SELFLIST) {
812 flags2 = flags2 | QR2_SELFLIST;
814 else if (newval == 0) {
815 flags2 = flags2 & ~QR2_SELFLIST;
818 return(current_value);
821 if (newval != current_value) {
822 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
823 name, password, dirname, flags,
824 floor, order, view, flags2);
825 serv_getln(buf, sizeof buf);
838 * display the form for editing a room
840 void display_editroom(void)
845 char remote_room[SIZ];
848 char er_password[10];
850 char er_roomaide[26];
856 char *not_shared_with;
863 if (strlen(tab) == 0) tab = "admin";
867 serv_getln(buf, sizeof buf);
870 strcpy(WC->ImportantMessage, &buf[4]);
874 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
875 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
876 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
877 er_flags = extract_int(&buf[4], 3);
878 er_floor = extract_int(&buf[4], 4);
880 output_headers(1, 1, 1, 0, 0, 0);
882 /* print the tabbed dialog */
884 "<div class=\"fix_scrollbar_bug\">"
885 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
887 "<TD> </TD>\n");
889 if (!strcmp(tab, "admin")) {
890 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
893 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
895 wprintf(_("Administration"));
896 if (!strcmp(tab, "admin")) {
897 wprintf("</SPAN></TD>\n");
900 wprintf("</A></TD>\n");
903 wprintf("<TD> </TD>\n");
905 if (!strcmp(tab, "config")) {
906 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
909 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
911 wprintf(_("Configuration"));
912 if (!strcmp(tab, "config")) {
913 wprintf("</SPAN></TD>\n");
916 wprintf("</A></TD>\n");
919 wprintf("<TD> </TD>\n");
921 if (!strcmp(tab, "expire")) {
922 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
925 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
927 wprintf(_("Message expire policy"));
928 if (!strcmp(tab, "expire")) {
929 wprintf("</SPAN></TD>\n");
932 wprintf("</A></TD>\n");
935 wprintf("<TD> </TD>\n");
937 if (!strcmp(tab, "access")) {
938 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
941 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
943 wprintf(_("Access controls"));
944 if (!strcmp(tab, "access")) {
945 wprintf("</SPAN></TD>\n");
948 wprintf("</A></TD>\n");
951 wprintf("<TD> </TD>\n");
953 if (!strcmp(tab, "sharing")) {
954 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
957 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
959 wprintf(_("Sharing"));
960 if (!strcmp(tab, "sharing")) {
961 wprintf("</SPAN></TD>\n");
964 wprintf("</A></TD>\n");
967 wprintf("<TD> </TD>\n");
969 if (!strcmp(tab, "listserv")) {
970 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
973 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
975 wprintf(_("Mailing list service"));
976 if (!strcmp(tab, "listserv")) {
977 wprintf("</SPAN></TD>\n");
980 wprintf("</A></TD>\n");
983 wprintf("<TD> </TD>\n");
985 wprintf("</TR></TABLE></div>\n");
986 /* end tabbed dialog */
988 /* begin content of whatever tab is open now */
989 wprintf("<div class=\"fix_scrollbar_bug\">"
990 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
993 if (!strcmp(tab, "admin")) {
995 "<LI><a href=\"delete_room\" "
996 "onClick=\"return confirm('");
997 wprintf(_("Are you sure you want to delete this room?"));
999 wprintf(_("Delete this room"));
1001 "<LI><a href=\"display_editroompic\">\n");
1002 wprintf(_("Set or change the icon for this room's banner"));
1004 "<LI><a href=\"display_editinfo\">\n");
1005 wprintf(_("Edit this room's Info file"));
1010 if (!strcmp(tab, "config")) {
1011 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1013 wprintf("<UL><LI>");
1014 wprintf(_("Name of room: "));
1015 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1021 wprintf(_("Resides on floor: "));
1022 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1023 for (i = 0; i < 128; ++i)
1024 if (strlen(floorlist[i]) > 0) {
1025 wprintf("<OPTION ");
1027 wprintf("SELECTED ");
1028 wprintf("VALUE=\"%d\">", i);
1029 escputs(floorlist[i]);
1030 wprintf("</OPTION>\n");
1032 wprintf("</SELECT>\n");
1035 wprintf(_("Type of room:"));
1038 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1039 if ((er_flags & QR_PRIVATE) == 0)
1040 wprintf("CHECKED ");
1042 wprintf(_("Public room"));
1045 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1046 if ((er_flags & QR_PRIVATE) &&
1047 (er_flags & QR_GUESSNAME))
1048 wprintf("CHECKED ");
1050 wprintf(_("Private - guess name"));
1052 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1053 if ((er_flags & QR_PRIVATE) &&
1054 (er_flags & QR_PASSWORDED))
1055 wprintf("CHECKED ");
1057 wprintf(_("Private - require password:"));
1058 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1061 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1062 if ((er_flags & QR_PRIVATE)
1063 && ((er_flags & QR_GUESSNAME) == 0)
1064 && ((er_flags & QR_PASSWORDED) == 0))
1065 wprintf("CHECKED ");
1067 wprintf(_("Private - invitation only"));
1069 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1071 wprintf(_("If private, cause current users to forget room"));
1073 wprintf("\n</UL>\n");
1075 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1076 if (er_flags & QR_PREFONLY)
1077 wprintf("CHECKED ");
1079 wprintf(_("Preferred users only"));
1081 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1082 if (er_flags & QR_READONLY)
1083 wprintf("CHECKED ");
1085 wprintf(_("Read-only room"));
1087 /* directory stuff */
1088 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1089 if (er_flags & QR_DIRECTORY)
1090 wprintf("CHECKED ");
1092 wprintf(_("File directory room"));
1094 wprintf("\n<UL><LI>");
1095 wprintf(_("Directory name: "));
1096 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1099 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1100 if (er_flags & QR_UPLOAD)
1101 wprintf("CHECKED ");
1103 wprintf(_("Uploading allowed"));
1105 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1106 if (er_flags & QR_DOWNLOAD)
1107 wprintf("CHECKED ");
1109 wprintf(_("Downloading allowed"));
1111 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1112 if (er_flags & QR_VISDIR)
1113 wprintf("CHECKED ");
1115 wprintf(_("Visible directory"));
1118 /* end of directory stuff */
1120 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1121 if (er_flags & QR_NETWORK)
1122 wprintf("CHECKED ");
1124 wprintf(_("Network shared room"));
1126 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1127 if (er_flags & QR_PERMANENT)
1128 wprintf("CHECKED ");
1130 wprintf(_("Permanent (does not auto-purge)"));
1132 /* start of anon options */
1135 wprintf(_("Anonymous messages"));
1138 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1139 if (((er_flags & QR_ANONONLY) == 0)
1140 && ((er_flags & QR_ANONOPT) == 0))
1141 wprintf("CHECKED ");
1143 wprintf(_("No anonymous messages"));
1145 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1146 if (er_flags & QR_ANONONLY)
1147 wprintf("CHECKED ");
1149 wprintf(_("All messages are anonymous"));
1151 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1152 if (er_flags & QR_ANONOPT)
1153 wprintf("CHECKED ");
1155 wprintf(_("Prompt user when entering messages"));
1158 /* end of anon options */
1161 wprintf(_("Room aide: "));
1163 serv_getln(buf, sizeof buf);
1164 if (buf[0] != '2') {
1165 wprintf("<EM>%s</EM>\n", &buf[4]);
1167 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1168 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1171 wprintf("</UL><CENTER>\n");
1172 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1173 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1175 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1183 /* Sharing the room with other Citadel nodes... */
1184 if (!strcmp(tab, "sharing")) {
1186 shared_with = strdup("");
1187 not_shared_with = strdup("");
1189 /* Learn the current configuration */
1190 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1191 serv_getln(buf, sizeof buf);
1192 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1193 extract_token(node, buf, 0, '|', sizeof node);
1194 not_shared_with = realloc(not_shared_with,
1195 strlen(not_shared_with) + 32);
1196 strcat(not_shared_with, node);
1197 strcat(not_shared_with, "\n");
1201 serv_getln(buf, sizeof buf);
1202 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1203 extract_token(cmd, buf, 0, '|', sizeof cmd);
1204 extract_token(node, buf, 1, '|', sizeof node);
1205 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1206 if (!strcasecmp(cmd, "ignet_push_share")) {
1207 shared_with = realloc(shared_with,
1208 strlen(shared_with) + 32);
1209 strcat(shared_with, node);
1210 if (strlen(remote_room) > 0) {
1211 strcat(shared_with, "|");
1212 strcat(shared_with, remote_room);
1214 strcat(shared_with, "\n");
1218 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1219 extract_token(buf, shared_with, i, '\n', sizeof buf);
1220 extract_token(node, buf, 0, '|', sizeof node);
1221 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1222 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1223 if (!strcasecmp(node, cmd)) {
1224 remove_token(not_shared_with, j, '\n');
1229 /* Display the stuff */
1230 wprintf("<CENTER><br />"
1231 "<TABLE border=1 cellpadding=5><TR>"
1233 wprintf(_("Shared with"));
1234 wprintf("</I></B></TD>"
1236 wprintf(_("Not shared with"));
1237 wprintf("</I></B></TD></TR>\n"
1238 "<TR><TD VALIGN=TOP>\n");
1240 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1241 wprintf(_("Remote node name"));
1242 wprintf("</TD><TD>");
1243 wprintf(_("Remote room name"));
1244 wprintf("</TD><TD>");
1245 wprintf(_("Actions"));
1246 wprintf("</TD></TR>\n");
1248 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1249 extract_token(buf, shared_with, i, '\n', sizeof buf);
1250 extract_token(node, buf, 0, '|', sizeof node);
1251 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1252 if (strlen(node) > 0) {
1253 wprintf("<FORM METHOD=\"POST\" "
1254 "action=\"netedit\">"
1255 "<TR><TD>%s</TD>\n", node);
1258 if (strlen(remote_room) > 0) {
1259 escputs(remote_room);
1265 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1266 "VALUE=\"ignet_push_share|");
1268 if (strlen(remote_room) > 0) {
1270 urlescputs(remote_room);
1273 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1274 "VALUE=\"sharing\">\n");
1275 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1276 "VALUE=\"remove\">\n");
1277 wprintf("<INPUT TYPE=\"submit\" "
1278 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1279 wprintf("</TD></TR></FORM>\n");
1283 wprintf("</TABLE>\n");
1284 wprintf("</TD><TD VALIGN=TOP>\n");
1285 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1286 wprintf(_("Remote node name"));
1287 wprintf("</TD><TD>");
1288 wprintf(_("Remote room name"));
1289 wprintf("</TD><TD>");
1290 wprintf(_("Actions"));
1291 wprintf("</TD></TR>\n");
1293 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1294 extract_token(node, not_shared_with, i, '\n', sizeof node);
1295 if (strlen(node) > 0) {
1296 wprintf("<FORM METHOD=\"POST\" "
1297 "action=\"netedit\">"
1301 "<INPUT TYPE=\"INPUT\" "
1305 wprintf("<INPUT TYPE=\"hidden\" "
1307 "VALUE=\"ignet_push_share|");
1310 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1311 "VALUE=\"sharing\">\n");
1312 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1313 "VALUE=\"add\">\n");
1314 wprintf("<INPUT TYPE=\"submit\" "
1315 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1316 wprintf("</TD></TR></FORM>\n");
1320 wprintf("</TABLE>\n");
1321 wprintf("</TD></TR>"
1322 "</TABLE></CENTER><br />\n"
1323 "<I><B>%s</B><UL><LI>", _("Notes:"));
1324 wprintf(_("When sharing a room, "
1325 "it must be shared from both ends. Adding a node to "
1326 "the 'shared' list sends messages out, but in order to"
1327 " receive messages, the other nodes must be configured"
1328 " to send messages out to your system as well. "
1329 "<LI>If the remote room name is blank, it is assumed "
1330 "that the room name is identical on the remote node."
1331 "<LI>If the remote room name is different, the remote "
1332 "node must also configure the name of the room here."
1338 /* Mailing list management */
1339 if (!strcmp(tab, "listserv")) {
1341 wprintf("<br /><center>"
1342 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1343 "<TR><TD VALIGN=TOP>");
1345 wprintf(_("<i>The contents of this room are being "
1346 "mailed <b>as individual messages</b> "
1347 "to the following list recipients:"
1348 "</i><br /><br />\n"));
1351 serv_getln(buf, sizeof buf);
1352 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1353 extract_token(cmd, buf, 0, '|', sizeof cmd);
1354 if (!strcasecmp(cmd, "listrecp")) {
1355 extract_token(recp, buf, 1, '|', sizeof recp);
1358 wprintf(" <a href=\"netedit&cmd=remove&line="
1361 wprintf("&tab=listserv\">");
1362 wprintf(_("(remove)"));
1363 wprintf("</A><br />");
1366 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1367 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1368 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1369 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1370 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1371 wprintf("</FORM>\n");
1373 wprintf("</TD><TD VALIGN=TOP>\n");
1375 wprintf(_("<i>The contents of this room are being "
1376 "mailed <b>in digest form</b> "
1377 "to the following list recipients:"
1378 "</i><br /><br />\n"));
1381 serv_getln(buf, sizeof buf);
1382 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1383 extract_token(cmd, buf, 0, '|', sizeof cmd);
1384 if (!strcasecmp(cmd, "digestrecp")) {
1385 extract_token(recp, buf, 1, '|', sizeof recp);
1388 wprintf(" <a href=\"netedit&cmd=remove&line="
1391 wprintf("&tab=listserv\">");
1392 wprintf(_("(remove)"));
1393 wprintf("</A><br />");
1396 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1397 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1398 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1399 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1400 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1401 wprintf("</FORM>\n");
1403 wprintf("</TD></TR></TABLE><hr />\n");
1405 if (self_service(999) == 1) {
1406 wprintf(_("This room is configured to allow "
1407 "self-service subscribe/unsubscribe requests."));
1408 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1409 wprintf(_("Click to disable."));
1410 wprintf("</A><br />\n");
1411 wprintf(_("The URL for subscribe/unsubscribe is: "));
1412 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1413 (is_https ? "https" : "http"),
1417 wprintf(_("This room is <i>not</i> configured to allow "
1418 "self-service subscribe/unsubscribe requests."));
1419 wprintf(" <a href=\"toggle_self_service?newval=1&"
1421 wprintf(_("Click to enable."));
1422 wprintf("</A><br />\n");
1426 wprintf("</CENTER>\n");
1430 /* Mailing list management */
1431 if (!strcmp(tab, "expire")) {
1433 serv_puts("GPEX room");
1434 serv_getln(buf, sizeof buf);
1435 if (buf[0] == '2') {
1436 roompolicy = extract_int(&buf[4], 0);
1437 roomvalue = extract_int(&buf[4], 1);
1440 serv_puts("GPEX floor");
1441 serv_getln(buf, sizeof buf);
1442 if (buf[0] == '2') {
1443 floorpolicy = extract_int(&buf[4], 0);
1444 floorvalue = extract_int(&buf[4], 1);
1447 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1448 wprintf("<TABLE border=0 cellspacing=5>\n");
1449 wprintf("<TR><TD>");
1450 wprintf(_("Message expire policy for this room"));
1452 escputs(WC->wc_roomname);
1453 wprintf(")</TD><TD>");
1454 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1455 ((roompolicy == 0) ? "CHECKED" : "") );
1456 wprintf(_("Use the default policy for this floor"));
1457 wprintf("<br />\n");
1458 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1459 ((roompolicy == 1) ? "CHECKED" : "") );
1460 wprintf(_("Never automatically expire messages"));
1461 wprintf("<br />\n");
1462 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1463 ((roompolicy == 2) ? "CHECKED" : "") );
1464 wprintf(_("Expire by message count"));
1465 wprintf("<br />\n");
1466 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1467 ((roompolicy == 3) ? "CHECKED" : "") );
1468 wprintf(_("Expire by message age"));
1470 wprintf(_("Number of messages or days: "));
1471 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1472 wprintf("</TD></TR>\n");
1474 if (WC->axlevel >= 6) {
1475 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1476 wprintf("<TR><TD>");
1477 wprintf(_("Message expire policy for this floor"));
1479 escputs(floorlist[WC->wc_floor]);
1480 wprintf(")</TD><TD>");
1481 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1482 ((floorpolicy == 0) ? "CHECKED" : "") );
1483 wprintf(_("Use the system default"));
1484 wprintf("<br />\n");
1485 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1486 ((floorpolicy == 1) ? "CHECKED" : "") );
1487 wprintf(_("Never automatically expire messages"));
1488 wprintf("<br />\n");
1489 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1490 ((floorpolicy == 2) ? "CHECKED" : "") );
1491 wprintf(_("Expire by message count"));
1492 wprintf("<br />\n");
1493 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1494 ((floorpolicy == 3) ? "CHECKED" : "") );
1495 wprintf(_("Expire by message age"));
1497 wprintf(_("Number of messages or days: "));
1498 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1502 wprintf("<CENTER>\n");
1503 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1504 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1506 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1507 wprintf("</CENTER></TD><TR>\n");
1509 wprintf("</TABLE>\n"
1510 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1516 /* Mailing list management */
1517 if (!strcmp(tab, "access")) {
1521 /* end content of whatever tab is open now */
1522 wprintf("</TD></TR></TABLE></div>\n");
1529 * Toggle self-service list subscription
1531 void toggle_self_service(void) {
1534 newval = atoi(bstr("newval"));
1535 self_service(newval);
1542 * save new parameters for a room
1548 char er_password[10];
1549 char er_dirname[15];
1550 char er_roomaide[26];
1556 if (strlen(bstr("ok_button")) == 0) {
1557 strcpy(WC->ImportantMessage,
1558 _("Cancelled. Changes were not saved."));
1563 serv_getln(buf, sizeof buf);
1565 if (buf[0] != '2') {
1566 strcpy(WC->ImportantMessage, &buf[4]);
1570 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1571 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1572 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1573 er_flags = extract_int(&buf[4], 3);
1575 strcpy(er_roomaide, bstr("er_roomaide"));
1576 if (strlen(er_roomaide) == 0) {
1578 serv_getln(buf, sizeof buf);
1579 if (buf[0] != '2') {
1580 strcpy(er_roomaide, "");
1582 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1585 strcpy(buf, bstr("er_name"));
1587 if (strlen(buf) > 0) {
1588 strcpy(er_name, buf);
1591 strcpy(buf, bstr("er_password"));
1593 if (strlen(buf) > 0)
1594 strcpy(er_password, buf);
1596 strcpy(buf, bstr("er_dirname"));
1598 if (strlen(buf) > 0)
1599 strcpy(er_dirname, buf);
1601 strcpy(buf, bstr("type"));
1602 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1604 if (!strcmp(buf, "invonly")) {
1605 er_flags |= (QR_PRIVATE);
1607 if (!strcmp(buf, "hidden")) {
1608 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1610 if (!strcmp(buf, "passworded")) {
1611 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1613 if (!strcmp(bstr("prefonly"), "yes")) {
1614 er_flags |= QR_PREFONLY;
1616 er_flags &= ~QR_PREFONLY;
1619 if (!strcmp(bstr("readonly"), "yes")) {
1620 er_flags |= QR_READONLY;
1622 er_flags &= ~QR_READONLY;
1625 if (!strcmp(bstr("permanent"), "yes")) {
1626 er_flags |= QR_PERMANENT;
1628 er_flags &= ~QR_PERMANENT;
1631 if (!strcmp(bstr("network"), "yes")) {
1632 er_flags |= QR_NETWORK;
1634 er_flags &= ~QR_NETWORK;
1637 if (!strcmp(bstr("directory"), "yes")) {
1638 er_flags |= QR_DIRECTORY;
1640 er_flags &= ~QR_DIRECTORY;
1643 if (!strcmp(bstr("ulallowed"), "yes")) {
1644 er_flags |= QR_UPLOAD;
1646 er_flags &= ~QR_UPLOAD;
1649 if (!strcmp(bstr("dlallowed"), "yes")) {
1650 er_flags |= QR_DOWNLOAD;
1652 er_flags &= ~QR_DOWNLOAD;
1655 if (!strcmp(bstr("visdir"), "yes")) {
1656 er_flags |= QR_VISDIR;
1658 er_flags &= ~QR_VISDIR;
1661 strcpy(buf, bstr("anon"));
1663 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1664 if (!strcmp(buf, "anononly"))
1665 er_flags |= QR_ANONONLY;
1666 if (!strcmp(buf, "anon2"))
1667 er_flags |= QR_ANONOPT;
1670 if (!strcmp(bstr("bump"), "yes"))
1673 er_floor = atoi(bstr("er_floor"));
1675 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1676 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1678 serv_getln(buf, sizeof buf);
1679 if (buf[0] != '2') {
1680 strcpy(WC->ImportantMessage, &buf[4]);
1686 if (strlen(er_roomaide) > 0) {
1687 sprintf(buf, "SETA %s", er_roomaide);
1689 serv_getln(buf, sizeof buf);
1690 if (buf[0] != '2') {
1691 strcpy(WC->ImportantMessage, &buf[4]);
1692 display_main_menu();
1697 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1704 * Display form for Invite, Kick, and show Who Knows a room
1706 void do_invt_kick(void) {
1707 char buf[SIZ], room[SIZ], username[SIZ];
1710 serv_getln(buf, sizeof buf);
1712 if (buf[0] != '2') {
1716 extract_token(room, &buf[4], 0, '|', sizeof room);
1718 strcpy(username, bstr("username"));
1720 if (strlen(bstr("kick_button")) > 0) {
1721 sprintf(buf, "KICK %s", username);
1723 serv_getln(buf, sizeof buf);
1725 if (buf[0] != '2') {
1726 strcpy(WC->ImportantMessage, &buf[4]);
1728 sprintf(WC->ImportantMessage,
1729 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1734 if (strlen(bstr("invite_button")) > 0) {
1735 sprintf(buf, "INVT %s", username);
1737 serv_getln(buf, sizeof buf);
1739 if (buf[0] != '2') {
1740 strcpy(WC->ImportantMessage, &buf[4]);
1742 sprintf(WC->ImportantMessage,
1743 _("<B><I>User %s invited to room %s.</I></B>\n"),
1754 * Display form for Invite, Kick, and show Who Knows a room
1756 void display_whok(void)
1758 char buf[SIZ], room[SIZ], username[SIZ];
1761 serv_getln(buf, sizeof buf);
1763 if (buf[0] != '2') {
1767 extract_token(room, &buf[4], 0, '|', sizeof room);
1770 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1771 wprintf(_("The users listed below have access to this room. "
1772 "To remove a user from the access list, select the user "
1773 "name from the list and click 'Kick'."));
1774 wprintf("<br /><br />");
1776 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1777 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1778 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1780 serv_getln(buf, sizeof buf);
1781 if (buf[0] == '1') {
1782 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1783 extract_token(username, buf, 0, '|', sizeof username);
1784 wprintf("<OPTION>");
1789 wprintf("</SELECT><br />\n");
1791 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1792 wprintf("</FORM></CENTER>\n");
1794 wprintf("</TD><TD>");
1795 wprintf(_("To grant another user access to this room, enter the "
1796 "user name in the box below and click 'Invite'."));
1797 wprintf("<br /><br />");
1799 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1800 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1801 wprintf(_("Invite:"));
1803 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1804 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1805 "<input type=\"submit\" value=\"%s\">"
1806 "</FORM></CENTER>\n", _("Invite"));
1808 wprintf("</TD></TR></TABLE>\n");
1815 * display the form for entering a new room
1817 void display_entroom(void)
1822 serv_puts("CRE8 0");
1823 serv_getln(buf, sizeof buf);
1825 if (buf[0] != '2') {
1826 strcpy(WC->ImportantMessage, &buf[4]);
1827 display_main_menu();
1831 output_headers(1, 1, 2, 0, 0, 0);
1832 wprintf("<div id=\"banner\">\n"
1833 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1834 "<SPAN CLASS=\"titlebar\">");
1835 wprintf(_("Create a new room"));
1837 "</TD></TR></TABLE>\n"
1838 "</div>\n<div id=\"content\">\n"
1841 wprintf("<div class=\"fix_scrollbar_bug\">"
1842 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1844 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1846 wprintf("<UL><LI>");
1847 wprintf(_("Name of room: "));
1848 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1851 wprintf(_("Resides on floor: "));
1853 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1854 for (i = 0; i < 128; ++i)
1855 if (strlen(floorlist[i]) > 0) {
1856 wprintf("<OPTION ");
1857 wprintf("VALUE=\"%d\">", i);
1858 escputs(floorlist[i]);
1859 wprintf("</OPTION>\n");
1861 wprintf("</SELECT>\n");
1863 /* Our clever little snippet of JavaScript automatically selects
1864 * a public room if the view is set to Bulletin Board, and it
1865 * selects a mailbox room otherwise. The user can override this,
1869 wprintf(_("Default view for room: "));
1870 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1871 " if (this.form.er_view.value == 0) { "
1872 " this.form.type[0].checked=true; "
1873 " this.form.er_floor.disabled = false; "
1876 " this.form.type[4].checked=true; "
1877 " this.form.er_floor.disabled = true; "
1880 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1881 wprintf("<OPTION %s VALUE=\"%d\">",
1882 ((i == 0) ? "SELECTED" : ""), i );
1883 escputs(viewdefs[i]);
1884 wprintf("</OPTION>\n");
1886 wprintf("</SELECT>\n");
1889 wprintf(_("Type of room:"));
1892 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1893 wprintf("CHECKED OnChange=\""
1894 " if (this.form.type[0].checked == true) { "
1895 " this.form.er_floor.disabled = false; "
1898 wprintf(_("Public (automatically appears to everyone)"));
1900 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1901 " if (this.form.type[1].checked == true) { "
1902 " this.form.er_floor.disabled = false; "
1905 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1907 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1908 " if (this.form.type[2].checked == true) { "
1909 " this.form.er_floor.disabled = false; "
1912 wprintf(_("Private - require password: "));
1913 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1915 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1916 " if (this.form.type[3].checked == true) { "
1917 " this.form.er_floor.disabled = false; "
1920 wprintf(_("Private - invitation only"));
1922 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1924 " if (this.form.type[4].checked == true) { "
1925 " this.form.er_floor.disabled = true; "
1928 wprintf(_("Personal (mailbox for you only)"));
1930 wprintf("\n</UL>\n");
1932 wprintf("<CENTER>\n");
1933 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1935 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1936 wprintf("</CENTER>\n");
1937 wprintf("</FORM>\n<hr />");
1938 serv_printf("MESG roomaccess");
1939 serv_getln(buf, sizeof buf);
1940 if (buf[0] == '1') {
1943 wprintf("</td></tr></table></div>\n");
1951 * support function for entroom() -- sets the default view
1953 void er_set_default_view(int newview) {
1966 serv_getln(buf, sizeof buf);
1967 if (buf[0] != '2') return;
1969 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
1970 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
1971 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
1972 rm_bits1 = extract_int(&buf[4], 3);
1973 rm_floor = extract_int(&buf[4], 4);
1974 rm_listorder = extract_int(&buf[4], 5);
1975 rm_bits2 = extract_int(&buf[4], 7);
1977 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1978 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
1979 rm_listorder, newview, rm_bits2
1981 serv_getln(buf, sizeof buf);
1994 char er_password[SIZ];
1999 if (strlen(bstr("ok_button")) == 0) {
2000 strcpy(WC->ImportantMessage,
2001 _("Cancelled. No new room was created."));
2002 display_main_menu();
2005 strcpy(er_name, bstr("er_name"));
2006 strcpy(er_type, bstr("type"));
2007 strcpy(er_password, bstr("er_password"));
2008 er_floor = atoi(bstr("er_floor"));
2009 er_view = atoi(bstr("er_view"));
2012 if (!strcmp(er_type, "hidden"))
2014 if (!strcmp(er_type, "passworded"))
2016 if (!strcmp(er_type, "invonly"))
2018 if (!strcmp(er_type, "personal"))
2021 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2022 er_name, er_num_type, er_password, er_floor, 0, er_view);
2024 serv_getln(buf, sizeof buf);
2025 if (buf[0] != '2') {
2026 strcpy(WC->ImportantMessage, &buf[4]);
2027 display_main_menu();
2031 do_change_view(er_view); /* Now go there */
2036 * display the screen to enter a private room
2038 void display_private(char *rname, int req_pass)
2040 output_headers(1, 1, 2, 0, 0, 0);
2041 wprintf("<div id=\"banner\">\n"
2042 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2043 "<SPAN CLASS=\"titlebar\">");
2044 wprintf(_("Go to a hidden room"));
2046 "</TD></TR></TABLE>\n"
2047 "</div>\n<div id=\"content\">\n"
2050 wprintf("<div class=\"fix_scrollbar_bug\">"
2051 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2053 wprintf("<CENTER>\n");
2055 wprintf(_("If you know the name of a hidden (guess-name) or "
2056 "passworded room, you can enter that room by typing "
2057 "its name below. Once you gain access to a private "
2058 "room, it will appear in your regular room listings "
2059 "so you don't have to keep returning here."));
2060 wprintf("\n<br /><br />");
2062 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2064 wprintf("<table border=\"0\" cellspacing=\"5\" "
2065 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2067 wprintf(_("Enter room name:"));
2069 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2070 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2073 wprintf("</TD></TR><TR><TD>");
2074 wprintf(_("Enter room password:"));
2075 wprintf("</TD><TD>");
2076 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2078 wprintf("</TD></TR></TABLE><br />\n");
2080 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2082 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2086 wprintf("</FORM>\n");
2087 wprintf("</td></tr></table></div>\n");
2092 * goto a private room
2094 void goto_private(void)
2099 if (strlen(bstr("ok_button")) == 0) {
2100 display_main_menu();
2103 strcpy(hold_rm, WC->wc_roomname);
2104 strcpy(buf, "GOTO ");
2105 strcat(buf, bstr("gr_name"));
2107 strcat(buf, bstr("gr_pass"));
2109 serv_getln(buf, sizeof buf);
2111 if (buf[0] == '2') {
2112 smart_goto(bstr("gr_name"));
2115 if (!strncmp(buf, "540", 3)) {
2116 display_private(bstr("gr_name"), 1);
2119 output_headers(1, 1, 1, 0, 0, 0);
2120 wprintf("%s\n", &buf[4]);
2127 * display the screen to zap a room
2129 void display_zap(void)
2131 output_headers(1, 1, 2, 0, 0, 0);
2133 wprintf("<div id=\"banner\">\n");
2134 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2135 wprintf("<SPAN CLASS=\"titlebar\">");
2136 wprintf(_("Zap (forget/unsubscribe) the current room"));
2137 wprintf("</SPAN>\n");
2138 wprintf("</TD></TR></TABLE>\n");
2139 wprintf("</div>\n<div id=\"content\">\n");
2141 wprintf(_("If you select this option, <em>%s</em> will "
2142 "disappear from your room list. Is this what you wish "
2143 "to do?<br />\n"), WC->wc_roomname);
2145 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2146 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2148 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2149 wprintf("</FORM>\n");
2160 char final_destination[SIZ];
2162 /* If the forget-room routine fails for any reason, we fall back
2163 * to the current room; otherwise, we go to the Lobby
2165 strcpy(final_destination, WC->wc_roomname);
2167 if (strlen(bstr("ok_button")) > 0) {
2168 serv_printf("GOTO %s", WC->wc_roomname);
2169 serv_getln(buf, sizeof buf);
2170 if (buf[0] == '2') {
2172 serv_getln(buf, sizeof buf);
2173 if (buf[0] == '2') {
2174 strcpy(final_destination, "_BASEROOM_");
2178 smart_goto(final_destination);
2184 * Delete the current room
2186 void delete_room(void)
2190 serv_puts("KILL 1");
2191 serv_getln(buf, sizeof buf);
2192 if (buf[0] != '2') {
2193 strcpy(WC->ImportantMessage, &buf[4]);
2194 display_main_menu();
2197 smart_goto("_BASEROOM_");
2204 * Perform changes to a room's network configuration
2206 void netedit(void) {
2215 if (strlen(bstr("line"))==0) {
2220 strcpy(line, bstr("prefix"));
2221 strcat(line, bstr("line"));
2222 strcat(line, bstr("suffix"));
2231 serv_getln(buf, sizeof buf);
2232 if (buf[0] != '1') {
2238 /* This loop works for add *or* remove. Spiffy, eh? */
2239 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2240 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2241 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2242 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2243 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2244 if ( (strcasecmp(cmpa0, cmpb0))
2245 || (strcasecmp(cmpa1, cmpb1)) ) {
2246 fprintf(fp, "%s\n", buf);
2252 serv_getln(buf, sizeof buf);
2253 if (buf[0] != '4') {
2259 while (fgets(buf, sizeof buf, fp) != NULL) {
2260 buf[strlen(buf)-1] = 0;
2264 if (strlen(bstr("add_button")) > 0) {
2276 * Convert a room name to a folder-ish-looking name.
2278 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2283 * For mailboxes, just do it straight...
2286 sprintf(folder, "My folders|%s", room);
2290 * Otherwise, prefix the floor name as a "public folders" moniker
2293 sprintf(folder, "%s|%s", floorlist[floor], room);
2297 * Replace "\" characters with "|" for pseudo-folder-delimiting
2299 for (i=0; i<strlen(folder); ++i) {
2300 if (folder[i] == '\\') folder[i] = '|';
2308 * Back end for change_view()
2310 void do_change_view(int newview) {
2313 serv_printf("VIEW %d", newview);
2314 serv_getln(buf, sizeof buf);
2315 WC->wc_view = newview;
2316 smart_goto(WC->wc_roomname);
2322 * Change the view for this room
2324 void change_view(void) {
2327 view = atol(bstr("view"));
2328 do_change_view(view);
2333 * One big expanded tree list view --- like a folder list
2335 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2339 int has_subfolders = 0;
2342 parents = malloc(max_folders * sizeof(int));
2344 /* BEGIN TREE MENU */
2345 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2347 /* include NanoTree */
2348 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2350 /* initialize NanoTree */
2351 wprintf("<script type=\"text/javascript\"> \n"
2352 " showRootNode = false; \n"
2353 " sortNodes = false; \n"
2354 " dragable = false; \n"
2356 " function standardClick(treeNode) { \n"
2359 " var closedGif = 'static/folder_closed.gif'; \n"
2360 " var openGif = 'static/folder_open.gif'; \n"
2362 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2366 for (i=0; i<max_folders; ++i) {
2369 if ((i+1) < max_folders) {
2370 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2371 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2376 levels = num_tokens(fold[i].name, '|');
2377 parents[levels] = i;
2379 wprintf("var node%d = new TreeNode(%d, '", i, i);
2381 if (fold[i].selectable) {
2382 wprintf("<a href=\"dotgoto?room=");
2383 urlescputs(fold[i].room);
2388 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2390 else if (fold[i].hasnewmsgs) {
2391 wprintf("<SPAN CLASS=\"roomlist_new\">");
2394 wprintf("<SPAN CLASS=\"roomlist_old\">");
2396 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2401 if (has_subfolders) {
2402 wprintf("new Array(closedGif, openGif)");
2404 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2405 wprintf("'static/viewcontacts_16x.gif'");
2407 else if (fold[i].view == VIEW_CALENDAR) {
2408 wprintf("'static/calarea_16x.gif'");
2410 else if (fold[i].view == VIEW_TASKS) {
2411 wprintf("'static/taskmanag_16x.gif'");
2413 else if (fold[i].view == VIEW_NOTES) {
2414 wprintf("'static/storenotes_16x.gif'");
2416 else if (fold[i].view == VIEW_MAILBOX) {
2417 wprintf("'static/privatemess_16x.gif'");
2420 wprintf("'static/chatrooms_16x.gif'");
2423 urlescputs(fold[i].name);
2427 wprintf("rootNode.addChild(node%d);\n", i);
2430 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2434 wprintf("container = document.getElementById('roomlist_div'); \n"
2444 * Boxes and rooms and lists ... oh my!
2446 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2448 char floor_name[256];
2449 char old_floor_name[256];
2451 int levels, oldlevels;
2454 static int columns = 3;
2455 int boxes_per_column = 0;
2456 int current_column = 0;
2459 strcpy(floor_name, "");
2460 strcpy(old_floor_name, "");
2463 while (nf % columns != 0) ++nf;
2464 boxes_per_column = (nf / columns);
2465 if (boxes_per_column < 1) boxes_per_column = 1;
2467 /* Outer table (for columnization) */
2468 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2469 "<tr><td valign=top>");
2473 for (i=0; i<max_folders; ++i) {
2475 levels = num_tokens(fold[i].name, '|');
2476 extract_token(floor_name, fold[i].name, 0,
2477 '|', sizeof floor_name);
2479 if ( (strcasecmp(floor_name, old_floor_name))
2480 && (strlen(old_floor_name) > 0) ) {
2482 do_template("endbox");
2485 if ((num_boxes % boxes_per_column) == 0) {
2487 if (current_column < columns) {
2488 wprintf("</td><td valign=top>\n");
2492 strcpy(old_floor_name, floor_name);
2495 /* Begin inner box */
2496 stresc(boxtitle, floor_name, 1, 0);
2497 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2498 do_template("beginbox");
2505 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2506 if (fold[i].selectable) {
2507 wprintf("<a href=\"dotgoto?room=");
2508 urlescputs(fold[i].room);
2514 if (fold[i].hasnewmsgs) {
2515 wprintf("<SPAN CLASS=\"roomlist_new\">");
2518 wprintf("<SPAN CLASS=\"roomlist_old\">");
2520 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2523 if (fold[i].selectable) {
2529 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2530 wprintf(" (INBOX)");
2532 wprintf("<br />\n");
2535 /* End the final inner box */
2536 do_template("endbox");
2538 wprintf("</TD></TR></TABLE>\n");
2542 void set_floordiv_expanded(char *which_floordiv) {
2543 begin_ajax_response();
2544 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2545 end_ajax_response();
2551 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2553 char floor_name[256];
2554 char old_floor_name[256];
2555 char floordivtitle[256];
2556 char floordiv_id[32];
2557 int levels, oldlevels;
2559 int num_drop_targets = 0;
2562 strcpy(floor_name, "");
2563 strcpy(old_floor_name, "");
2567 for (i=0; i<max_folders; ++i) {
2569 levels = num_tokens(fold[i].name, '|');
2570 extract_token(floor_name, fold[i].name, 0,
2571 '|', sizeof floor_name);
2573 if ( (strcasecmp(floor_name, old_floor_name))
2574 && (strlen(old_floor_name) > 0) ) {
2577 wprintf("</div>\n"); /* floordiv */
2579 strcpy(old_floor_name, floor_name);
2583 stresc(floordivtitle, floor_name, 0, 0);
2584 sprintf(floordiv_id, "floordiv%d", i);
2585 wprintf("<span class=\"ib_roomlist_floor\" "
2586 "onClick=\"expand_floor('%s')\">"
2587 "%s</span><br>\n", floordiv_id, floordivtitle);
2588 wprintf("<div id=\"%s\" style=\"display:%s\">",
2590 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2597 wprintf("<div id=\"roomdiv%d\">", i);
2599 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2601 /* choose the icon */
2602 if (fold[i].view == VIEW_ADDRESSBOOK) {
2603 icon = "viewcontacts_16x.gif" ;
2605 else if (fold[i].view == VIEW_CALENDAR) {
2606 icon = "calarea_16x.gif" ;
2608 else if (fold[i].view == VIEW_TASKS) {
2609 icon = "taskmanag_16x.gif" ;
2611 else if (fold[i].view == VIEW_NOTES) {
2612 icon = "storenotes_16x.gif" ;
2614 else if (fold[i].view == VIEW_MAILBOX) {
2615 icon = "privatemess_16x.gif" ;
2618 icon = "chatrooms_16x.gif" ;
2621 if (fold[i].selectable) {
2622 wprintf("<a href=\"dotgoto?room=");
2623 urlescputs(fold[i].room);
2625 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2630 if (fold[i].hasnewmsgs) {
2631 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2634 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2636 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2638 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2639 wprintf(" (INBOX)");
2642 if (fold[i].selectable) {
2649 wprintf("</div>\n"); /* roomdiv */
2652 wprintf("</div>\n"); /* floordiv */
2655 /* BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2656 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2658 num_drop_targets = 0;
2660 for (i=0; i<max_folders; ++i) {
2661 levels = num_tokens(fold[i].name, '|');
2663 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2664 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2665 jsescputs(fold[i].room);
2671 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2672 if (strlen(WC->floordiv_expanded) > 1) {
2673 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2677 /* END: The old invisible pixel trick, to get our JavaScript to initialize */
2683 * Show the room list. (only should get called by
2684 * knrooms() because that's where output_headers() is called from)
2687 void list_all_rooms_by_floor(char *viewpref) {
2690 struct folder *fold = NULL;
2692 int max_folders = 0;
2693 int alloc_folders = 0;
2697 int num_floors = 1; /* add an extra one for private folders */
2699 /* If our cached folder list is very old, burn it. */
2700 if (WC->cache_fold != NULL) {
2701 if ((time(NULL) - WC->cache_timestamp) > 300) {
2702 free(WC->cache_fold);
2703 WC->cache_fold = NULL;
2707 /* Can we do the iconbar roomlist from cache? */
2708 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2709 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2713 /* Grab the floor table so we know how to build the list... */
2716 /* Start with the mailboxes */
2719 fold = malloc(sizeof(struct folder));
2720 memset(fold, 0, sizeof(struct folder));
2721 strcpy(fold[0].name, "My folders");
2722 fold[0].is_mailbox = 1;
2724 /* Then add floors */
2726 serv_getln(buf, sizeof buf);
2727 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2728 if (max_folders >= alloc_folders) {
2729 alloc_folders = max_folders + 100;
2730 fold = realloc(fold,
2731 alloc_folders * sizeof(struct folder));
2733 memset(&fold[max_folders], 0, sizeof(struct folder));
2734 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2741 serv_getln(buf, sizeof buf);
2742 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2743 if (max_folders >= alloc_folders) {
2744 alloc_folders = max_folders + 100;
2745 fold = realloc(fold,
2746 alloc_folders * sizeof(struct folder));
2748 memset(&fold[max_folders], 0, sizeof(struct folder));
2749 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2750 ra_flags = extract_int(buf, 5);
2751 flags = extract_int(buf, 1);
2752 fold[max_folders].floor = extract_int(buf, 2);
2753 fold[max_folders].hasnewmsgs =
2754 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2755 if (flags & QR_MAILBOX) {
2756 fold[max_folders].is_mailbox = 1;
2758 fold[max_folders].view = extract_int(buf, 6);
2759 room_to_folder(fold[max_folders].name,
2760 fold[max_folders].room,
2761 fold[max_folders].floor,
2762 fold[max_folders].is_mailbox);
2763 fold[max_folders].selectable = 1;
2767 /* Bubble-sort the folder list */
2768 for (i=0; i<max_folders; ++i) {
2769 for (j=0; j<(max_folders-1)-i; ++j) {
2770 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2771 swap = strcasecmp(fold[j].name, fold[j+1].name);
2774 if ( (fold[j+1].is_mailbox)
2775 && (!fold[j].is_mailbox)) {
2783 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2784 memcpy(&fold[j], &fold[j+1],
2785 sizeof(struct folder));
2786 memcpy(&fold[j+1], &ftmp,
2787 sizeof(struct folder));
2793 if (!strcasecmp(viewpref, "folders")) {
2794 do_folder_view(fold, max_folders, num_floors);
2796 else if (!strcasecmp(viewpref, "hackish_view")) {
2797 for (i=0; i<max_folders; ++i) {
2798 escputs(fold[i].name);
2799 wprintf("<br />\n");
2802 else if (!strcasecmp(viewpref, "iconbar")) {
2803 do_iconbar_view(fold, max_folders, num_floors);
2806 do_rooms_view(fold, max_folders, num_floors);
2809 /* Don't free the folder list ... cache it for future use! */
2810 if (WC->cache_fold != NULL) {
2811 free(WC->cache_fold);
2813 WC->cache_fold = fold;
2814 WC->cache_max_folders = max_folders;
2815 WC->cache_num_floors = num_floors;
2816 WC->cache_timestamp = time(NULL);
2820 /* Do either a known rooms list or a folders list, depending on the
2824 char listviewpref[SIZ];
2826 output_headers(1, 1, 2, 0, 0, 0);
2828 /* Determine whether the user is trying to change views */
2829 if (bstr("view") != NULL) {
2830 if (strlen(bstr("view")) > 0) {
2831 set_preference("roomlistview", bstr("view"), 1);
2835 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2837 if ( (strcasecmp(listviewpref, "folders"))
2838 && (strcasecmp(listviewpref, "table")) ) {
2839 strcpy(listviewpref, "rooms");
2843 wprintf("<div id=\"banner\">\n"
2844 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2845 "<SPAN CLASS=\"titlebar\">"
2847 if (!strcasecmp(listviewpref, "rooms")) {
2848 wprintf(_("Room list"));
2850 if (!strcasecmp(listviewpref, "folders")) {
2851 wprintf(_("Folder list"));
2853 if (!strcasecmp(listviewpref, "table")) {
2854 wprintf(_("Room list"));
2856 wprintf("</SPAN></TD>\n");
2858 /* offer the ability to switch views */
2859 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2860 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2861 "OnChange=\"location.href=roomlistomatic.newview.options"
2862 "[selectedIndex].value\">\n");
2864 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
2867 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2870 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
2871 "View as folder list"
2873 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2876 wprintf("</SELECT><br />");
2878 wprintf("</FORM></TD></TR></TABLE>\n");
2881 "<div id=\"content\">\n");
2883 /* Display the room list in the user's preferred format */
2884 list_all_rooms_by_floor(listviewpref);
2891 * Set the message expire policy for this room and/or floor
2893 void set_room_policy(void) {
2896 if (strlen(bstr("ok_button")) == 0) {
2897 strcpy(WC->ImportantMessage,
2898 _("Cancelled. Changes were not saved."));
2903 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2904 serv_getln(buf, sizeof buf);
2905 strcpy(WC->ImportantMessage, &buf[4]);
2907 if (WC->axlevel >= 6) {
2908 strcat(WC->ImportantMessage, "<br />\n");
2909 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2910 serv_getln(buf, sizeof buf);
2911 strcat(WC->ImportantMessage, &buf[4]);