5 * \defgroup RoomOps Lots of different room-related operations.
10 char floorlist[128][SIZ]; /**< list of our floor names */
12 char *viewdefs[7]; /**< the different kinds of available views */
15 * \brief initialize the viewdefs with localized strings
17 void initialize_viewdefs(void) {
18 viewdefs[0] = _("Bulletin Board");
19 viewdefs[1] = _("Mail Folder");
20 viewdefs[2] = _("Address Book");
21 viewdefs[3] = _("Calendar");
22 viewdefs[4] = _("Task List");
23 viewdefs[5] = _("Notes List");
24 viewdefs[6] = _("Wiki");
29 * \brief load the list of floors
31 void load_floorlist(void)
36 for (a = 0; a < 128; ++a)
40 serv_getln(buf, sizeof buf);
42 strcpy(floorlist[0], "Main Floor");
45 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
46 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
52 * \brief remove a room from the march list
54 void remove_march(char *aaa)
56 struct march *mptr, *mptr2;
58 if (WC->march == NULL)
61 if (!strcasecmp(WC->march->march_name, aaa)) {
62 mptr = WC->march->next;
68 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
69 if (!strcasecmp(mptr->march_name, aaa)) {
70 mptr2->next = mptr->next;
83 * \brief display rooms in tree structure???
84 * \param rp the roomlist to build a tree from
86 void room_tree_list(struct roomlisting *rp)
95 room_tree_list(rp->lnext);
97 strcpy(rmname, rp->rlname);
100 wprintf("<a href=\"dotgoto&room=");
104 escputs1(rmname, 1, 1);
105 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
107 else if (f & QR_DIRECTORY)
109 else if (f & QR_NETWORK)
113 wprintf("</A><TT> </TT>\n");
115 room_tree_list(rp->rnext);
121 * \brief Room ordering stuff (compare first by floor, then by order)
122 * \param r1 first roomlist to compare
123 * \param r2 second roomlist co compare
124 * \return are they the same???
126 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
128 if ((r1 == NULL) && (r2 == NULL))
134 if (r1->rlfloor < r2->rlfloor)
136 if (r1->rlfloor > r2->rlfloor)
138 if (r1->rlorder < r2->rlorder)
140 if (r1->rlorder > r2->rlorder)
147 * \brief Common code for all room listings
148 * \param variety what???
150 void listrms(char *variety)
155 struct roomlisting *rl = NULL;
156 struct roomlisting *rp;
157 struct roomlisting *rs;
160 /** Ask the server for a room list */
162 serv_getln(buf, sizeof buf);
167 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
169 rp = malloc(sizeof(struct roomlisting));
170 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
171 rp->rlflags = extract_int(buf, 1);
172 rp->rlfloor = extract_int(buf, 2);
173 rp->rlorder = extract_int(buf, 3);
182 if (rordercmp(rp, rs) < 0) {
183 if (rs->lnext == NULL) {
190 if (rs->rnext == NULL) {
203 * If no rooms were listed, print an nbsp to make the cell
204 * borders show up anyway.
206 if (num_rooms == 0) wprintf(" ");
211 * \brief list all forgotten rooms
213 void zapped_list(void)
215 output_headers(1, 1, 0, 0, 0, 0);
217 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
218 do_template("beginbox");
222 wprintf("<br /><br />\n");
223 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
224 do_template("endbox");
230 * \brief read this room's info file (set v to 1 for verbose mode)
237 serv_getln(buf, sizeof buf);
250 * \brief Display room banner icon.
251 * The server doesn't actually
252 * need the room name, but we supply it in order to
253 * keep the browser from using a cached icon from
256 void embed_room_graphic(void) {
259 serv_puts("OIMG _roompic_");
260 serv_getln(buf, sizeof buf);
262 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
263 urlescputs(WC->wc_roomname);
266 serv_getln(buf, sizeof buf);
268 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
269 wprintf("<img height=48 width=48 src=\""
270 "static/viewcontacts_48x.gif"
274 else if (WC->wc_view == VIEW_CALENDAR) {
275 wprintf("<img height=48 width=48 src=\""
276 "static/calarea_48x.gif"
280 else if (WC->wc_view == VIEW_TASKS) {
281 wprintf("<img height=48 width=48 src=\""
282 "static/taskmanag_48x.gif"
286 else if (WC->wc_view == VIEW_NOTES) {
287 wprintf("<img height=48 width=48 src=\""
288 "static/storenotes_48x.gif"
292 else if (WC->wc_view == VIEW_MAILBOX) {
293 wprintf("<img height=48 width=48 src=\""
294 "static/privatemess_48x.gif"
299 wprintf("<img height=48 width=48 src=\""
300 "static/chatrooms_48x.gif"
310 * \brief Display the current view and offer an option to change it
312 void embed_view_o_matic(void) {
315 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
316 "<span class=\"room_banner_new_messages\">");
317 wprintf(_("View as:"));
319 "<SELECT NAME=\"newview\" SIZE=\"1\" "
320 "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif;"
321 " font-size: 7pt; background: #444455; color: #ddddcc;\" "
322 "OnChange=\"location.href=viewomatic.newview.options"
323 "[selectedIndex].value\">\n");
325 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
327 * Only offer the views that make sense, given the default
328 * view for the room. For example, don't offer a Calendar
329 * view in a non-Calendar room.
333 || (i == WC->wc_default_view)
334 || ( (i == 0) && (WC->wc_default_view == 1) )
335 || ( (i == 1) && (WC->wc_default_view == 0) )
338 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
339 ((i == WC->wc_view) ? "SELECTED" : ""),
341 escputs(viewdefs[i]);
342 wprintf("</OPTION>\n");
345 wprintf("</select></span></form>\n");
350 * \brief view room banner
352 * \param navbar_style
354 void embed_room_banner(char *got, int navbar_style) {
358 * We need to have the information returned by a GOTO server command.
359 * If it isn't supplied, we fake it by issuing our own GOTO.
362 serv_printf("GOTO %s", WC->wc_roomname);
363 serv_getln(buf, sizeof buf);
367 /** The browser needs some information for its own use */
368 wprintf("<script type=\"text/javascript\"> \n"
369 " room_is_trash = %d; \n"
375 * If the user happens to select the "make this my start page" link,
376 * we want it to remember the URL as a "/dotskip" one instead of
377 * a "skip" or "gotonext" or something like that.
379 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
382 /** Check for new mail. */
383 WC->new_mail = extract_int(&got[4], 9);
384 WC->wc_view = extract_int(&got[4], 11);
386 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
387 svprintf("NUMMSGS", WCS_STRING,
388 _("%d new of %d messages"),
389 extract_int(&got[4], 1),
390 extract_int(&got[4], 2)
392 svcallback("ROOMPIC", embed_room_graphic);
393 svcallback("ROOMINFO", readinfo);
394 svcallback("VIEWOMATIC", embed_view_o_matic);
395 svcallback("START", offer_start_page);
397 do_template("roombanner");
398 if (navbar_style != navbar_none) {
400 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
401 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
404 if (navbar_style == navbar_default) wprintf(
406 "<a href=\"ungoto\">"
407 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
408 "<span class=\"navbar_link\">%s</span></A>"
409 "</td>\n", _("Ungoto")
412 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
415 "<a href=\"readnew\">"
416 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
417 "<span class=\"navbar_link\">%s</span></A>"
418 "</td>\n", _("Read new messages")
422 if (navbar_style == navbar_default) {
423 switch(WC->wc_view) {
424 case VIEW_ADDRESSBOOK:
427 "<a href=\"readfwd\">"
428 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
430 "<span class=\"navbar_link\">"
432 "</span></a></td>\n", _("View contacts")
438 "<a href=\"readfwd?calview=day\">"
439 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
441 "<span class=\"navbar_link\">"
443 "</span></a></td>\n", _("Day view")
447 "<a href=\"readfwd?calview=month\">"
448 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
450 "<span class=\"navbar_link\">"
452 "</span></a></td>\n", _("Month view")
458 "<a href=\"readfwd\">"
459 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
461 "<span class=\"navbar_link\">"
463 "</span></a></td>\n", _("View tasks")
469 "<a href=\"readfwd\">"
470 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
472 "<span class=\"navbar_link\">"
474 "</span></a></td>\n", _("View notes")
480 "<a href=\"readfwd\">"
481 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
483 "<span class=\"navbar_link\">"
485 "</span></a></td>\n", _("View message list")
491 "<a href=\"readfwd\">"
492 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
494 "<span class=\"navbar_link\">"
496 "</span></a></td>\n", _("Wiki home")
502 "<a href=\"readfwd\">"
503 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
505 "<span class=\"navbar_link\">"
507 "</span></a></td>\n", _("Read all messages")
513 if (navbar_style == navbar_default) {
514 switch(WC->wc_view) {
515 case VIEW_ADDRESSBOOK:
517 "<td><a href=\"display_enter\">"
518 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
519 "border=\"0\"><span class=\"navbar_link\">"
521 "</span></a></td>\n", _("Add new contact")
526 "<td><a href=\"display_enter\">"
527 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
528 "border=\"0\"><span class=\"navbar_link\">"
530 "</span></a></td>\n", _("Add new event")
535 "<td><a href=\"display_enter\">"
536 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
537 "border=\"0\"><span class=\"navbar_link\">"
539 "</span></a></td>\n", _("Add new task")
544 "<td><a href=\"javascript:add_new_note();\">"
545 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
546 "border=\"0\"><span class=\"navbar_link\">"
548 "</span></a></td>\n", _("Add new note")
552 safestrncpy(buf, bstr("page"), sizeof buf);
555 "<td><a href=\"display_enter?wikipage=%s\">"
556 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
557 "border=\"0\"><span class=\"navbar_link\">"
559 "</span></a></td>\n", buf, _("Edit this page")
564 "<td><a href=\"display_enter\">"
565 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
566 "border=\"0\"><span class=\"navbar_link\">"
568 "</span></a></td>\n", _("Enter a message")
574 if (navbar_style == navbar_default) wprintf(
578 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
579 "<span class=\"navbar_link\">%s</span></a>"
581 _("Leave all messages marked as unread, go to next room with unread messages"),
585 if (navbar_style == navbar_default) wprintf(
587 "<a href=\"gotonext\" "
589 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
590 "<span class=\"navbar_link\">%s</span></a>"
592 _("Mark all messages as read, go to next room with unread messages"),
596 wprintf("</tr></table></div>\n");
606 * \brief back end routine to take the session to a new room
607 * \param gname room to go to
610 int gotoroom(char *gname)
613 static long ls = (-1L);
616 /** store ungoto information */
617 strcpy(WC->ugname, WC->wc_roomname);
620 /** move to the new room */
621 serv_printf("GOTO %s", gname);
622 serv_getln(buf, sizeof buf);
626 serv_puts("GOTO _BASEROOM_");
627 serv_getln(buf, sizeof buf);
634 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
635 WC->room_flags = extract_int(&buf[4], 4);
636 /* highest_msg_read = extract_int(&buf[4],6);
637 maxmsgnum = extract_int(&buf[4],5);
639 WC->is_mailbox = extract_int(&buf[4],7);
640 ls = extract_long(&buf[4], 6);
641 WC->wc_floor = extract_int(&buf[4], 10);
642 WC->wc_view = extract_int(&buf[4], 11);
643 WC->wc_default_view = extract_int(&buf[4], 12);
644 WC->wc_is_trash = extract_int(&buf[4], 13);
647 WC->is_room_aide = WC->is_aide;
649 WC->is_room_aide = (char) extract_int(&buf[4], 8);
651 remove_march(WC->wc_roomname);
652 if (!strcasecmp(gname, "_BASEROOM_"))
660 * \brief Locate the room on the march list which we most want to go to.
662 * is measured given a "weight" of preference based on various factors.
663 * \param desired_floor the room number on the citadel server
664 * \return the roomname
666 char *pop_march(int desired_floor)
668 static char TheRoom[128];
670 int TheOrder = 32767;
673 struct march *mptr = NULL;
675 strcpy(TheRoom, "_BASEROOM_");
676 if (WC->march == NULL)
679 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
681 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
682 weight = weight + 10000;
683 if (mptr->march_floor == desired_floor)
684 weight = weight + 5000;
686 weight = weight + ((128 - (mptr->march_floor)) * 128);
687 weight = weight + (128 - (mptr->march_order));
689 if (weight > TheWeight) {
691 strcpy(TheRoom, mptr->march_name);
692 TheFloor = mptr->march_floor;
693 TheOrder = mptr->march_order;
702 *\brief Goto next room having unread messages.
703 * We want to skip over rooms that the user has already been to, and take the
704 * user back to the lobby when done. The room we end up in is placed in
705 * newroom - which is set to 0 (the lobby) initially.
706 * We start the search in the current room rather than the beginning to prevent
707 * two or more concurrent users from dragging each other back to the same room.
712 struct march *mptr, *mptr2;
716 * First check to see if the march-mode list is already allocated.
717 * If it is, pop the first room off the list and go there.
720 if (WC->march == NULL) {
722 serv_getln(buf, sizeof buf);
724 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
725 mptr = (struct march *) malloc(sizeof(struct march));
727 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
728 mptr->march_floor = extract_int(buf, 2);
729 mptr->march_order = extract_int(buf, 3);
730 if (WC->march == NULL) {
734 while (mptr2->next != NULL)
740 * add _BASEROOM_ to the end of the march list, so the user will end up
741 * in the system base room (usually the Lobby>) at the end of the loop
743 mptr = (struct march *) malloc(sizeof(struct march));
745 strcpy(mptr->march_name, "_BASEROOM_");
746 if (WC->march == NULL) {
750 while (mptr2->next != NULL)
755 * ...and remove the room we're currently in, so a <G>oto doesn't make us
756 * walk around in circles
758 remove_march(WC->wc_roomname);
760 if (WC->march != NULL) {
761 strcpy(next_room, pop_march(-1));
763 strcpy(next_room, "_BASEROOM_");
767 smart_goto(next_room);
772 * \brief goto next room
773 * \param next_room next room to go to
775 void smart_goto(char *next_room) {
783 * \brief mark all messages in current room as having been read
785 void slrp_highest(void)
790 serv_puts("SLRP HIGHEST");
791 serv_getln(buf, sizeof buf);
793 wprintf("<EM>%s</EM><br />\n", &buf[4]);
800 * \brief un-goto the previous room
806 if (!strcmp(WC->ugname, "")) {
807 smart_goto(WC->wc_roomname);
810 serv_printf("GOTO %s", WC->ugname);
811 serv_getln(buf, sizeof buf);
813 smart_goto(WC->wc_roomname);
816 if (WC->uglsn >= 0L) {
817 serv_printf("SLRP %ld", WC->uglsn);
818 serv_getln(buf, sizeof buf);
820 strcpy(buf, WC->ugname);
821 strcpy(WC->ugname, "");
830 * \brief Set/clear/read the "self-service list subscribe" flag for a room
832 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
833 * \return return the new value.
836 int self_service(int newval) {
837 int current_value = 0;
843 int flags, floor, order, view, flags2;
846 serv_getln(buf, sizeof buf);
847 if (buf[0] != '2') return(0);
849 extract_token(name, &buf[4], 0, '|', sizeof name);
850 extract_token(password, &buf[4], 1, '|', sizeof password);
851 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
852 flags = extract_int(&buf[4], 3);
853 floor = extract_int(&buf[4], 4);
854 order = extract_int(&buf[4], 5);
855 view = extract_int(&buf[4], 6);
856 flags2 = extract_int(&buf[4], 7);
858 if (flags2 & QR2_SELFLIST) {
866 flags2 = flags2 | QR2_SELFLIST;
868 else if (newval == 0) {
869 flags2 = flags2 & ~QR2_SELFLIST;
872 return(current_value);
875 if (newval != current_value) {
876 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
877 name, password, dirname, flags,
878 floor, order, view, flags2);
879 serv_getln(buf, sizeof buf);
892 * \brief display the form for editing a room
894 void display_editroom(void)
899 char remote_room[SIZ];
902 char er_password[10];
904 char er_roomaide[26];
910 char *not_shared_with;
917 if (strlen(tab) == 0) tab = "admin";
921 serv_getln(buf, sizeof buf);
924 strcpy(WC->ImportantMessage, &buf[4]);
928 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
929 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
930 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
931 er_flags = extract_int(&buf[4], 3);
932 er_floor = extract_int(&buf[4], 4);
934 output_headers(1, 1, 1, 0, 0, 0);
936 /** print the tabbed dialog */
938 "<div class=\"fix_scrollbar_bug\">"
939 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
941 "<TD> </TD>\n");
943 if (!strcmp(tab, "admin")) {
944 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
947 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
949 wprintf(_("Administration"));
950 if (!strcmp(tab, "admin")) {
951 wprintf("</SPAN></TD>\n");
954 wprintf("</A></TD>\n");
957 wprintf("<TD> </TD>\n");
959 if (!strcmp(tab, "config")) {
960 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
963 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
965 wprintf(_("Configuration"));
966 if (!strcmp(tab, "config")) {
967 wprintf("</SPAN></TD>\n");
970 wprintf("</A></TD>\n");
973 wprintf("<TD> </TD>\n");
975 if (!strcmp(tab, "expire")) {
976 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
979 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
981 wprintf(_("Message expire policy"));
982 if (!strcmp(tab, "expire")) {
983 wprintf("</SPAN></TD>\n");
986 wprintf("</A></TD>\n");
989 wprintf("<TD> </TD>\n");
991 if (!strcmp(tab, "access")) {
992 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
995 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
997 wprintf(_("Access controls"));
998 if (!strcmp(tab, "access")) {
999 wprintf("</SPAN></TD>\n");
1002 wprintf("</A></TD>\n");
1005 wprintf("<TD> </TD>\n");
1007 if (!strcmp(tab, "sharing")) {
1008 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1011 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
1013 wprintf(_("Sharing"));
1014 if (!strcmp(tab, "sharing")) {
1015 wprintf("</SPAN></TD>\n");
1018 wprintf("</A></TD>\n");
1021 wprintf("<TD> </TD>\n");
1023 if (!strcmp(tab, "listserv")) {
1024 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1027 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
1029 wprintf(_("Mailing list service"));
1030 if (!strcmp(tab, "listserv")) {
1031 wprintf("</SPAN></TD>\n");
1034 wprintf("</A></TD>\n");
1037 wprintf("<TD> </TD>\n");
1039 wprintf("</TR></TABLE></div>\n");
1040 /** end tabbed dialog */
1042 /** begin content of whatever tab is open now */
1043 wprintf("<div class=\"fix_scrollbar_bug\">"
1044 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
1047 if (!strcmp(tab, "admin")) {
1049 "<LI><a href=\"delete_room\" "
1050 "onClick=\"return confirm('");
1051 wprintf(_("Are you sure you want to delete this room?"));
1052 wprintf("');\">\n");
1053 wprintf(_("Delete this room"));
1055 "<LI><a href=\"display_editroompic\">\n");
1056 wprintf(_("Set or change the icon for this room's banner"));
1058 "<LI><a href=\"display_editinfo\">\n");
1059 wprintf(_("Edit this room's Info file"));
1064 if (!strcmp(tab, "config")) {
1065 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1067 wprintf("<UL><LI>");
1068 wprintf(_("Name of room: "));
1069 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1075 wprintf(_("Resides on floor: "));
1076 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1077 for (i = 0; i < 128; ++i)
1078 if (strlen(floorlist[i]) > 0) {
1079 wprintf("<OPTION ");
1081 wprintf("SELECTED ");
1082 wprintf("VALUE=\"%d\">", i);
1083 escputs(floorlist[i]);
1084 wprintf("</OPTION>\n");
1086 wprintf("</SELECT>\n");
1089 wprintf(_("Type of room:"));
1092 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1093 if ((er_flags & QR_PRIVATE) == 0)
1094 wprintf("CHECKED ");
1096 wprintf(_("Public room"));
1099 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1100 if ((er_flags & QR_PRIVATE) &&
1101 (er_flags & QR_GUESSNAME))
1102 wprintf("CHECKED ");
1104 wprintf(_("Private - guess name"));
1106 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1107 if ((er_flags & QR_PRIVATE) &&
1108 (er_flags & QR_PASSWORDED))
1109 wprintf("CHECKED ");
1111 wprintf(_("Private - require password:"));
1112 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1115 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1116 if ((er_flags & QR_PRIVATE)
1117 && ((er_flags & QR_GUESSNAME) == 0)
1118 && ((er_flags & QR_PASSWORDED) == 0))
1119 wprintf("CHECKED ");
1121 wprintf(_("Private - invitation only"));
1123 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1125 wprintf(_("If private, cause current users to forget room"));
1127 wprintf("\n</UL>\n");
1129 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1130 if (er_flags & QR_PREFONLY)
1131 wprintf("CHECKED ");
1133 wprintf(_("Preferred users only"));
1135 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1136 if (er_flags & QR_READONLY)
1137 wprintf("CHECKED ");
1139 wprintf(_("Read-only room"));
1141 /** directory stuff */
1142 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1143 if (er_flags & QR_DIRECTORY)
1144 wprintf("CHECKED ");
1146 wprintf(_("File directory room"));
1148 wprintf("\n<UL><LI>");
1149 wprintf(_("Directory name: "));
1150 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1153 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1154 if (er_flags & QR_UPLOAD)
1155 wprintf("CHECKED ");
1157 wprintf(_("Uploading allowed"));
1159 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1160 if (er_flags & QR_DOWNLOAD)
1161 wprintf("CHECKED ");
1163 wprintf(_("Downloading allowed"));
1165 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1166 if (er_flags & QR_VISDIR)
1167 wprintf("CHECKED ");
1169 wprintf(_("Visible directory"));
1172 /** end of directory stuff */
1174 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1175 if (er_flags & QR_NETWORK)
1176 wprintf("CHECKED ");
1178 wprintf(_("Network shared room"));
1180 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1181 if (er_flags & QR_PERMANENT)
1182 wprintf("CHECKED ");
1184 wprintf(_("Permanent (does not auto-purge)"));
1186 /** start of anon options */
1189 wprintf(_("Anonymous messages"));
1192 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1193 if (((er_flags & QR_ANONONLY) == 0)
1194 && ((er_flags & QR_ANONOPT) == 0))
1195 wprintf("CHECKED ");
1197 wprintf(_("No anonymous messages"));
1199 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1200 if (er_flags & QR_ANONONLY)
1201 wprintf("CHECKED ");
1203 wprintf(_("All messages are anonymous"));
1205 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1206 if (er_flags & QR_ANONOPT)
1207 wprintf("CHECKED ");
1209 wprintf(_("Prompt user when entering messages"));
1212 /* end of anon options */
1215 wprintf(_("Room aide: "));
1217 serv_getln(buf, sizeof buf);
1218 if (buf[0] != '2') {
1219 wprintf("<EM>%s</EM>\n", &buf[4]);
1221 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1222 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1225 wprintf("</UL><CENTER>\n");
1226 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1227 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1229 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1237 /** Sharing the room with other Citadel nodes... */
1238 if (!strcmp(tab, "sharing")) {
1240 shared_with = strdup("");
1241 not_shared_with = strdup("");
1243 /** Learn the current configuration */
1244 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1245 serv_getln(buf, sizeof buf);
1246 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1247 extract_token(node, buf, 0, '|', sizeof node);
1248 not_shared_with = realloc(not_shared_with,
1249 strlen(not_shared_with) + 32);
1250 strcat(not_shared_with, node);
1251 strcat(not_shared_with, "\n");
1255 serv_getln(buf, sizeof buf);
1256 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1257 extract_token(cmd, buf, 0, '|', sizeof cmd);
1258 extract_token(node, buf, 1, '|', sizeof node);
1259 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1260 if (!strcasecmp(cmd, "ignet_push_share")) {
1261 shared_with = realloc(shared_with,
1262 strlen(shared_with) + 32);
1263 strcat(shared_with, node);
1264 if (strlen(remote_room) > 0) {
1265 strcat(shared_with, "|");
1266 strcat(shared_with, remote_room);
1268 strcat(shared_with, "\n");
1272 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1273 extract_token(buf, shared_with, i, '\n', sizeof buf);
1274 extract_token(node, buf, 0, '|', sizeof node);
1275 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1276 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1277 if (!strcasecmp(node, cmd)) {
1278 remove_token(not_shared_with, j, '\n');
1283 /** Display the stuff */
1284 wprintf("<CENTER><br />"
1285 "<TABLE border=1 cellpadding=5><TR>"
1287 wprintf(_("Shared with"));
1288 wprintf("</I></B></TD>"
1290 wprintf(_("Not shared with"));
1291 wprintf("</I></B></TD></TR>\n"
1292 "<TR><TD VALIGN=TOP>\n");
1294 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1295 wprintf(_("Remote node name"));
1296 wprintf("</TD><TD>");
1297 wprintf(_("Remote room name"));
1298 wprintf("</TD><TD>");
1299 wprintf(_("Actions"));
1300 wprintf("</TD></TR>\n");
1302 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1303 extract_token(buf, shared_with, i, '\n', sizeof buf);
1304 extract_token(node, buf, 0, '|', sizeof node);
1305 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1306 if (strlen(node) > 0) {
1307 wprintf("<FORM METHOD=\"POST\" "
1308 "action=\"netedit\">"
1309 "<TR><TD>%s</TD>\n", node);
1312 if (strlen(remote_room) > 0) {
1313 escputs(remote_room);
1319 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1320 "VALUE=\"ignet_push_share|");
1322 if (strlen(remote_room) > 0) {
1324 urlescputs(remote_room);
1327 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1328 "VALUE=\"sharing\">\n");
1329 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1330 "VALUE=\"remove\">\n");
1331 wprintf("<INPUT TYPE=\"submit\" "
1332 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1333 wprintf("</TD></TR></FORM>\n");
1337 wprintf("</TABLE>\n");
1338 wprintf("</TD><TD VALIGN=TOP>\n");
1339 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1340 wprintf(_("Remote node name"));
1341 wprintf("</TD><TD>");
1342 wprintf(_("Remote room name"));
1343 wprintf("</TD><TD>");
1344 wprintf(_("Actions"));
1345 wprintf("</TD></TR>\n");
1347 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1348 extract_token(node, not_shared_with, i, '\n', sizeof node);
1349 if (strlen(node) > 0) {
1350 wprintf("<FORM METHOD=\"POST\" "
1351 "action=\"netedit\">"
1355 "<INPUT TYPE=\"INPUT\" "
1359 wprintf("<INPUT TYPE=\"hidden\" "
1361 "VALUE=\"ignet_push_share|");
1364 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1365 "VALUE=\"sharing\">\n");
1366 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1367 "VALUE=\"add\">\n");
1368 wprintf("<INPUT TYPE=\"submit\" "
1369 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1370 wprintf("</TD></TR></FORM>\n");
1374 wprintf("</TABLE>\n");
1375 wprintf("</TD></TR>"
1376 "</TABLE></CENTER><br />\n"
1377 "<I><B>%s</B><UL><LI>", _("Notes:"));
1378 wprintf(_("When sharing a room, "
1379 "it must be shared from both ends. Adding a node to "
1380 "the 'shared' list sends messages out, but in order to"
1381 " receive messages, the other nodes must be configured"
1382 " to send messages out to your system as well. "
1383 "<LI>If the remote room name is blank, it is assumed "
1384 "that the room name is identical on the remote node."
1385 "<LI>If the remote room name is different, the remote "
1386 "node must also configure the name of the room here."
1392 /** Mailing list management */
1393 if (!strcmp(tab, "listserv")) {
1395 wprintf("<br /><center>"
1396 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1397 "<TR><TD VALIGN=TOP>");
1399 wprintf(_("<i>The contents of this room are being "
1400 "mailed <b>as individual messages</b> "
1401 "to the following list recipients:"
1402 "</i><br /><br />\n"));
1405 serv_getln(buf, sizeof buf);
1406 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1407 extract_token(cmd, buf, 0, '|', sizeof cmd);
1408 if (!strcasecmp(cmd, "listrecp")) {
1409 extract_token(recp, buf, 1, '|', sizeof recp);
1412 wprintf(" <a href=\"netedit&cmd=remove&line="
1415 wprintf("&tab=listserv\">");
1416 wprintf(_("(remove)"));
1417 wprintf("</A><br />");
1420 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1421 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1422 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1423 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1424 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1425 wprintf("</FORM>\n");
1427 wprintf("</TD><TD VALIGN=TOP>\n");
1429 wprintf(_("<i>The contents of this room are being "
1430 "mailed <b>in digest form</b> "
1431 "to the following list recipients:"
1432 "</i><br /><br />\n"));
1435 serv_getln(buf, sizeof buf);
1436 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1437 extract_token(cmd, buf, 0, '|', sizeof cmd);
1438 if (!strcasecmp(cmd, "digestrecp")) {
1439 extract_token(recp, buf, 1, '|', sizeof recp);
1442 wprintf(" <a href=\"netedit&cmd=remove&line="
1445 wprintf("&tab=listserv\">");
1446 wprintf(_("(remove)"));
1447 wprintf("</A><br />");
1450 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1451 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1452 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1453 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1454 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1455 wprintf("</FORM>\n");
1457 wprintf("</TD></TR></TABLE><hr />\n");
1459 if (self_service(999) == 1) {
1460 wprintf(_("This room is configured to allow "
1461 "self-service subscribe/unsubscribe requests."));
1462 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1463 wprintf(_("Click to disable."));
1464 wprintf("</A><br />\n");
1465 wprintf(_("The URL for subscribe/unsubscribe is: "));
1466 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1467 (is_https ? "https" : "http"),
1471 wprintf(_("This room is <i>not</i> configured to allow "
1472 "self-service subscribe/unsubscribe requests."));
1473 wprintf(" <a href=\"toggle_self_service?newval=1&"
1475 wprintf(_("Click to enable."));
1476 wprintf("</A><br />\n");
1480 wprintf("</CENTER>\n");
1484 /** Mailing list management */
1485 if (!strcmp(tab, "expire")) {
1487 serv_puts("GPEX room");
1488 serv_getln(buf, sizeof buf);
1489 if (buf[0] == '2') {
1490 roompolicy = extract_int(&buf[4], 0);
1491 roomvalue = extract_int(&buf[4], 1);
1494 serv_puts("GPEX floor");
1495 serv_getln(buf, sizeof buf);
1496 if (buf[0] == '2') {
1497 floorpolicy = extract_int(&buf[4], 0);
1498 floorvalue = extract_int(&buf[4], 1);
1501 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1502 wprintf("<TABLE border=0 cellspacing=5>\n");
1503 wprintf("<TR><TD>");
1504 wprintf(_("Message expire policy for this room"));
1506 escputs(WC->wc_roomname);
1507 wprintf(")</TD><TD>");
1508 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1509 ((roompolicy == 0) ? "CHECKED" : "") );
1510 wprintf(_("Use the default policy for this floor"));
1511 wprintf("<br />\n");
1512 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1513 ((roompolicy == 1) ? "CHECKED" : "") );
1514 wprintf(_("Never automatically expire messages"));
1515 wprintf("<br />\n");
1516 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1517 ((roompolicy == 2) ? "CHECKED" : "") );
1518 wprintf(_("Expire by message count"));
1519 wprintf("<br />\n");
1520 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1521 ((roompolicy == 3) ? "CHECKED" : "") );
1522 wprintf(_("Expire by message age"));
1524 wprintf(_("Number of messages or days: "));
1525 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1526 wprintf("</TD></TR>\n");
1528 if (WC->axlevel >= 6) {
1529 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1530 wprintf("<TR><TD>");
1531 wprintf(_("Message expire policy for this floor"));
1533 escputs(floorlist[WC->wc_floor]);
1534 wprintf(")</TD><TD>");
1535 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1536 ((floorpolicy == 0) ? "CHECKED" : "") );
1537 wprintf(_("Use the system default"));
1538 wprintf("<br />\n");
1539 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1540 ((floorpolicy == 1) ? "CHECKED" : "") );
1541 wprintf(_("Never automatically expire messages"));
1542 wprintf("<br />\n");
1543 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1544 ((floorpolicy == 2) ? "CHECKED" : "") );
1545 wprintf(_("Expire by message count"));
1546 wprintf("<br />\n");
1547 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1548 ((floorpolicy == 3) ? "CHECKED" : "") );
1549 wprintf(_("Expire by message age"));
1551 wprintf(_("Number of messages or days: "));
1552 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1556 wprintf("<CENTER>\n");
1557 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1558 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1560 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1561 wprintf("</CENTER></TD><TR>\n");
1563 wprintf("</TABLE>\n"
1564 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1570 /** Mailing list management */
1571 if (!strcmp(tab, "access")) {
1575 /** end content of whatever tab is open now */
1576 wprintf("</TD></TR></TABLE></div>\n");
1583 * \brief Toggle self-service list subscription
1585 void toggle_self_service(void) {
1588 newval = atoi(bstr("newval"));
1589 self_service(newval);
1596 * \brief save new parameters for a room
1602 char er_password[10];
1603 char er_dirname[15];
1604 char er_roomaide[26];
1610 if (strlen(bstr("ok_button")) == 0) {
1611 strcpy(WC->ImportantMessage,
1612 _("Cancelled. Changes were not saved."));
1617 serv_getln(buf, sizeof buf);
1619 if (buf[0] != '2') {
1620 strcpy(WC->ImportantMessage, &buf[4]);
1624 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1625 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1626 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1627 er_flags = extract_int(&buf[4], 3);
1629 strcpy(er_roomaide, bstr("er_roomaide"));
1630 if (strlen(er_roomaide) == 0) {
1632 serv_getln(buf, sizeof buf);
1633 if (buf[0] != '2') {
1634 strcpy(er_roomaide, "");
1636 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1639 strcpy(buf, bstr("er_name"));
1641 if (strlen(buf) > 0) {
1642 strcpy(er_name, buf);
1645 strcpy(buf, bstr("er_password"));
1647 if (strlen(buf) > 0)
1648 strcpy(er_password, buf);
1650 strcpy(buf, bstr("er_dirname"));
1652 if (strlen(buf) > 0)
1653 strcpy(er_dirname, buf);
1655 strcpy(buf, bstr("type"));
1656 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1658 if (!strcmp(buf, "invonly")) {
1659 er_flags |= (QR_PRIVATE);
1661 if (!strcmp(buf, "hidden")) {
1662 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1664 if (!strcmp(buf, "passworded")) {
1665 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1667 if (!strcmp(bstr("prefonly"), "yes")) {
1668 er_flags |= QR_PREFONLY;
1670 er_flags &= ~QR_PREFONLY;
1673 if (!strcmp(bstr("readonly"), "yes")) {
1674 er_flags |= QR_READONLY;
1676 er_flags &= ~QR_READONLY;
1679 if (!strcmp(bstr("permanent"), "yes")) {
1680 er_flags |= QR_PERMANENT;
1682 er_flags &= ~QR_PERMANENT;
1685 if (!strcmp(bstr("network"), "yes")) {
1686 er_flags |= QR_NETWORK;
1688 er_flags &= ~QR_NETWORK;
1691 if (!strcmp(bstr("directory"), "yes")) {
1692 er_flags |= QR_DIRECTORY;
1694 er_flags &= ~QR_DIRECTORY;
1697 if (!strcmp(bstr("ulallowed"), "yes")) {
1698 er_flags |= QR_UPLOAD;
1700 er_flags &= ~QR_UPLOAD;
1703 if (!strcmp(bstr("dlallowed"), "yes")) {
1704 er_flags |= QR_DOWNLOAD;
1706 er_flags &= ~QR_DOWNLOAD;
1709 if (!strcmp(bstr("visdir"), "yes")) {
1710 er_flags |= QR_VISDIR;
1712 er_flags &= ~QR_VISDIR;
1715 strcpy(buf, bstr("anon"));
1717 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1718 if (!strcmp(buf, "anononly"))
1719 er_flags |= QR_ANONONLY;
1720 if (!strcmp(buf, "anon2"))
1721 er_flags |= QR_ANONOPT;
1724 if (!strcmp(bstr("bump"), "yes"))
1727 er_floor = atoi(bstr("er_floor"));
1729 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1730 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1732 serv_getln(buf, sizeof buf);
1733 if (buf[0] != '2') {
1734 strcpy(WC->ImportantMessage, &buf[4]);
1740 if (strlen(er_roomaide) > 0) {
1741 sprintf(buf, "SETA %s", er_roomaide);
1743 serv_getln(buf, sizeof buf);
1744 if (buf[0] != '2') {
1745 strcpy(WC->ImportantMessage, &buf[4]);
1746 display_main_menu();
1751 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1758 * \brief Display form for Invite, Kick, and show Who Knows a room
1760 void do_invt_kick(void) {
1761 char buf[SIZ], room[SIZ], username[SIZ];
1764 serv_getln(buf, sizeof buf);
1766 if (buf[0] != '2') {
1770 extract_token(room, &buf[4], 0, '|', sizeof room);
1772 strcpy(username, bstr("username"));
1774 if (strlen(bstr("kick_button")) > 0) {
1775 sprintf(buf, "KICK %s", username);
1777 serv_getln(buf, sizeof buf);
1779 if (buf[0] != '2') {
1780 strcpy(WC->ImportantMessage, &buf[4]);
1782 sprintf(WC->ImportantMessage,
1783 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1788 if (strlen(bstr("invite_button")) > 0) {
1789 sprintf(buf, "INVT %s", username);
1791 serv_getln(buf, sizeof buf);
1793 if (buf[0] != '2') {
1794 strcpy(WC->ImportantMessage, &buf[4]);
1796 sprintf(WC->ImportantMessage,
1797 _("<B><I>User %s invited to room %s.</I></B>\n"),
1808 * \brief Display form for Invite, Kick, and show Who Knows a room
1810 void display_whok(void)
1812 char buf[SIZ], room[SIZ], username[SIZ];
1815 serv_getln(buf, sizeof buf);
1817 if (buf[0] != '2') {
1821 extract_token(room, &buf[4], 0, '|', sizeof room);
1824 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1825 wprintf(_("The users listed below have access to this room. "
1826 "To remove a user from the access list, select the user "
1827 "name from the list and click 'Kick'."));
1828 wprintf("<br /><br />");
1830 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1831 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1832 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1834 serv_getln(buf, sizeof buf);
1835 if (buf[0] == '1') {
1836 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1837 extract_token(username, buf, 0, '|', sizeof username);
1838 wprintf("<OPTION>");
1843 wprintf("</SELECT><br />\n");
1845 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1846 wprintf("</FORM></CENTER>\n");
1848 wprintf("</TD><TD>");
1849 wprintf(_("To grant another user access to this room, enter the "
1850 "user name in the box below and click 'Invite'."));
1851 wprintf("<br /><br />");
1853 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1854 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1855 wprintf(_("Invite:"));
1857 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1858 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1859 "<input type=\"submit\" value=\"%s\">"
1860 "</FORM></CENTER>\n", _("Invite"));
1862 wprintf("</TD></TR></TABLE>\n");
1869 * \brief display the form for entering a new room
1871 void display_entroom(void)
1876 serv_puts("CRE8 0");
1877 serv_getln(buf, sizeof buf);
1879 if (buf[0] != '2') {
1880 strcpy(WC->ImportantMessage, &buf[4]);
1881 display_main_menu();
1885 output_headers(1, 1, 2, 0, 0, 0);
1886 wprintf("<div id=\"banner\">\n"
1887 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1888 "<SPAN CLASS=\"titlebar\">");
1889 wprintf(_("Create a new room"));
1891 "</TD></TR></TABLE>\n"
1892 "</div>\n<div id=\"content\">\n"
1895 wprintf("<div class=\"fix_scrollbar_bug\">"
1896 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1898 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1900 wprintf("<UL><LI>");
1901 wprintf(_("Name of room: "));
1902 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1905 wprintf(_("Resides on floor: "));
1907 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1908 for (i = 0; i < 128; ++i)
1909 if (strlen(floorlist[i]) > 0) {
1910 wprintf("<OPTION ");
1911 wprintf("VALUE=\"%d\">", i);
1912 escputs(floorlist[i]);
1913 wprintf("</OPTION>\n");
1915 wprintf("</SELECT>\n");
1918 * Our clever little snippet of JavaScript automatically selects
1919 * a public room if the view is set to Bulletin Board or wiki, and
1920 * it selects a mailbox room otherwise. The user can override this,
1921 * of course. We also disable the floor selector for mailboxes.
1924 wprintf(_("Default view for room: "));
1925 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1926 " if ( (this.form.er_view.value == 0) "
1927 " || (this.form.er_view.value == 6) ) { "
1928 " this.form.type[0].checked=true; "
1929 " this.form.er_floor.disabled = false; "
1932 " this.form.type[4].checked=true; "
1933 " this.form.er_floor.disabled = true; "
1936 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1937 wprintf("<OPTION %s VALUE=\"%d\">",
1938 ((i == 0) ? "SELECTED" : ""), i );
1939 escputs(viewdefs[i]);
1940 wprintf("</OPTION>\n");
1942 wprintf("</SELECT>\n");
1945 wprintf(_("Type of room:"));
1948 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1949 wprintf("CHECKED OnChange=\""
1950 " if (this.form.type[0].checked == true) { "
1951 " this.form.er_floor.disabled = false; "
1954 wprintf(_("Public (automatically appears to everyone)"));
1956 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1957 " if (this.form.type[1].checked == true) { "
1958 " this.form.er_floor.disabled = false; "
1961 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1963 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1964 " if (this.form.type[2].checked == true) { "
1965 " this.form.er_floor.disabled = false; "
1968 wprintf(_("Private - require password: "));
1969 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1971 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1972 " if (this.form.type[3].checked == true) { "
1973 " this.form.er_floor.disabled = false; "
1976 wprintf(_("Private - invitation only"));
1978 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1980 " if (this.form.type[4].checked == true) { "
1981 " this.form.er_floor.disabled = true; "
1984 wprintf(_("Personal (mailbox for you only)"));
1986 wprintf("\n</UL>\n");
1988 wprintf("<CENTER>\n");
1989 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1991 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1992 wprintf("</CENTER>\n");
1993 wprintf("</FORM>\n<hr />");
1994 serv_printf("MESG roomaccess");
1995 serv_getln(buf, sizeof buf);
1996 if (buf[0] == '1') {
1999 wprintf("</td></tr></table></div>\n");
2007 * \brief support function for entroom() -- sets the default view
2009 void er_set_default_view(int newview) {
2022 serv_getln(buf, sizeof buf);
2023 if (buf[0] != '2') return;
2025 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2026 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2027 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2028 rm_bits1 = extract_int(&buf[4], 3);
2029 rm_floor = extract_int(&buf[4], 4);
2030 rm_listorder = extract_int(&buf[4], 5);
2031 rm_bits2 = extract_int(&buf[4], 7);
2033 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2034 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2035 rm_listorder, newview, rm_bits2
2037 serv_getln(buf, sizeof buf);
2043 * \brief enter a new room
2050 char er_password[SIZ];
2055 if (strlen(bstr("ok_button")) == 0) {
2056 strcpy(WC->ImportantMessage,
2057 _("Cancelled. No new room was created."));
2058 display_main_menu();
2061 strcpy(er_name, bstr("er_name"));
2062 strcpy(er_type, bstr("type"));
2063 strcpy(er_password, bstr("er_password"));
2064 er_floor = atoi(bstr("er_floor"));
2065 er_view = atoi(bstr("er_view"));
2068 if (!strcmp(er_type, "hidden"))
2070 if (!strcmp(er_type, "passworded"))
2072 if (!strcmp(er_type, "invonly"))
2074 if (!strcmp(er_type, "personal"))
2077 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2078 er_name, er_num_type, er_password, er_floor, 0, er_view);
2080 serv_getln(buf, sizeof buf);
2081 if (buf[0] != '2') {
2082 strcpy(WC->ImportantMessage, &buf[4]);
2083 display_main_menu();
2087 do_change_view(er_view); /* Now go there */
2092 * \brief display the screen to enter a private room
2094 void display_private(char *rname, int req_pass)
2096 output_headers(1, 1, 2, 0, 0, 0);
2097 wprintf("<div id=\"banner\">\n"
2098 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2099 "<SPAN CLASS=\"titlebar\">");
2100 wprintf(_("Go to a hidden room"));
2102 "</TD></TR></TABLE>\n"
2103 "</div>\n<div id=\"content\">\n"
2106 wprintf("<div class=\"fix_scrollbar_bug\">"
2107 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2109 wprintf("<CENTER>\n");
2111 wprintf(_("If you know the name of a hidden (guess-name) or "
2112 "passworded room, you can enter that room by typing "
2113 "its name below. Once you gain access to a private "
2114 "room, it will appear in your regular room listings "
2115 "so you don't have to keep returning here."));
2116 wprintf("\n<br /><br />");
2118 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2120 wprintf("<table border=\"0\" cellspacing=\"5\" "
2121 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2123 wprintf(_("Enter room name:"));
2125 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2126 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2129 wprintf("</TD></TR><TR><TD>");
2130 wprintf(_("Enter room password:"));
2131 wprintf("</TD><TD>");
2132 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2134 wprintf("</TD></TR></TABLE><br />\n");
2136 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2138 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2142 wprintf("</FORM>\n");
2143 wprintf("</td></tr></table></div>\n");
2148 * \brief goto a private room
2150 void goto_private(void)
2155 if (strlen(bstr("ok_button")) == 0) {
2156 display_main_menu();
2159 strcpy(hold_rm, WC->wc_roomname);
2160 strcpy(buf, "GOTO ");
2161 strcat(buf, bstr("gr_name"));
2163 strcat(buf, bstr("gr_pass"));
2165 serv_getln(buf, sizeof buf);
2167 if (buf[0] == '2') {
2168 smart_goto(bstr("gr_name"));
2171 if (!strncmp(buf, "540", 3)) {
2172 display_private(bstr("gr_name"), 1);
2175 output_headers(1, 1, 1, 0, 0, 0);
2176 wprintf("%s\n", &buf[4]);
2183 * \brief display the screen to zap a room
2185 void display_zap(void)
2187 output_headers(1, 1, 2, 0, 0, 0);
2189 wprintf("<div id=\"banner\">\n");
2190 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2191 wprintf("<SPAN CLASS=\"titlebar\">");
2192 wprintf(_("Zap (forget/unsubscribe) the current room"));
2193 wprintf("</SPAN>\n");
2194 wprintf("</TD></TR></TABLE>\n");
2195 wprintf("</div>\n<div id=\"content\">\n");
2197 wprintf(_("If you select this option, <em>%s</em> will "
2198 "disappear from your room list. Is this what you wish "
2199 "to do?<br />\n"), WC->wc_roomname);
2201 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2202 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2204 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2205 wprintf("</FORM>\n");
2216 char final_destination[SIZ];
2219 * If the forget-room routine fails for any reason, we fall back
2220 * to the current room; otherwise, we go to the Lobby
2222 strcpy(final_destination, WC->wc_roomname);
2224 if (strlen(bstr("ok_button")) > 0) {
2225 serv_printf("GOTO %s", WC->wc_roomname);
2226 serv_getln(buf, sizeof buf);
2227 if (buf[0] == '2') {
2229 serv_getln(buf, sizeof buf);
2230 if (buf[0] == '2') {
2231 strcpy(final_destination, "_BASEROOM_");
2235 smart_goto(final_destination);
2241 * \brief Delete the current room
2243 void delete_room(void)
2247 serv_puts("KILL 1");
2248 serv_getln(buf, sizeof buf);
2249 if (buf[0] != '2') {
2250 strcpy(WC->ImportantMessage, &buf[4]);
2251 display_main_menu();
2254 smart_goto("_BASEROOM_");
2261 * \brief Perform changes to a room's network configuration
2263 void netedit(void) {
2272 if (strlen(bstr("line"))==0) {
2277 strcpy(line, bstr("prefix"));
2278 strcat(line, bstr("line"));
2279 strcat(line, bstr("suffix"));
2288 serv_getln(buf, sizeof buf);
2289 if (buf[0] != '1') {
2295 /** This loop works for add *or* remove. Spiffy, eh? */
2296 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2297 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2298 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2299 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2300 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2301 if ( (strcasecmp(cmpa0, cmpb0))
2302 || (strcasecmp(cmpa1, cmpb1)) ) {
2303 fprintf(fp, "%s\n", buf);
2309 serv_getln(buf, sizeof buf);
2310 if (buf[0] != '4') {
2316 while (fgets(buf, sizeof buf, fp) != NULL) {
2317 buf[strlen(buf)-1] = 0;
2321 if (strlen(bstr("add_button")) > 0) {
2333 * \brief Convert a room name to a folder-ish-looking name.
2334 * \param folder the folderish name
2335 * \param room the room name
2336 * \param floor the floor name
2337 * \param is_mailbox is it a mailbox?
2339 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2344 * For mailboxes, just do it straight...
2347 sprintf(folder, "My folders|%s", room);
2351 * Otherwise, prefix the floor name as a "public folders" moniker
2354 sprintf(folder, "%s|%s", floorlist[floor], room);
2358 * Replace "\" characters with "|" for pseudo-folder-delimiting
2360 for (i=0; i<strlen(folder); ++i) {
2361 if (folder[i] == '\\') folder[i] = '|';
2369 * \brief Back end for change_view()
2370 * \param newview set newview???
2372 void do_change_view(int newview) {
2375 serv_printf("VIEW %d", newview);
2376 serv_getln(buf, sizeof buf);
2377 WC->wc_view = newview;
2378 smart_goto(WC->wc_roomname);
2384 * \brief Change the view for this room
2386 void change_view(void) {
2389 view = atol(bstr("view"));
2390 do_change_view(view);
2395 * \brief One big expanded tree list view --- like a folder list
2396 * \param fold the folder to view
2397 * \param max_folders how many folders???
2398 * \param num_floors hom many floors???
2400 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2404 int has_subfolders = 0;
2407 parents = malloc(max_folders * sizeof(int));
2409 /** BEGIN TREE MENU */
2410 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2412 /** include NanoTree */
2413 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2415 /** initialize NanoTree */
2416 wprintf("<script type=\"text/javascript\"> \n"
2417 " showRootNode = false; \n"
2418 " sortNodes = false; \n"
2419 " dragable = false; \n"
2421 " function standardClick(treeNode) { \n"
2424 " var closedGif = 'static/folder_closed.gif'; \n"
2425 " var openGif = 'static/folder_open.gif'; \n"
2427 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2431 for (i=0; i<max_folders; ++i) {
2434 if ((i+1) < max_folders) {
2435 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2436 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2441 levels = num_tokens(fold[i].name, '|');
2442 parents[levels] = i;
2444 wprintf("var node%d = new TreeNode(%d, '", i, i);
2446 if (fold[i].selectable) {
2447 wprintf("<a href=\"dotgoto?room=");
2448 urlescputs(fold[i].room);
2453 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2455 else if (fold[i].hasnewmsgs) {
2456 wprintf("<SPAN CLASS=\"roomlist_new\">");
2459 wprintf("<SPAN CLASS=\"roomlist_old\">");
2461 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2466 if (has_subfolders) {
2467 wprintf("new Array(closedGif, openGif)");
2469 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2470 wprintf("'static/viewcontacts_16x.gif'");
2472 else if (fold[i].view == VIEW_CALENDAR) {
2473 wprintf("'static/calarea_16x.gif'");
2475 else if (fold[i].view == VIEW_TASKS) {
2476 wprintf("'static/taskmanag_16x.gif'");
2478 else if (fold[i].view == VIEW_NOTES) {
2479 wprintf("'static/storenotes_16x.gif'");
2481 else if (fold[i].view == VIEW_MAILBOX) {
2482 wprintf("'static/privatemess_16x.gif'");
2485 wprintf("'static/chatrooms_16x.gif'");
2488 urlescputs(fold[i].name);
2492 wprintf("rootNode.addChild(node%d);\n", i);
2495 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2499 wprintf("container = document.getElementById('roomlist_div'); \n"
2505 /** END TREE MENU */
2509 * \brief Boxes and rooms and lists ... oh my!
2510 * \param fold the folder to view
2511 * \param max_folders how many folders???
2512 * \param num_floors hom many floors???
2514 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2516 char floor_name[256];
2517 char old_floor_name[256];
2519 int levels, oldlevels;
2522 static int columns = 3;
2523 int boxes_per_column = 0;
2524 int current_column = 0;
2527 strcpy(floor_name, "");
2528 strcpy(old_floor_name, "");
2531 while (nf % columns != 0) ++nf;
2532 boxes_per_column = (nf / columns);
2533 if (boxes_per_column < 1) boxes_per_column = 1;
2535 /** Outer table (for columnization) */
2536 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2537 "<tr><td valign=top>");
2541 for (i=0; i<max_folders; ++i) {
2543 levels = num_tokens(fold[i].name, '|');
2544 extract_token(floor_name, fold[i].name, 0,
2545 '|', sizeof floor_name);
2547 if ( (strcasecmp(floor_name, old_floor_name))
2548 && (strlen(old_floor_name) > 0) ) {
2550 do_template("endbox");
2553 if ((num_boxes % boxes_per_column) == 0) {
2555 if (current_column < columns) {
2556 wprintf("</td><td valign=top>\n");
2560 strcpy(old_floor_name, floor_name);
2563 /** Begin inner box */
2564 stresc(boxtitle, floor_name, 1, 0);
2565 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2566 do_template("beginbox");
2573 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2574 if (fold[i].selectable) {
2575 wprintf("<a href=\"dotgoto?room=");
2576 urlescputs(fold[i].room);
2582 if (fold[i].hasnewmsgs) {
2583 wprintf("<SPAN CLASS=\"roomlist_new\">");
2586 wprintf("<SPAN CLASS=\"roomlist_old\">");
2588 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2591 if (fold[i].selectable) {
2597 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2598 wprintf(" (INBOX)");
2600 wprintf("<br />\n");
2603 /** End the final inner box */
2604 do_template("endbox");
2606 wprintf("</TD></TR></TABLE>\n");
2610 * \brief print a floor div???
2611 * \param which_floordiv name of the floordiv???
2613 void set_floordiv_expanded(char *which_floordiv) {
2614 begin_ajax_response();
2615 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2616 end_ajax_response();
2620 * \brief view the iconbar
2621 * \param fold the folder to view
2622 * \param max_folders how many folders???
2623 * \param num_floors hom many floors???
2625 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2627 char floor_name[256];
2628 char old_floor_name[256];
2629 char floordivtitle[256];
2630 char floordiv_id[32];
2631 int levels, oldlevels;
2633 int num_drop_targets = 0;
2636 strcpy(floor_name, "");
2637 strcpy(old_floor_name, "");
2641 for (i=0; i<max_folders; ++i) {
2643 levels = num_tokens(fold[i].name, '|');
2644 extract_token(floor_name, fold[i].name, 0,
2645 '|', sizeof floor_name);
2647 if ( (strcasecmp(floor_name, old_floor_name))
2648 && (strlen(old_floor_name) > 0) ) {
2649 /** End inner box */
2651 wprintf("</div>\n"); /** floordiv */
2653 strcpy(old_floor_name, floor_name);
2657 stresc(floordivtitle, floor_name, 0, 0);
2658 sprintf(floordiv_id, "floordiv%d", i);
2659 wprintf("<span class=\"ib_roomlist_floor\" "
2660 "onClick=\"expand_floor('%s')\">"
2661 "%s</span><br>\n", floordiv_id, floordivtitle);
2662 wprintf("<div id=\"%s\" style=\"display:%s\">",
2664 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2671 wprintf("<div id=\"roomdiv%d\">", i);
2673 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2675 /** choose the icon */
2676 if (fold[i].view == VIEW_ADDRESSBOOK) {
2677 icon = "viewcontacts_16x.gif" ;
2679 else if (fold[i].view == VIEW_CALENDAR) {
2680 icon = "calarea_16x.gif" ;
2682 else if (fold[i].view == VIEW_TASKS) {
2683 icon = "taskmanag_16x.gif" ;
2685 else if (fold[i].view == VIEW_NOTES) {
2686 icon = "storenotes_16x.gif" ;
2688 else if (fold[i].view == VIEW_MAILBOX) {
2689 icon = "privatemess_16x.gif" ;
2692 icon = "chatrooms_16x.gif" ;
2695 if (fold[i].selectable) {
2696 wprintf("<a href=\"dotgoto?room=");
2697 urlescputs(fold[i].room);
2699 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2704 if (fold[i].hasnewmsgs) {
2705 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2708 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2710 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2712 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2713 wprintf(" (INBOX)");
2716 if (fold[i].selectable) {
2723 wprintf("</div>\n"); /** roomdiv */
2726 wprintf("</div>\n"); /** floordiv */
2729 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2730 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2732 num_drop_targets = 0;
2734 for (i=0; i<max_folders; ++i) {
2735 levels = num_tokens(fold[i].name, '|');
2737 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2738 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2739 jsescputs(fold[i].room);
2745 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2746 if (strlen(WC->floordiv_expanded) > 1) {
2747 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2751 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2757 * \brief Show the room list.
2758 * (only should get called by
2759 * knrooms() because that's where output_headers() is called from)
2760 * \param viewpref the view preferences???
2763 void list_all_rooms_by_floor(char *viewpref) {
2766 struct folder *fold = NULL;
2768 int max_folders = 0;
2769 int alloc_folders = 0;
2773 int num_floors = 1; /** add an extra one for private folders */
2775 /** If our cached folder list is very old, burn it. */
2776 if (WC->cache_fold != NULL) {
2777 if ((time(NULL) - WC->cache_timestamp) > 300) {
2778 free(WC->cache_fold);
2779 WC->cache_fold = NULL;
2783 /** Can we do the iconbar roomlist from cache? */
2784 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2785 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2789 /** Grab the floor table so we know how to build the list... */
2792 /** Start with the mailboxes */
2795 fold = malloc(sizeof(struct folder));
2796 memset(fold, 0, sizeof(struct folder));
2797 strcpy(fold[0].name, "My folders");
2798 fold[0].is_mailbox = 1;
2800 /** Then add floors */
2802 serv_getln(buf, sizeof buf);
2803 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2804 if (max_folders >= alloc_folders) {
2805 alloc_folders = max_folders + 100;
2806 fold = realloc(fold,
2807 alloc_folders * sizeof(struct folder));
2809 memset(&fold[max_folders], 0, sizeof(struct folder));
2810 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2815 /** Now add rooms */
2817 serv_getln(buf, sizeof buf);
2818 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2819 if (max_folders >= alloc_folders) {
2820 alloc_folders = max_folders + 100;
2821 fold = realloc(fold,
2822 alloc_folders * sizeof(struct folder));
2824 memset(&fold[max_folders], 0, sizeof(struct folder));
2825 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2826 ra_flags = extract_int(buf, 5);
2827 flags = extract_int(buf, 1);
2828 fold[max_folders].floor = extract_int(buf, 2);
2829 fold[max_folders].hasnewmsgs =
2830 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2831 if (flags & QR_MAILBOX) {
2832 fold[max_folders].is_mailbox = 1;
2834 fold[max_folders].view = extract_int(buf, 6);
2835 room_to_folder(fold[max_folders].name,
2836 fold[max_folders].room,
2837 fold[max_folders].floor,
2838 fold[max_folders].is_mailbox);
2839 fold[max_folders].selectable = 1;
2843 /** Bubble-sort the folder list */
2844 for (i=0; i<max_folders; ++i) {
2845 for (j=0; j<(max_folders-1)-i; ++j) {
2846 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2847 swap = strcasecmp(fold[j].name, fold[j+1].name);
2850 if ( (fold[j+1].is_mailbox)
2851 && (!fold[j].is_mailbox)) {
2859 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2860 memcpy(&fold[j], &fold[j+1],
2861 sizeof(struct folder));
2862 memcpy(&fold[j+1], &ftmp,
2863 sizeof(struct folder));
2869 if (!strcasecmp(viewpref, "folders")) {
2870 do_folder_view(fold, max_folders, num_floors);
2872 else if (!strcasecmp(viewpref, "hackish_view")) {
2873 for (i=0; i<max_folders; ++i) {
2874 escputs(fold[i].name);
2875 wprintf("<br />\n");
2878 else if (!strcasecmp(viewpref, "iconbar")) {
2879 do_iconbar_view(fold, max_folders, num_floors);
2882 do_rooms_view(fold, max_folders, num_floors);
2885 /* Don't free the folder list ... cache it for future use! */
2886 if (WC->cache_fold != NULL) {
2887 free(WC->cache_fold);
2889 WC->cache_fold = fold;
2890 WC->cache_max_folders = max_folders;
2891 WC->cache_num_floors = num_floors;
2892 WC->cache_timestamp = time(NULL);
2897 * \brief Do either a known rooms list or a folders list, depending on the
2902 char listviewpref[SIZ];
2904 output_headers(1, 1, 2, 0, 0, 0);
2906 /** Determine whether the user is trying to change views */
2907 if (bstr("view") != NULL) {
2908 if (strlen(bstr("view")) > 0) {
2909 set_preference("roomlistview", bstr("view"), 1);
2913 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2915 if ( (strcasecmp(listviewpref, "folders"))
2916 && (strcasecmp(listviewpref, "table")) ) {
2917 strcpy(listviewpref, "rooms");
2921 wprintf("<div id=\"banner\">\n"
2922 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2923 "<SPAN CLASS=\"titlebar\">"
2925 if (!strcasecmp(listviewpref, "rooms")) {
2926 wprintf(_("Room list"));
2928 if (!strcasecmp(listviewpref, "folders")) {
2929 wprintf(_("Folder list"));
2931 if (!strcasecmp(listviewpref, "table")) {
2932 wprintf(_("Room list"));
2934 wprintf("</SPAN></TD>\n");
2936 /** offer the ability to switch views */
2937 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2938 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2939 "OnChange=\"location.href=roomlistomatic.newview.options"
2940 "[selectedIndex].value\">\n");
2942 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
2945 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2948 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
2949 "View as folder list"
2951 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2954 wprintf("</SELECT><br />");
2956 wprintf("</FORM></TD></TR></TABLE>\n");
2959 "<div id=\"content\">\n");
2961 /** Display the room list in the user's preferred format */
2962 list_all_rooms_by_floor(listviewpref);
2969 * \brief Set the message expire policy for this room and/or floor
2971 void set_room_policy(void) {
2974 if (strlen(bstr("ok_button")) == 0) {
2975 strcpy(WC->ImportantMessage,
2976 _("Cancelled. Changes were not saved."));
2981 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2982 serv_getln(buf, sizeof buf);
2983 strcpy(WC->ImportantMessage, &buf[4]);
2985 if (WC->axlevel >= 6) {
2986 strcat(WC->ImportantMessage, "<br />\n");
2987 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2988 serv_getln(buf, sizeof buf);
2989 strcat(WC->ImportantMessage, &buf[4]);