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", _("Read all messages")
502 if (navbar_style == navbar_default) {
503 switch(WC->wc_view) {
504 case VIEW_ADDRESSBOOK:
506 "<td><a href=\"display_enter\">"
507 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
508 "border=\"0\"><span class=\"navbar_link\">"
510 "</span></a></td>\n", _("Add new contact")
515 "<td><a href=\"display_enter\">"
516 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
517 "border=\"0\"><span class=\"navbar_link\">"
519 "</span></a></td>\n", _("Add new event")
524 "<td><a href=\"display_enter\">"
525 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
526 "border=\"0\"><span class=\"navbar_link\">"
528 "</span></a></td>\n", _("Add new task")
533 "<td><a href=\"display_enter\">"
534 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
535 "border=\"0\"><span class=\"navbar_link\">"
537 "</span></a></td>\n", _("Add new note")
541 safestrncpy(buf, bstr("page"), sizeof buf);
544 "<td><a href=\"display_enter?wikipage=%s\">"
545 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
546 "border=\"0\"><span class=\"navbar_link\">"
548 "</span></a></td>\n", buf, _("Edit this page")
553 "<td><a href=\"display_enter\">"
554 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
555 "border=\"0\"><span class=\"navbar_link\">"
557 "</span></a></td>\n", _("Enter a message")
563 if (navbar_style == navbar_default) wprintf(
567 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
568 "<span class=\"navbar_link\">%s</span></a>"
570 _("Leave all messages marked as unread, go to next room with unread messages"),
574 if (navbar_style == navbar_default) wprintf(
576 "<a href=\"gotonext\" "
578 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
579 "<span class=\"navbar_link\">%s</span></a>"
581 _("Mark all messages as read, go to next room with unread messages"),
585 wprintf("</tr></table></div>\n");
595 * \brief back end routine to take the session to a new room
596 * \param gname room to go to
599 int gotoroom(char *gname)
602 static long ls = (-1L);
605 /** store ungoto information */
606 strcpy(WC->ugname, WC->wc_roomname);
609 /** move to the new room */
610 serv_printf("GOTO %s", gname);
611 serv_getln(buf, sizeof buf);
615 serv_puts("GOTO _BASEROOM_");
616 serv_getln(buf, sizeof buf);
623 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
624 WC->room_flags = extract_int(&buf[4], 4);
625 /* highest_msg_read = extract_int(&buf[4],6);
626 maxmsgnum = extract_int(&buf[4],5);
628 WC->is_mailbox = extract_int(&buf[4],7);
629 ls = extract_long(&buf[4], 6);
630 WC->wc_floor = extract_int(&buf[4], 10);
631 WC->wc_view = extract_int(&buf[4], 11);
632 WC->wc_default_view = extract_int(&buf[4], 12);
633 WC->wc_is_trash = extract_int(&buf[4], 13);
636 WC->is_room_aide = WC->is_aide;
638 WC->is_room_aide = (char) extract_int(&buf[4], 8);
640 remove_march(WC->wc_roomname);
641 if (!strcasecmp(gname, "_BASEROOM_"))
649 * \brief Locate the room on the march list which we most want to go to.
651 * is measured given a "weight" of preference based on various factors.
652 * \param desired_floor the room number on the citadel server
653 * \return the roomname
655 char *pop_march(int desired_floor)
657 static char TheRoom[128];
659 int TheOrder = 32767;
662 struct march *mptr = NULL;
664 strcpy(TheRoom, "_BASEROOM_");
665 if (WC->march == NULL)
668 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
670 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
671 weight = weight + 10000;
672 if (mptr->march_floor == desired_floor)
673 weight = weight + 5000;
675 weight = weight + ((128 - (mptr->march_floor)) * 128);
676 weight = weight + (128 - (mptr->march_order));
678 if (weight > TheWeight) {
680 strcpy(TheRoom, mptr->march_name);
681 TheFloor = mptr->march_floor;
682 TheOrder = mptr->march_order;
691 *\brief Goto next room having unread messages.
692 * We want to skip over rooms that the user has already been to, and take the
693 * user back to the lobby when done. The room we end up in is placed in
694 * newroom - which is set to 0 (the lobby) initially.
695 * We start the search in the current room rather than the beginning to prevent
696 * two or more concurrent users from dragging each other back to the same room.
701 struct march *mptr, *mptr2;
705 * First check to see if the march-mode list is already allocated.
706 * If it is, pop the first room off the list and go there.
709 if (WC->march == NULL) {
711 serv_getln(buf, sizeof buf);
713 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
714 mptr = (struct march *) malloc(sizeof(struct march));
716 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
717 mptr->march_floor = extract_int(buf, 2);
718 mptr->march_order = extract_int(buf, 3);
719 if (WC->march == NULL) {
723 while (mptr2->next != NULL)
729 * add _BASEROOM_ to the end of the march list, so the user will end up
730 * in the system base room (usually the Lobby>) at the end of the loop
732 mptr = (struct march *) malloc(sizeof(struct march));
734 strcpy(mptr->march_name, "_BASEROOM_");
735 if (WC->march == NULL) {
739 while (mptr2->next != NULL)
744 * ...and remove the room we're currently in, so a <G>oto doesn't make us
745 * walk around in circles
747 remove_march(WC->wc_roomname);
749 if (WC->march != NULL) {
750 strcpy(next_room, pop_march(-1));
752 strcpy(next_room, "_BASEROOM_");
756 smart_goto(next_room);
761 * \brief goto next room
762 * \param next_room next room to go to
764 void smart_goto(char *next_room) {
772 * \brief mark all messages in current room as having been read
774 void slrp_highest(void)
779 serv_puts("SLRP HIGHEST");
780 serv_getln(buf, sizeof buf);
782 wprintf("<EM>%s</EM><br />\n", &buf[4]);
789 * \brief un-goto the previous room
795 if (!strcmp(WC->ugname, "")) {
796 smart_goto(WC->wc_roomname);
799 serv_printf("GOTO %s", WC->ugname);
800 serv_getln(buf, sizeof buf);
802 smart_goto(WC->wc_roomname);
805 if (WC->uglsn >= 0L) {
806 serv_printf("SLRP %ld", WC->uglsn);
807 serv_getln(buf, sizeof buf);
809 strcpy(buf, WC->ugname);
810 strcpy(WC->ugname, "");
819 * \brief Set/clear/read the "self-service list subscribe" flag for a room
821 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
822 * \return return the new value.
825 int self_service(int newval) {
826 int current_value = 0;
832 int flags, floor, order, view, flags2;
835 serv_getln(buf, sizeof buf);
836 if (buf[0] != '2') return(0);
838 extract_token(name, &buf[4], 0, '|', sizeof name);
839 extract_token(password, &buf[4], 1, '|', sizeof password);
840 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
841 flags = extract_int(&buf[4], 3);
842 floor = extract_int(&buf[4], 4);
843 order = extract_int(&buf[4], 5);
844 view = extract_int(&buf[4], 6);
845 flags2 = extract_int(&buf[4], 7);
847 if (flags2 & QR2_SELFLIST) {
855 flags2 = flags2 | QR2_SELFLIST;
857 else if (newval == 0) {
858 flags2 = flags2 & ~QR2_SELFLIST;
861 return(current_value);
864 if (newval != current_value) {
865 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
866 name, password, dirname, flags,
867 floor, order, view, flags2);
868 serv_getln(buf, sizeof buf);
881 * \brief display the form for editing a room
883 void display_editroom(void)
888 char remote_room[SIZ];
891 char er_password[10];
893 char er_roomaide[26];
899 char *not_shared_with;
906 if (strlen(tab) == 0) tab = "admin";
910 serv_getln(buf, sizeof buf);
913 strcpy(WC->ImportantMessage, &buf[4]);
917 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
918 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
919 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
920 er_flags = extract_int(&buf[4], 3);
921 er_floor = extract_int(&buf[4], 4);
923 output_headers(1, 1, 1, 0, 0, 0);
925 /** print the tabbed dialog */
927 "<div class=\"fix_scrollbar_bug\">"
928 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
930 "<TD> </TD>\n");
932 if (!strcmp(tab, "admin")) {
933 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
936 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
938 wprintf(_("Administration"));
939 if (!strcmp(tab, "admin")) {
940 wprintf("</SPAN></TD>\n");
943 wprintf("</A></TD>\n");
946 wprintf("<TD> </TD>\n");
948 if (!strcmp(tab, "config")) {
949 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
952 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
954 wprintf(_("Configuration"));
955 if (!strcmp(tab, "config")) {
956 wprintf("</SPAN></TD>\n");
959 wprintf("</A></TD>\n");
962 wprintf("<TD> </TD>\n");
964 if (!strcmp(tab, "expire")) {
965 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
968 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
970 wprintf(_("Message expire policy"));
971 if (!strcmp(tab, "expire")) {
972 wprintf("</SPAN></TD>\n");
975 wprintf("</A></TD>\n");
978 wprintf("<TD> </TD>\n");
980 if (!strcmp(tab, "access")) {
981 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
984 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
986 wprintf(_("Access controls"));
987 if (!strcmp(tab, "access")) {
988 wprintf("</SPAN></TD>\n");
991 wprintf("</A></TD>\n");
994 wprintf("<TD> </TD>\n");
996 if (!strcmp(tab, "sharing")) {
997 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1000 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
1002 wprintf(_("Sharing"));
1003 if (!strcmp(tab, "sharing")) {
1004 wprintf("</SPAN></TD>\n");
1007 wprintf("</A></TD>\n");
1010 wprintf("<TD> </TD>\n");
1012 if (!strcmp(tab, "listserv")) {
1013 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1016 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
1018 wprintf(_("Mailing list service"));
1019 if (!strcmp(tab, "listserv")) {
1020 wprintf("</SPAN></TD>\n");
1023 wprintf("</A></TD>\n");
1026 wprintf("<TD> </TD>\n");
1028 wprintf("</TR></TABLE></div>\n");
1029 /** end tabbed dialog */
1031 /** begin content of whatever tab is open now */
1032 wprintf("<div class=\"fix_scrollbar_bug\">"
1033 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
1036 if (!strcmp(tab, "admin")) {
1038 "<LI><a href=\"delete_room\" "
1039 "onClick=\"return confirm('");
1040 wprintf(_("Are you sure you want to delete this room?"));
1041 wprintf("');\">\n");
1042 wprintf(_("Delete this room"));
1044 "<LI><a href=\"display_editroompic\">\n");
1045 wprintf(_("Set or change the icon for this room's banner"));
1047 "<LI><a href=\"display_editinfo\">\n");
1048 wprintf(_("Edit this room's Info file"));
1053 if (!strcmp(tab, "config")) {
1054 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1056 wprintf("<UL><LI>");
1057 wprintf(_("Name of room: "));
1058 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1064 wprintf(_("Resides on floor: "));
1065 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1066 for (i = 0; i < 128; ++i)
1067 if (strlen(floorlist[i]) > 0) {
1068 wprintf("<OPTION ");
1070 wprintf("SELECTED ");
1071 wprintf("VALUE=\"%d\">", i);
1072 escputs(floorlist[i]);
1073 wprintf("</OPTION>\n");
1075 wprintf("</SELECT>\n");
1078 wprintf(_("Type of room:"));
1081 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1082 if ((er_flags & QR_PRIVATE) == 0)
1083 wprintf("CHECKED ");
1085 wprintf(_("Public room"));
1088 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1089 if ((er_flags & QR_PRIVATE) &&
1090 (er_flags & QR_GUESSNAME))
1091 wprintf("CHECKED ");
1093 wprintf(_("Private - guess name"));
1095 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1096 if ((er_flags & QR_PRIVATE) &&
1097 (er_flags & QR_PASSWORDED))
1098 wprintf("CHECKED ");
1100 wprintf(_("Private - require password:"));
1101 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1104 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1105 if ((er_flags & QR_PRIVATE)
1106 && ((er_flags & QR_GUESSNAME) == 0)
1107 && ((er_flags & QR_PASSWORDED) == 0))
1108 wprintf("CHECKED ");
1110 wprintf(_("Private - invitation only"));
1112 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1114 wprintf(_("If private, cause current users to forget room"));
1116 wprintf("\n</UL>\n");
1118 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1119 if (er_flags & QR_PREFONLY)
1120 wprintf("CHECKED ");
1122 wprintf(_("Preferred users only"));
1124 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1125 if (er_flags & QR_READONLY)
1126 wprintf("CHECKED ");
1128 wprintf(_("Read-only room"));
1130 /** directory stuff */
1131 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1132 if (er_flags & QR_DIRECTORY)
1133 wprintf("CHECKED ");
1135 wprintf(_("File directory room"));
1137 wprintf("\n<UL><LI>");
1138 wprintf(_("Directory name: "));
1139 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1142 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1143 if (er_flags & QR_UPLOAD)
1144 wprintf("CHECKED ");
1146 wprintf(_("Uploading allowed"));
1148 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1149 if (er_flags & QR_DOWNLOAD)
1150 wprintf("CHECKED ");
1152 wprintf(_("Downloading allowed"));
1154 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1155 if (er_flags & QR_VISDIR)
1156 wprintf("CHECKED ");
1158 wprintf(_("Visible directory"));
1161 /** end of directory stuff */
1163 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1164 if (er_flags & QR_NETWORK)
1165 wprintf("CHECKED ");
1167 wprintf(_("Network shared room"));
1169 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1170 if (er_flags & QR_PERMANENT)
1171 wprintf("CHECKED ");
1173 wprintf(_("Permanent (does not auto-purge)"));
1175 /** start of anon options */
1178 wprintf(_("Anonymous messages"));
1181 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1182 if (((er_flags & QR_ANONONLY) == 0)
1183 && ((er_flags & QR_ANONOPT) == 0))
1184 wprintf("CHECKED ");
1186 wprintf(_("No anonymous messages"));
1188 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1189 if (er_flags & QR_ANONONLY)
1190 wprintf("CHECKED ");
1192 wprintf(_("All messages are anonymous"));
1194 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1195 if (er_flags & QR_ANONOPT)
1196 wprintf("CHECKED ");
1198 wprintf(_("Prompt user when entering messages"));
1201 /* end of anon options */
1204 wprintf(_("Room aide: "));
1206 serv_getln(buf, sizeof buf);
1207 if (buf[0] != '2') {
1208 wprintf("<EM>%s</EM>\n", &buf[4]);
1210 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1211 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1214 wprintf("</UL><CENTER>\n");
1215 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1216 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1218 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1226 /** Sharing the room with other Citadel nodes... */
1227 if (!strcmp(tab, "sharing")) {
1229 shared_with = strdup("");
1230 not_shared_with = strdup("");
1232 /** Learn the current configuration */
1233 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1234 serv_getln(buf, sizeof buf);
1235 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1236 extract_token(node, buf, 0, '|', sizeof node);
1237 not_shared_with = realloc(not_shared_with,
1238 strlen(not_shared_with) + 32);
1239 strcat(not_shared_with, node);
1240 strcat(not_shared_with, "\n");
1244 serv_getln(buf, sizeof buf);
1245 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1246 extract_token(cmd, buf, 0, '|', sizeof cmd);
1247 extract_token(node, buf, 1, '|', sizeof node);
1248 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1249 if (!strcasecmp(cmd, "ignet_push_share")) {
1250 shared_with = realloc(shared_with,
1251 strlen(shared_with) + 32);
1252 strcat(shared_with, node);
1253 if (strlen(remote_room) > 0) {
1254 strcat(shared_with, "|");
1255 strcat(shared_with, remote_room);
1257 strcat(shared_with, "\n");
1261 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1262 extract_token(buf, shared_with, i, '\n', sizeof buf);
1263 extract_token(node, buf, 0, '|', sizeof node);
1264 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1265 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1266 if (!strcasecmp(node, cmd)) {
1267 remove_token(not_shared_with, j, '\n');
1272 /** Display the stuff */
1273 wprintf("<CENTER><br />"
1274 "<TABLE border=1 cellpadding=5><TR>"
1276 wprintf(_("Shared with"));
1277 wprintf("</I></B></TD>"
1279 wprintf(_("Not shared with"));
1280 wprintf("</I></B></TD></TR>\n"
1281 "<TR><TD VALIGN=TOP>\n");
1283 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1284 wprintf(_("Remote node name"));
1285 wprintf("</TD><TD>");
1286 wprintf(_("Remote room name"));
1287 wprintf("</TD><TD>");
1288 wprintf(_("Actions"));
1289 wprintf("</TD></TR>\n");
1291 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1292 extract_token(buf, shared_with, i, '\n', sizeof buf);
1293 extract_token(node, buf, 0, '|', sizeof node);
1294 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1295 if (strlen(node) > 0) {
1296 wprintf("<FORM METHOD=\"POST\" "
1297 "action=\"netedit\">"
1298 "<TR><TD>%s</TD>\n", node);
1301 if (strlen(remote_room) > 0) {
1302 escputs(remote_room);
1308 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1309 "VALUE=\"ignet_push_share|");
1311 if (strlen(remote_room) > 0) {
1313 urlescputs(remote_room);
1316 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1317 "VALUE=\"sharing\">\n");
1318 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1319 "VALUE=\"remove\">\n");
1320 wprintf("<INPUT TYPE=\"submit\" "
1321 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1322 wprintf("</TD></TR></FORM>\n");
1326 wprintf("</TABLE>\n");
1327 wprintf("</TD><TD VALIGN=TOP>\n");
1328 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1329 wprintf(_("Remote node name"));
1330 wprintf("</TD><TD>");
1331 wprintf(_("Remote room name"));
1332 wprintf("</TD><TD>");
1333 wprintf(_("Actions"));
1334 wprintf("</TD></TR>\n");
1336 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1337 extract_token(node, not_shared_with, i, '\n', sizeof node);
1338 if (strlen(node) > 0) {
1339 wprintf("<FORM METHOD=\"POST\" "
1340 "action=\"netedit\">"
1344 "<INPUT TYPE=\"INPUT\" "
1348 wprintf("<INPUT TYPE=\"hidden\" "
1350 "VALUE=\"ignet_push_share|");
1353 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1354 "VALUE=\"sharing\">\n");
1355 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1356 "VALUE=\"add\">\n");
1357 wprintf("<INPUT TYPE=\"submit\" "
1358 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1359 wprintf("</TD></TR></FORM>\n");
1363 wprintf("</TABLE>\n");
1364 wprintf("</TD></TR>"
1365 "</TABLE></CENTER><br />\n"
1366 "<I><B>%s</B><UL><LI>", _("Notes:"));
1367 wprintf(_("When sharing a room, "
1368 "it must be shared from both ends. Adding a node to "
1369 "the 'shared' list sends messages out, but in order to"
1370 " receive messages, the other nodes must be configured"
1371 " to send messages out to your system as well. "
1372 "<LI>If the remote room name is blank, it is assumed "
1373 "that the room name is identical on the remote node."
1374 "<LI>If the remote room name is different, the remote "
1375 "node must also configure the name of the room here."
1381 /** Mailing list management */
1382 if (!strcmp(tab, "listserv")) {
1384 wprintf("<br /><center>"
1385 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1386 "<TR><TD VALIGN=TOP>");
1388 wprintf(_("<i>The contents of this room are being "
1389 "mailed <b>as individual messages</b> "
1390 "to the following list recipients:"
1391 "</i><br /><br />\n"));
1394 serv_getln(buf, sizeof buf);
1395 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1396 extract_token(cmd, buf, 0, '|', sizeof cmd);
1397 if (!strcasecmp(cmd, "listrecp")) {
1398 extract_token(recp, buf, 1, '|', sizeof recp);
1401 wprintf(" <a href=\"netedit&cmd=remove&line="
1404 wprintf("&tab=listserv\">");
1405 wprintf(_("(remove)"));
1406 wprintf("</A><br />");
1409 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1410 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1411 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1412 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1413 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1414 wprintf("</FORM>\n");
1416 wprintf("</TD><TD VALIGN=TOP>\n");
1418 wprintf(_("<i>The contents of this room are being "
1419 "mailed <b>in digest form</b> "
1420 "to the following list recipients:"
1421 "</i><br /><br />\n"));
1424 serv_getln(buf, sizeof buf);
1425 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1426 extract_token(cmd, buf, 0, '|', sizeof cmd);
1427 if (!strcasecmp(cmd, "digestrecp")) {
1428 extract_token(recp, buf, 1, '|', sizeof recp);
1431 wprintf(" <a href=\"netedit&cmd=remove&line="
1434 wprintf("&tab=listserv\">");
1435 wprintf(_("(remove)"));
1436 wprintf("</A><br />");
1439 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1440 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1441 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1442 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1443 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1444 wprintf("</FORM>\n");
1446 wprintf("</TD></TR></TABLE><hr />\n");
1448 if (self_service(999) == 1) {
1449 wprintf(_("This room is configured to allow "
1450 "self-service subscribe/unsubscribe requests."));
1451 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1452 wprintf(_("Click to disable."));
1453 wprintf("</A><br />\n");
1454 wprintf(_("The URL for subscribe/unsubscribe is: "));
1455 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1456 (is_https ? "https" : "http"),
1460 wprintf(_("This room is <i>not</i> configured to allow "
1461 "self-service subscribe/unsubscribe requests."));
1462 wprintf(" <a href=\"toggle_self_service?newval=1&"
1464 wprintf(_("Click to enable."));
1465 wprintf("</A><br />\n");
1469 wprintf("</CENTER>\n");
1473 /** Mailing list management */
1474 if (!strcmp(tab, "expire")) {
1476 serv_puts("GPEX room");
1477 serv_getln(buf, sizeof buf);
1478 if (buf[0] == '2') {
1479 roompolicy = extract_int(&buf[4], 0);
1480 roomvalue = extract_int(&buf[4], 1);
1483 serv_puts("GPEX floor");
1484 serv_getln(buf, sizeof buf);
1485 if (buf[0] == '2') {
1486 floorpolicy = extract_int(&buf[4], 0);
1487 floorvalue = extract_int(&buf[4], 1);
1490 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1491 wprintf("<TABLE border=0 cellspacing=5>\n");
1492 wprintf("<TR><TD>");
1493 wprintf(_("Message expire policy for this room"));
1495 escputs(WC->wc_roomname);
1496 wprintf(")</TD><TD>");
1497 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1498 ((roompolicy == 0) ? "CHECKED" : "") );
1499 wprintf(_("Use the default policy for this floor"));
1500 wprintf("<br />\n");
1501 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1502 ((roompolicy == 1) ? "CHECKED" : "") );
1503 wprintf(_("Never automatically expire messages"));
1504 wprintf("<br />\n");
1505 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1506 ((roompolicy == 2) ? "CHECKED" : "") );
1507 wprintf(_("Expire by message count"));
1508 wprintf("<br />\n");
1509 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1510 ((roompolicy == 3) ? "CHECKED" : "") );
1511 wprintf(_("Expire by message age"));
1513 wprintf(_("Number of messages or days: "));
1514 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1515 wprintf("</TD></TR>\n");
1517 if (WC->axlevel >= 6) {
1518 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1519 wprintf("<TR><TD>");
1520 wprintf(_("Message expire policy for this floor"));
1522 escputs(floorlist[WC->wc_floor]);
1523 wprintf(")</TD><TD>");
1524 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1525 ((floorpolicy == 0) ? "CHECKED" : "") );
1526 wprintf(_("Use the system default"));
1527 wprintf("<br />\n");
1528 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1529 ((floorpolicy == 1) ? "CHECKED" : "") );
1530 wprintf(_("Never automatically expire messages"));
1531 wprintf("<br />\n");
1532 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1533 ((floorpolicy == 2) ? "CHECKED" : "") );
1534 wprintf(_("Expire by message count"));
1535 wprintf("<br />\n");
1536 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1537 ((floorpolicy == 3) ? "CHECKED" : "") );
1538 wprintf(_("Expire by message age"));
1540 wprintf(_("Number of messages or days: "));
1541 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1545 wprintf("<CENTER>\n");
1546 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1547 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1549 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1550 wprintf("</CENTER></TD><TR>\n");
1552 wprintf("</TABLE>\n"
1553 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1559 /** Mailing list management */
1560 if (!strcmp(tab, "access")) {
1564 /** end content of whatever tab is open now */
1565 wprintf("</TD></TR></TABLE></div>\n");
1572 * \brief Toggle self-service list subscription
1574 void toggle_self_service(void) {
1577 newval = atoi(bstr("newval"));
1578 self_service(newval);
1585 * \brief save new parameters for a room
1591 char er_password[10];
1592 char er_dirname[15];
1593 char er_roomaide[26];
1599 if (strlen(bstr("ok_button")) == 0) {
1600 strcpy(WC->ImportantMessage,
1601 _("Cancelled. Changes were not saved."));
1606 serv_getln(buf, sizeof buf);
1608 if (buf[0] != '2') {
1609 strcpy(WC->ImportantMessage, &buf[4]);
1613 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1614 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1615 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1616 er_flags = extract_int(&buf[4], 3);
1618 strcpy(er_roomaide, bstr("er_roomaide"));
1619 if (strlen(er_roomaide) == 0) {
1621 serv_getln(buf, sizeof buf);
1622 if (buf[0] != '2') {
1623 strcpy(er_roomaide, "");
1625 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1628 strcpy(buf, bstr("er_name"));
1630 if (strlen(buf) > 0) {
1631 strcpy(er_name, buf);
1634 strcpy(buf, bstr("er_password"));
1636 if (strlen(buf) > 0)
1637 strcpy(er_password, buf);
1639 strcpy(buf, bstr("er_dirname"));
1641 if (strlen(buf) > 0)
1642 strcpy(er_dirname, buf);
1644 strcpy(buf, bstr("type"));
1645 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1647 if (!strcmp(buf, "invonly")) {
1648 er_flags |= (QR_PRIVATE);
1650 if (!strcmp(buf, "hidden")) {
1651 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1653 if (!strcmp(buf, "passworded")) {
1654 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1656 if (!strcmp(bstr("prefonly"), "yes")) {
1657 er_flags |= QR_PREFONLY;
1659 er_flags &= ~QR_PREFONLY;
1662 if (!strcmp(bstr("readonly"), "yes")) {
1663 er_flags |= QR_READONLY;
1665 er_flags &= ~QR_READONLY;
1668 if (!strcmp(bstr("permanent"), "yes")) {
1669 er_flags |= QR_PERMANENT;
1671 er_flags &= ~QR_PERMANENT;
1674 if (!strcmp(bstr("network"), "yes")) {
1675 er_flags |= QR_NETWORK;
1677 er_flags &= ~QR_NETWORK;
1680 if (!strcmp(bstr("directory"), "yes")) {
1681 er_flags |= QR_DIRECTORY;
1683 er_flags &= ~QR_DIRECTORY;
1686 if (!strcmp(bstr("ulallowed"), "yes")) {
1687 er_flags |= QR_UPLOAD;
1689 er_flags &= ~QR_UPLOAD;
1692 if (!strcmp(bstr("dlallowed"), "yes")) {
1693 er_flags |= QR_DOWNLOAD;
1695 er_flags &= ~QR_DOWNLOAD;
1698 if (!strcmp(bstr("visdir"), "yes")) {
1699 er_flags |= QR_VISDIR;
1701 er_flags &= ~QR_VISDIR;
1704 strcpy(buf, bstr("anon"));
1706 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1707 if (!strcmp(buf, "anononly"))
1708 er_flags |= QR_ANONONLY;
1709 if (!strcmp(buf, "anon2"))
1710 er_flags |= QR_ANONOPT;
1713 if (!strcmp(bstr("bump"), "yes"))
1716 er_floor = atoi(bstr("er_floor"));
1718 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1719 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1721 serv_getln(buf, sizeof buf);
1722 if (buf[0] != '2') {
1723 strcpy(WC->ImportantMessage, &buf[4]);
1729 if (strlen(er_roomaide) > 0) {
1730 sprintf(buf, "SETA %s", er_roomaide);
1732 serv_getln(buf, sizeof buf);
1733 if (buf[0] != '2') {
1734 strcpy(WC->ImportantMessage, &buf[4]);
1735 display_main_menu();
1740 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1747 * \brief Display form for Invite, Kick, and show Who Knows a room
1749 void do_invt_kick(void) {
1750 char buf[SIZ], room[SIZ], username[SIZ];
1753 serv_getln(buf, sizeof buf);
1755 if (buf[0] != '2') {
1759 extract_token(room, &buf[4], 0, '|', sizeof room);
1761 strcpy(username, bstr("username"));
1763 if (strlen(bstr("kick_button")) > 0) {
1764 sprintf(buf, "KICK %s", username);
1766 serv_getln(buf, sizeof buf);
1768 if (buf[0] != '2') {
1769 strcpy(WC->ImportantMessage, &buf[4]);
1771 sprintf(WC->ImportantMessage,
1772 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1777 if (strlen(bstr("invite_button")) > 0) {
1778 sprintf(buf, "INVT %s", username);
1780 serv_getln(buf, sizeof buf);
1782 if (buf[0] != '2') {
1783 strcpy(WC->ImportantMessage, &buf[4]);
1785 sprintf(WC->ImportantMessage,
1786 _("<B><I>User %s invited to room %s.</I></B>\n"),
1797 * \brief Display form for Invite, Kick, and show Who Knows a room
1799 void display_whok(void)
1801 char buf[SIZ], room[SIZ], username[SIZ];
1804 serv_getln(buf, sizeof buf);
1806 if (buf[0] != '2') {
1810 extract_token(room, &buf[4], 0, '|', sizeof room);
1813 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1814 wprintf(_("The users listed below have access to this room. "
1815 "To remove a user from the access list, select the user "
1816 "name from the list and click 'Kick'."));
1817 wprintf("<br /><br />");
1819 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1820 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1821 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1823 serv_getln(buf, sizeof buf);
1824 if (buf[0] == '1') {
1825 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1826 extract_token(username, buf, 0, '|', sizeof username);
1827 wprintf("<OPTION>");
1832 wprintf("</SELECT><br />\n");
1834 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1835 wprintf("</FORM></CENTER>\n");
1837 wprintf("</TD><TD>");
1838 wprintf(_("To grant another user access to this room, enter the "
1839 "user name in the box below and click 'Invite'."));
1840 wprintf("<br /><br />");
1842 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1843 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1844 wprintf(_("Invite:"));
1846 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1847 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1848 "<input type=\"submit\" value=\"%s\">"
1849 "</FORM></CENTER>\n", _("Invite"));
1851 wprintf("</TD></TR></TABLE>\n");
1858 * \brief display the form for entering a new room
1860 void display_entroom(void)
1865 serv_puts("CRE8 0");
1866 serv_getln(buf, sizeof buf);
1868 if (buf[0] != '2') {
1869 strcpy(WC->ImportantMessage, &buf[4]);
1870 display_main_menu();
1874 output_headers(1, 1, 2, 0, 0, 0);
1875 wprintf("<div id=\"banner\">\n"
1876 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1877 "<SPAN CLASS=\"titlebar\">");
1878 wprintf(_("Create a new room"));
1880 "</TD></TR></TABLE>\n"
1881 "</div>\n<div id=\"content\">\n"
1884 wprintf("<div class=\"fix_scrollbar_bug\">"
1885 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1887 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1889 wprintf("<UL><LI>");
1890 wprintf(_("Name of room: "));
1891 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1894 wprintf(_("Resides on floor: "));
1896 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1897 for (i = 0; i < 128; ++i)
1898 if (strlen(floorlist[i]) > 0) {
1899 wprintf("<OPTION ");
1900 wprintf("VALUE=\"%d\">", i);
1901 escputs(floorlist[i]);
1902 wprintf("</OPTION>\n");
1904 wprintf("</SELECT>\n");
1907 * Our clever little snippet of JavaScript automatically selects
1908 * a public room if the view is set to Bulletin Board or wiki, and
1909 * it selects a mailbox room otherwise. The user can override this,
1910 * of course. We also disable the floor selector for mailboxes.
1913 wprintf(_("Default view for room: "));
1914 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1915 " if ( (this.form.er_view.value == 0) "
1916 " || (this.form.er_view.value == 6) ) { "
1917 " this.form.type[0].checked=true; "
1918 " this.form.er_floor.disabled = false; "
1921 " this.form.type[4].checked=true; "
1922 " this.form.er_floor.disabled = true; "
1925 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1926 wprintf("<OPTION %s VALUE=\"%d\">",
1927 ((i == 0) ? "SELECTED" : ""), i );
1928 escputs(viewdefs[i]);
1929 wprintf("</OPTION>\n");
1931 wprintf("</SELECT>\n");
1934 wprintf(_("Type of room:"));
1937 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1938 wprintf("CHECKED OnChange=\""
1939 " if (this.form.type[0].checked == true) { "
1940 " this.form.er_floor.disabled = false; "
1943 wprintf(_("Public (automatically appears to everyone)"));
1945 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1946 " if (this.form.type[1].checked == true) { "
1947 " this.form.er_floor.disabled = false; "
1950 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1952 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1953 " if (this.form.type[2].checked == true) { "
1954 " this.form.er_floor.disabled = false; "
1957 wprintf(_("Private - require password: "));
1958 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1960 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1961 " if (this.form.type[3].checked == true) { "
1962 " this.form.er_floor.disabled = false; "
1965 wprintf(_("Private - invitation only"));
1967 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1969 " if (this.form.type[4].checked == true) { "
1970 " this.form.er_floor.disabled = true; "
1973 wprintf(_("Personal (mailbox for you only)"));
1975 wprintf("\n</UL>\n");
1977 wprintf("<CENTER>\n");
1978 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1980 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1981 wprintf("</CENTER>\n");
1982 wprintf("</FORM>\n<hr />");
1983 serv_printf("MESG roomaccess");
1984 serv_getln(buf, sizeof buf);
1985 if (buf[0] == '1') {
1988 wprintf("</td></tr></table></div>\n");
1996 * \brief support function for entroom() -- sets the default view
1998 void er_set_default_view(int newview) {
2011 serv_getln(buf, sizeof buf);
2012 if (buf[0] != '2') return;
2014 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2015 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2016 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2017 rm_bits1 = extract_int(&buf[4], 3);
2018 rm_floor = extract_int(&buf[4], 4);
2019 rm_listorder = extract_int(&buf[4], 5);
2020 rm_bits2 = extract_int(&buf[4], 7);
2022 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2023 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2024 rm_listorder, newview, rm_bits2
2026 serv_getln(buf, sizeof buf);
2032 * \brief enter a new room
2039 char er_password[SIZ];
2044 if (strlen(bstr("ok_button")) == 0) {
2045 strcpy(WC->ImportantMessage,
2046 _("Cancelled. No new room was created."));
2047 display_main_menu();
2050 strcpy(er_name, bstr("er_name"));
2051 strcpy(er_type, bstr("type"));
2052 strcpy(er_password, bstr("er_password"));
2053 er_floor = atoi(bstr("er_floor"));
2054 er_view = atoi(bstr("er_view"));
2057 if (!strcmp(er_type, "hidden"))
2059 if (!strcmp(er_type, "passworded"))
2061 if (!strcmp(er_type, "invonly"))
2063 if (!strcmp(er_type, "personal"))
2066 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2067 er_name, er_num_type, er_password, er_floor, 0, er_view);
2069 serv_getln(buf, sizeof buf);
2070 if (buf[0] != '2') {
2071 strcpy(WC->ImportantMessage, &buf[4]);
2072 display_main_menu();
2076 do_change_view(er_view); /* Now go there */
2081 * \brief display the screen to enter a private room
2083 void display_private(char *rname, int req_pass)
2085 output_headers(1, 1, 2, 0, 0, 0);
2086 wprintf("<div id=\"banner\">\n"
2087 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2088 "<SPAN CLASS=\"titlebar\">");
2089 wprintf(_("Go to a hidden room"));
2091 "</TD></TR></TABLE>\n"
2092 "</div>\n<div id=\"content\">\n"
2095 wprintf("<div class=\"fix_scrollbar_bug\">"
2096 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2098 wprintf("<CENTER>\n");
2100 wprintf(_("If you know the name of a hidden (guess-name) or "
2101 "passworded room, you can enter that room by typing "
2102 "its name below. Once you gain access to a private "
2103 "room, it will appear in your regular room listings "
2104 "so you don't have to keep returning here."));
2105 wprintf("\n<br /><br />");
2107 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2109 wprintf("<table border=\"0\" cellspacing=\"5\" "
2110 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2112 wprintf(_("Enter room name:"));
2114 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2115 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2118 wprintf("</TD></TR><TR><TD>");
2119 wprintf(_("Enter room password:"));
2120 wprintf("</TD><TD>");
2121 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2123 wprintf("</TD></TR></TABLE><br />\n");
2125 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2127 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2131 wprintf("</FORM>\n");
2132 wprintf("</td></tr></table></div>\n");
2137 * \brief goto a private room
2139 void goto_private(void)
2144 if (strlen(bstr("ok_button")) == 0) {
2145 display_main_menu();
2148 strcpy(hold_rm, WC->wc_roomname);
2149 strcpy(buf, "GOTO ");
2150 strcat(buf, bstr("gr_name"));
2152 strcat(buf, bstr("gr_pass"));
2154 serv_getln(buf, sizeof buf);
2156 if (buf[0] == '2') {
2157 smart_goto(bstr("gr_name"));
2160 if (!strncmp(buf, "540", 3)) {
2161 display_private(bstr("gr_name"), 1);
2164 output_headers(1, 1, 1, 0, 0, 0);
2165 wprintf("%s\n", &buf[4]);
2172 * \brief display the screen to zap a room
2174 void display_zap(void)
2176 output_headers(1, 1, 2, 0, 0, 0);
2178 wprintf("<div id=\"banner\">\n");
2179 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2180 wprintf("<SPAN CLASS=\"titlebar\">");
2181 wprintf(_("Zap (forget/unsubscribe) the current room"));
2182 wprintf("</SPAN>\n");
2183 wprintf("</TD></TR></TABLE>\n");
2184 wprintf("</div>\n<div id=\"content\">\n");
2186 wprintf(_("If you select this option, <em>%s</em> will "
2187 "disappear from your room list. Is this what you wish "
2188 "to do?<br />\n"), WC->wc_roomname);
2190 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2191 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2193 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2194 wprintf("</FORM>\n");
2205 char final_destination[SIZ];
2208 * If the forget-room routine fails for any reason, we fall back
2209 * to the current room; otherwise, we go to the Lobby
2211 strcpy(final_destination, WC->wc_roomname);
2213 if (strlen(bstr("ok_button")) > 0) {
2214 serv_printf("GOTO %s", WC->wc_roomname);
2215 serv_getln(buf, sizeof buf);
2216 if (buf[0] == '2') {
2218 serv_getln(buf, sizeof buf);
2219 if (buf[0] == '2') {
2220 strcpy(final_destination, "_BASEROOM_");
2224 smart_goto(final_destination);
2230 * \brief Delete the current room
2232 void delete_room(void)
2236 serv_puts("KILL 1");
2237 serv_getln(buf, sizeof buf);
2238 if (buf[0] != '2') {
2239 strcpy(WC->ImportantMessage, &buf[4]);
2240 display_main_menu();
2243 smart_goto("_BASEROOM_");
2250 * \brief Perform changes to a room's network configuration
2252 void netedit(void) {
2261 if (strlen(bstr("line"))==0) {
2266 strcpy(line, bstr("prefix"));
2267 strcat(line, bstr("line"));
2268 strcat(line, bstr("suffix"));
2277 serv_getln(buf, sizeof buf);
2278 if (buf[0] != '1') {
2284 /** This loop works for add *or* remove. Spiffy, eh? */
2285 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2286 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2287 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2288 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2289 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2290 if ( (strcasecmp(cmpa0, cmpb0))
2291 || (strcasecmp(cmpa1, cmpb1)) ) {
2292 fprintf(fp, "%s\n", buf);
2298 serv_getln(buf, sizeof buf);
2299 if (buf[0] != '4') {
2305 while (fgets(buf, sizeof buf, fp) != NULL) {
2306 buf[strlen(buf)-1] = 0;
2310 if (strlen(bstr("add_button")) > 0) {
2322 * \brief Convert a room name to a folder-ish-looking name.
2323 * \param folder the folderish name
2324 * \param room the room name
2325 * \param floor the floor name
2326 * \param is_mailbox is it a mailbox?
2328 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2333 * For mailboxes, just do it straight...
2336 sprintf(folder, "My folders|%s", room);
2340 * Otherwise, prefix the floor name as a "public folders" moniker
2343 sprintf(folder, "%s|%s", floorlist[floor], room);
2347 * Replace "\" characters with "|" for pseudo-folder-delimiting
2349 for (i=0; i<strlen(folder); ++i) {
2350 if (folder[i] == '\\') folder[i] = '|';
2358 * \brief Back end for change_view()
2359 * \param newview set newview???
2361 void do_change_view(int newview) {
2364 serv_printf("VIEW %d", newview);
2365 serv_getln(buf, sizeof buf);
2366 WC->wc_view = newview;
2367 smart_goto(WC->wc_roomname);
2373 * \brief Change the view for this room
2375 void change_view(void) {
2378 view = atol(bstr("view"));
2379 do_change_view(view);
2384 * \brief One big expanded tree list view --- like a folder list
2385 * \param fold the folder to view
2386 * \param max_folders how many folders???
2387 * \param num_floors hom many floors???
2389 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2393 int has_subfolders = 0;
2396 parents = malloc(max_folders * sizeof(int));
2398 /** BEGIN TREE MENU */
2399 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2401 /** include NanoTree */
2402 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2404 /** initialize NanoTree */
2405 wprintf("<script type=\"text/javascript\"> \n"
2406 " showRootNode = false; \n"
2407 " sortNodes = false; \n"
2408 " dragable = false; \n"
2410 " function standardClick(treeNode) { \n"
2413 " var closedGif = 'static/folder_closed.gif'; \n"
2414 " var openGif = 'static/folder_open.gif'; \n"
2416 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2420 for (i=0; i<max_folders; ++i) {
2423 if ((i+1) < max_folders) {
2424 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2425 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2430 levels = num_tokens(fold[i].name, '|');
2431 parents[levels] = i;
2433 wprintf("var node%d = new TreeNode(%d, '", i, i);
2435 if (fold[i].selectable) {
2436 wprintf("<a href=\"dotgoto?room=");
2437 urlescputs(fold[i].room);
2442 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2444 else if (fold[i].hasnewmsgs) {
2445 wprintf("<SPAN CLASS=\"roomlist_new\">");
2448 wprintf("<SPAN CLASS=\"roomlist_old\">");
2450 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2455 if (has_subfolders) {
2456 wprintf("new Array(closedGif, openGif)");
2458 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2459 wprintf("'static/viewcontacts_16x.gif'");
2461 else if (fold[i].view == VIEW_CALENDAR) {
2462 wprintf("'static/calarea_16x.gif'");
2464 else if (fold[i].view == VIEW_TASKS) {
2465 wprintf("'static/taskmanag_16x.gif'");
2467 else if (fold[i].view == VIEW_NOTES) {
2468 wprintf("'static/storenotes_16x.gif'");
2470 else if (fold[i].view == VIEW_MAILBOX) {
2471 wprintf("'static/privatemess_16x.gif'");
2474 wprintf("'static/chatrooms_16x.gif'");
2477 urlescputs(fold[i].name);
2481 wprintf("rootNode.addChild(node%d);\n", i);
2484 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2488 wprintf("container = document.getElementById('roomlist_div'); \n"
2494 /** END TREE MENU */
2498 * \brief Boxes and rooms and lists ... oh my!
2499 * \param fold the folder to view
2500 * \param max_folders how many folders???
2501 * \param num_floors hom many floors???
2503 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2505 char floor_name[256];
2506 char old_floor_name[256];
2508 int levels, oldlevels;
2511 static int columns = 3;
2512 int boxes_per_column = 0;
2513 int current_column = 0;
2516 strcpy(floor_name, "");
2517 strcpy(old_floor_name, "");
2520 while (nf % columns != 0) ++nf;
2521 boxes_per_column = (nf / columns);
2522 if (boxes_per_column < 1) boxes_per_column = 1;
2524 /** Outer table (for columnization) */
2525 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2526 "<tr><td valign=top>");
2530 for (i=0; i<max_folders; ++i) {
2532 levels = num_tokens(fold[i].name, '|');
2533 extract_token(floor_name, fold[i].name, 0,
2534 '|', sizeof floor_name);
2536 if ( (strcasecmp(floor_name, old_floor_name))
2537 && (strlen(old_floor_name) > 0) ) {
2539 do_template("endbox");
2542 if ((num_boxes % boxes_per_column) == 0) {
2544 if (current_column < columns) {
2545 wprintf("</td><td valign=top>\n");
2549 strcpy(old_floor_name, floor_name);
2552 /** Begin inner box */
2553 stresc(boxtitle, floor_name, 1, 0);
2554 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2555 do_template("beginbox");
2562 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2563 if (fold[i].selectable) {
2564 wprintf("<a href=\"dotgoto?room=");
2565 urlescputs(fold[i].room);
2571 if (fold[i].hasnewmsgs) {
2572 wprintf("<SPAN CLASS=\"roomlist_new\">");
2575 wprintf("<SPAN CLASS=\"roomlist_old\">");
2577 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2580 if (fold[i].selectable) {
2586 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2587 wprintf(" (INBOX)");
2589 wprintf("<br />\n");
2592 /** End the final inner box */
2593 do_template("endbox");
2595 wprintf("</TD></TR></TABLE>\n");
2599 * \brief print a floor div???
2600 * \param which_floordiv name of the floordiv???
2602 void set_floordiv_expanded(char *which_floordiv) {
2603 begin_ajax_response();
2604 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2605 end_ajax_response();
2609 * \brief view the iconbar
2610 * \param fold the folder to view
2611 * \param max_folders how many folders???
2612 * \param num_floors hom many floors???
2614 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2616 char floor_name[256];
2617 char old_floor_name[256];
2618 char floordivtitle[256];
2619 char floordiv_id[32];
2620 int levels, oldlevels;
2622 int num_drop_targets = 0;
2625 strcpy(floor_name, "");
2626 strcpy(old_floor_name, "");
2630 for (i=0; i<max_folders; ++i) {
2632 levels = num_tokens(fold[i].name, '|');
2633 extract_token(floor_name, fold[i].name, 0,
2634 '|', sizeof floor_name);
2636 if ( (strcasecmp(floor_name, old_floor_name))
2637 && (strlen(old_floor_name) > 0) ) {
2638 /** End inner box */
2640 wprintf("</div>\n"); /** floordiv */
2642 strcpy(old_floor_name, floor_name);
2646 stresc(floordivtitle, floor_name, 0, 0);
2647 sprintf(floordiv_id, "floordiv%d", i);
2648 wprintf("<span class=\"ib_roomlist_floor\" "
2649 "onClick=\"expand_floor('%s')\">"
2650 "%s</span><br>\n", floordiv_id, floordivtitle);
2651 wprintf("<div id=\"%s\" style=\"display:%s\">",
2653 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2660 wprintf("<div id=\"roomdiv%d\">", i);
2662 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2664 /** choose the icon */
2665 if (fold[i].view == VIEW_ADDRESSBOOK) {
2666 icon = "viewcontacts_16x.gif" ;
2668 else if (fold[i].view == VIEW_CALENDAR) {
2669 icon = "calarea_16x.gif" ;
2671 else if (fold[i].view == VIEW_TASKS) {
2672 icon = "taskmanag_16x.gif" ;
2674 else if (fold[i].view == VIEW_NOTES) {
2675 icon = "storenotes_16x.gif" ;
2677 else if (fold[i].view == VIEW_MAILBOX) {
2678 icon = "privatemess_16x.gif" ;
2681 icon = "chatrooms_16x.gif" ;
2684 if (fold[i].selectable) {
2685 wprintf("<a href=\"dotgoto?room=");
2686 urlescputs(fold[i].room);
2688 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2693 if (fold[i].hasnewmsgs) {
2694 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2697 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2699 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2701 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2702 wprintf(" (INBOX)");
2705 if (fold[i].selectable) {
2712 wprintf("</div>\n"); /** roomdiv */
2715 wprintf("</div>\n"); /** floordiv */
2718 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2719 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2721 num_drop_targets = 0;
2723 for (i=0; i<max_folders; ++i) {
2724 levels = num_tokens(fold[i].name, '|');
2726 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2727 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2728 jsescputs(fold[i].room);
2734 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2735 if (strlen(WC->floordiv_expanded) > 1) {
2736 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2740 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2746 * \brief Show the room list.
2747 * (only should get called by
2748 * knrooms() because that's where output_headers() is called from)
2749 * \param viewpref the view preferences???
2752 void list_all_rooms_by_floor(char *viewpref) {
2755 struct folder *fold = NULL;
2757 int max_folders = 0;
2758 int alloc_folders = 0;
2762 int num_floors = 1; /** add an extra one for private folders */
2764 /** If our cached folder list is very old, burn it. */
2765 if (WC->cache_fold != NULL) {
2766 if ((time(NULL) - WC->cache_timestamp) > 300) {
2767 free(WC->cache_fold);
2768 WC->cache_fold = NULL;
2772 /** Can we do the iconbar roomlist from cache? */
2773 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2774 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2778 /** Grab the floor table so we know how to build the list... */
2781 /** Start with the mailboxes */
2784 fold = malloc(sizeof(struct folder));
2785 memset(fold, 0, sizeof(struct folder));
2786 strcpy(fold[0].name, "My folders");
2787 fold[0].is_mailbox = 1;
2789 /** Then add floors */
2791 serv_getln(buf, sizeof buf);
2792 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2793 if (max_folders >= alloc_folders) {
2794 alloc_folders = max_folders + 100;
2795 fold = realloc(fold,
2796 alloc_folders * sizeof(struct folder));
2798 memset(&fold[max_folders], 0, sizeof(struct folder));
2799 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2804 /** Now add rooms */
2806 serv_getln(buf, sizeof buf);
2807 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2808 if (max_folders >= alloc_folders) {
2809 alloc_folders = max_folders + 100;
2810 fold = realloc(fold,
2811 alloc_folders * sizeof(struct folder));
2813 memset(&fold[max_folders], 0, sizeof(struct folder));
2814 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2815 ra_flags = extract_int(buf, 5);
2816 flags = extract_int(buf, 1);
2817 fold[max_folders].floor = extract_int(buf, 2);
2818 fold[max_folders].hasnewmsgs =
2819 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2820 if (flags & QR_MAILBOX) {
2821 fold[max_folders].is_mailbox = 1;
2823 fold[max_folders].view = extract_int(buf, 6);
2824 room_to_folder(fold[max_folders].name,
2825 fold[max_folders].room,
2826 fold[max_folders].floor,
2827 fold[max_folders].is_mailbox);
2828 fold[max_folders].selectable = 1;
2832 /** Bubble-sort the folder list */
2833 for (i=0; i<max_folders; ++i) {
2834 for (j=0; j<(max_folders-1)-i; ++j) {
2835 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2836 swap = strcasecmp(fold[j].name, fold[j+1].name);
2839 if ( (fold[j+1].is_mailbox)
2840 && (!fold[j].is_mailbox)) {
2848 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2849 memcpy(&fold[j], &fold[j+1],
2850 sizeof(struct folder));
2851 memcpy(&fold[j+1], &ftmp,
2852 sizeof(struct folder));
2858 if (!strcasecmp(viewpref, "folders")) {
2859 do_folder_view(fold, max_folders, num_floors);
2861 else if (!strcasecmp(viewpref, "hackish_view")) {
2862 for (i=0; i<max_folders; ++i) {
2863 escputs(fold[i].name);
2864 wprintf("<br />\n");
2867 else if (!strcasecmp(viewpref, "iconbar")) {
2868 do_iconbar_view(fold, max_folders, num_floors);
2871 do_rooms_view(fold, max_folders, num_floors);
2874 /* Don't free the folder list ... cache it for future use! */
2875 if (WC->cache_fold != NULL) {
2876 free(WC->cache_fold);
2878 WC->cache_fold = fold;
2879 WC->cache_max_folders = max_folders;
2880 WC->cache_num_floors = num_floors;
2881 WC->cache_timestamp = time(NULL);
2886 * \brief Do either a known rooms list or a folders list, depending on the
2891 char listviewpref[SIZ];
2893 output_headers(1, 1, 2, 0, 0, 0);
2895 /** Determine whether the user is trying to change views */
2896 if (bstr("view") != NULL) {
2897 if (strlen(bstr("view")) > 0) {
2898 set_preference("roomlistview", bstr("view"), 1);
2902 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2904 if ( (strcasecmp(listviewpref, "folders"))
2905 && (strcasecmp(listviewpref, "table")) ) {
2906 strcpy(listviewpref, "rooms");
2910 wprintf("<div id=\"banner\">\n"
2911 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2912 "<SPAN CLASS=\"titlebar\">"
2914 if (!strcasecmp(listviewpref, "rooms")) {
2915 wprintf(_("Room list"));
2917 if (!strcasecmp(listviewpref, "folders")) {
2918 wprintf(_("Folder list"));
2920 if (!strcasecmp(listviewpref, "table")) {
2921 wprintf(_("Room list"));
2923 wprintf("</SPAN></TD>\n");
2925 /** offer the ability to switch views */
2926 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2927 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2928 "OnChange=\"location.href=roomlistomatic.newview.options"
2929 "[selectedIndex].value\">\n");
2931 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
2934 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2937 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
2938 "View as folder list"
2940 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2943 wprintf("</SELECT><br />");
2945 wprintf("</FORM></TD></TR></TABLE>\n");
2948 "<div id=\"content\">\n");
2950 /** Display the room list in the user's preferred format */
2951 list_all_rooms_by_floor(listviewpref);
2958 * \brief Set the message expire policy for this room and/or floor
2960 void set_room_policy(void) {
2963 if (strlen(bstr("ok_button")) == 0) {
2964 strcpy(WC->ImportantMessage,
2965 _("Cancelled. Changes were not saved."));
2970 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2971 serv_getln(buf, sizeof buf);
2972 strcpy(WC->ImportantMessage, &buf[4]);
2974 if (WC->axlevel >= 6) {
2975 strcat(WC->ImportantMessage, "<br />\n");
2976 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2977 serv_getln(buf, sizeof buf);
2978 strcat(WC->ImportantMessage, &buf[4]);