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;
201 /** Ask the server for a room list */
203 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 "onmouseover=\"javascript:document.getElementById('room_infos').style.display='block';\" "
282 "onmouseout=\"javascript:document.getElementById('room_infos').style.display='none';\" "
284 wprintf(_("Room info"));
285 wprintf("</div><div id=\"room_infos\">");
298 * \brief Display room banner icon.
299 * The server doesn't actually
300 * need the room name, but we supply it in order to
301 * keep the browser from using a cached icon from
304 void embed_room_graphic(void) {
307 serv_puts("OIMG _roompic_");
308 serv_getln(buf, sizeof buf);
310 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
311 urlescputs(WC->wc_roomname);
314 serv_getln(buf, sizeof buf);
316 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
317 wprintf("<img height=48 width=48 src=\""
318 "static/viewcontacts_48x.gif"
322 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
323 wprintf("<img height=48 width=48 src=\""
324 "static/calarea_48x.gif"
328 else if (WC->wc_view == VIEW_TASKS) {
329 wprintf("<img height=48 width=48 src=\""
330 "static/taskmanag_48x.gif"
334 else if (WC->wc_view == VIEW_NOTES) {
335 wprintf("<img height=48 width=48 src=\""
336 "static/storenotes_48x.gif"
340 else if (WC->wc_view == VIEW_MAILBOX) {
341 wprintf("<img height=48 width=48 src=\""
342 "static/privatemess_48x.gif"
347 wprintf("<img height=48 width=48 src=\""
348 "static/chatrooms_48x.gif"
358 * \brief Display the current view and offer an option to change it
360 void embed_view_o_matic(void) {
363 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
364 "<label for=\"view_name\">");
365 wprintf(_("View as:"));
367 "<select name=\"newview\" size=\"1\" "
368 "id=\"view_name\" class=\"selectbox\" "
369 "OnChange=\"location.href=viewomatic.newview.options"
370 "[selectedIndex].value\">\n");
372 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
374 * Only offer the views that make sense, given the default
375 * view for the room. For example, don't offer a Calendar
376 * view in a non-Calendar room.
380 || (i == WC->wc_default_view) /**< default */
381 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
382 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
383 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
386 wprintf("<option %s value=\"changeview?view=%d\">",
387 ((i == WC->wc_view) ? "selected" : ""),
389 escputs(viewdefs[i]);
390 wprintf("</option>\n");
393 wprintf("</select></form>\n");
398 * \brief Display a search box
400 void embed_search_o_matic(void) {
401 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n"
402 "<label for=\"search_name\">");
403 wprintf(_("Search: "));
404 wprintf("</label> <input "
405 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
406 "id=\"search_name\" class=\"inputbox\">\n"
408 wprintf("</select></form>\n");
413 * \brief Embed the room banner
415 * \param got The information returned from a GOTO server command
416 * \param navbar_style Determines which navigation buttons to display
420 void embed_room_banner(char *got, int navbar_style) {
424 * We need to have the information returned by a GOTO server command.
425 * If it isn't supplied, we fake it by issuing our own GOTO.
428 serv_printf("GOTO %s", WC->wc_roomname);
429 serv_getln(buf, sizeof buf);
433 /** The browser needs some information for its own use */
434 wprintf("<script type=\"text/javascript\"> \n"
435 " room_is_trash = %d; \n"
441 * If the user happens to select the "make this my start page" link,
442 * we want it to remember the URL as a "/dotskip" one instead of
443 * a "skip" or "gotonext" or something like that.
445 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
448 /** Check for new mail. */
449 WC->new_mail = extract_int(&got[4], 9);
450 WC->wc_view = extract_int(&got[4], 11);
452 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
453 svprintf("NUMMSGS", WCS_STRING,
454 _("%d new of %d messages"),
455 extract_int(&got[4], 1),
456 extract_int(&got[4], 2)
458 svcallback("ROOMPIC", embed_room_graphic);
459 svcallback("ROOMINFO", readinfo);
460 svcallback("VIEWOMATIC", embed_view_o_matic);
461 svcallback("SEARCHOMATIC", embed_search_o_matic);
462 svcallback("START", offer_start_page);
464 do_template("roombanner");
465 if (navbar_style != navbar_none) {
467 wprintf("<div id=\"navbar\">\n"
472 if (navbar_style == navbar_default) wprintf(
473 "<li class=\"ungoto\">"
474 "<a href=\"ungoto\">"
475 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
476 "<span class=\"navbar_link\">%s</span></A>"
477 "</li>\n", _("Ungoto")
480 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
482 "<li class=\"newmess\">"
483 "<a href=\"readnew\">"
484 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
485 "<span class=\"navbar_link\">%s</span></A>"
486 "</li>\n", _("Read new messages")
490 if (navbar_style == navbar_default) {
491 switch(WC->wc_view) {
492 case VIEW_ADDRESSBOOK:
494 "<li class=\"viewcontacts\">"
495 "<a href=\"readfwd\">"
496 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
498 "<span class=\"navbar_link\">"
500 "</span></a></li>\n", _("View contacts")
505 "<li class=\"staskday\">"
506 "<a href=\"readfwd?calview=day\">"
507 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
509 "<span class=\"navbar_link\">"
511 "</span></a></li>\n", _("Day view")
514 "<li class=\"monthview\">"
515 "<a href=\"readfwd?calview=month\">"
516 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
518 "<span class=\"navbar_link\">"
520 "</span></a></li>\n", _("Month view")
525 "<li class=\"monthview\">"
526 "<a href=\"readfwd?calview=month\">"
527 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
529 "<span class=\"navbar_link\">"
531 "</span></a></li>\n", _("Calendar list")
536 "<li class=\"taskmanag\">"
537 "<a href=\"readfwd\">"
538 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
540 "<span class=\"navbar_link\">"
542 "</span></a></li>\n", _("View tasks")
547 "<li class=\"viewnotes\">"
548 "<a href=\"readfwd\">"
549 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
551 "<span class=\"navbar_link\">"
553 "</span></a></li>\n", _("View notes")
558 "<li class=\"readallmess\">"
559 "<a href=\"readfwd\">"
560 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
562 "<span class=\"navbar_link\">"
564 "</span></a></li>\n", _("View message list")
569 "<li class=\"readallmess\">"
570 "<a href=\"readfwd\">"
571 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
573 "<span class=\"navbar_link\">"
575 "</span></a></li>\n", _("Wiki home")
580 "<li class=\"readallmess\">"
581 "<a href=\"readfwd\">"
582 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
584 "<span class=\"navbar_link\">"
586 "</span></a></li>\n", _("Read all messages")
592 if (navbar_style == navbar_default) {
593 switch(WC->wc_view) {
594 case VIEW_ADDRESSBOOK:
596 "<li class=\"addnewcontact\">"
597 "<a href=\"display_enter\">"
598 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
599 "border=\"0\"><span class=\"navbar_link\">"
601 "</span></a></li>\n", _("Add new contact")
606 wprintf("<li class=\"addevent\"><a href=\"display_enter");
607 if (strlen(bstr("year")) > 0) wprintf("?year=%s", bstr("year"));
608 if (strlen(bstr("month")) > 0) wprintf("?month=%s", bstr("month"));
609 if (strlen(bstr("day")) > 0) wprintf("?day=%s", bstr("day"));
611 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
612 "border=\"0\"><span class=\"navbar_link\">"
614 "</span></a></li>\n", _("Add new event")
619 "<li class=\"newmess\">"
620 "<a href=\"display_enter\">"
621 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
622 "border=\"0\"><span class=\"navbar_link\">"
624 "</span></a></li>\n", _("Add new task")
629 "<li class=\"enternewnote\">"
630 "<a href=\"javascript:add_new_note();\">"
631 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
632 "border=\"0\"><span class=\"navbar_link\">"
634 "</span></a></li>\n", _("Add new note")
638 safestrncpy(buf, bstr("page"), sizeof buf);
641 "<li class=\"newmess\">"
642 "<a href=\"display_enter?wikipage=%s\">"
643 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
644 "border=\"0\"><span class=\"navbar_link\">"
646 "</span></a></li>\n", buf, _("Edit this page")
651 "<li class=\"newmess\">"
652 "<a href=\"display_enter\">"
653 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
654 "border=\"0\"><span class=\"navbar_link\">"
656 "</span></a></li>\n", _("Write mail")
661 "<li class=\"newmess\">"
662 "<a href=\"display_enter\">"
663 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
664 "border=\"0\"><span class=\"navbar_link\">"
666 "</span></a></li>\n", _("Enter a message")
672 if (navbar_style == navbar_default) wprintf(
673 "<li class=\"skipthisroom\">"
676 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
677 "<span class=\"navbar_link\">%s</span></a>"
679 _("Leave all messages marked as unread, go to next room with unread messages"),
683 if (navbar_style == navbar_default) wprintf(
684 "<li class=\"markngo\">"
685 "<a href=\"gotonext\" "
687 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
688 "<span class=\"navbar_link\">%s</span></a>"
690 _("Mark all messages as read, go to next room with unread messages"),
694 wprintf("</ul></div>\n");
701 * \brief back end routine to take the session to a new room
702 * \param gname room to go to
705 int gotoroom(char *gname)
708 static long ls = (-1L);
711 /** store ungoto information */
712 strcpy(WC->ugname, WC->wc_roomname);
715 /** move to the new room */
716 serv_printf("GOTO %s", gname);
717 serv_getln(buf, sizeof buf);
721 serv_puts("GOTO _BASEROOM_");
722 serv_getln(buf, sizeof buf);
729 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
730 WC->room_flags = extract_int(&buf[4], 4);
731 /* highest_msg_read = extract_int(&buf[4],6);
732 maxmsgnum = extract_int(&buf[4],5);
734 WC->is_mailbox = extract_int(&buf[4],7);
735 ls = extract_long(&buf[4], 6);
736 WC->wc_floor = extract_int(&buf[4], 10);
737 WC->wc_view = extract_int(&buf[4], 11);
738 WC->wc_default_view = extract_int(&buf[4], 12);
739 WC->wc_is_trash = extract_int(&buf[4], 13);
742 WC->is_room_aide = WC->is_aide;
744 WC->is_room_aide = (char) extract_int(&buf[4], 8);
746 remove_march(WC->wc_roomname);
747 if (!strcasecmp(gname, "_BASEROOM_"))
755 * \brief Locate the room on the march list which we most want to go to.
757 * is measured given a "weight" of preference based on various factors.
758 * \param desired_floor the room number on the citadel server
759 * \return the roomname
761 char *pop_march(int desired_floor)
763 static char TheRoom[128];
765 int TheOrder = 32767;
768 struct march *mptr = NULL;
770 strcpy(TheRoom, "_BASEROOM_");
771 if (WC->march == NULL)
774 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
776 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
777 weight = weight + 10000;
778 if (mptr->march_floor == desired_floor)
779 weight = weight + 5000;
781 weight = weight + ((128 - (mptr->march_floor)) * 128);
782 weight = weight + (128 - (mptr->march_order));
784 if (weight > TheWeight) {
786 strcpy(TheRoom, mptr->march_name);
787 TheFloor = mptr->march_floor;
788 TheOrder = mptr->march_order;
797 *\brief Goto next room having unread messages.
798 * We want to skip over rooms that the user has already been to, and take the
799 * user back to the lobby when done. The room we end up in is placed in
800 * newroom - which is set to 0 (the lobby) initially.
801 * We start the search in the current room rather than the beginning to prevent
802 * two or more concurrent users from dragging each other back to the same room.
807 struct march *mptr, *mptr2;
812 * First check to see if the march-mode list is already allocated.
813 * If it is, pop the first room off the list and go there.
816 if (WC->march == NULL) {
818 serv_getln(buf, sizeof buf);
820 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
821 extract_token(room_name, buf, 0, '|', sizeof room_name);
822 if (strcasecmp(room_name, WC->wc_roomname)) {
823 mptr = (struct march *) malloc(sizeof(struct march));
825 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
826 mptr->march_floor = extract_int(buf, 2);
827 mptr->march_order = extract_int(buf, 3);
828 if (WC->march == NULL) {
832 while (mptr2->next != NULL)
839 * add _BASEROOM_ to the end of the march list, so the user will end up
840 * in the system base room (usually the Lobby>) at the end of the loop
842 mptr = (struct march *) malloc(sizeof(struct march));
844 strcpy(mptr->march_name, "_BASEROOM_");
845 if (WC->march == NULL) {
849 while (mptr2->next != NULL)
854 * ...and remove the room we're currently in, so a <G>oto doesn't make us
855 * walk around in circles
857 remove_march(WC->wc_roomname);
859 if (WC->march != NULL) {
860 strcpy(next_room, pop_march(-1));
862 strcpy(next_room, "_BASEROOM_");
866 smart_goto(next_room);
871 * \brief goto next room
872 * \param next_room next room to go to
874 void smart_goto(char *next_room) {
882 * \brief mark all messages in current room as having been read
884 void slrp_highest(void)
888 serv_puts("SLRP HIGHEST");
889 serv_getln(buf, sizeof buf);
894 * \brief un-goto the previous room
900 if (!strcmp(WC->ugname, "")) {
901 smart_goto(WC->wc_roomname);
904 serv_printf("GOTO %s", WC->ugname);
905 serv_getln(buf, sizeof buf);
907 smart_goto(WC->wc_roomname);
910 if (WC->uglsn >= 0L) {
911 serv_printf("SLRP %ld", WC->uglsn);
912 serv_getln(buf, sizeof buf);
914 strcpy(buf, WC->ugname);
915 strcpy(WC->ugname, "");
924 * \brief Set/clear/read the "self-service list subscribe" flag for a room
926 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
927 * \return return the new value.
930 int self_service(int newval) {
931 int current_value = 0;
937 int flags, floor, order, view, flags2;
940 serv_getln(buf, sizeof buf);
941 if (buf[0] != '2') return(0);
943 extract_token(name, &buf[4], 0, '|', sizeof name);
944 extract_token(password, &buf[4], 1, '|', sizeof password);
945 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
946 flags = extract_int(&buf[4], 3);
947 floor = extract_int(&buf[4], 4);
948 order = extract_int(&buf[4], 5);
949 view = extract_int(&buf[4], 6);
950 flags2 = extract_int(&buf[4], 7);
952 if (flags2 & QR2_SELFLIST) {
960 flags2 = flags2 | QR2_SELFLIST;
962 else if (newval == 0) {
963 flags2 = flags2 & ~QR2_SELFLIST;
966 return(current_value);
969 if (newval != current_value) {
970 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
971 name, password, dirname, flags,
972 floor, order, view, flags2);
973 serv_getln(buf, sizeof buf);
986 * \brief display the form for editing a room
988 void display_editroom(void)
993 char remote_room[SIZ];
996 char er_password[10];
998 char er_roomaide[26];
1004 char *not_shared_with;
1007 int floorpolicy = 0;
1011 if (strlen(tab) == 0) tab = "admin";
1015 serv_getln(buf, sizeof buf);
1017 if (buf[0] != '2') {
1018 strcpy(WC->ImportantMessage, &buf[4]);
1019 display_main_menu();
1022 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1023 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1024 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1025 er_flags = extract_int(&buf[4], 3);
1026 er_floor = extract_int(&buf[4], 4);
1028 output_headers(1, 1, 1, 0, 0, 0);
1030 /** print the tabbed dialog */
1032 "<div class=\"fix_scrollbar_bug\">"
1033 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
1035 "<TD> </TD>\n");
1037 if (!strcmp(tab, "admin")) {
1038 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1041 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1043 wprintf(_("Administration"));
1044 if (!strcmp(tab, "admin")) {
1045 wprintf("</SPAN></TD>\n");
1048 wprintf("</A></TD>\n");
1051 wprintf("<TD> </TD>\n");
1053 if (!strcmp(tab, "config")) {
1054 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1057 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=config\">");
1059 wprintf(_("Configuration"));
1060 if (!strcmp(tab, "config")) {
1061 wprintf("</SPAN></TD>\n");
1064 wprintf("</A></TD>\n");
1067 wprintf("<TD> </TD>\n");
1069 if (!strcmp(tab, "expire")) {
1070 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1073 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1075 wprintf(_("Message expire policy"));
1076 if (!strcmp(tab, "expire")) {
1077 wprintf("</SPAN></TD>\n");
1080 wprintf("</A></TD>\n");
1083 wprintf("<TD> </TD>\n");
1085 if (!strcmp(tab, "access")) {
1086 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1089 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=access\">");
1091 wprintf(_("Access controls"));
1092 if (!strcmp(tab, "access")) {
1093 wprintf("</SPAN></TD>\n");
1096 wprintf("</A></TD>\n");
1099 wprintf("<TD> </TD>\n");
1101 if (!strcmp(tab, "sharing")) {
1102 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1105 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1107 wprintf(_("Sharing"));
1108 if (!strcmp(tab, "sharing")) {
1109 wprintf("</SPAN></TD>\n");
1112 wprintf("</A></TD>\n");
1115 wprintf("<TD> </TD>\n");
1117 if (!strcmp(tab, "listserv")) {
1118 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1121 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1123 wprintf(_("Mailing list service"));
1124 if (!strcmp(tab, "listserv")) {
1125 wprintf("</SPAN></TD>\n");
1128 wprintf("</A></TD>\n");
1131 wprintf("<TD> </TD>\n");
1133 wprintf("</TR></TABLE></div>\n");
1134 /** end tabbed dialog */
1136 /** begin content of whatever tab is open now */
1137 wprintf("<div class=\"fix_scrollbar_bug\">"
1138 "<TABLE class=\"roomops_background\">\n"
1141 if (!strcmp(tab, "admin")) {
1143 "<LI><a href=\"delete_room\" "
1144 "onClick=\"return confirm('");
1145 wprintf(_("Are you sure you want to delete this room?"));
1146 wprintf("');\">\n");
1147 wprintf(_("Delete this room"));
1149 "<LI><a href=\"display_editroompic\">\n");
1150 wprintf(_("Set or change the icon for this room's banner"));
1152 "<LI><a href=\"display_editinfo\">\n");
1153 wprintf(_("Edit this room's Info file"));
1158 if (!strcmp(tab, "config")) {
1159 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1161 wprintf("<UL><LI>");
1162 wprintf(_("Name of room: "));
1163 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1169 wprintf(_("Resides on floor: "));
1170 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1171 for (i = 0; i < 128; ++i)
1172 if (strlen(floorlist[i]) > 0) {
1173 wprintf("<OPTION ");
1175 wprintf("SELECTED ");
1176 wprintf("VALUE=\"%d\">", i);
1177 escputs(floorlist[i]);
1178 wprintf("</OPTION>\n");
1180 wprintf("</SELECT>\n");
1183 wprintf(_("Type of room:"));
1186 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1187 if ((er_flags & QR_PRIVATE) == 0)
1188 wprintf("CHECKED ");
1190 wprintf(_("Public room"));
1193 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1194 if ((er_flags & QR_PRIVATE) &&
1195 (er_flags & QR_GUESSNAME))
1196 wprintf("CHECKED ");
1198 wprintf(_("Private - guess name"));
1200 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1201 if ((er_flags & QR_PRIVATE) &&
1202 (er_flags & QR_PASSWORDED))
1203 wprintf("CHECKED ");
1205 wprintf(_("Private - require password:"));
1206 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1209 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1210 if ((er_flags & QR_PRIVATE)
1211 && ((er_flags & QR_GUESSNAME) == 0)
1212 && ((er_flags & QR_PASSWORDED) == 0))
1213 wprintf("CHECKED ");
1215 wprintf(_("Private - invitation only"));
1217 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1219 wprintf(_("If private, cause current users to forget room"));
1221 wprintf("\n</UL>\n");
1223 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1224 if (er_flags & QR_PREFONLY)
1225 wprintf("CHECKED ");
1227 wprintf(_("Preferred users only"));
1229 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1230 if (er_flags & QR_READONLY)
1231 wprintf("CHECKED ");
1233 wprintf(_("Read-only room"));
1235 /** directory stuff */
1236 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1237 if (er_flags & QR_DIRECTORY)
1238 wprintf("CHECKED ");
1240 wprintf(_("File directory room"));
1242 wprintf("\n<UL><LI>");
1243 wprintf(_("Directory name: "));
1244 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1247 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1248 if (er_flags & QR_UPLOAD)
1249 wprintf("CHECKED ");
1251 wprintf(_("Uploading allowed"));
1253 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1254 if (er_flags & QR_DOWNLOAD)
1255 wprintf("CHECKED ");
1257 wprintf(_("Downloading allowed"));
1259 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1260 if (er_flags & QR_VISDIR)
1261 wprintf("CHECKED ");
1263 wprintf(_("Visible directory"));
1266 /** end of directory stuff */
1268 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1269 if (er_flags & QR_NETWORK)
1270 wprintf("CHECKED ");
1272 wprintf(_("Network shared room"));
1274 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1275 if (er_flags & QR_PERMANENT)
1276 wprintf("CHECKED ");
1278 wprintf(_("Permanent (does not auto-purge)"));
1280 /** start of anon options */
1283 wprintf(_("Anonymous messages"));
1286 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1287 if (((er_flags & QR_ANONONLY) == 0)
1288 && ((er_flags & QR_ANONOPT) == 0))
1289 wprintf("CHECKED ");
1291 wprintf(_("No anonymous messages"));
1293 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1294 if (er_flags & QR_ANONONLY)
1295 wprintf("CHECKED ");
1297 wprintf(_("All messages are anonymous"));
1299 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1300 if (er_flags & QR_ANONOPT)
1301 wprintf("CHECKED ");
1303 wprintf(_("Prompt user when entering messages"));
1306 /* end of anon options */
1309 wprintf(_("Room aide: "));
1311 serv_getln(buf, sizeof buf);
1312 if (buf[0] != '2') {
1313 wprintf("<em>%s</em>\n", &buf[4]);
1315 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1316 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1319 wprintf("</UL><CENTER>\n");
1320 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1321 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1323 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1331 /** Sharing the room with other Citadel nodes... */
1332 if (!strcmp(tab, "sharing")) {
1334 shared_with = strdup("");
1335 not_shared_with = strdup("");
1337 /** Learn the current configuration */
1338 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1339 serv_getln(buf, sizeof buf);
1340 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1341 extract_token(node, buf, 0, '|', sizeof node);
1342 not_shared_with = realloc(not_shared_with,
1343 strlen(not_shared_with) + 32);
1344 strcat(not_shared_with, node);
1345 strcat(not_shared_with, "\n");
1349 serv_getln(buf, sizeof buf);
1350 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1351 extract_token(cmd, buf, 0, '|', sizeof cmd);
1352 extract_token(node, buf, 1, '|', sizeof node);
1353 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1354 if (!strcasecmp(cmd, "ignet_push_share")) {
1355 shared_with = realloc(shared_with,
1356 strlen(shared_with) + 32);
1357 strcat(shared_with, node);
1358 if (strlen(remote_room) > 0) {
1359 strcat(shared_with, "|");
1360 strcat(shared_with, remote_room);
1362 strcat(shared_with, "\n");
1366 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1367 extract_token(buf, shared_with, i, '\n', sizeof buf);
1368 extract_token(node, buf, 0, '|', sizeof node);
1369 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1370 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1371 if (!strcasecmp(node, cmd)) {
1372 remove_token(not_shared_with, j, '\n');
1377 /** Display the stuff */
1378 wprintf("<CENTER><br />"
1379 "<TABLE border=1 cellpadding=5><TR>"
1381 wprintf(_("Shared with"));
1382 wprintf("</I></B></TD>"
1384 wprintf(_("Not shared with"));
1385 wprintf("</I></B></TD></TR>\n"
1386 "<TR><TD VALIGN=TOP>\n");
1388 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1389 wprintf(_("Remote node name"));
1390 wprintf("</TD><TD>");
1391 wprintf(_("Remote room name"));
1392 wprintf("</TD><TD>");
1393 wprintf(_("Actions"));
1394 wprintf("</TD></TR>\n");
1396 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1397 extract_token(buf, shared_with, i, '\n', sizeof buf);
1398 extract_token(node, buf, 0, '|', sizeof node);
1399 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1400 if (strlen(node) > 0) {
1401 wprintf("<FORM METHOD=\"POST\" "
1402 "action=\"netedit\">"
1403 "<TR><TD>%s</TD>\n", node);
1406 if (strlen(remote_room) > 0) {
1407 escputs(remote_room);
1413 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1414 "VALUE=\"ignet_push_share|");
1416 if (strlen(remote_room) > 0) {
1418 urlescputs(remote_room);
1421 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1422 "VALUE=\"sharing\">\n");
1423 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1424 "VALUE=\"remove\">\n");
1425 wprintf("<INPUT TYPE=\"submit\" "
1426 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1427 wprintf("</TD></TR></FORM>\n");
1431 wprintf("</TABLE>\n");
1432 wprintf("</TD><TD VALIGN=TOP>\n");
1433 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1434 wprintf(_("Remote node name"));
1435 wprintf("</TD><TD>");
1436 wprintf(_("Remote room name"));
1437 wprintf("</TD><TD>");
1438 wprintf(_("Actions"));
1439 wprintf("</TD></TR>\n");
1441 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1442 extract_token(node, not_shared_with, i, '\n', sizeof node);
1443 if (strlen(node) > 0) {
1444 wprintf("<FORM METHOD=\"POST\" "
1445 "action=\"netedit\">"
1449 "<INPUT TYPE=\"INPUT\" "
1453 wprintf("<INPUT TYPE=\"hidden\" "
1455 "VALUE=\"ignet_push_share|");
1458 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1459 "VALUE=\"sharing\">\n");
1460 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1461 "VALUE=\"add\">\n");
1462 wprintf("<INPUT TYPE=\"submit\" "
1463 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1464 wprintf("</TD></TR></FORM>\n");
1468 wprintf("</TABLE>\n");
1469 wprintf("</TD></TR>"
1470 "</TABLE></CENTER><br />\n"
1471 "<I><B>%s</B><UL><LI>", _("Notes:"));
1472 wprintf(_("When sharing a room, "
1473 "it must be shared from both ends. Adding a node to "
1474 "the 'shared' list sends messages out, but in order to"
1475 " receive messages, the other nodes must be configured"
1476 " to send messages out to your system as well. "
1477 "<LI>If the remote room name is blank, it is assumed "
1478 "that the room name is identical on the remote node."
1479 "<LI>If the remote room name is different, the remote "
1480 "node must also configure the name of the room here."
1486 /** Mailing list management */
1487 if (!strcmp(tab, "listserv")) {
1489 wprintf("<br /><center>"
1490 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1491 "<TR><TD VALIGN=TOP>");
1493 wprintf(_("<i>The contents of this room are being "
1494 "mailed <b>as individual messages</b> "
1495 "to the following list recipients:"
1496 "</i><br /><br />\n"));
1499 serv_getln(buf, sizeof buf);
1500 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1501 extract_token(cmd, buf, 0, '|', sizeof cmd);
1502 if (!strcasecmp(cmd, "listrecp")) {
1503 extract_token(recp, buf, 1, '|', sizeof recp);
1506 wprintf(" <a href=\"netedit&cmd=remove&line="
1509 wprintf("&tab=listserv\">");
1510 wprintf(_("(remove)"));
1511 wprintf("</A><br />");
1514 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1515 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1516 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1517 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1518 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1519 wprintf("</FORM>\n");
1521 wprintf("</TD><TD VALIGN=TOP>\n");
1523 wprintf(_("<i>The contents of this room are being "
1524 "mailed <b>in digest form</b> "
1525 "to the following list recipients:"
1526 "</i><br /><br />\n"));
1529 serv_getln(buf, sizeof buf);
1530 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1531 extract_token(cmd, buf, 0, '|', sizeof cmd);
1532 if (!strcasecmp(cmd, "digestrecp")) {
1533 extract_token(recp, buf, 1, '|', sizeof recp);
1536 wprintf(" <a href=\"netedit&cmd=remove&line="
1539 wprintf("&tab=listserv\">");
1540 wprintf(_("(remove)"));
1541 wprintf("</A><br />");
1544 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1545 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1546 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1547 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1548 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1549 wprintf("</FORM>\n");
1551 wprintf("</TD></TR></TABLE><hr />\n");
1553 if (self_service(999) == 1) {
1554 wprintf(_("This room is configured to allow "
1555 "self-service subscribe/unsubscribe requests."));
1556 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1557 wprintf(_("Click to disable."));
1558 wprintf("</A><br />\n");
1559 wprintf(_("The URL for subscribe/unsubscribe is: "));
1560 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1561 (is_https ? "https" : "http"),
1565 wprintf(_("This room is <i>not</i> configured to allow "
1566 "self-service subscribe/unsubscribe requests."));
1567 wprintf(" <a href=\"toggle_self_service?newval=1&"
1569 wprintf(_("Click to enable."));
1570 wprintf("</A><br />\n");
1574 wprintf("</CENTER>\n");
1578 /** Mailing list management */
1579 if (!strcmp(tab, "expire")) {
1581 serv_puts("GPEX room");
1582 serv_getln(buf, sizeof buf);
1583 if (buf[0] == '2') {
1584 roompolicy = extract_int(&buf[4], 0);
1585 roomvalue = extract_int(&buf[4], 1);
1588 serv_puts("GPEX floor");
1589 serv_getln(buf, sizeof buf);
1590 if (buf[0] == '2') {
1591 floorpolicy = extract_int(&buf[4], 0);
1592 floorvalue = extract_int(&buf[4], 1);
1595 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1596 wprintf("<TABLE border=0 cellspacing=5>\n");
1597 wprintf("<TR><TD>");
1598 wprintf(_("Message expire policy for this room"));
1600 escputs(WC->wc_roomname);
1601 wprintf(")</TD><TD>");
1602 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1603 ((roompolicy == 0) ? "CHECKED" : "") );
1604 wprintf(_("Use the default policy for this floor"));
1605 wprintf("<br />\n");
1606 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1607 ((roompolicy == 1) ? "CHECKED" : "") );
1608 wprintf(_("Never automatically expire messages"));
1609 wprintf("<br />\n");
1610 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1611 ((roompolicy == 2) ? "CHECKED" : "") );
1612 wprintf(_("Expire by message count"));
1613 wprintf("<br />\n");
1614 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1615 ((roompolicy == 3) ? "CHECKED" : "") );
1616 wprintf(_("Expire by message age"));
1618 wprintf(_("Number of messages or days: "));
1619 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1620 wprintf("</TD></TR>\n");
1622 if (WC->axlevel >= 6) {
1623 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1624 wprintf("<TR><TD>");
1625 wprintf(_("Message expire policy for this floor"));
1627 escputs(floorlist[WC->wc_floor]);
1628 wprintf(")</TD><TD>");
1629 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1630 ((floorpolicy == 0) ? "CHECKED" : "") );
1631 wprintf(_("Use the system default"));
1632 wprintf("<br />\n");
1633 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1634 ((floorpolicy == 1) ? "CHECKED" : "") );
1635 wprintf(_("Never automatically expire messages"));
1636 wprintf("<br />\n");
1637 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1638 ((floorpolicy == 2) ? "CHECKED" : "") );
1639 wprintf(_("Expire by message count"));
1640 wprintf("<br />\n");
1641 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1642 ((floorpolicy == 3) ? "CHECKED" : "") );
1643 wprintf(_("Expire by message age"));
1645 wprintf(_("Number of messages or days: "));
1646 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1650 wprintf("<CENTER>\n");
1651 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1652 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1654 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1655 wprintf("</CENTER></TD><TR>\n");
1657 wprintf("</TABLE>\n"
1658 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1664 /** Mailing list management */
1665 if (!strcmp(tab, "access")) {
1669 /** end content of whatever tab is open now */
1670 wprintf("</TD></TR></TABLE></div>\n");
1677 * \brief Toggle self-service list subscription
1679 void toggle_self_service(void) {
1682 newval = atoi(bstr("newval"));
1683 self_service(newval);
1690 * \brief save new parameters for a room
1696 char er_password[10];
1697 char er_dirname[15];
1698 char er_roomaide[26];
1704 if (strlen(bstr("ok_button")) == 0) {
1705 strcpy(WC->ImportantMessage,
1706 _("Cancelled. Changes were not saved."));
1711 serv_getln(buf, sizeof buf);
1713 if (buf[0] != '2') {
1714 strcpy(WC->ImportantMessage, &buf[4]);
1718 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1719 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1720 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1721 er_flags = extract_int(&buf[4], 3);
1723 strcpy(er_roomaide, bstr("er_roomaide"));
1724 if (strlen(er_roomaide) == 0) {
1726 serv_getln(buf, sizeof buf);
1727 if (buf[0] != '2') {
1728 strcpy(er_roomaide, "");
1730 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1733 strcpy(buf, bstr("er_name"));
1735 if (strlen(buf) > 0) {
1736 strcpy(er_name, buf);
1739 strcpy(buf, bstr("er_password"));
1741 if (strlen(buf) > 0)
1742 strcpy(er_password, buf);
1744 strcpy(buf, bstr("er_dirname"));
1746 if (strlen(buf) > 0)
1747 strcpy(er_dirname, buf);
1749 strcpy(buf, bstr("type"));
1750 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1752 if (!strcmp(buf, "invonly")) {
1753 er_flags |= (QR_PRIVATE);
1755 if (!strcmp(buf, "hidden")) {
1756 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1758 if (!strcmp(buf, "passworded")) {
1759 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1761 if (!strcmp(bstr("prefonly"), "yes")) {
1762 er_flags |= QR_PREFONLY;
1764 er_flags &= ~QR_PREFONLY;
1767 if (!strcmp(bstr("readonly"), "yes")) {
1768 er_flags |= QR_READONLY;
1770 er_flags &= ~QR_READONLY;
1773 if (!strcmp(bstr("permanent"), "yes")) {
1774 er_flags |= QR_PERMANENT;
1776 er_flags &= ~QR_PERMANENT;
1779 if (!strcmp(bstr("network"), "yes")) {
1780 er_flags |= QR_NETWORK;
1782 er_flags &= ~QR_NETWORK;
1785 if (!strcmp(bstr("directory"), "yes")) {
1786 er_flags |= QR_DIRECTORY;
1788 er_flags &= ~QR_DIRECTORY;
1791 if (!strcmp(bstr("ulallowed"), "yes")) {
1792 er_flags |= QR_UPLOAD;
1794 er_flags &= ~QR_UPLOAD;
1797 if (!strcmp(bstr("dlallowed"), "yes")) {
1798 er_flags |= QR_DOWNLOAD;
1800 er_flags &= ~QR_DOWNLOAD;
1803 if (!strcmp(bstr("visdir"), "yes")) {
1804 er_flags |= QR_VISDIR;
1806 er_flags &= ~QR_VISDIR;
1809 strcpy(buf, bstr("anon"));
1811 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1812 if (!strcmp(buf, "anononly"))
1813 er_flags |= QR_ANONONLY;
1814 if (!strcmp(buf, "anon2"))
1815 er_flags |= QR_ANONOPT;
1818 if (!strcmp(bstr("bump"), "yes"))
1821 er_floor = atoi(bstr("er_floor"));
1823 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1824 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1826 serv_getln(buf, sizeof buf);
1827 if (buf[0] != '2') {
1828 strcpy(WC->ImportantMessage, &buf[4]);
1834 if (strlen(er_roomaide) > 0) {
1835 sprintf(buf, "SETA %s", er_roomaide);
1837 serv_getln(buf, sizeof buf);
1838 if (buf[0] != '2') {
1839 strcpy(WC->ImportantMessage, &buf[4]);
1840 display_main_menu();
1845 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1852 * \brief Display form for Invite, Kick, and show Who Knows a room
1854 void do_invt_kick(void) {
1855 char buf[SIZ], room[SIZ], username[SIZ];
1858 serv_getln(buf, sizeof buf);
1860 if (buf[0] != '2') {
1864 extract_token(room, &buf[4], 0, '|', sizeof room);
1866 strcpy(username, bstr("username"));
1868 if (strlen(bstr("kick_button")) > 0) {
1869 sprintf(buf, "KICK %s", username);
1871 serv_getln(buf, sizeof buf);
1873 if (buf[0] != '2') {
1874 strcpy(WC->ImportantMessage, &buf[4]);
1876 sprintf(WC->ImportantMessage,
1877 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1882 if (strlen(bstr("invite_button")) > 0) {
1883 sprintf(buf, "INVT %s", username);
1885 serv_getln(buf, sizeof buf);
1887 if (buf[0] != '2') {
1888 strcpy(WC->ImportantMessage, &buf[4]);
1890 sprintf(WC->ImportantMessage,
1891 _("<B><I>User %s invited to room %s.</I></B>\n"),
1902 * \brief Display form for Invite, Kick, and show Who Knows a room
1904 void display_whok(void)
1906 char buf[SIZ], room[SIZ], username[SIZ];
1909 serv_getln(buf, sizeof buf);
1911 if (buf[0] != '2') {
1915 extract_token(room, &buf[4], 0, '|', sizeof room);
1918 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1919 wprintf(_("The users listed below have access to this room. "
1920 "To remove a user from the access list, select the user "
1921 "name from the list and click 'Kick'."));
1922 wprintf("<br /><br />");
1924 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1925 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1926 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1928 serv_getln(buf, sizeof buf);
1929 if (buf[0] == '1') {
1930 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1931 extract_token(username, buf, 0, '|', sizeof username);
1932 wprintf("<OPTION>");
1937 wprintf("</SELECT><br />\n");
1939 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1940 wprintf("</FORM></CENTER>\n");
1942 wprintf("</TD><TD>");
1943 wprintf(_("To grant another user access to this room, enter the "
1944 "user name in the box below and click 'Invite'."));
1945 wprintf("<br /><br />");
1947 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1948 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1949 wprintf(_("Invite:"));
1951 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1952 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1953 "<input type=\"submit\" value=\"%s\">"
1954 "</FORM></CENTER>\n", _("Invite"));
1956 wprintf("</TD></TR></TABLE>\n");
1963 * \brief display the form for entering a new room
1965 void display_entroom(void)
1970 serv_puts("CRE8 0");
1971 serv_getln(buf, sizeof buf);
1973 if (buf[0] != '2') {
1974 strcpy(WC->ImportantMessage, &buf[4]);
1975 display_main_menu();
1979 output_headers(1, 1, 2, 0, 0, 0);
1980 wprintf("<div id=\"banner\">\n"
1981 "<TABLE class=\"roomops_banner\"><TR><TD>"
1982 "<SPAN CLASS=\"titlebar\">");
1983 wprintf(_("Create a new room"));
1985 "</TD></TR></TABLE>\n"
1986 "</div>\n<div id=\"content\">\n"
1989 wprintf("<div class=\"fix_scrollbar_bug\">"
1990 "<table class=\"roomops_background\"><tr><td>\n");
1992 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1994 wprintf("<UL><LI>");
1995 wprintf(_("Name of room: "));
1996 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1999 wprintf(_("Resides on floor: "));
2001 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
2002 for (i = 0; i < 128; ++i)
2003 if (strlen(floorlist[i]) > 0) {
2004 wprintf("<OPTION ");
2005 wprintf("VALUE=\"%d\">", i);
2006 escputs(floorlist[i]);
2007 wprintf("</OPTION>\n");
2009 wprintf("</SELECT>\n");
2012 * Our clever little snippet of JavaScript automatically selects
2013 * a public room if the view is set to Bulletin Board or wiki, and
2014 * it selects a mailbox room otherwise. The user can override this,
2015 * of course. We also disable the floor selector for mailboxes.
2018 wprintf(_("Default view for room: "));
2019 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
2020 " if ( (this.form.er_view.value == 0) "
2021 " || (this.form.er_view.value == 6) ) { "
2022 " this.form.type[0].checked=true; "
2023 " this.form.er_floor.disabled = false; "
2026 " this.form.type[4].checked=true; "
2027 " this.form.er_floor.disabled = true; "
2030 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2031 if (is_view_allowed_as_default(i)) {
2032 wprintf("<OPTION %s VALUE=\"%d\">",
2033 ((i == 0) ? "SELECTED" : ""), i );
2034 escputs(viewdefs[i]);
2035 wprintf("</OPTION>\n");
2038 wprintf("</SELECT>\n");
2041 wprintf(_("Type of room:"));
2044 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2045 wprintf("CHECKED OnChange=\""
2046 " if (this.form.type[0].checked == true) { "
2047 " this.form.er_floor.disabled = false; "
2050 wprintf(_("Public (automatically appears to everyone)"));
2052 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2053 " if (this.form.type[1].checked == true) { "
2054 " this.form.er_floor.disabled = false; "
2057 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2059 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2060 " if (this.form.type[2].checked == true) { "
2061 " this.form.er_floor.disabled = false; "
2064 wprintf(_("Private - require password: "));
2065 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2067 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2068 " if (this.form.type[3].checked == true) { "
2069 " this.form.er_floor.disabled = false; "
2072 wprintf(_("Private - invitation only"));
2074 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2076 " if (this.form.type[4].checked == true) { "
2077 " this.form.er_floor.disabled = true; "
2080 wprintf(_("Personal (mailbox for you only)"));
2082 wprintf("\n</UL>\n");
2084 wprintf("<CENTER>\n");
2085 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2087 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2088 wprintf("</CENTER>\n");
2089 wprintf("</FORM>\n<hr />");
2090 serv_printf("MESG roomaccess");
2091 serv_getln(buf, sizeof buf);
2092 if (buf[0] == '1') {
2095 wprintf("</td></tr></table></div>\n");
2103 * \brief support function for entroom() -- sets the default view
2105 void er_set_default_view(int newview) {
2118 serv_getln(buf, sizeof buf);
2119 if (buf[0] != '2') return;
2121 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2122 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2123 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2124 rm_bits1 = extract_int(&buf[4], 3);
2125 rm_floor = extract_int(&buf[4], 4);
2126 rm_listorder = extract_int(&buf[4], 5);
2127 rm_bits2 = extract_int(&buf[4], 7);
2129 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2130 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2131 rm_listorder, newview, rm_bits2
2133 serv_getln(buf, sizeof buf);
2139 * \brief enter a new room
2146 char er_password[SIZ];
2151 if (strlen(bstr("ok_button")) == 0) {
2152 strcpy(WC->ImportantMessage,
2153 _("Cancelled. No new room was created."));
2154 display_main_menu();
2157 strcpy(er_name, bstr("er_name"));
2158 strcpy(er_type, bstr("type"));
2159 strcpy(er_password, bstr("er_password"));
2160 er_floor = atoi(bstr("er_floor"));
2161 er_view = atoi(bstr("er_view"));
2164 if (!strcmp(er_type, "hidden"))
2166 if (!strcmp(er_type, "passworded"))
2168 if (!strcmp(er_type, "invonly"))
2170 if (!strcmp(er_type, "personal"))
2173 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2174 er_name, er_num_type, er_password, er_floor, 0, er_view);
2176 serv_getln(buf, sizeof buf);
2177 if (buf[0] != '2') {
2178 strcpy(WC->ImportantMessage, &buf[4]);
2179 display_main_menu();
2183 do_change_view(er_view); /* Now go there */
2188 * \brief display the screen to enter a private room
2190 void display_private(char *rname, int req_pass)
2192 output_headers(1, 1, 2, 0, 0, 0);
2193 wprintf("<div id=\"banner\">\n"
2194 "<TABLE class=\"roomops_banner\"><TR><TD>"
2195 "<SPAN CLASS=\"titlebar\">");
2196 wprintf(_("Go to a hidden room"));
2198 "</TD></TR></TABLE>\n"
2199 "</div>\n<div id=\"content\">\n"
2202 wprintf("<div class=\"fix_scrollbar_bug\">"
2203 "<table class=\"roomops_background\"><tr><td>\n");
2205 wprintf("<CENTER>\n");
2207 wprintf(_("If you know the name of a hidden (guess-name) or "
2208 "passworded room, you can enter that room by typing "
2209 "its name below. Once you gain access to a private "
2210 "room, it will appear in your regular room listings "
2211 "so you don't have to keep returning here."));
2212 wprintf("\n<br /><br />");
2214 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2216 wprintf("<table border=\"0\" cellspacing=\"5\" "
2217 "cellpadding=\"5\" class=\"roomops_background_alt\">\n"
2219 wprintf(_("Enter room name:"));
2221 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2222 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2225 wprintf("</TD></TR><TR><TD>");
2226 wprintf(_("Enter room password:"));
2227 wprintf("</TD><TD>");
2228 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2230 wprintf("</TD></TR></TABLE><br />\n");
2232 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2234 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2238 wprintf("</FORM>\n");
2239 wprintf("</td></tr></table></div>\n");
2244 * \brief goto a private room
2246 void goto_private(void)
2251 if (strlen(bstr("ok_button")) == 0) {
2252 display_main_menu();
2255 strcpy(hold_rm, WC->wc_roomname);
2256 strcpy(buf, "GOTO ");
2257 strcat(buf, bstr("gr_name"));
2259 strcat(buf, bstr("gr_pass"));
2261 serv_getln(buf, sizeof buf);
2263 if (buf[0] == '2') {
2264 smart_goto(bstr("gr_name"));
2267 if (!strncmp(buf, "540", 3)) {
2268 display_private(bstr("gr_name"), 1);
2271 output_headers(1, 1, 1, 0, 0, 0);
2272 wprintf("%s\n", &buf[4]);
2279 * \brief display the screen to zap a room
2281 void display_zap(void)
2283 output_headers(1, 1, 2, 0, 0, 0);
2285 wprintf("<div id=\"banner\">\n");
2286 wprintf("<TABLE class=\"roomops_zap\"><TR><TD>");
2287 wprintf("<SPAN CLASS=\"titlebar\">");
2288 wprintf(_("Zap (forget/unsubscribe) the current room"));
2289 wprintf("</SPAN>\n");
2290 wprintf("</TD></TR></TABLE>\n");
2291 wprintf("</div>\n<div id=\"content\">\n");
2293 wprintf(_("If you select this option, <em>%s</em> will "
2294 "disappear from your room list. Is this what you wish "
2295 "to do?<br />\n"), WC->wc_roomname);
2297 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2298 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2300 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2301 wprintf("</FORM>\n");
2312 char final_destination[SIZ];
2315 * If the forget-room routine fails for any reason, we fall back
2316 * to the current room; otherwise, we go to the Lobby
2318 strcpy(final_destination, WC->wc_roomname);
2320 if (strlen(bstr("ok_button")) > 0) {
2321 serv_printf("GOTO %s", WC->wc_roomname);
2322 serv_getln(buf, sizeof buf);
2323 if (buf[0] == '2') {
2325 serv_getln(buf, sizeof buf);
2326 if (buf[0] == '2') {
2327 strcpy(final_destination, "_BASEROOM_");
2331 smart_goto(final_destination);
2337 * \brief Delete the current room
2339 void delete_room(void)
2343 serv_puts("KILL 1");
2344 serv_getln(buf, sizeof buf);
2345 if (buf[0] != '2') {
2346 strcpy(WC->ImportantMessage, &buf[4]);
2347 display_main_menu();
2350 smart_goto("_BASEROOM_");
2357 * \brief Perform changes to a room's network configuration
2359 void netedit(void) {
2368 if (strlen(bstr("line"))==0) {
2373 strcpy(line, bstr("prefix"));
2374 strcat(line, bstr("line"));
2375 strcat(line, bstr("suffix"));
2384 serv_getln(buf, sizeof buf);
2385 if (buf[0] != '1') {
2391 /** This loop works for add *or* remove. Spiffy, eh? */
2392 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2393 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2394 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2395 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2396 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2397 if ( (strcasecmp(cmpa0, cmpb0))
2398 || (strcasecmp(cmpa1, cmpb1)) ) {
2399 fprintf(fp, "%s\n", buf);
2405 serv_getln(buf, sizeof buf);
2406 if (buf[0] != '4') {
2412 while (fgets(buf, sizeof buf, fp) != NULL) {
2413 buf[strlen(buf)-1] = 0;
2417 if (strlen(bstr("add_button")) > 0) {
2429 * \brief Convert a room name to a folder-ish-looking name.
2430 * \param folder the folderish name
2431 * \param room the room name
2432 * \param floor the floor name
2433 * \param is_mailbox is it a mailbox?
2435 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2440 * For mailboxes, just do it straight...
2443 sprintf(folder, "My folders|%s", room);
2447 * Otherwise, prefix the floor name as a "public folders" moniker
2450 sprintf(folder, "%s|%s", floorlist[floor], room);
2454 * Replace "\" characters with "|" for pseudo-folder-delimiting
2456 for (i=0; i<strlen(folder); ++i) {
2457 if (folder[i] == '\\') folder[i] = '|';
2465 * \brief Back end for change_view()
2466 * \param newview set newview???
2468 void do_change_view(int newview) {
2471 serv_printf("VIEW %d", newview);
2472 serv_getln(buf, sizeof buf);
2473 WC->wc_view = newview;
2474 smart_goto(WC->wc_roomname);
2480 * \brief Change the view for this room
2482 void change_view(void) {
2485 view = atol(bstr("view"));
2486 do_change_view(view);
2491 * \brief One big expanded tree list view --- like a folder list
2492 * \param fold the folder to view
2493 * \param max_folders how many folders???
2494 * \param num_floors hom many floors???
2496 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2500 int has_subfolders = 0;
2503 parents = malloc(max_folders * sizeof(int));
2505 /** BEGIN TREE MENU */
2506 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2508 /** include NanoTree */
2509 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2511 /** initialize NanoTree */
2512 wprintf("<script type=\"text/javascript\"> \n"
2513 " showRootNode = false; \n"
2514 " sortNodes = false; \n"
2515 " dragable = false; \n"
2517 " function standardClick(treeNode) { \n"
2520 " var closedGif = 'static/folder_closed.gif'; \n"
2521 " var openGif = 'static/folder_open.gif'; \n"
2523 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2527 for (i=0; i<max_folders; ++i) {
2530 if ((i+1) < max_folders) {
2531 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2532 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2537 levels = num_tokens(fold[i].name, '|');
2538 parents[levels] = i;
2540 wprintf("var node%d = new TreeNode(%d, '", i, i);
2542 if (fold[i].selectable) {
2543 wprintf("<a href=\"dotgoto?room=");
2544 urlescputs(fold[i].room);
2549 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2551 else if (fold[i].hasnewmsgs) {
2552 wprintf("<SPAN CLASS=\"roomlist_new\">");
2555 wprintf("<SPAN CLASS=\"roomlist_old\">");
2557 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2562 if (has_subfolders) {
2563 wprintf("new Array(closedGif, openGif)");
2565 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2566 wprintf("'static/viewcontacts_16x.gif'");
2568 else if (fold[i].view == VIEW_CALENDAR) {
2569 wprintf("'static/calarea_16x.gif'");
2571 else if (fold[i].view == VIEW_CALBRIEF) {
2572 wprintf("'static/calarea_16x.gif'");
2574 else if (fold[i].view == VIEW_TASKS) {
2575 wprintf("'static/taskmanag_16x.gif'");
2577 else if (fold[i].view == VIEW_NOTES) {
2578 wprintf("'static/storenotes_16x.gif'");
2580 else if (fold[i].view == VIEW_MAILBOX) {
2581 wprintf("'static/privatemess_16x.gif'");
2584 wprintf("'static/chatrooms_16x.gif'");
2587 urlescputs(fold[i].name);
2591 wprintf("rootNode.addChild(node%d);\n", i);
2594 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2598 wprintf("container = document.getElementById('roomlist_div'); \n"
2604 /** END TREE MENU */
2608 * \brief Boxes and rooms and lists ... oh my!
2609 * \param fold the folder to view
2610 * \param max_folders how many folders???
2611 * \param num_floors hom many floors???
2613 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2615 char floor_name[256];
2616 char old_floor_name[256];
2618 int levels, oldlevels;
2621 static int columns = 3;
2622 int boxes_per_column = 0;
2623 int current_column = 0;
2626 strcpy(floor_name, "");
2627 strcpy(old_floor_name, "");
2630 while (nf % columns != 0) ++nf;
2631 boxes_per_column = (nf / columns);
2632 if (boxes_per_column < 1) boxes_per_column = 1;
2634 /** Outer table (for columnization) */
2635 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2636 "<tr><td valign=top>");
2640 for (i=0; i<max_folders; ++i) {
2642 levels = num_tokens(fold[i].name, '|');
2643 extract_token(floor_name, fold[i].name, 0,
2644 '|', sizeof floor_name);
2646 if ( (strcasecmp(floor_name, old_floor_name))
2647 && (strlen(old_floor_name) > 0) ) {
2649 do_template("endbox");
2652 if ((num_boxes % boxes_per_column) == 0) {
2654 if (current_column < columns) {
2655 wprintf("</td><td valign=top>\n");
2659 strcpy(old_floor_name, floor_name);
2662 /** Begin inner box */
2663 stresc(boxtitle, floor_name, 1, 0);
2664 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2665 do_template("beginbox");
2672 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2673 if (fold[i].selectable) {
2674 wprintf("<a href=\"dotgoto?room=");
2675 urlescputs(fold[i].room);
2681 if (fold[i].hasnewmsgs) {
2682 wprintf("<SPAN CLASS=\"roomlist_new\">");
2685 wprintf("<SPAN CLASS=\"roomlist_old\">");
2687 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2690 if (fold[i].selectable) {
2696 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2697 wprintf(" (INBOX)");
2699 wprintf("<br />\n");
2702 /** End the final inner box */
2703 do_template("endbox");
2705 wprintf("</TD></TR></TABLE>\n");
2709 * \brief print a floor div???
2710 * \param which_floordiv name of the floordiv???
2712 void set_floordiv_expanded(char *which_floordiv) {
2713 begin_ajax_response();
2714 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2715 end_ajax_response();
2719 * \brief view the iconbar
2720 * \param fold the folder to view
2721 * \param max_folders how many folders???
2722 * \param num_floors hom many floors???
2724 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2726 char floor_name[256];
2727 char old_floor_name[256];
2728 char floordivtitle[256];
2729 char floordiv_id[32];
2730 int levels, oldlevels;
2732 int num_drop_targets = 0;
2735 strcpy(floor_name, "");
2736 strcpy(old_floor_name, "");
2740 for (i=0; i<max_folders; ++i) {
2742 levels = num_tokens(fold[i].name, '|');
2743 extract_token(floor_name, fold[i].name, 0,
2744 '|', sizeof floor_name);
2746 if ( (strcasecmp(floor_name, old_floor_name))
2747 && (strlen(old_floor_name) > 0) ) {
2748 /** End inner box */
2750 wprintf("</div>\n"); /** floordiv */
2752 strcpy(old_floor_name, floor_name);
2756 stresc(floordivtitle, floor_name, 0, 0);
2757 sprintf(floordiv_id, "floordiv%d", i);
2758 wprintf("<span class=\"ib_roomlist_floor\" "
2759 "onClick=\"expand_floor('%s')\">"
2760 "%s</span><br>\n", floordiv_id, floordivtitle);
2761 wprintf("<div id=\"%s\" style=\"display:%s\">",
2763 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2770 wprintf("<div id=\"roomdiv%d\">", i);
2772 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2774 /** choose the icon */
2775 if (fold[i].view == VIEW_ADDRESSBOOK) {
2776 icon = "viewcontacts_16x.gif" ;
2778 else if (fold[i].view == VIEW_CALENDAR) {
2779 icon = "calarea_16x.gif" ;
2781 else if (fold[i].view == VIEW_CALBRIEF) {
2782 icon = "calarea_16x.gif" ;
2784 else if (fold[i].view == VIEW_TASKS) {
2785 icon = "taskmanag_16x.gif" ;
2787 else if (fold[i].view == VIEW_NOTES) {
2788 icon = "storenotes_16x.gif" ;
2790 else if (fold[i].view == VIEW_MAILBOX) {
2791 icon = "privatemess_16x.gif" ;
2794 icon = "chatrooms_16x.gif" ;
2797 if (fold[i].selectable) {
2798 wprintf("<a href=\"dotgoto?room=");
2799 urlescputs(fold[i].room);
2801 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2806 if (fold[i].hasnewmsgs) {
2807 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2810 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2812 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2814 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2815 wprintf(" (INBOX)");
2818 if (fold[i].selectable) {
2825 wprintf("</div>\n"); /** roomdiv */
2828 wprintf("</div>\n"); /** floordiv */
2831 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2832 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2834 num_drop_targets = 0;
2836 for (i=0; i<max_folders; ++i) {
2837 levels = num_tokens(fold[i].name, '|');
2839 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2840 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2841 jsescputs(fold[i].room);
2847 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2848 if (strlen(WC->floordiv_expanded) > 1) {
2849 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2853 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2859 * \brief Show the room list.
2860 * (only should get called by
2861 * knrooms() because that's where output_headers() is called from)
2862 * \param viewpref the view preferences???
2865 void list_all_rooms_by_floor(char *viewpref) {
2868 struct folder *fold = NULL;
2870 int max_folders = 0;
2871 int alloc_folders = 0;
2875 int num_floors = 1; /** add an extra one for private folders */
2877 /** If our cached folder list is very old, burn it. */
2878 if (WC->cache_fold != NULL) {
2879 if ((time(NULL) - WC->cache_timestamp) > 300) {
2880 free(WC->cache_fold);
2881 WC->cache_fold = NULL;
2885 /** Can we do the iconbar roomlist from cache? */
2886 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2887 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2891 /** Grab the floor table so we know how to build the list... */
2894 /** Start with the mailboxes */
2897 fold = malloc(sizeof(struct folder));
2898 memset(fold, 0, sizeof(struct folder));
2899 strcpy(fold[0].name, "My folders");
2900 fold[0].is_mailbox = 1;
2902 /** Then add floors */
2904 serv_getln(buf, sizeof buf);
2905 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2906 if (max_folders >= alloc_folders) {
2907 alloc_folders = max_folders + 100;
2908 fold = realloc(fold,
2909 alloc_folders * sizeof(struct folder));
2911 memset(&fold[max_folders], 0, sizeof(struct folder));
2912 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2917 /** refresh the messages index for this room */
2918 // serv_puts("GOTO ");
2919 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
2920 /** Now add rooms */
2922 serv_getln(buf, sizeof buf);
2923 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2924 if (max_folders >= alloc_folders) {
2925 alloc_folders = max_folders + 100;
2926 fold = realloc(fold,
2927 alloc_folders * sizeof(struct folder));
2929 memset(&fold[max_folders], 0, sizeof(struct folder));
2930 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2931 ra_flags = extract_int(buf, 5);
2932 flags = extract_int(buf, 1);
2933 fold[max_folders].floor = extract_int(buf, 2);
2934 fold[max_folders].hasnewmsgs =
2935 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2936 if (flags & QR_MAILBOX) {
2937 fold[max_folders].is_mailbox = 1;
2939 fold[max_folders].view = extract_int(buf, 6);
2940 room_to_folder(fold[max_folders].name,
2941 fold[max_folders].room,
2942 fold[max_folders].floor,
2943 fold[max_folders].is_mailbox);
2944 fold[max_folders].selectable = 1;
2948 /** Bubble-sort the folder list */
2949 for (i=0; i<max_folders; ++i) {
2950 for (j=0; j<(max_folders-1)-i; ++j) {
2951 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2952 swap = strcasecmp(fold[j].name, fold[j+1].name);
2955 if ( (fold[j+1].is_mailbox)
2956 && (!fold[j].is_mailbox)) {
2964 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2965 memcpy(&fold[j], &fold[j+1],
2966 sizeof(struct folder));
2967 memcpy(&fold[j+1], &ftmp,
2968 sizeof(struct folder));
2974 if (!strcasecmp(viewpref, "folders")) {
2975 do_folder_view(fold, max_folders, num_floors);
2977 else if (!strcasecmp(viewpref, "hackish_view")) {
2978 for (i=0; i<max_folders; ++i) {
2979 escputs(fold[i].name);
2980 wprintf("<br />\n");
2983 else if (!strcasecmp(viewpref, "iconbar")) {
2984 do_iconbar_view(fold, max_folders, num_floors);
2987 do_rooms_view(fold, max_folders, num_floors);
2990 /* Don't free the folder list ... cache it for future use! */
2991 if (WC->cache_fold != NULL) {
2992 free(WC->cache_fold);
2994 WC->cache_fold = fold;
2995 WC->cache_max_folders = max_folders;
2996 WC->cache_num_floors = num_floors;
2997 WC->cache_timestamp = time(NULL);
3002 * \brief Do either a known rooms list or a folders list, depending on the
3007 char listviewpref[SIZ];
3009 output_headers(1, 1, 2, 0, 0, 0);
3011 /** Determine whether the user is trying to change views */
3012 if (bstr("view") != NULL) {
3013 if (strlen(bstr("view")) > 0) {
3014 set_preference("roomlistview", bstr("view"), 1);
3018 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3020 if ( (strcasecmp(listviewpref, "folders"))
3021 && (strcasecmp(listviewpref, "table")) ) {
3022 strcpy(listviewpref, "rooms");
3026 wprintf("<div id=\"banner\">\n"
3027 "<TABLE class=\"roomops_banner\"><TR><TD>"
3028 "<SPAN CLASS=\"titlebar\">"
3030 if (!strcasecmp(listviewpref, "rooms")) {
3031 wprintf(_("Room list"));
3033 if (!strcasecmp(listviewpref, "folders")) {
3034 wprintf(_("Folder list"));
3036 if (!strcasecmp(listviewpref, "table")) {
3037 wprintf(_("Room list"));
3039 wprintf("</SPAN></TD>\n");
3041 /** offer the ability to switch views */
3042 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
3043 "<SELECT NAME=\"newview\" SIZE=\"1\" "
3044 "OnChange=\"location.href=roomlistomatic.newview.options"
3045 "[selectedIndex].value\">\n");
3047 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3050 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3053 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3054 "View as folder list"
3056 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3059 wprintf("</SELECT><br />");
3061 wprintf("</FORM></TD></TR></TABLE>\n");
3064 "<div id=\"content\">\n");
3066 /** Display the room list in the user's preferred format */
3067 list_all_rooms_by_floor(listviewpref);
3074 * \brief Set the message expire policy for this room and/or floor
3076 void set_room_policy(void) {
3079 if (strlen(bstr("ok_button")) == 0) {
3080 strcpy(WC->ImportantMessage,
3081 _("Cancelled. Changes were not saved."));
3086 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3087 serv_getln(buf, sizeof buf);
3088 strcpy(WC->ImportantMessage, &buf[4]);
3090 if (WC->axlevel >= 6) {
3091 strcat(WC->ImportantMessage, "<br />\n");
3092 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3093 serv_getln(buf, sizeof buf);
3094 strcat(WC->ImportantMessage, &buf[4]);