5 * \defgroup RoomOps Lots of different room-related operations.
6 * \ingroup CitadelCommunitacion
11 char floorlist[128][SIZ]; /**< list of our floor names */
13 char *viewdefs[8]; /**< the different kinds of available views */
16 * \brief initialize the viewdefs with localized strings
18 void initialize_viewdefs(void) {
19 viewdefs[0] = _("Bulletin Board");
20 viewdefs[1] = _("Mail Folder");
21 viewdefs[2] = _("Address Book");
22 viewdefs[3] = _("Calendar");
23 viewdefs[4] = _("Task List");
24 viewdefs[5] = _("Notes List");
25 viewdefs[6] = _("Wiki");
26 viewdefs[7] = _("Calendar List");
30 * \brief Determine which views are allowed as the default for creating a new room.
32 * \param which_view The view ID being queried.
34 int is_view_allowed_as_default(int which_view)
37 case VIEW_BBS: return(1);
38 case VIEW_MAILBOX: return(1);
39 case VIEW_ADDRESSBOOK: return(1);
40 case VIEW_CALENDAR: return(1);
41 case VIEW_TASKS: return(1);
42 case VIEW_NOTES: return(1);
43 case VIEW_WIKI: return(0); /**< because it isn't finished yet */
44 case VIEW_CALBRIEF: return(0);
45 default: return(0); /**< should never get here */
51 * \brief load the list of floors
53 void load_floorlist(void)
58 for (a = 0; a < 128; ++a)
62 serv_getln(buf, sizeof buf);
64 strcpy(floorlist[0], "Main Floor");
67 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
68 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
74 * \brief Free a session's march list
76 * \param wcf Pointer to session being cleared
78 void free_march_list(struct wcsession *wcf)
82 while (wcf->march != NULL) {
83 mptr = wcf->march->next;
93 * \brief remove a room from the march list
95 void remove_march(char *aaa)
97 struct march *mptr, *mptr2;
99 if (WC->march == NULL)
102 if (!strcasecmp(WC->march->march_name, aaa)) {
103 mptr = WC->march->next;
109 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
110 if (!strcasecmp(mptr->march_name, aaa)) {
111 mptr2->next = mptr->next;
124 * \brief display rooms in tree structure???
125 * \param rp the roomlist to build a tree from
127 void room_tree_list(struct roomlisting *rp)
136 room_tree_list(rp->lnext);
138 strcpy(rmname, rp->rlname);
141 wprintf("<a href=\"dotgoto&room=");
145 escputs1(rmname, 1, 1);
146 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
148 else if (f & QR_DIRECTORY)
150 else if (f & QR_NETWORK)
154 wprintf("</A><TT> </TT>\n");
156 room_tree_list(rp->rnext);
162 * \brief Room ordering stuff (compare first by floor, then by order)
163 * \param r1 first roomlist to compare
164 * \param r2 second roomlist co compare
165 * \return are they the same???
167 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
169 if ((r1 == NULL) && (r2 == NULL))
175 if (r1->rlfloor < r2->rlfloor)
177 if (r1->rlfloor > r2->rlfloor)
179 if (r1->rlorder < r2->rlorder)
181 if (r1->rlorder > r2->rlorder)
188 * \brief Common code for all room listings
189 * \param variety what???
191 void listrms(char *variety)
196 struct roomlisting *rl = NULL;
197 struct roomlisting *rp;
198 struct roomlisting *rs;
200 /** Ask the server for a room list */
202 serv_getln(buf, sizeof buf);
208 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
210 rp = malloc(sizeof(struct roomlisting));
211 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
212 rp->rlflags = extract_int(buf, 1);
213 rp->rlfloor = extract_int(buf, 2);
214 rp->rlorder = extract_int(buf, 3);
223 if (rordercmp(rp, rs) < 0) {
224 if (rs->lnext == NULL) {
231 if (rs->rnext == NULL) {
244 * If no rooms were listed, print an nbsp to make the cell
245 * borders show up anyway.
247 if (num_rooms == 0) wprintf(" ");
252 * \brief list all forgotten rooms
254 void zapped_list(void)
256 output_headers(1, 1, 0, 0, 0, 0);
258 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
259 do_template("beginbox");
263 wprintf("<br /><br />\n");
264 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
265 do_template("endbox");
271 * \brief read this room's info file (set v to 1 for verbose mode)
278 serv_getln(buf, sizeof buf);
280 wprintf("<div class=\"infos\" "
281 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
283 wprintf(_("Room info"));
284 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">"
285 "<p class=\"close_infos\" "
286 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
288 wprintf(_("Close window"));
302 * \brief Display room banner icon.
303 * The server doesn't actually
304 * need the room name, but we supply it in order to
305 * keep the browser from using a cached icon from
308 void embed_room_graphic(void) {
311 serv_puts("OIMG _roompic_");
312 serv_getln(buf, sizeof buf);
314 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
315 urlescputs(WC->wc_roomname);
318 serv_getln(buf, sizeof buf);
320 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
321 wprintf("<img height=48 width=48 src=\""
322 "static/viewcontacts_48x.gif"
326 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
327 wprintf("<img height=48 width=48 src=\""
328 "static/calarea_48x.gif"
332 else if (WC->wc_view == VIEW_TASKS) {
333 wprintf("<img height=48 width=48 src=\""
334 "static/taskmanag_48x.gif"
338 else if (WC->wc_view == VIEW_NOTES) {
339 wprintf("<img height=48 width=48 src=\""
340 "static/storenotes_48x.gif"
344 else if (WC->wc_view == VIEW_MAILBOX) {
345 wprintf("<img height=48 width=48 src=\""
346 "static/privatemess_48x.gif"
351 wprintf("<img height=48 width=48 src=\""
352 "static/chatrooms_48x.gif"
362 * \brief Display the current view and offer an option to change it
364 void embed_view_o_matic(void) {
367 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
368 "<label for=\"view_name\">");
369 wprintf(_("View as:"));
371 "<select name=\"newview\" size=\"1\" "
372 "id=\"view_name\" class=\"selectbox\" "
373 "OnChange=\"location.href=viewomatic.newview.options"
374 "[selectedIndex].value\">\n");
376 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
378 * Only offer the views that make sense, given the default
379 * view for the room. For example, don't offer a Calendar
380 * view in a non-Calendar room.
384 || (i == WC->wc_default_view) /**< default */
385 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
386 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
387 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
390 wprintf("<option %s value=\"changeview?view=%d\">",
391 ((i == WC->wc_view) ? "selected" : ""),
393 escputs(viewdefs[i]);
394 wprintf("</option>\n");
397 wprintf("</select></form>\n");
402 * \brief Display a search box
404 void embed_search_o_matic(void) {
405 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n"
406 "<label for=\"search_name\">");
407 wprintf(_("Search: "));
408 wprintf("</label> <input "
409 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
410 "id=\"search_name\" class=\"inputbox\">\n"
412 wprintf("</select></form>\n");
417 * \brief Embed the room banner
419 * \param got The information returned from a GOTO server command
420 * \param navbar_style Determines which navigation buttons to display
424 void embed_room_banner(char *got, int navbar_style) {
428 * We need to have the information returned by a GOTO server command.
429 * If it isn't supplied, we fake it by issuing our own GOTO.
432 serv_printf("GOTO %s", WC->wc_roomname);
433 serv_getln(buf, sizeof buf);
437 /** The browser needs some information for its own use */
438 wprintf("<script type=\"text/javascript\"> \n"
439 " room_is_trash = %d; \n"
445 * If the user happens to select the "make this my start page" link,
446 * we want it to remember the URL as a "/dotskip" one instead of
447 * a "skip" or "gotonext" or something like that.
449 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
452 /** Check for new mail. */
453 WC->new_mail = extract_int(&got[4], 9);
454 WC->wc_view = extract_int(&got[4], 11);
456 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
457 svprintf("NUMMSGS", WCS_STRING,
458 _("%d new of %d messages"),
459 extract_int(&got[4], 1),
460 extract_int(&got[4], 2)
462 svcallback("ROOMPIC", embed_room_graphic);
463 svcallback("ROOMINFO", readinfo);
464 svcallback("VIEWOMATIC", embed_view_o_matic);
465 svcallback("SEARCHOMATIC", embed_search_o_matic);
466 svcallback("START", offer_start_page);
468 do_template("roombanner");
469 if (navbar_style != navbar_none) {
471 wprintf("<div id=\"navbar\">\n"
476 if (navbar_style == navbar_default) wprintf(
477 "<li class=\"ungoto\">"
478 "<a href=\"ungoto\">"
479 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
480 "<span class=\"navbar_link\">%s</span></A>"
481 "</li>\n", _("Ungoto")
484 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
486 "<li class=\"newmess\">"
487 "<a href=\"readnew\">"
488 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
489 "<span class=\"navbar_link\">%s</span></A>"
490 "</li>\n", _("Read new messages")
494 if (navbar_style == navbar_default) {
495 switch(WC->wc_view) {
496 case VIEW_ADDRESSBOOK:
498 "<li class=\"viewcontacts\">"
499 "<a href=\"readfwd\">"
500 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
502 "<span class=\"navbar_link\">"
504 "</span></a></li>\n", _("View contacts")
509 "<li class=\"staskday\">"
510 "<a href=\"readfwd?calview=day\">"
511 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
513 "<span class=\"navbar_link\">"
515 "</span></a></li>\n", _("Day view")
518 "<li class=\"monthview\">"
519 "<a href=\"readfwd?calview=month\">"
520 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
522 "<span class=\"navbar_link\">"
524 "</span></a></li>\n", _("Month view")
529 "<li class=\"monthview\">"
530 "<a href=\"readfwd?calview=month\">"
531 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
533 "<span class=\"navbar_link\">"
535 "</span></a></li>\n", _("Calendar list")
540 "<li class=\"taskmanag\">"
541 "<a href=\"readfwd\">"
542 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
544 "<span class=\"navbar_link\">"
546 "</span></a></li>\n", _("View tasks")
551 "<li class=\"viewnotes\">"
552 "<a href=\"readfwd\">"
553 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
555 "<span class=\"navbar_link\">"
557 "</span></a></li>\n", _("View notes")
562 "<li class=\"readallmess\">"
563 "<a href=\"readfwd\">"
564 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
566 "<span class=\"navbar_link\">"
568 "</span></a></li>\n", _("View message list")
573 "<li class=\"readallmess\">"
574 "<a href=\"readfwd\">"
575 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
577 "<span class=\"navbar_link\">"
579 "</span></a></li>\n", _("Wiki home")
584 "<li class=\"readallmess\">"
585 "<a href=\"readfwd\">"
586 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
588 "<span class=\"navbar_link\">"
590 "</span></a></li>\n", _("Read all messages")
596 if (navbar_style == navbar_default) {
597 switch(WC->wc_view) {
598 case VIEW_ADDRESSBOOK:
600 "<li class=\"addnewcontact\">"
601 "<a href=\"display_enter\">"
602 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
603 "border=\"0\"><span class=\"navbar_link\">"
605 "</span></a></li>\n", _("Add new contact")
610 wprintf("<li class=\"addevent\"><a href=\"display_enter");
611 if (strlen(bstr("year")) > 0) wprintf("?year=%s", bstr("year"));
612 if (strlen(bstr("month")) > 0) wprintf("?month=%s", bstr("month"));
613 if (strlen(bstr("day")) > 0) wprintf("?day=%s", bstr("day"));
615 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
616 "border=\"0\"><span class=\"navbar_link\">"
618 "</span></a></li>\n", _("Add new event")
623 "<li class=\"newmess\">"
624 "<a href=\"display_enter\">"
625 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
626 "border=\"0\"><span class=\"navbar_link\">"
628 "</span></a></li>\n", _("Add new task")
633 "<li class=\"enternewnote\">"
634 "<a href=\"javascript:add_new_note();\">"
635 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
636 "border=\"0\"><span class=\"navbar_link\">"
638 "</span></a></li>\n", _("Add new note")
642 safestrncpy(buf, bstr("page"), sizeof buf);
645 "<li class=\"newmess\">"
646 "<a href=\"display_enter?wikipage=%s\">"
647 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
648 "border=\"0\"><span class=\"navbar_link\">"
650 "</span></a></li>\n", buf, _("Edit this page")
655 "<li class=\"newmess\">"
656 "<a href=\"display_enter\">"
657 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
658 "border=\"0\"><span class=\"navbar_link\">"
660 "</span></a></li>\n", _("Write mail")
665 "<li class=\"newmess\">"
666 "<a href=\"display_enter\">"
667 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
668 "border=\"0\"><span class=\"navbar_link\">"
670 "</span></a></li>\n", _("Enter a message")
676 if (navbar_style == navbar_default) wprintf(
677 "<li class=\"skipthisroom\">"
680 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
681 "<span class=\"navbar_link\">%s</span></a>"
683 _("Leave all messages marked as unread, go to next room with unread messages"),
687 if (navbar_style == navbar_default) wprintf(
688 "<li class=\"markngo\">"
689 "<a href=\"gotonext\" "
691 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
692 "<span class=\"navbar_link\">%s</span></a>"
694 _("Mark all messages as read, go to next room with unread messages"),
698 wprintf("</ul></div>\n");
705 * \brief back end routine to take the session to a new room
706 * \param gname room to go to
709 int gotoroom(char *gname)
712 static long ls = (-1L);
715 /** store ungoto information */
716 strcpy(WC->ugname, WC->wc_roomname);
719 /** move to the new room */
720 serv_printf("GOTO %s", gname);
721 serv_getln(buf, sizeof buf);
725 serv_puts("GOTO _BASEROOM_");
726 serv_getln(buf, sizeof buf);
733 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
734 WC->room_flags = extract_int(&buf[4], 4);
735 /* highest_msg_read = extract_int(&buf[4],6);
736 maxmsgnum = extract_int(&buf[4],5);
738 WC->is_mailbox = extract_int(&buf[4],7);
739 ls = extract_long(&buf[4], 6);
740 WC->wc_floor = extract_int(&buf[4], 10);
741 WC->wc_view = extract_int(&buf[4], 11);
742 WC->wc_default_view = extract_int(&buf[4], 12);
743 WC->wc_is_trash = extract_int(&buf[4], 13);
744 WC->room_flags2 = extract_int(&buf[4], 14);
747 WC->is_room_aide = WC->is_aide;
749 WC->is_room_aide = (char) extract_int(&buf[4], 8);
751 remove_march(WC->wc_roomname);
752 if (!strcasecmp(gname, "_BASEROOM_"))
760 * \brief Locate the room on the march list which we most want to go to.
762 * is measured given a "weight" of preference based on various factors.
763 * \param desired_floor the room number on the citadel server
764 * \return the roomname
766 char *pop_march(int desired_floor)
768 static char TheRoom[128];
770 int TheOrder = 32767;
773 struct march *mptr = NULL;
775 strcpy(TheRoom, "_BASEROOM_");
776 if (WC->march == NULL)
779 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
781 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
782 weight = weight + 10000;
783 if (mptr->march_floor == desired_floor)
784 weight = weight + 5000;
786 weight = weight + ((128 - (mptr->march_floor)) * 128);
787 weight = weight + (128 - (mptr->march_order));
789 if (weight > TheWeight) {
791 strcpy(TheRoom, mptr->march_name);
792 TheFloor = mptr->march_floor;
793 TheOrder = mptr->march_order;
802 *\brief Goto next room having unread messages.
803 * We want to skip over rooms that the user has already been to, and take the
804 * user back to the lobby when done. The room we end up in is placed in
805 * newroom - which is set to 0 (the lobby) initially.
806 * We start the search in the current room rather than the beginning to prevent
807 * two or more concurrent users from dragging each other back to the same room.
812 struct march *mptr, *mptr2;
817 * First check to see if the march-mode list is already allocated.
818 * If it is, pop the first room off the list and go there.
821 if (WC->march == NULL) {
823 serv_getln(buf, sizeof buf);
825 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
826 extract_token(room_name, buf, 0, '|', sizeof room_name);
827 if (strcasecmp(room_name, WC->wc_roomname)) {
828 mptr = (struct march *) malloc(sizeof(struct march));
830 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
831 mptr->march_floor = extract_int(buf, 2);
832 mptr->march_order = extract_int(buf, 3);
833 if (WC->march == NULL) {
837 while (mptr2->next != NULL)
844 * add _BASEROOM_ to the end of the march list, so the user will end up
845 * in the system base room (usually the Lobby>) at the end of the loop
847 mptr = (struct march *) malloc(sizeof(struct march));
849 strcpy(mptr->march_name, "_BASEROOM_");
850 if (WC->march == NULL) {
854 while (mptr2->next != NULL)
859 * ...and remove the room we're currently in, so a <G>oto doesn't make us
860 * walk around in circles
862 remove_march(WC->wc_roomname);
864 if (WC->march != NULL) {
865 strcpy(next_room, pop_march(-1));
867 strcpy(next_room, "_BASEROOM_");
871 smart_goto(next_room);
876 * \brief goto next room
877 * \param next_room next room to go to
879 void smart_goto(char *next_room) {
887 * \brief mark all messages in current room as having been read
889 void slrp_highest(void)
893 serv_puts("SLRP HIGHEST");
894 serv_getln(buf, sizeof buf);
899 * \brief un-goto the previous room
905 if (!strcmp(WC->ugname, "")) {
906 smart_goto(WC->wc_roomname);
909 serv_printf("GOTO %s", WC->ugname);
910 serv_getln(buf, sizeof buf);
912 smart_goto(WC->wc_roomname);
915 if (WC->uglsn >= 0L) {
916 serv_printf("SLRP %ld", WC->uglsn);
917 serv_getln(buf, sizeof buf);
919 strcpy(buf, WC->ugname);
920 strcpy(WC->ugname, "");
929 * \brief Set/clear/read the "self-service list subscribe" flag for a room
931 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
932 * \return return the new value.
935 int self_service(int newval) {
936 int current_value = 0;
942 int flags, floor, order, view, flags2;
945 serv_getln(buf, sizeof buf);
946 if (buf[0] != '2') return(0);
948 extract_token(name, &buf[4], 0, '|', sizeof name);
949 extract_token(password, &buf[4], 1, '|', sizeof password);
950 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
951 flags = extract_int(&buf[4], 3);
952 floor = extract_int(&buf[4], 4);
953 order = extract_int(&buf[4], 5);
954 view = extract_int(&buf[4], 6);
955 flags2 = extract_int(&buf[4], 7);
957 if (flags2 & QR2_SELFLIST) {
965 flags2 = flags2 | QR2_SELFLIST;
967 else if (newval == 0) {
968 flags2 = flags2 & ~QR2_SELFLIST;
971 return(current_value);
974 if (newval != current_value) {
975 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
976 name, password, dirname, flags,
977 floor, order, view, flags2);
978 serv_getln(buf, sizeof buf);
991 * \brief display the form for editing a room
993 void display_editroom(void)
998 char remote_room[128];
1001 char er_password[10];
1002 char er_dirname[15];
1003 char er_roomaide[26];
1010 char *not_shared_with;
1013 int floorpolicy = 0;
1017 if (strlen(tab) == 0) tab = "admin";
1021 serv_getln(buf, sizeof buf);
1023 if (buf[0] != '2') {
1024 strcpy(WC->ImportantMessage, &buf[4]);
1025 display_main_menu();
1028 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1029 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1030 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1031 er_flags = extract_int(&buf[4], 3);
1032 er_floor = extract_int(&buf[4], 4);
1033 er_flags2 = extract_int(&buf[4], 7);
1035 output_headers(1, 1, 1, 0, 0, 0);
1037 /** print the tabbed dialog */
1039 "<div class=\"fix_scrollbar_bug\">"
1040 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
1042 "<TD> </TD>\n");
1044 if (!strcmp(tab, "admin")) {
1045 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1048 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1050 wprintf(_("Administration"));
1051 if (!strcmp(tab, "admin")) {
1052 wprintf("</SPAN></TD>\n");
1055 wprintf("</A></TD>\n");
1058 wprintf("<TD> </TD>\n");
1060 if (!strcmp(tab, "config")) {
1061 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1064 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=config\">");
1066 wprintf(_("Configuration"));
1067 if (!strcmp(tab, "config")) {
1068 wprintf("</SPAN></TD>\n");
1071 wprintf("</A></TD>\n");
1074 wprintf("<TD> </TD>\n");
1076 if (!strcmp(tab, "expire")) {
1077 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1080 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1082 wprintf(_("Message expire policy"));
1083 if (!strcmp(tab, "expire")) {
1084 wprintf("</SPAN></TD>\n");
1087 wprintf("</A></TD>\n");
1090 wprintf("<TD> </TD>\n");
1092 if (!strcmp(tab, "access")) {
1093 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1096 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=access\">");
1098 wprintf(_("Access controls"));
1099 if (!strcmp(tab, "access")) {
1100 wprintf("</SPAN></TD>\n");
1103 wprintf("</A></TD>\n");
1106 wprintf("<TD> </TD>\n");
1108 if (!strcmp(tab, "sharing")) {
1109 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1112 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1114 wprintf(_("Sharing"));
1115 if (!strcmp(tab, "sharing")) {
1116 wprintf("</SPAN></TD>\n");
1119 wprintf("</A></TD>\n");
1122 wprintf("<TD> </TD>\n");
1124 if (!strcmp(tab, "listserv")) {
1125 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1128 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1130 wprintf(_("Mailing list service"));
1131 if (!strcmp(tab, "listserv")) {
1132 wprintf("</SPAN></TD>\n");
1135 wprintf("</A></TD>\n");
1138 wprintf("<TD> </TD>\n");
1140 wprintf("</TR></TABLE></div>\n");
1141 /** end tabbed dialog */
1143 /** begin content of whatever tab is open now */
1144 wprintf("<div class=\"fix_scrollbar_bug\">"
1145 "<TABLE class=\"roomops_background\">\n"
1148 if (!strcmp(tab, "admin")) {
1150 "<LI><a href=\"delete_room\" "
1151 "onClick=\"return confirm('");
1152 wprintf(_("Are you sure you want to delete this room?"));
1153 wprintf("');\">\n");
1154 wprintf(_("Delete this room"));
1156 "<LI><a href=\"display_editroompic\">\n");
1157 wprintf(_("Set or change the icon for this room's banner"));
1159 "<LI><a href=\"display_editinfo\">\n");
1160 wprintf(_("Edit this room's Info file"));
1165 if (!strcmp(tab, "config")) {
1166 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1168 wprintf("<UL><LI>");
1169 wprintf(_("Name of room: "));
1170 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1176 wprintf(_("Resides on floor: "));
1177 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1178 for (i = 0; i < 128; ++i)
1179 if (strlen(floorlist[i]) > 0) {
1180 wprintf("<OPTION ");
1182 wprintf("SELECTED ");
1183 wprintf("VALUE=\"%d\">", i);
1184 escputs(floorlist[i]);
1185 wprintf("</OPTION>\n");
1187 wprintf("</SELECT>\n");
1190 wprintf(_("Type of room:"));
1193 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1194 if ((er_flags & QR_PRIVATE) == 0)
1195 wprintf("CHECKED ");
1197 wprintf(_("Public (automatically appears to everyone)"));
1200 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1201 if ((er_flags & QR_PRIVATE) &&
1202 (er_flags & QR_GUESSNAME))
1203 wprintf("CHECKED ");
1205 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1207 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1208 if ((er_flags & QR_PRIVATE) &&
1209 (er_flags & QR_PASSWORDED))
1210 wprintf("CHECKED ");
1212 wprintf(_("Private - require password: "));
1213 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1216 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1217 if ((er_flags & QR_PRIVATE)
1218 && ((er_flags & QR_GUESSNAME) == 0)
1219 && ((er_flags & QR_PASSWORDED) == 0))
1220 wprintf("CHECKED ");
1222 wprintf(_("Private - invitation only"));
1224 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1226 wprintf(_("If private, cause current users to forget room"));
1228 wprintf("\n</UL>\n");
1230 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1231 if (er_flags & QR_PREFONLY)
1232 wprintf("CHECKED ");
1234 wprintf(_("Preferred users only"));
1236 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1237 if (er_flags & QR_READONLY)
1238 wprintf("CHECKED ");
1240 wprintf(_("Read-only room"));
1242 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1243 if (er_flags2 & QR2_COLLABDEL)
1244 wprintf("CHECKED ");
1246 wprintf(_("All users allowed to post may also delete messages"));
1248 /** directory stuff */
1249 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1250 if (er_flags & QR_DIRECTORY)
1251 wprintf("CHECKED ");
1253 wprintf(_("File directory room"));
1255 wprintf("\n<UL><LI>");
1256 wprintf(_("Directory name: "));
1257 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1260 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1261 if (er_flags & QR_UPLOAD)
1262 wprintf("CHECKED ");
1264 wprintf(_("Uploading allowed"));
1266 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1267 if (er_flags & QR_DOWNLOAD)
1268 wprintf("CHECKED ");
1270 wprintf(_("Downloading allowed"));
1272 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1273 if (er_flags & QR_VISDIR)
1274 wprintf("CHECKED ");
1276 wprintf(_("Visible directory"));
1279 /** end of directory stuff */
1281 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1282 if (er_flags & QR_NETWORK)
1283 wprintf("CHECKED ");
1285 wprintf(_("Network shared room"));
1287 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1288 if (er_flags & QR_PERMANENT)
1289 wprintf("CHECKED ");
1291 wprintf(_("Permanent (does not auto-purge)"));
1293 /** start of anon options */
1296 wprintf(_("Anonymous messages"));
1299 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1300 if (((er_flags & QR_ANONONLY) == 0)
1301 && ((er_flags & QR_ANONOPT) == 0))
1302 wprintf("CHECKED ");
1304 wprintf(_("No anonymous messages"));
1306 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1307 if (er_flags & QR_ANONONLY)
1308 wprintf("CHECKED ");
1310 wprintf(_("All messages are anonymous"));
1312 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1313 if (er_flags & QR_ANONOPT)
1314 wprintf("CHECKED ");
1316 wprintf(_("Prompt user when entering messages"));
1319 /* end of anon options */
1322 wprintf(_("Room aide: "));
1324 serv_getln(buf, sizeof buf);
1325 if (buf[0] != '2') {
1326 wprintf("<em>%s</em>\n", &buf[4]);
1328 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1329 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1332 wprintf("</UL><CENTER>\n");
1333 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1334 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1336 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1344 /** Sharing the room with other Citadel nodes... */
1345 if (!strcmp(tab, "sharing")) {
1347 shared_with = strdup("");
1348 not_shared_with = strdup("");
1350 /** Learn the current configuration */
1351 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1352 serv_getln(buf, sizeof buf);
1353 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1354 extract_token(node, buf, 0, '|', sizeof node);
1355 not_shared_with = realloc(not_shared_with,
1356 strlen(not_shared_with) + 32);
1357 strcat(not_shared_with, node);
1358 strcat(not_shared_with, "\n");
1362 serv_getln(buf, sizeof buf);
1363 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1364 extract_token(cmd, buf, 0, '|', sizeof cmd);
1365 extract_token(node, buf, 1, '|', sizeof node);
1366 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1367 if (!strcasecmp(cmd, "ignet_push_share")) {
1368 shared_with = realloc(shared_with,
1369 strlen(shared_with) + 32);
1370 strcat(shared_with, node);
1371 if (strlen(remote_room) > 0) {
1372 strcat(shared_with, "|");
1373 strcat(shared_with, remote_room);
1375 strcat(shared_with, "\n");
1379 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1380 extract_token(buf, shared_with, i, '\n', sizeof buf);
1381 extract_token(node, buf, 0, '|', sizeof node);
1382 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1383 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1384 if (!strcasecmp(node, cmd)) {
1385 remove_token(not_shared_with, j, '\n');
1390 /** Display the stuff */
1391 wprintf("<CENTER><br />"
1392 "<TABLE border=1 cellpadding=5><TR>"
1394 wprintf(_("Shared with"));
1395 wprintf("</I></B></TD>"
1397 wprintf(_("Not shared with"));
1398 wprintf("</I></B></TD></TR>\n"
1399 "<TR><TD VALIGN=TOP>\n");
1401 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1402 wprintf(_("Remote node name"));
1403 wprintf("</TD><TD>");
1404 wprintf(_("Remote room name"));
1405 wprintf("</TD><TD>");
1406 wprintf(_("Actions"));
1407 wprintf("</TD></TR>\n");
1409 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1410 extract_token(buf, shared_with, i, '\n', sizeof buf);
1411 extract_token(node, buf, 0, '|', sizeof node);
1412 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1413 if (strlen(node) > 0) {
1414 wprintf("<FORM METHOD=\"POST\" "
1415 "action=\"netedit\">"
1416 "<TR><TD>%s</TD>\n", node);
1419 if (strlen(remote_room) > 0) {
1420 escputs(remote_room);
1426 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1427 "VALUE=\"ignet_push_share|");
1429 if (strlen(remote_room) > 0) {
1431 urlescputs(remote_room);
1434 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1435 "VALUE=\"sharing\">\n");
1436 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1437 "VALUE=\"remove\">\n");
1438 wprintf("<INPUT TYPE=\"submit\" "
1439 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1440 wprintf("</TD></TR></FORM>\n");
1444 wprintf("</TABLE>\n");
1445 wprintf("</TD><TD VALIGN=TOP>\n");
1446 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1447 wprintf(_("Remote node name"));
1448 wprintf("</TD><TD>");
1449 wprintf(_("Remote room name"));
1450 wprintf("</TD><TD>");
1451 wprintf(_("Actions"));
1452 wprintf("</TD></TR>\n");
1454 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1455 extract_token(node, not_shared_with, i, '\n', sizeof node);
1456 if (strlen(node) > 0) {
1457 wprintf("<FORM METHOD=\"POST\" "
1458 "action=\"netedit\">"
1462 "<INPUT TYPE=\"INPUT\" "
1466 wprintf("<INPUT TYPE=\"hidden\" "
1468 "VALUE=\"ignet_push_share|");
1471 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1472 "VALUE=\"sharing\">\n");
1473 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1474 "VALUE=\"add\">\n");
1475 wprintf("<INPUT TYPE=\"submit\" "
1476 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1477 wprintf("</TD></TR></FORM>\n");
1481 wprintf("</TABLE>\n");
1482 wprintf("</TD></TR>"
1483 "</TABLE></CENTER><br />\n"
1484 "<I><B>%s</B><UL><LI>", _("Notes:"));
1485 wprintf(_("When sharing a room, "
1486 "it must be shared from both ends. Adding a node to "
1487 "the 'shared' list sends messages out, but in order to"
1488 " receive messages, the other nodes must be configured"
1489 " to send messages out to your system as well. "
1490 "<LI>If the remote room name is blank, it is assumed "
1491 "that the room name is identical on the remote node."
1492 "<LI>If the remote room name is different, the remote "
1493 "node must also configure the name of the room here."
1499 /** Mailing list management */
1500 if (!strcmp(tab, "listserv")) {
1502 wprintf("<br /><center>"
1503 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1504 "<TR><TD VALIGN=TOP>");
1506 wprintf(_("<i>The contents of this room are being "
1507 "mailed <b>as individual messages</b> "
1508 "to the following list recipients:"
1509 "</i><br /><br />\n"));
1512 serv_getln(buf, sizeof buf);
1513 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1514 extract_token(cmd, buf, 0, '|', sizeof cmd);
1515 if (!strcasecmp(cmd, "listrecp")) {
1516 extract_token(recp, buf, 1, '|', sizeof recp);
1519 wprintf(" <a href=\"netedit&cmd=remove&line="
1522 wprintf("&tab=listserv\">");
1523 wprintf(_("(remove)"));
1524 wprintf("</A><br />");
1527 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1528 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1529 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1530 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1531 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1532 wprintf("</FORM>\n");
1534 wprintf("</TD><TD VALIGN=TOP>\n");
1536 wprintf(_("<i>The contents of this room are being "
1537 "mailed <b>in digest form</b> "
1538 "to the following list recipients:"
1539 "</i><br /><br />\n"));
1542 serv_getln(buf, sizeof buf);
1543 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1544 extract_token(cmd, buf, 0, '|', sizeof cmd);
1545 if (!strcasecmp(cmd, "digestrecp")) {
1546 extract_token(recp, buf, 1, '|', sizeof recp);
1549 wprintf(" <a href=\"netedit&cmd=remove&line="
1552 wprintf("&tab=listserv\">");
1553 wprintf(_("(remove)"));
1554 wprintf("</A><br />");
1557 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1558 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1559 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1560 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1561 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1562 wprintf("</FORM>\n");
1564 wprintf("</TD></TR></TABLE><hr />\n");
1566 if (self_service(999) == 1) {
1567 wprintf(_("This room is configured to allow "
1568 "self-service subscribe/unsubscribe requests."));
1569 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1570 wprintf(_("Click to disable."));
1571 wprintf("</A><br />\n");
1572 wprintf(_("The URL for subscribe/unsubscribe is: "));
1573 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1574 (is_https ? "https" : "http"),
1578 wprintf(_("This room is <i>not</i> configured to allow "
1579 "self-service subscribe/unsubscribe requests."));
1580 wprintf(" <a href=\"toggle_self_service?newval=1&"
1582 wprintf(_("Click to enable."));
1583 wprintf("</A><br />\n");
1587 wprintf("</CENTER>\n");
1591 /** Mailing list management */
1592 if (!strcmp(tab, "expire")) {
1594 serv_puts("GPEX room");
1595 serv_getln(buf, sizeof buf);
1596 if (buf[0] == '2') {
1597 roompolicy = extract_int(&buf[4], 0);
1598 roomvalue = extract_int(&buf[4], 1);
1601 serv_puts("GPEX floor");
1602 serv_getln(buf, sizeof buf);
1603 if (buf[0] == '2') {
1604 floorpolicy = extract_int(&buf[4], 0);
1605 floorvalue = extract_int(&buf[4], 1);
1608 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1609 wprintf("<TABLE border=0 cellspacing=5>\n");
1610 wprintf("<TR><TD>");
1611 wprintf(_("Message expire policy for this room"));
1613 escputs(WC->wc_roomname);
1614 wprintf(")</TD><TD>");
1615 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1616 ((roompolicy == 0) ? "CHECKED" : "") );
1617 wprintf(_("Use the default policy for this floor"));
1618 wprintf("<br />\n");
1619 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1620 ((roompolicy == 1) ? "CHECKED" : "") );
1621 wprintf(_("Never automatically expire messages"));
1622 wprintf("<br />\n");
1623 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1624 ((roompolicy == 2) ? "CHECKED" : "") );
1625 wprintf(_("Expire by message count"));
1626 wprintf("<br />\n");
1627 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1628 ((roompolicy == 3) ? "CHECKED" : "") );
1629 wprintf(_("Expire by message age"));
1631 wprintf(_("Number of messages or days: "));
1632 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1633 wprintf("</TD></TR>\n");
1635 if (WC->axlevel >= 6) {
1636 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1637 wprintf("<TR><TD>");
1638 wprintf(_("Message expire policy for this floor"));
1640 escputs(floorlist[WC->wc_floor]);
1641 wprintf(")</TD><TD>");
1642 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1643 ((floorpolicy == 0) ? "CHECKED" : "") );
1644 wprintf(_("Use the system default"));
1645 wprintf("<br />\n");
1646 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1647 ((floorpolicy == 1) ? "CHECKED" : "") );
1648 wprintf(_("Never automatically expire messages"));
1649 wprintf("<br />\n");
1650 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1651 ((floorpolicy == 2) ? "CHECKED" : "") );
1652 wprintf(_("Expire by message count"));
1653 wprintf("<br />\n");
1654 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1655 ((floorpolicy == 3) ? "CHECKED" : "") );
1656 wprintf(_("Expire by message age"));
1658 wprintf(_("Number of messages or days: "));
1659 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1663 wprintf("<CENTER>\n");
1664 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1665 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1667 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1668 wprintf("</CENTER></TD><TR>\n");
1670 wprintf("</TABLE>\n"
1671 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1677 /** Mailing list management */
1678 if (!strcmp(tab, "access")) {
1682 /** end content of whatever tab is open now */
1683 wprintf("</TD></TR></TABLE></div>\n");
1690 * \brief Toggle self-service list subscription
1692 void toggle_self_service(void) {
1695 newval = atoi(bstr("newval"));
1696 self_service(newval);
1703 * \brief save new parameters for a room
1709 char er_password[10];
1710 char er_dirname[15];
1711 char er_roomaide[26];
1714 int er_listingorder;
1720 if (strlen(bstr("ok_button")) == 0) {
1721 strcpy(WC->ImportantMessage,
1722 _("Cancelled. Changes were not saved."));
1727 serv_getln(buf, sizeof buf);
1729 if (buf[0] != '2') {
1730 strcpy(WC->ImportantMessage, &buf[4]);
1734 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1735 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1736 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1737 er_flags = extract_int(&buf[4], 3);
1738 er_listingorder = extract_int(&buf[4], 5);
1739 er_defaultview = extract_int(&buf[4], 6);
1740 er_flags2 = extract_int(&buf[4], 7);
1742 strcpy(er_roomaide, bstr("er_roomaide"));
1743 if (strlen(er_roomaide) == 0) {
1745 serv_getln(buf, sizeof buf);
1746 if (buf[0] != '2') {
1747 strcpy(er_roomaide, "");
1749 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1752 strcpy(buf, bstr("er_name"));
1754 if (strlen(buf) > 0) {
1755 strcpy(er_name, buf);
1758 strcpy(buf, bstr("er_password"));
1760 if (strlen(buf) > 0)
1761 strcpy(er_password, buf);
1763 strcpy(buf, bstr("er_dirname"));
1765 if (strlen(buf) > 0)
1766 strcpy(er_dirname, buf);
1768 strcpy(buf, bstr("type"));
1769 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1771 if (!strcmp(buf, "invonly")) {
1772 er_flags |= (QR_PRIVATE);
1774 if (!strcmp(buf, "hidden")) {
1775 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1777 if (!strcmp(buf, "passworded")) {
1778 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1780 if (!strcmp(bstr("prefonly"), "yes")) {
1781 er_flags |= QR_PREFONLY;
1783 er_flags &= ~QR_PREFONLY;
1786 if (!strcmp(bstr("readonly"), "yes")) {
1787 er_flags |= QR_READONLY;
1789 er_flags &= ~QR_READONLY;
1792 if (!strcmp(bstr("collabdel"), "yes")) {
1793 er_flags2 |= QR2_COLLABDEL;
1795 er_flags2 &= ~QR2_COLLABDEL;
1798 if (!strcmp(bstr("permanent"), "yes")) {
1799 er_flags |= QR_PERMANENT;
1801 er_flags &= ~QR_PERMANENT;
1804 if (!strcmp(bstr("network"), "yes")) {
1805 er_flags |= QR_NETWORK;
1807 er_flags &= ~QR_NETWORK;
1810 if (!strcmp(bstr("directory"), "yes")) {
1811 er_flags |= QR_DIRECTORY;
1813 er_flags &= ~QR_DIRECTORY;
1816 if (!strcmp(bstr("ulallowed"), "yes")) {
1817 er_flags |= QR_UPLOAD;
1819 er_flags &= ~QR_UPLOAD;
1822 if (!strcmp(bstr("dlallowed"), "yes")) {
1823 er_flags |= QR_DOWNLOAD;
1825 er_flags &= ~QR_DOWNLOAD;
1828 if (!strcmp(bstr("visdir"), "yes")) {
1829 er_flags |= QR_VISDIR;
1831 er_flags &= ~QR_VISDIR;
1834 strcpy(buf, bstr("anon"));
1836 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1837 if (!strcmp(buf, "anononly"))
1838 er_flags |= QR_ANONONLY;
1839 if (!strcmp(buf, "anon2"))
1840 er_flags |= QR_ANONOPT;
1843 if (!strcmp(bstr("bump"), "yes"))
1846 er_floor = atoi(bstr("er_floor"));
1848 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
1849 er_name, er_password, er_dirname, er_flags, bump, er_floor,
1850 er_listingorder, er_defaultview, er_flags2);
1852 serv_getln(buf, sizeof buf);
1853 if (buf[0] != '2') {
1854 strcpy(WC->ImportantMessage, &buf[4]);
1860 if (strlen(er_roomaide) > 0) {
1861 sprintf(buf, "SETA %s", er_roomaide);
1863 serv_getln(buf, sizeof buf);
1864 if (buf[0] != '2') {
1865 strcpy(WC->ImportantMessage, &buf[4]);
1866 display_main_menu();
1871 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1878 * \brief Display form for Invite, Kick, and show Who Knows a room
1880 void do_invt_kick(void) {
1881 char buf[SIZ], room[SIZ], username[SIZ];
1884 serv_getln(buf, sizeof buf);
1886 if (buf[0] != '2') {
1890 extract_token(room, &buf[4], 0, '|', sizeof room);
1892 strcpy(username, bstr("username"));
1894 if (strlen(bstr("kick_button")) > 0) {
1895 sprintf(buf, "KICK %s", username);
1897 serv_getln(buf, sizeof buf);
1899 if (buf[0] != '2') {
1900 strcpy(WC->ImportantMessage, &buf[4]);
1902 sprintf(WC->ImportantMessage,
1903 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1908 if (strlen(bstr("invite_button")) > 0) {
1909 sprintf(buf, "INVT %s", username);
1911 serv_getln(buf, sizeof buf);
1913 if (buf[0] != '2') {
1914 strcpy(WC->ImportantMessage, &buf[4]);
1916 sprintf(WC->ImportantMessage,
1917 _("<B><I>User %s invited to room %s.</I></B>\n"),
1928 * \brief Display form for Invite, Kick, and show Who Knows a room
1930 void display_whok(void)
1932 char buf[SIZ], room[SIZ], username[SIZ];
1935 serv_getln(buf, sizeof buf);
1937 if (buf[0] != '2') {
1941 extract_token(room, &buf[4], 0, '|', sizeof room);
1944 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1945 wprintf(_("The users listed below have access to this room. "
1946 "To remove a user from the access list, select the user "
1947 "name from the list and click 'Kick'."));
1948 wprintf("<br /><br />");
1950 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1951 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1952 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1954 serv_getln(buf, sizeof buf);
1955 if (buf[0] == '1') {
1956 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1957 extract_token(username, buf, 0, '|', sizeof username);
1958 wprintf("<OPTION>");
1963 wprintf("</SELECT><br />\n");
1965 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1966 wprintf("</FORM></CENTER>\n");
1968 wprintf("</TD><TD>");
1969 wprintf(_("To grant another user access to this room, enter the "
1970 "user name in the box below and click 'Invite'."));
1971 wprintf("<br /><br />");
1973 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1974 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1975 wprintf(_("Invite:"));
1977 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1978 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1979 "<input type=\"submit\" value=\"%s\">"
1980 "</FORM></CENTER>\n", _("Invite"));
1982 wprintf("</TD></TR></TABLE>\n");
1989 * \brief display the form for entering a new room
1991 void display_entroom(void)
1996 serv_puts("CRE8 0");
1997 serv_getln(buf, sizeof buf);
1999 if (buf[0] != '2') {
2000 strcpy(WC->ImportantMessage, &buf[4]);
2001 display_main_menu();
2005 output_headers(1, 1, 2, 0, 0, 0);
2006 wprintf("<div id=\"banner\">\n"
2007 "<TABLE class=\"roomops_banner\"><TR><TD>"
2008 "<SPAN CLASS=\"titlebar\">");
2009 wprintf(_("Create a new room"));
2011 "</TD></TR></TABLE>\n"
2012 "</div>\n<div id=\"content\">\n"
2015 wprintf("<div class=\"fix_scrollbar_bug\">"
2016 "<table class=\"roomops_background\"><tr><td>\n");
2018 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2020 wprintf("<UL><LI>");
2021 wprintf(_("Name of room: "));
2022 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2025 wprintf(_("Resides on floor: "));
2027 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
2028 for (i = 0; i < 128; ++i)
2029 if (strlen(floorlist[i]) > 0) {
2030 wprintf("<OPTION ");
2031 wprintf("VALUE=\"%d\">", i);
2032 escputs(floorlist[i]);
2033 wprintf("</OPTION>\n");
2035 wprintf("</SELECT>\n");
2038 * Our clever little snippet of JavaScript automatically selects
2039 * a public room if the view is set to Bulletin Board or wiki, and
2040 * it selects a mailbox room otherwise. The user can override this,
2041 * of course. We also disable the floor selector for mailboxes.
2044 wprintf(_("Default view for room: "));
2045 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
2046 " if ( (this.form.er_view.value == 0) "
2047 " || (this.form.er_view.value == 6) ) { "
2048 " this.form.type[0].checked=true; "
2049 " this.form.er_floor.disabled = false; "
2052 " this.form.type[4].checked=true; "
2053 " this.form.er_floor.disabled = true; "
2056 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2057 if (is_view_allowed_as_default(i)) {
2058 wprintf("<OPTION %s VALUE=\"%d\">",
2059 ((i == 0) ? "SELECTED" : ""), i );
2060 escputs(viewdefs[i]);
2061 wprintf("</OPTION>\n");
2064 wprintf("</SELECT>\n");
2067 wprintf(_("Type of room:"));
2070 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2071 wprintf("CHECKED OnChange=\""
2072 " if (this.form.type[0].checked == true) { "
2073 " this.form.er_floor.disabled = false; "
2076 wprintf(_("Public (automatically appears to everyone)"));
2078 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2079 " if (this.form.type[1].checked == true) { "
2080 " this.form.er_floor.disabled = false; "
2083 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2085 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2086 " if (this.form.type[2].checked == true) { "
2087 " this.form.er_floor.disabled = false; "
2090 wprintf(_("Private - require password: "));
2091 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2093 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2094 " if (this.form.type[3].checked == true) { "
2095 " this.form.er_floor.disabled = false; "
2098 wprintf(_("Private - invitation only"));
2100 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2102 " if (this.form.type[4].checked == true) { "
2103 " this.form.er_floor.disabled = true; "
2106 wprintf(_("Personal (mailbox for you only)"));
2108 wprintf("\n</UL>\n");
2110 wprintf("<CENTER>\n");
2111 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2113 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2114 wprintf("</CENTER>\n");
2115 wprintf("</FORM>\n<hr />");
2116 serv_printf("MESG roomaccess");
2117 serv_getln(buf, sizeof buf);
2118 if (buf[0] == '1') {
2121 wprintf("</td></tr></table></div>\n");
2129 * \brief support function for entroom() -- sets the default view
2131 void er_set_default_view(int newview) {
2144 serv_getln(buf, sizeof buf);
2145 if (buf[0] != '2') return;
2147 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2148 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2149 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2150 rm_bits1 = extract_int(&buf[4], 3);
2151 rm_floor = extract_int(&buf[4], 4);
2152 rm_listorder = extract_int(&buf[4], 5);
2153 rm_bits2 = extract_int(&buf[4], 7);
2155 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2156 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2157 rm_listorder, newview, rm_bits2
2159 serv_getln(buf, sizeof buf);
2165 * \brief enter a new room
2172 char er_password[SIZ];
2177 if (strlen(bstr("ok_button")) == 0) {
2178 strcpy(WC->ImportantMessage,
2179 _("Cancelled. No new room was created."));
2180 display_main_menu();
2183 strcpy(er_name, bstr("er_name"));
2184 strcpy(er_type, bstr("type"));
2185 strcpy(er_password, bstr("er_password"));
2186 er_floor = atoi(bstr("er_floor"));
2187 er_view = atoi(bstr("er_view"));
2190 if (!strcmp(er_type, "hidden"))
2192 if (!strcmp(er_type, "passworded"))
2194 if (!strcmp(er_type, "invonly"))
2196 if (!strcmp(er_type, "personal"))
2199 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2200 er_name, er_num_type, er_password, er_floor, 0, er_view);
2202 serv_getln(buf, sizeof buf);
2203 if (buf[0] != '2') {
2204 strcpy(WC->ImportantMessage, &buf[4]);
2205 display_main_menu();
2209 do_change_view(er_view); /* Now go there */
2214 * \brief display the screen to enter a private room
2216 void display_private(char *rname, int req_pass)
2218 output_headers(1, 1, 2, 0, 0, 0);
2219 wprintf("<div id=\"banner\">\n"
2220 "<TABLE class=\"roomops_banner\"><TR><TD>"
2221 "<SPAN CLASS=\"titlebar\">");
2222 wprintf(_("Go to a hidden room"));
2224 "</TD></TR></TABLE>\n"
2225 "</div>\n<div id=\"content\">\n"
2228 wprintf("<div class=\"fix_scrollbar_bug\">"
2229 "<table class=\"roomops_background\"><tr><td>\n");
2231 wprintf("<CENTER>\n");
2233 wprintf(_("If you know the name of a hidden (guess-name) or "
2234 "passworded room, you can enter that room by typing "
2235 "its name below. Once you gain access to a private "
2236 "room, it will appear in your regular room listings "
2237 "so you don't have to keep returning here."));
2238 wprintf("\n<br /><br />");
2240 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2242 wprintf("<table border=\"0\" cellspacing=\"5\" "
2243 "cellpadding=\"5\" class=\"roomops_background_alt\">\n"
2245 wprintf(_("Enter room name:"));
2247 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2248 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2251 wprintf("</TD></TR><TR><TD>");
2252 wprintf(_("Enter room password:"));
2253 wprintf("</TD><TD>");
2254 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2256 wprintf("</TD></TR></TABLE><br />\n");
2258 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2260 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2264 wprintf("</FORM>\n");
2265 wprintf("</td></tr></table></div>\n");
2270 * \brief goto a private room
2272 void goto_private(void)
2277 if (strlen(bstr("ok_button")) == 0) {
2278 display_main_menu();
2281 strcpy(hold_rm, WC->wc_roomname);
2282 strcpy(buf, "GOTO ");
2283 strcat(buf, bstr("gr_name"));
2285 strcat(buf, bstr("gr_pass"));
2287 serv_getln(buf, sizeof buf);
2289 if (buf[0] == '2') {
2290 smart_goto(bstr("gr_name"));
2293 if (!strncmp(buf, "540", 3)) {
2294 display_private(bstr("gr_name"), 1);
2297 output_headers(1, 1, 1, 0, 0, 0);
2298 wprintf("%s\n", &buf[4]);
2305 * \brief display the screen to zap a room
2307 void display_zap(void)
2309 output_headers(1, 1, 2, 0, 0, 0);
2311 wprintf("<div id=\"banner\">\n");
2312 wprintf("<TABLE class=\"roomops_zap\"><TR><TD>");
2313 wprintf("<SPAN CLASS=\"titlebar\">");
2314 wprintf(_("Zap (forget/unsubscribe) the current room"));
2315 wprintf("</SPAN>\n");
2316 wprintf("</TD></TR></TABLE>\n");
2317 wprintf("</div>\n<div id=\"content\">\n");
2319 wprintf(_("If you select this option, <em>%s</em> will "
2320 "disappear from your room list. Is this what you wish "
2321 "to do?<br />\n"), WC->wc_roomname);
2323 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2324 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2326 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2327 wprintf("</FORM>\n");
2338 char final_destination[SIZ];
2341 * If the forget-room routine fails for any reason, we fall back
2342 * to the current room; otherwise, we go to the Lobby
2344 strcpy(final_destination, WC->wc_roomname);
2346 if (strlen(bstr("ok_button")) > 0) {
2347 serv_printf("GOTO %s", WC->wc_roomname);
2348 serv_getln(buf, sizeof buf);
2349 if (buf[0] == '2') {
2351 serv_getln(buf, sizeof buf);
2352 if (buf[0] == '2') {
2353 strcpy(final_destination, "_BASEROOM_");
2357 smart_goto(final_destination);
2363 * \brief Delete the current room
2365 void delete_room(void)
2369 serv_puts("KILL 1");
2370 serv_getln(buf, sizeof buf);
2371 if (buf[0] != '2') {
2372 strcpy(WC->ImportantMessage, &buf[4]);
2373 display_main_menu();
2376 smart_goto("_BASEROOM_");
2383 * \brief Perform changes to a room's network configuration
2385 void netedit(void) {
2394 if (strlen(bstr("line"))==0) {
2399 strcpy(line, bstr("prefix"));
2400 strcat(line, bstr("line"));
2401 strcat(line, bstr("suffix"));
2410 serv_getln(buf, sizeof buf);
2411 if (buf[0] != '1') {
2417 /** This loop works for add *or* remove. Spiffy, eh? */
2418 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2419 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2420 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2421 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2422 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2423 if ( (strcasecmp(cmpa0, cmpb0))
2424 || (strcasecmp(cmpa1, cmpb1)) ) {
2425 fprintf(fp, "%s\n", buf);
2431 serv_getln(buf, sizeof buf);
2432 if (buf[0] != '4') {
2438 while (fgets(buf, sizeof buf, fp) != NULL) {
2439 buf[strlen(buf)-1] = 0;
2443 if (strlen(bstr("add_button")) > 0) {
2455 * \brief Convert a room name to a folder-ish-looking name.
2456 * \param folder the folderish name
2457 * \param room the room name
2458 * \param floor the floor name
2459 * \param is_mailbox is it a mailbox?
2461 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2466 * For mailboxes, just do it straight...
2469 sprintf(folder, "My folders|%s", room);
2473 * Otherwise, prefix the floor name as a "public folders" moniker
2476 sprintf(folder, "%s|%s", floorlist[floor], room);
2480 * Replace "\" characters with "|" for pseudo-folder-delimiting
2482 for (i=0; i<strlen(folder); ++i) {
2483 if (folder[i] == '\\') folder[i] = '|';
2491 * \brief Back end for change_view()
2492 * \param newview set newview???
2494 void do_change_view(int newview) {
2497 serv_printf("VIEW %d", newview);
2498 serv_getln(buf, sizeof buf);
2499 WC->wc_view = newview;
2500 smart_goto(WC->wc_roomname);
2506 * \brief Change the view for this room
2508 void change_view(void) {
2511 view = atol(bstr("view"));
2512 do_change_view(view);
2517 * \brief One big expanded tree list view --- like a folder list
2518 * \param fold the folder to view
2519 * \param max_folders how many folders???
2520 * \param num_floors hom many floors???
2522 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2526 int has_subfolders = 0;
2529 parents = malloc(max_folders * sizeof(int));
2531 /** BEGIN TREE MENU */
2532 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2534 /** include NanoTree */
2535 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2537 /** initialize NanoTree */
2538 wprintf("<script type=\"text/javascript\"> \n"
2539 " showRootNode = false; \n"
2540 " sortNodes = false; \n"
2541 " dragable = false; \n"
2543 " function standardClick(treeNode) { \n"
2546 " var closedGif = 'static/folder_closed.gif'; \n"
2547 " var openGif = 'static/folder_open.gif'; \n"
2549 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2553 for (i=0; i<max_folders; ++i) {
2556 if ((i+1) < max_folders) {
2557 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2558 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2563 levels = num_tokens(fold[i].name, '|');
2564 parents[levels] = i;
2566 wprintf("var node%d = new TreeNode(%d, '", i, i);
2568 if (fold[i].selectable) {
2569 wprintf("<a href=\"dotgoto?room=");
2570 urlescputs(fold[i].room);
2575 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2577 else if (fold[i].hasnewmsgs) {
2578 wprintf("<SPAN CLASS=\"roomlist_new\">");
2581 wprintf("<SPAN CLASS=\"roomlist_old\">");
2583 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2588 if (has_subfolders) {
2589 wprintf("new Array(closedGif, openGif)");
2591 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2592 wprintf("'static/viewcontacts_16x.gif'");
2594 else if (fold[i].view == VIEW_CALENDAR) {
2595 wprintf("'static/calarea_16x.gif'");
2597 else if (fold[i].view == VIEW_CALBRIEF) {
2598 wprintf("'static/calarea_16x.gif'");
2600 else if (fold[i].view == VIEW_TASKS) {
2601 wprintf("'static/taskmanag_16x.gif'");
2603 else if (fold[i].view == VIEW_NOTES) {
2604 wprintf("'static/storenotes_16x.gif'");
2606 else if (fold[i].view == VIEW_MAILBOX) {
2607 wprintf("'static/privatemess_16x.gif'");
2610 wprintf("'static/chatrooms_16x.gif'");
2613 urlescputs(fold[i].name);
2617 wprintf("rootNode.addChild(node%d);\n", i);
2620 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2624 wprintf("container = document.getElementById('roomlist_div'); \n"
2630 /** END TREE MENU */
2634 * \brief Boxes and rooms and lists ... oh my!
2635 * \param fold the folder to view
2636 * \param max_folders how many folders???
2637 * \param num_floors hom many floors???
2639 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2641 char floor_name[256];
2642 char old_floor_name[256];
2644 int levels, oldlevels;
2647 static int columns = 3;
2648 int boxes_per_column = 0;
2649 int current_column = 0;
2652 strcpy(floor_name, "");
2653 strcpy(old_floor_name, "");
2656 while (nf % columns != 0) ++nf;
2657 boxes_per_column = (nf / columns);
2658 if (boxes_per_column < 1) boxes_per_column = 1;
2660 /** Outer table (for columnization) */
2661 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2662 "<tr><td valign=top>");
2666 for (i=0; i<max_folders; ++i) {
2668 levels = num_tokens(fold[i].name, '|');
2669 extract_token(floor_name, fold[i].name, 0,
2670 '|', sizeof floor_name);
2672 if ( (strcasecmp(floor_name, old_floor_name))
2673 && (strlen(old_floor_name) > 0) ) {
2675 do_template("endbox");
2678 if ((num_boxes % boxes_per_column) == 0) {
2680 if (current_column < columns) {
2681 wprintf("</td><td valign=top>\n");
2685 strcpy(old_floor_name, floor_name);
2688 /** Begin inner box */
2689 stresc(boxtitle, floor_name, 1, 0);
2690 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2691 do_template("beginbox");
2698 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2699 if (fold[i].selectable) {
2700 wprintf("<a href=\"dotgoto?room=");
2701 urlescputs(fold[i].room);
2707 if (fold[i].hasnewmsgs) {
2708 wprintf("<SPAN CLASS=\"roomlist_new\">");
2711 wprintf("<SPAN CLASS=\"roomlist_old\">");
2713 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2716 if (fold[i].selectable) {
2722 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2723 wprintf(" (INBOX)");
2725 wprintf("<br />\n");
2728 /** End the final inner box */
2729 do_template("endbox");
2731 wprintf("</TD></TR></TABLE>\n");
2735 * \brief print a floor div???
2736 * \param which_floordiv name of the floordiv???
2738 void set_floordiv_expanded(char *which_floordiv) {
2739 begin_ajax_response();
2740 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2741 end_ajax_response();
2745 * \brief view the iconbar
2746 * \param fold the folder to view
2747 * \param max_folders how many folders???
2748 * \param num_floors hom many floors???
2750 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2752 char floor_name[256];
2753 char old_floor_name[256];
2754 char floordivtitle[256];
2755 char floordiv_id[32];
2756 int levels, oldlevels;
2758 int num_drop_targets = 0;
2761 strcpy(floor_name, "");
2762 strcpy(old_floor_name, "");
2766 for (i=0; i<max_folders; ++i) {
2768 levels = num_tokens(fold[i].name, '|');
2769 extract_token(floor_name, fold[i].name, 0,
2770 '|', sizeof floor_name);
2772 if ( (strcasecmp(floor_name, old_floor_name))
2773 && (strlen(old_floor_name) > 0) ) {
2774 /** End inner box */
2776 wprintf("</div>\n"); /** floordiv */
2778 strcpy(old_floor_name, floor_name);
2782 stresc(floordivtitle, floor_name, 0, 0);
2783 sprintf(floordiv_id, "floordiv%d", i);
2784 wprintf("<span class=\"ib_roomlist_floor\" "
2785 "onClick=\"expand_floor('%s')\">"
2786 "%s</span><br>\n", floordiv_id, floordivtitle);
2787 wprintf("<div id=\"%s\" style=\"display:%s\">",
2789 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2796 wprintf("<div id=\"roomdiv%d\">", i);
2798 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2800 /** choose the icon */
2801 if (fold[i].view == VIEW_ADDRESSBOOK) {
2802 icon = "viewcontacts_16x.gif" ;
2804 else if (fold[i].view == VIEW_CALENDAR) {
2805 icon = "calarea_16x.gif" ;
2807 else if (fold[i].view == VIEW_CALBRIEF) {
2808 icon = "calarea_16x.gif" ;
2810 else if (fold[i].view == VIEW_TASKS) {
2811 icon = "taskmanag_16x.gif" ;
2813 else if (fold[i].view == VIEW_NOTES) {
2814 icon = "storenotes_16x.gif" ;
2816 else if (fold[i].view == VIEW_MAILBOX) {
2817 icon = "privatemess_16x.gif" ;
2820 icon = "chatrooms_16x.gif" ;
2823 if (fold[i].selectable) {
2824 wprintf("<a href=\"dotgoto?room=");
2825 urlescputs(fold[i].room);
2827 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2832 if (fold[i].hasnewmsgs) {
2833 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2836 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2838 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2840 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2841 wprintf(" (INBOX)");
2844 if (fold[i].selectable) {
2851 wprintf("</div>\n"); /** roomdiv */
2854 wprintf("</div>\n"); /** floordiv */
2857 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2858 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2860 num_drop_targets = 0;
2862 for (i=0; i<max_folders; ++i) {
2863 levels = num_tokens(fold[i].name, '|');
2865 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2866 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2867 jsescputs(fold[i].room);
2873 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2874 if (strlen(WC->floordiv_expanded) > 1) {
2875 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2879 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2885 * \brief Show the room list.
2886 * (only should get called by
2887 * knrooms() because that's where output_headers() is called from)
2888 * \param viewpref the view preferences???
2891 void list_all_rooms_by_floor(char *viewpref) {
2894 struct folder *fold = NULL;
2896 int max_folders = 0;
2897 int alloc_folders = 0;
2901 int num_floors = 1; /** add an extra one for private folders */
2903 /** If our cached folder list is very old, burn it. */
2904 if (WC->cache_fold != NULL) {
2905 if ((time(NULL) - WC->cache_timestamp) > 300) {
2906 free(WC->cache_fold);
2907 WC->cache_fold = NULL;
2911 /** Can we do the iconbar roomlist from cache? */
2912 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2913 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2917 /** Grab the floor table so we know how to build the list... */
2920 /** Start with the mailboxes */
2923 fold = malloc(sizeof(struct folder));
2924 memset(fold, 0, sizeof(struct folder));
2925 strcpy(fold[0].name, "My folders");
2926 fold[0].is_mailbox = 1;
2928 /** Then add floors */
2930 serv_getln(buf, sizeof buf);
2931 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2932 if (max_folders >= alloc_folders) {
2933 alloc_folders = max_folders + 100;
2934 fold = realloc(fold,
2935 alloc_folders * sizeof(struct folder));
2937 memset(&fold[max_folders], 0, sizeof(struct folder));
2938 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2943 /** refresh the messages index for this room */
2944 // serv_puts("GOTO ");
2945 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
2946 /** Now add rooms */
2948 serv_getln(buf, sizeof buf);
2949 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2950 if (max_folders >= alloc_folders) {
2951 alloc_folders = max_folders + 100;
2952 fold = realloc(fold,
2953 alloc_folders * sizeof(struct folder));
2955 memset(&fold[max_folders], 0, sizeof(struct folder));
2956 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2957 ra_flags = extract_int(buf, 5);
2958 flags = extract_int(buf, 1);
2959 fold[max_folders].floor = extract_int(buf, 2);
2960 fold[max_folders].hasnewmsgs =
2961 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2962 if (flags & QR_MAILBOX) {
2963 fold[max_folders].is_mailbox = 1;
2965 fold[max_folders].view = extract_int(buf, 6);
2966 room_to_folder(fold[max_folders].name,
2967 fold[max_folders].room,
2968 fold[max_folders].floor,
2969 fold[max_folders].is_mailbox);
2970 fold[max_folders].selectable = 1;
2974 /** Bubble-sort the folder list */
2975 for (i=0; i<max_folders; ++i) {
2976 for (j=0; j<(max_folders-1)-i; ++j) {
2977 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2978 swap = strcasecmp(fold[j].name, fold[j+1].name);
2981 if ( (fold[j+1].is_mailbox)
2982 && (!fold[j].is_mailbox)) {
2990 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2991 memcpy(&fold[j], &fold[j+1],
2992 sizeof(struct folder));
2993 memcpy(&fold[j+1], &ftmp,
2994 sizeof(struct folder));
3000 if (!strcasecmp(viewpref, "folders")) {
3001 do_folder_view(fold, max_folders, num_floors);
3003 else if (!strcasecmp(viewpref, "hackish_view")) {
3004 for (i=0; i<max_folders; ++i) {
3005 escputs(fold[i].name);
3006 wprintf("<br />\n");
3009 else if (!strcasecmp(viewpref, "iconbar")) {
3010 do_iconbar_view(fold, max_folders, num_floors);
3013 do_rooms_view(fold, max_folders, num_floors);
3016 /* Don't free the folder list ... cache it for future use! */
3017 if (WC->cache_fold != NULL) {
3018 free(WC->cache_fold);
3020 WC->cache_fold = fold;
3021 WC->cache_max_folders = max_folders;
3022 WC->cache_num_floors = num_floors;
3023 WC->cache_timestamp = time(NULL);
3028 * \brief Do either a known rooms list or a folders list, depending on the
3033 char listviewpref[SIZ];
3035 output_headers(1, 1, 2, 0, 0, 0);
3037 /** Determine whether the user is trying to change views */
3038 if (bstr("view") != NULL) {
3039 if (strlen(bstr("view")) > 0) {
3040 set_preference("roomlistview", bstr("view"), 1);
3044 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3046 if ( (strcasecmp(listviewpref, "folders"))
3047 && (strcasecmp(listviewpref, "table")) ) {
3048 strcpy(listviewpref, "rooms");
3052 wprintf("<div id=\"banner\">\n"
3053 "<TABLE class=\"roomops_banner\"><TR><TD>"
3054 "<SPAN CLASS=\"titlebar\">"
3056 if (!strcasecmp(listviewpref, "rooms")) {
3057 wprintf(_("Room list"));
3059 if (!strcasecmp(listviewpref, "folders")) {
3060 wprintf(_("Folder list"));
3062 if (!strcasecmp(listviewpref, "table")) {
3063 wprintf(_("Room list"));
3065 wprintf("</SPAN></TD>\n");
3067 /** offer the ability to switch views */
3068 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
3069 "<SELECT NAME=\"newview\" SIZE=\"1\" "
3070 "OnChange=\"location.href=roomlistomatic.newview.options"
3071 "[selectedIndex].value\">\n");
3073 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3076 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3079 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3080 "View as folder list"
3082 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3085 wprintf("</SELECT><br />");
3087 wprintf("</FORM></TD></TR></TABLE>\n");
3090 "<div id=\"content\">\n");
3092 /** Display the room list in the user's preferred format */
3093 list_all_rooms_by_floor(listviewpref);
3100 * \brief Set the message expire policy for this room and/or floor
3102 void set_room_policy(void) {
3105 if (strlen(bstr("ok_button")) == 0) {
3106 strcpy(WC->ImportantMessage,
3107 _("Cancelled. Changes were not saved."));
3112 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3113 serv_getln(buf, sizeof buf);
3114 strcpy(WC->ImportantMessage, &buf[4]);
3116 if (WC->axlevel >= 6) {
3117 strcat(WC->ImportantMessage, "<br />\n");
3118 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3119 serv_getln(buf, sizeof buf);
3120 strcat(WC->ImportantMessage, &buf[4]);