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 int fullinfo_len = 0;
281 serv_getln(buf, sizeof buf);
284 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
285 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
286 strcpy(&fullinfo[fullinfo_len], buf);
287 fullinfo_len += strlen(buf);
291 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
292 strcpy(&briefinfo[50], "...");
294 wprintf("<div class=\"infos\" "
295 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
298 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
299 wprintf("<img class=\"close_infos\" "
300 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
301 "src=\"static/closewindow.gif\" alt=\"%s\">",
316 * \brief Display room banner icon.
317 * The server doesn't actually
318 * need the room name, but we supply it in order to
319 * keep the browser from using a cached icon from
322 void embed_room_graphic(void) {
325 serv_puts("OIMG _roompic_");
326 serv_getln(buf, sizeof buf);
328 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
329 urlescputs(WC->wc_roomname);
332 serv_getln(buf, sizeof buf);
334 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
335 wprintf("<img height=48 width=48 src=\""
336 "static/viewcontacts_48x.gif"
340 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
341 wprintf("<img height=48 width=48 src=\""
342 "static/calarea_48x.gif"
346 else if (WC->wc_view == VIEW_TASKS) {
347 wprintf("<img height=48 width=48 src=\""
348 "static/taskmanag_48x.gif"
352 else if (WC->wc_view == VIEW_NOTES) {
353 wprintf("<img height=48 width=48 src=\""
354 "static/storenotes_48x.gif"
358 else if (WC->wc_view == VIEW_MAILBOX) {
359 wprintf("<img height=48 width=48 src=\""
360 "static/privatemess_48x.gif"
365 wprintf("<img height=48 width=48 src=\""
366 "static/chatrooms_48x.gif"
376 * \brief Display the current view and offer an option to change it
378 void embed_view_o_matic(void) {
381 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
382 "<label for=\"view_name\">");
383 wprintf(_("View as:"));
385 "<select name=\"newview\" size=\"1\" "
386 "id=\"view_name\" class=\"selectbox\" "
387 "OnChange=\"location.href=viewomatic.newview.options"
388 "[selectedIndex].value\">\n");
390 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
392 * Only offer the views that make sense, given the default
393 * view for the room. For example, don't offer a Calendar
394 * view in a non-Calendar room.
398 || (i == WC->wc_default_view) /**< default */
399 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
400 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
401 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
404 wprintf("<option %s value=\"changeview?view=%d\">",
405 ((i == WC->wc_view) ? "selected" : ""),
407 escputs(viewdefs[i]);
408 wprintf("</option>\n");
411 wprintf("</select></form>\n");
416 * \brief Display a search box
418 void embed_search_o_matic(void) {
419 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n"
420 "<label for=\"search_name\">");
421 wprintf(_("Search: "));
422 wprintf("</label> <input "
423 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
424 "id=\"search_name\" class=\"inputbox\">\n"
426 wprintf("</select></form>\n");
431 * \brief Embed the room banner
433 * \param got The information returned from a GOTO server command
434 * \param navbar_style Determines which navigation buttons to display
438 void embed_room_banner(char *got, int navbar_style) {
442 * We need to have the information returned by a GOTO server command.
443 * If it isn't supplied, we fake it by issuing our own GOTO.
446 serv_printf("GOTO %s", WC->wc_roomname);
447 serv_getln(buf, sizeof buf);
451 /** The browser needs some information for its own use */
452 wprintf("<script type=\"text/javascript\"> \n"
453 " room_is_trash = %d; \n"
459 * If the user happens to select the "make this my start page" link,
460 * we want it to remember the URL as a "/dotskip" one instead of
461 * a "skip" or "gotonext" or something like that.
463 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
466 /** Check for new mail. */
467 WC->new_mail = extract_int(&got[4], 9);
468 WC->wc_view = extract_int(&got[4], 11);
470 stresc(buf, WC->wc_roomname, 1, 1);
471 svprintf("ROOMNAME", WCS_STRING, "%s", buf);
472 svprintf("NUMMSGS", WCS_STRING,
473 _("%d new of %d messages"),
474 extract_int(&got[4], 1),
475 extract_int(&got[4], 2)
477 svcallback("ROOMPIC", embed_room_graphic);
478 svcallback("ROOMINFO", readinfo);
479 svcallback("VIEWOMATIC", embed_view_o_matic);
480 svcallback("SEARCHOMATIC", embed_search_o_matic);
481 svcallback("START", offer_start_page);
483 do_template("roombanner");
484 if (navbar_style != navbar_none) {
486 wprintf("<div id=\"navbar\"><ul>");
488 if (navbar_style == navbar_default) wprintf(
489 "<li class=\"ungoto\">"
490 "<a href=\"ungoto\">"
491 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
492 "<span class=\"navbar_link\">%s</span></A>"
493 "</li>\n", _("Ungoto")
496 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
498 "<li class=\"newmess\">"
499 "<a href=\"readnew\">"
500 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
501 "<span class=\"navbar_link\">%s</span></A>"
502 "</li>\n", _("Read new messages")
506 if (navbar_style == navbar_default) {
507 switch(WC->wc_view) {
508 case VIEW_ADDRESSBOOK:
510 "<li class=\"viewcontacts\">"
511 "<a href=\"readfwd\">"
512 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
514 "<span class=\"navbar_link\">"
516 "</span></a></li>\n", _("View contacts")
521 "<li class=\"staskday\">"
522 "<a href=\"readfwd?calview=day\">"
523 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
525 "<span class=\"navbar_link\">"
527 "</span></a></li>\n", _("Day view")
530 "<li class=\"monthview\">"
531 "<a href=\"readfwd?calview=month\">"
532 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
534 "<span class=\"navbar_link\">"
536 "</span></a></li>\n", _("Month view")
541 "<li class=\"monthview\">"
542 "<a href=\"readfwd?calview=month\">"
543 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
545 "<span class=\"navbar_link\">"
547 "</span></a></li>\n", _("Calendar list")
552 "<li class=\"taskmanag\">"
553 "<a href=\"readfwd\">"
554 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
556 "<span class=\"navbar_link\">"
558 "</span></a></li>\n", _("View tasks")
563 "<li class=\"viewnotes\">"
564 "<a href=\"readfwd\">"
565 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
567 "<span class=\"navbar_link\">"
569 "</span></a></li>\n", _("View notes")
574 "<li class=\"readallmess\">"
575 "<a href=\"readfwd\">"
576 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
578 "<span class=\"navbar_link\">"
580 "</span></a></li>\n", _("View message list")
585 "<li class=\"readallmess\">"
586 "<a href=\"readfwd\">"
587 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
589 "<span class=\"navbar_link\">"
591 "</span></a></li>\n", _("Wiki home")
596 "<li class=\"readallmess\">"
597 "<a href=\"readfwd\">"
598 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
600 "<span class=\"navbar_link\">"
602 "</span></a></li>\n", _("Read all messages")
608 if (navbar_style == navbar_default) {
609 switch(WC->wc_view) {
610 case VIEW_ADDRESSBOOK:
612 "<li class=\"addnewcontact\">"
613 "<a href=\"display_enter\">"
614 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
615 "border=\"0\"><span class=\"navbar_link\">"
617 "</span></a></li>\n", _("Add new contact")
622 wprintf("<li class=\"addevent\"><a href=\"display_enter");
623 if (strlen(bstr("year")) > 0) wprintf("?year=%s", bstr("year"));
624 if (strlen(bstr("month")) > 0) wprintf("?month=%s", bstr("month"));
625 if (strlen(bstr("day")) > 0) wprintf("?day=%s", bstr("day"));
627 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
628 "border=\"0\"><span class=\"navbar_link\">"
630 "</span></a></li>\n", _("Add new event")
635 "<li class=\"newmess\">"
636 "<a href=\"display_enter\">"
637 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
638 "border=\"0\"><span class=\"navbar_link\">"
640 "</span></a></li>\n", _("Add new task")
645 "<li class=\"enternewnote\">"
646 "<a href=\"javascript:add_new_note();\">"
647 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
648 "border=\"0\"><span class=\"navbar_link\">"
650 "</span></a></li>\n", _("Add new note")
654 safestrncpy(buf, bstr("page"), sizeof buf);
657 "<li class=\"newmess\">"
658 "<a href=\"display_enter?wikipage=%s\">"
659 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
660 "border=\"0\"><span class=\"navbar_link\">"
662 "</span></a></li>\n", buf, _("Edit this page")
667 "<li class=\"newmess\">"
668 "<a href=\"display_enter\">"
669 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
670 "border=\"0\"><span class=\"navbar_link\">"
672 "</span></a></li>\n", _("Write mail")
677 "<li class=\"newmess\">"
678 "<a href=\"display_enter\">"
679 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
680 "border=\"0\"><span class=\"navbar_link\">"
682 "</span></a></li>\n", _("Enter a message")
688 if (navbar_style == navbar_default) wprintf(
689 "<li class=\"skipthisroom\">"
692 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
693 "<span class=\"navbar_link\">%s</span></a>"
695 _("Leave all messages marked as unread, go to next room with unread messages"),
699 if (navbar_style == navbar_default) wprintf(
700 "<li class=\"markngo\">"
701 "<a href=\"gotonext\" "
703 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
704 "<span class=\"navbar_link\">%s</span></a>"
706 _("Mark all messages as read, go to next room with unread messages"),
710 wprintf("</ul></div>\n");
717 * \brief back end routine to take the session to a new room
718 * \param gname room to go to
721 int gotoroom(char *gname)
724 static long ls = (-1L);
727 /** store ungoto information */
728 strcpy(WC->ugname, WC->wc_roomname);
731 /** move to the new room */
732 serv_printf("GOTO %s", gname);
733 serv_getln(buf, sizeof buf);
737 serv_puts("GOTO _BASEROOM_");
738 serv_getln(buf, sizeof buf);
745 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
746 WC->room_flags = extract_int(&buf[4], 4);
747 /* highest_msg_read = extract_int(&buf[4],6);
748 maxmsgnum = extract_int(&buf[4],5);
750 WC->is_mailbox = extract_int(&buf[4],7);
751 ls = extract_long(&buf[4], 6);
752 WC->wc_floor = extract_int(&buf[4], 10);
753 WC->wc_view = extract_int(&buf[4], 11);
754 WC->wc_default_view = extract_int(&buf[4], 12);
755 WC->wc_is_trash = extract_int(&buf[4], 13);
756 WC->room_flags2 = extract_int(&buf[4], 14);
759 WC->is_room_aide = WC->is_aide;
761 WC->is_room_aide = (char) extract_int(&buf[4], 8);
763 remove_march(WC->wc_roomname);
764 if (!strcasecmp(gname, "_BASEROOM_"))
772 * \brief Locate the room on the march list which we most want to go to.
774 * is measured given a "weight" of preference based on various factors.
775 * \param desired_floor the room number on the citadel server
776 * \return the roomname
778 char *pop_march(int desired_floor)
780 static char TheRoom[128];
782 int TheOrder = 32767;
785 struct march *mptr = NULL;
787 strcpy(TheRoom, "_BASEROOM_");
788 if (WC->march == NULL)
791 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
793 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
794 weight = weight + 10000;
795 if (mptr->march_floor == desired_floor)
796 weight = weight + 5000;
798 weight = weight + ((128 - (mptr->march_floor)) * 128);
799 weight = weight + (128 - (mptr->march_order));
801 if (weight > TheWeight) {
803 strcpy(TheRoom, mptr->march_name);
804 TheFloor = mptr->march_floor;
805 TheOrder = mptr->march_order;
814 *\brief Goto next room having unread messages.
815 * We want to skip over rooms that the user has already been to, and take the
816 * user back to the lobby when done. The room we end up in is placed in
817 * newroom - which is set to 0 (the lobby) initially.
818 * We start the search in the current room rather than the beginning to prevent
819 * two or more concurrent users from dragging each other back to the same room.
824 struct march *mptr, *mptr2;
829 * First check to see if the march-mode list is already allocated.
830 * If it is, pop the first room off the list and go there.
833 if (WC->march == NULL) {
835 serv_getln(buf, sizeof buf);
837 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
838 extract_token(room_name, buf, 0, '|', sizeof room_name);
839 if (strcasecmp(room_name, WC->wc_roomname)) {
840 mptr = (struct march *) malloc(sizeof(struct march));
842 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
843 mptr->march_floor = extract_int(buf, 2);
844 mptr->march_order = extract_int(buf, 3);
845 if (WC->march == NULL) {
849 while (mptr2->next != NULL)
856 * add _BASEROOM_ to the end of the march list, so the user will end up
857 * in the system base room (usually the Lobby>) at the end of the loop
859 mptr = (struct march *) malloc(sizeof(struct march));
861 strcpy(mptr->march_name, "_BASEROOM_");
862 if (WC->march == NULL) {
866 while (mptr2->next != NULL)
871 * ...and remove the room we're currently in, so a <G>oto doesn't make us
872 * walk around in circles
874 remove_march(WC->wc_roomname);
876 if (WC->march != NULL) {
877 strcpy(next_room, pop_march(-1));
879 strcpy(next_room, "_BASEROOM_");
883 smart_goto(next_room);
888 * \brief goto next room
889 * \param next_room next room to go to
891 void smart_goto(char *next_room) {
899 * \brief mark all messages in current room as having been read
901 void slrp_highest(void)
905 serv_puts("SLRP HIGHEST");
906 serv_getln(buf, sizeof buf);
911 * \brief un-goto the previous room
917 if (!strcmp(WC->ugname, "")) {
918 smart_goto(WC->wc_roomname);
921 serv_printf("GOTO %s", WC->ugname);
922 serv_getln(buf, sizeof buf);
924 smart_goto(WC->wc_roomname);
927 if (WC->uglsn >= 0L) {
928 serv_printf("SLRP %ld", WC->uglsn);
929 serv_getln(buf, sizeof buf);
931 strcpy(buf, WC->ugname);
932 strcpy(WC->ugname, "");
941 * \brief Set/clear/read the "self-service list subscribe" flag for a room
943 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
944 * \return return the new value.
947 int self_service(int newval) {
948 int current_value = 0;
954 int flags, floor, order, view, flags2;
957 serv_getln(buf, sizeof buf);
958 if (buf[0] != '2') return(0);
960 extract_token(name, &buf[4], 0, '|', sizeof name);
961 extract_token(password, &buf[4], 1, '|', sizeof password);
962 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
963 flags = extract_int(&buf[4], 3);
964 floor = extract_int(&buf[4], 4);
965 order = extract_int(&buf[4], 5);
966 view = extract_int(&buf[4], 6);
967 flags2 = extract_int(&buf[4], 7);
969 if (flags2 & QR2_SELFLIST) {
977 flags2 = flags2 | QR2_SELFLIST;
979 else if (newval == 0) {
980 flags2 = flags2 & ~QR2_SELFLIST;
983 return(current_value);
986 if (newval != current_value) {
987 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
988 name, password, dirname, flags,
989 floor, order, view, flags2);
990 serv_getln(buf, sizeof buf);
1003 * \brief display the form for editing a room
1005 void display_editroom(void)
1010 char remote_room[128];
1013 char er_password[10];
1014 char er_dirname[15];
1015 char er_roomaide[26];
1022 char *not_shared_with;
1025 int floorpolicy = 0;
1029 if (strlen(tab) == 0) tab = "admin";
1033 serv_getln(buf, sizeof buf);
1035 if (buf[0] != '2') {
1036 strcpy(WC->ImportantMessage, &buf[4]);
1037 display_main_menu();
1040 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1041 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1042 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1043 er_flags = extract_int(&buf[4], 3);
1044 er_floor = extract_int(&buf[4], 4);
1045 er_flags2 = extract_int(&buf[4], 7);
1047 output_headers(1, 1, 1, 0, 0, 0);
1049 /** print the tabbed dialog */
1051 "<div class=\"fix_scrollbar_bug\">"
1052 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
1054 "<TD> </TD>\n");
1056 if (!strcmp(tab, "admin")) {
1057 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1060 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1062 wprintf(_("Administration"));
1063 if (!strcmp(tab, "admin")) {
1064 wprintf("</SPAN></TD>\n");
1067 wprintf("</A></TD>\n");
1070 wprintf("<TD> </TD>\n");
1072 if (!strcmp(tab, "config")) {
1073 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1076 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=config\">");
1078 wprintf(_("Configuration"));
1079 if (!strcmp(tab, "config")) {
1080 wprintf("</SPAN></TD>\n");
1083 wprintf("</A></TD>\n");
1086 wprintf("<TD> </TD>\n");
1088 if (!strcmp(tab, "expire")) {
1089 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1092 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1094 wprintf(_("Message expire policy"));
1095 if (!strcmp(tab, "expire")) {
1096 wprintf("</SPAN></TD>\n");
1099 wprintf("</A></TD>\n");
1102 wprintf("<TD> </TD>\n");
1104 if (!strcmp(tab, "access")) {
1105 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1108 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=access\">");
1110 wprintf(_("Access controls"));
1111 if (!strcmp(tab, "access")) {
1112 wprintf("</SPAN></TD>\n");
1115 wprintf("</A></TD>\n");
1118 wprintf("<TD> </TD>\n");
1120 if (!strcmp(tab, "sharing")) {
1121 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1124 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1126 wprintf(_("Sharing"));
1127 if (!strcmp(tab, "sharing")) {
1128 wprintf("</SPAN></TD>\n");
1131 wprintf("</A></TD>\n");
1134 wprintf("<TD> </TD>\n");
1136 if (!strcmp(tab, "listserv")) {
1137 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1140 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1142 wprintf(_("Mailing list service"));
1143 if (!strcmp(tab, "listserv")) {
1144 wprintf("</SPAN></TD>\n");
1147 wprintf("</A></TD>\n");
1150 wprintf("<TD> </TD>\n");
1152 wprintf("</TR></TABLE></div>\n");
1153 /** end tabbed dialog */
1155 /** begin content of whatever tab is open now */
1156 wprintf("<div class=\"fix_scrollbar_bug\">"
1157 "<TABLE class=\"roomops_background\">\n"
1160 if (!strcmp(tab, "admin")) {
1162 "<LI><a href=\"delete_room\" "
1163 "onClick=\"return confirm('");
1164 wprintf(_("Are you sure you want to delete this room?"));
1165 wprintf("');\">\n");
1166 wprintf(_("Delete this room"));
1168 "<LI><a href=\"display_editroompic\">\n");
1169 wprintf(_("Set or change the icon for this room's banner"));
1171 "<LI><a href=\"display_editinfo\">\n");
1172 wprintf(_("Edit this room's Info file"));
1177 if (!strcmp(tab, "config")) {
1178 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1180 wprintf("<UL><LI>");
1181 wprintf(_("Name of room: "));
1182 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1188 wprintf(_("Resides on floor: "));
1189 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1190 for (i = 0; i < 128; ++i)
1191 if (strlen(floorlist[i]) > 0) {
1192 wprintf("<OPTION ");
1194 wprintf("SELECTED ");
1195 wprintf("VALUE=\"%d\">", i);
1196 escputs(floorlist[i]);
1197 wprintf("</OPTION>\n");
1199 wprintf("</SELECT>\n");
1202 wprintf(_("Type of room:"));
1205 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1206 if ((er_flags & QR_PRIVATE) == 0)
1207 wprintf("CHECKED ");
1209 wprintf(_("Public (automatically appears to everyone)"));
1212 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1213 if ((er_flags & QR_PRIVATE) &&
1214 (er_flags & QR_GUESSNAME))
1215 wprintf("CHECKED ");
1217 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1219 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1220 if ((er_flags & QR_PRIVATE) &&
1221 (er_flags & QR_PASSWORDED))
1222 wprintf("CHECKED ");
1224 wprintf(_("Private - require password: "));
1225 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1228 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1229 if ((er_flags & QR_PRIVATE)
1230 && ((er_flags & QR_GUESSNAME) == 0)
1231 && ((er_flags & QR_PASSWORDED) == 0))
1232 wprintf("CHECKED ");
1234 wprintf(_("Private - invitation only"));
1236 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1238 wprintf(_("If private, cause current users to forget room"));
1240 wprintf("\n</UL>\n");
1242 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1243 if (er_flags & QR_PREFONLY)
1244 wprintf("CHECKED ");
1246 wprintf(_("Preferred users only"));
1248 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1249 if (er_flags & QR_READONLY)
1250 wprintf("CHECKED ");
1252 wprintf(_("Read-only room"));
1254 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1255 if (er_flags2 & QR2_COLLABDEL)
1256 wprintf("CHECKED ");
1258 wprintf(_("All users allowed to post may also delete messages"));
1260 /** directory stuff */
1261 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1262 if (er_flags & QR_DIRECTORY)
1263 wprintf("CHECKED ");
1265 wprintf(_("File directory room"));
1267 wprintf("\n<UL><LI>");
1268 wprintf(_("Directory name: "));
1269 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1272 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1273 if (er_flags & QR_UPLOAD)
1274 wprintf("CHECKED ");
1276 wprintf(_("Uploading allowed"));
1278 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1279 if (er_flags & QR_DOWNLOAD)
1280 wprintf("CHECKED ");
1282 wprintf(_("Downloading allowed"));
1284 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1285 if (er_flags & QR_VISDIR)
1286 wprintf("CHECKED ");
1288 wprintf(_("Visible directory"));
1291 /** end of directory stuff */
1293 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1294 if (er_flags & QR_NETWORK)
1295 wprintf("CHECKED ");
1297 wprintf(_("Network shared room"));
1299 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1300 if (er_flags & QR_PERMANENT)
1301 wprintf("CHECKED ");
1303 wprintf(_("Permanent (does not auto-purge)"));
1305 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1306 if (er_flags2 & QR2_SUBJECTREQ)
1307 wprintf("CHECKED ");
1309 wprintf(_("Subject Required (Force users to specify a message subject)"));
1311 /** start of anon options */
1314 wprintf(_("Anonymous messages"));
1317 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1318 if (((er_flags & QR_ANONONLY) == 0)
1319 && ((er_flags & QR_ANONOPT) == 0))
1320 wprintf("CHECKED ");
1322 wprintf(_("No anonymous messages"));
1324 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1325 if (er_flags & QR_ANONONLY)
1326 wprintf("CHECKED ");
1328 wprintf(_("All messages are anonymous"));
1330 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1331 if (er_flags & QR_ANONOPT)
1332 wprintf("CHECKED ");
1334 wprintf(_("Prompt user when entering messages"));
1337 /* end of anon options */
1340 wprintf(_("Room aide: "));
1342 serv_getln(buf, sizeof buf);
1343 if (buf[0] != '2') {
1344 wprintf("<em>%s</em>\n", &buf[4]);
1346 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1347 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1350 wprintf("</UL><CENTER>\n");
1351 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1352 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1354 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1362 /** Sharing the room with other Citadel nodes... */
1363 if (!strcmp(tab, "sharing")) {
1365 shared_with = strdup("");
1366 not_shared_with = strdup("");
1368 /** Learn the current configuration */
1369 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1370 serv_getln(buf, sizeof buf);
1371 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1372 extract_token(node, buf, 0, '|', sizeof node);
1373 not_shared_with = realloc(not_shared_with,
1374 strlen(not_shared_with) + 32);
1375 strcat(not_shared_with, node);
1376 strcat(not_shared_with, "\n");
1380 serv_getln(buf, sizeof buf);
1381 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1382 extract_token(cmd, buf, 0, '|', sizeof cmd);
1383 extract_token(node, buf, 1, '|', sizeof node);
1384 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1385 if (!strcasecmp(cmd, "ignet_push_share")) {
1386 shared_with = realloc(shared_with,
1387 strlen(shared_with) + 32);
1388 strcat(shared_with, node);
1389 if (strlen(remote_room) > 0) {
1390 strcat(shared_with, "|");
1391 strcat(shared_with, remote_room);
1393 strcat(shared_with, "\n");
1397 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1398 extract_token(buf, shared_with, i, '\n', sizeof buf);
1399 extract_token(node, buf, 0, '|', sizeof node);
1400 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1401 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1402 if (!strcasecmp(node, cmd)) {
1403 remove_token(not_shared_with, j, '\n');
1408 /** Display the stuff */
1409 wprintf("<CENTER><br />"
1410 "<TABLE border=1 cellpadding=5><TR>"
1412 wprintf(_("Shared with"));
1413 wprintf("</I></B></TD>"
1415 wprintf(_("Not shared with"));
1416 wprintf("</I></B></TD></TR>\n"
1417 "<TR><TD VALIGN=TOP>\n");
1419 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1420 wprintf(_("Remote node name"));
1421 wprintf("</TD><TD>");
1422 wprintf(_("Remote room name"));
1423 wprintf("</TD><TD>");
1424 wprintf(_("Actions"));
1425 wprintf("</TD></TR>\n");
1427 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1428 extract_token(buf, shared_with, i, '\n', sizeof buf);
1429 extract_token(node, buf, 0, '|', sizeof node);
1430 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1431 if (strlen(node) > 0) {
1432 wprintf("<FORM METHOD=\"POST\" "
1433 "action=\"netedit\">"
1434 "<TR><TD>%s</TD>\n", node);
1437 if (strlen(remote_room) > 0) {
1438 escputs(remote_room);
1444 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1445 "VALUE=\"ignet_push_share|");
1447 if (strlen(remote_room) > 0) {
1449 urlescputs(remote_room);
1452 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1453 "VALUE=\"sharing\">\n");
1454 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1455 "VALUE=\"remove\">\n");
1456 wprintf("<INPUT TYPE=\"submit\" "
1457 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1458 wprintf("</TD></TR></FORM>\n");
1462 wprintf("</TABLE>\n");
1463 wprintf("</TD><TD VALIGN=TOP>\n");
1464 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1465 wprintf(_("Remote node name"));
1466 wprintf("</TD><TD>");
1467 wprintf(_("Remote room name"));
1468 wprintf("</TD><TD>");
1469 wprintf(_("Actions"));
1470 wprintf("</TD></TR>\n");
1472 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1473 extract_token(node, not_shared_with, i, '\n', sizeof node);
1474 if (strlen(node) > 0) {
1475 wprintf("<FORM METHOD=\"POST\" "
1476 "action=\"netedit\">"
1480 "<INPUT TYPE=\"INPUT\" "
1484 wprintf("<INPUT TYPE=\"hidden\" "
1486 "VALUE=\"ignet_push_share|");
1489 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1490 "VALUE=\"sharing\">\n");
1491 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1492 "VALUE=\"add\">\n");
1493 wprintf("<INPUT TYPE=\"submit\" "
1494 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1495 wprintf("</TD></TR></FORM>\n");
1499 wprintf("</TABLE>\n");
1500 wprintf("</TD></TR>"
1501 "</TABLE></CENTER><br />\n"
1502 "<I><B>%s</B><UL><LI>", _("Notes:"));
1503 wprintf(_("When sharing a room, "
1504 "it must be shared from both ends. Adding a node to "
1505 "the 'shared' list sends messages out, but in order to"
1506 " receive messages, the other nodes must be configured"
1507 " to send messages out to your system as well. "
1508 "<LI>If the remote room name is blank, it is assumed "
1509 "that the room name is identical on the remote node."
1510 "<LI>If the remote room name is different, the remote "
1511 "node must also configure the name of the room here."
1517 /** Mailing list management */
1518 if (!strcmp(tab, "listserv")) {
1520 wprintf("<br /><center>"
1521 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1522 "<TR><TD VALIGN=TOP>");
1524 wprintf(_("<i>The contents of this room are being "
1525 "mailed <b>as individual messages</b> "
1526 "to the following list recipients:"
1527 "</i><br /><br />\n"));
1530 serv_getln(buf, sizeof buf);
1531 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1532 extract_token(cmd, buf, 0, '|', sizeof cmd);
1533 if (!strcasecmp(cmd, "listrecp")) {
1534 extract_token(recp, buf, 1, '|', sizeof recp);
1537 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
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=\"listrecp|\">\n");
1547 wprintf("<INPUT TYPE=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1548 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1549 wprintf("</FORM>\n");
1551 wprintf("</TD><TD VALIGN=TOP>\n");
1553 wprintf(_("<i>The contents of this room are being "
1554 "mailed <b>in digest form</b> "
1555 "to the following list recipients:"
1556 "</i><br /><br />\n"));
1559 serv_getln(buf, sizeof buf);
1560 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1561 extract_token(cmd, buf, 0, '|', sizeof cmd);
1562 if (!strcasecmp(cmd, "digestrecp")) {
1563 extract_token(recp, buf, 1, '|', sizeof recp);
1566 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1570 wprintf(_("(remove)"));
1571 wprintf("</A><br />");
1574 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1575 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1576 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1577 wprintf("<INPUT TYPE=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1578 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1579 wprintf("</FORM>\n");
1581 wprintf("</TD></TR></TABLE>\n");
1583 /** Pop open an address book -- begin **/
1584 wprintf("<div align=right>"
1585 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1587 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1592 _("Add recipients from Contacts or other address books"),
1593 _("Add recipients from Contacts or other address books")
1595 /** Pop open an address book -- end **/
1598 if (self_service(999) == 1) {
1599 wprintf(_("This room is configured to allow "
1600 "self-service subscribe/unsubscribe requests."));
1601 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1602 wprintf(_("Click to disable."));
1603 wprintf("</A><br />\n");
1604 wprintf(_("The URL for subscribe/unsubscribe is: "));
1605 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1606 (is_https ? "https" : "http"),
1610 wprintf(_("This room is <i>not</i> configured to allow "
1611 "self-service subscribe/unsubscribe requests."));
1612 wprintf(" <a href=\"toggle_self_service?newval=1&"
1614 wprintf(_("Click to enable."));
1615 wprintf("</A><br />\n");
1619 wprintf("</CENTER>\n");
1623 /** Mailing list management */
1624 if (!strcmp(tab, "expire")) {
1626 serv_puts("GPEX room");
1627 serv_getln(buf, sizeof buf);
1628 if (buf[0] == '2') {
1629 roompolicy = extract_int(&buf[4], 0);
1630 roomvalue = extract_int(&buf[4], 1);
1633 serv_puts("GPEX floor");
1634 serv_getln(buf, sizeof buf);
1635 if (buf[0] == '2') {
1636 floorpolicy = extract_int(&buf[4], 0);
1637 floorvalue = extract_int(&buf[4], 1);
1640 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1641 wprintf("<TABLE border=0 cellspacing=5>\n");
1642 wprintf("<TR><TD>");
1643 wprintf(_("Message expire policy for this room"));
1645 escputs(WC->wc_roomname);
1646 wprintf(")</TD><TD>");
1647 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1648 ((roompolicy == 0) ? "CHECKED" : "") );
1649 wprintf(_("Use the default policy for this floor"));
1650 wprintf("<br />\n");
1651 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1652 ((roompolicy == 1) ? "CHECKED" : "") );
1653 wprintf(_("Never automatically expire messages"));
1654 wprintf("<br />\n");
1655 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1656 ((roompolicy == 2) ? "CHECKED" : "") );
1657 wprintf(_("Expire by message count"));
1658 wprintf("<br />\n");
1659 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1660 ((roompolicy == 3) ? "CHECKED" : "") );
1661 wprintf(_("Expire by message age"));
1663 wprintf(_("Number of messages or days: "));
1664 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1665 wprintf("</TD></TR>\n");
1667 if (WC->axlevel >= 6) {
1668 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1669 wprintf("<TR><TD>");
1670 wprintf(_("Message expire policy for this floor"));
1672 escputs(floorlist[WC->wc_floor]);
1673 wprintf(")</TD><TD>");
1674 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1675 ((floorpolicy == 0) ? "CHECKED" : "") );
1676 wprintf(_("Use the system default"));
1677 wprintf("<br />\n");
1678 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1679 ((floorpolicy == 1) ? "CHECKED" : "") );
1680 wprintf(_("Never automatically expire messages"));
1681 wprintf("<br />\n");
1682 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1683 ((floorpolicy == 2) ? "CHECKED" : "") );
1684 wprintf(_("Expire by message count"));
1685 wprintf("<br />\n");
1686 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1687 ((floorpolicy == 3) ? "CHECKED" : "") );
1688 wprintf(_("Expire by message age"));
1690 wprintf(_("Number of messages or days: "));
1691 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1695 wprintf("<CENTER>\n");
1696 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1697 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1699 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1700 wprintf("</CENTER></TD><TR>\n");
1702 wprintf("</TABLE>\n"
1703 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1709 /** Mailing list management */
1710 if (!strcmp(tab, "access")) {
1714 /** end content of whatever tab is open now */
1715 wprintf("</TD></TR></TABLE></div>\n");
1717 address_book_popup();
1723 * \brief Toggle self-service list subscription
1725 void toggle_self_service(void) {
1728 newval = atoi(bstr("newval"));
1729 self_service(newval);
1736 * \brief save new parameters for a room
1742 char er_password[10];
1743 char er_dirname[15];
1744 char er_roomaide[26];
1747 int er_listingorder;
1753 if (strlen(bstr("ok_button")) == 0) {
1754 strcpy(WC->ImportantMessage,
1755 _("Cancelled. Changes were not saved."));
1760 serv_getln(buf, sizeof buf);
1762 if (buf[0] != '2') {
1763 strcpy(WC->ImportantMessage, &buf[4]);
1767 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1768 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1769 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1770 er_flags = extract_int(&buf[4], 3);
1771 er_listingorder = extract_int(&buf[4], 5);
1772 er_defaultview = extract_int(&buf[4], 6);
1773 er_flags2 = extract_int(&buf[4], 7);
1775 strcpy(er_roomaide, bstr("er_roomaide"));
1776 if (strlen(er_roomaide) == 0) {
1778 serv_getln(buf, sizeof buf);
1779 if (buf[0] != '2') {
1780 strcpy(er_roomaide, "");
1782 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1785 strcpy(buf, bstr("er_name"));
1787 if (strlen(buf) > 0) {
1788 strcpy(er_name, buf);
1791 strcpy(buf, bstr("er_password"));
1793 if (strlen(buf) > 0)
1794 strcpy(er_password, buf);
1796 strcpy(buf, bstr("er_dirname"));
1798 if (strlen(buf) > 0)
1799 strcpy(er_dirname, buf);
1801 strcpy(buf, bstr("type"));
1802 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1804 if (!strcmp(buf, "invonly")) {
1805 er_flags |= (QR_PRIVATE);
1807 if (!strcmp(buf, "hidden")) {
1808 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1810 if (!strcmp(buf, "passworded")) {
1811 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1813 if (!strcmp(bstr("prefonly"), "yes")) {
1814 er_flags |= QR_PREFONLY;
1816 er_flags &= ~QR_PREFONLY;
1819 if (!strcmp(bstr("readonly"), "yes")) {
1820 er_flags |= QR_READONLY;
1822 er_flags &= ~QR_READONLY;
1825 if (!strcmp(bstr("collabdel"), "yes")) {
1826 er_flags2 |= QR2_COLLABDEL;
1828 er_flags2 &= ~QR2_COLLABDEL;
1831 if (!strcmp(bstr("permanent"), "yes")) {
1832 er_flags |= QR_PERMANENT;
1834 er_flags &= ~QR_PERMANENT;
1837 if (!strcmp(bstr("subjectreq"), "yes")) {
1838 er_flags2 |= QR2_SUBJECTREQ;
1840 er_flags2 &= ~QR2_SUBJECTREQ;
1843 if (!strcmp(bstr("network"), "yes")) {
1844 er_flags |= QR_NETWORK;
1846 er_flags &= ~QR_NETWORK;
1849 if (!strcmp(bstr("directory"), "yes")) {
1850 er_flags |= QR_DIRECTORY;
1852 er_flags &= ~QR_DIRECTORY;
1855 if (!strcmp(bstr("ulallowed"), "yes")) {
1856 er_flags |= QR_UPLOAD;
1858 er_flags &= ~QR_UPLOAD;
1861 if (!strcmp(bstr("dlallowed"), "yes")) {
1862 er_flags |= QR_DOWNLOAD;
1864 er_flags &= ~QR_DOWNLOAD;
1867 if (!strcmp(bstr("visdir"), "yes")) {
1868 er_flags |= QR_VISDIR;
1870 er_flags &= ~QR_VISDIR;
1873 strcpy(buf, bstr("anon"));
1875 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1876 if (!strcmp(buf, "anononly"))
1877 er_flags |= QR_ANONONLY;
1878 if (!strcmp(buf, "anon2"))
1879 er_flags |= QR_ANONOPT;
1882 if (!strcmp(bstr("bump"), "yes"))
1885 er_floor = atoi(bstr("er_floor"));
1887 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
1888 er_name, er_password, er_dirname, er_flags, bump, er_floor,
1889 er_listingorder, er_defaultview, er_flags2);
1891 serv_getln(buf, sizeof buf);
1892 if (buf[0] != '2') {
1893 strcpy(WC->ImportantMessage, &buf[4]);
1899 if (strlen(er_roomaide) > 0) {
1900 sprintf(buf, "SETA %s", er_roomaide);
1902 serv_getln(buf, sizeof buf);
1903 if (buf[0] != '2') {
1904 strcpy(WC->ImportantMessage, &buf[4]);
1905 display_main_menu();
1910 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1917 * \brief Display form for Invite, Kick, and show Who Knows a room
1919 void do_invt_kick(void) {
1920 char buf[SIZ], room[SIZ], username[SIZ];
1923 serv_getln(buf, sizeof buf);
1925 if (buf[0] != '2') {
1929 extract_token(room, &buf[4], 0, '|', sizeof room);
1931 strcpy(username, bstr("username"));
1933 if (strlen(bstr("kick_button")) > 0) {
1934 sprintf(buf, "KICK %s", username);
1936 serv_getln(buf, sizeof buf);
1938 if (buf[0] != '2') {
1939 strcpy(WC->ImportantMessage, &buf[4]);
1941 sprintf(WC->ImportantMessage,
1942 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1947 if (strlen(bstr("invite_button")) > 0) {
1948 sprintf(buf, "INVT %s", username);
1950 serv_getln(buf, sizeof buf);
1952 if (buf[0] != '2') {
1953 strcpy(WC->ImportantMessage, &buf[4]);
1955 sprintf(WC->ImportantMessage,
1956 _("<B><I>User %s invited to room %s.</I></B>\n"),
1967 * \brief Display form for Invite, Kick, and show Who Knows a room
1969 void display_whok(void)
1971 char buf[SIZ], room[SIZ], username[SIZ];
1974 serv_getln(buf, sizeof buf);
1976 if (buf[0] != '2') {
1980 extract_token(room, &buf[4], 0, '|', sizeof room);
1983 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1984 wprintf(_("The users listed below have access to this room. "
1985 "To remove a user from the access list, select the user "
1986 "name from the list and click 'Kick'."));
1987 wprintf("<br /><br />");
1989 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1990 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1991 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1993 serv_getln(buf, sizeof buf);
1994 if (buf[0] == '1') {
1995 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1996 extract_token(username, buf, 0, '|', sizeof username);
1997 wprintf("<OPTION>");
2002 wprintf("</SELECT><br />\n");
2004 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2005 wprintf("</FORM></CENTER>\n");
2007 wprintf("</TD><TD>");
2008 wprintf(_("To grant another user access to this room, enter the "
2009 "user name in the box below and click 'Invite'."));
2010 wprintf("<br /><br />");
2012 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
2013 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2014 wprintf(_("Invite:"));
2016 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
2017 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2018 "<input type=\"submit\" value=\"%s\">"
2019 "</FORM></CENTER>\n", _("Invite"));
2021 wprintf("</TD></TR></TABLE>\n");
2028 * \brief display the form for entering a new room
2030 void display_entroom(void)
2035 serv_puts("CRE8 0");
2036 serv_getln(buf, sizeof buf);
2038 if (buf[0] != '2') {
2039 strcpy(WC->ImportantMessage, &buf[4]);
2040 display_main_menu();
2044 output_headers(1, 1, 2, 0, 0, 0);
2045 wprintf("<div id=\"banner\">\n"
2046 "<TABLE class=\"roomops_banner\"><TR><TD>"
2047 "<SPAN CLASS=\"titlebar\">");
2048 wprintf(_("Create a new room"));
2050 "</TD></TR></TABLE>\n"
2051 "</div>\n<div id=\"content\">\n"
2054 wprintf("<div class=\"fix_scrollbar_bug\">"
2055 "<table class=\"roomops_background\"><tr><td>\n");
2057 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2059 wprintf("<UL><LI>");
2060 wprintf(_("Name of room: "));
2061 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2064 wprintf(_("Resides on floor: "));
2066 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
2067 for (i = 0; i < 128; ++i)
2068 if (strlen(floorlist[i]) > 0) {
2069 wprintf("<OPTION ");
2070 wprintf("VALUE=\"%d\">", i);
2071 escputs(floorlist[i]);
2072 wprintf("</OPTION>\n");
2074 wprintf("</SELECT>\n");
2077 * Our clever little snippet of JavaScript automatically selects
2078 * a public room if the view is set to Bulletin Board or wiki, and
2079 * it selects a mailbox room otherwise. The user can override this,
2080 * of course. We also disable the floor selector for mailboxes.
2083 wprintf(_("Default view for room: "));
2084 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
2085 " if ( (this.form.er_view.value == 0) "
2086 " || (this.form.er_view.value == 6) ) { "
2087 " this.form.type[0].checked=true; "
2088 " this.form.er_floor.disabled = false; "
2091 " this.form.type[4].checked=true; "
2092 " this.form.er_floor.disabled = true; "
2095 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2096 if (is_view_allowed_as_default(i)) {
2097 wprintf("<OPTION %s VALUE=\"%d\">",
2098 ((i == 0) ? "SELECTED" : ""), i );
2099 escputs(viewdefs[i]);
2100 wprintf("</OPTION>\n");
2103 wprintf("</SELECT>\n");
2106 wprintf(_("Type of room:"));
2109 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2110 wprintf("CHECKED OnChange=\""
2111 " if (this.form.type[0].checked == true) { "
2112 " this.form.er_floor.disabled = false; "
2115 wprintf(_("Public (automatically appears to everyone)"));
2117 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2118 " if (this.form.type[1].checked == true) { "
2119 " this.form.er_floor.disabled = false; "
2122 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2124 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2125 " if (this.form.type[2].checked == true) { "
2126 " this.form.er_floor.disabled = false; "
2129 wprintf(_("Private - require password: "));
2130 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2132 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2133 " if (this.form.type[3].checked == true) { "
2134 " this.form.er_floor.disabled = false; "
2137 wprintf(_("Private - invitation only"));
2139 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2141 " if (this.form.type[4].checked == true) { "
2142 " this.form.er_floor.disabled = true; "
2145 wprintf(_("Personal (mailbox for you only)"));
2147 wprintf("\n</UL>\n");
2149 wprintf("<CENTER>\n");
2150 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2152 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2153 wprintf("</CENTER>\n");
2154 wprintf("</FORM>\n<hr />");
2155 serv_printf("MESG roomaccess");
2156 serv_getln(buf, sizeof buf);
2157 if (buf[0] == '1') {
2160 wprintf("</td></tr></table></div>\n");
2168 * \brief support function for entroom() -- sets the default view
2170 void er_set_default_view(int newview) {
2183 serv_getln(buf, sizeof buf);
2184 if (buf[0] != '2') return;
2186 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2187 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2188 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2189 rm_bits1 = extract_int(&buf[4], 3);
2190 rm_floor = extract_int(&buf[4], 4);
2191 rm_listorder = extract_int(&buf[4], 5);
2192 rm_bits2 = extract_int(&buf[4], 7);
2194 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2195 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2196 rm_listorder, newview, rm_bits2
2198 serv_getln(buf, sizeof buf);
2204 * \brief enter a new room
2211 char er_password[SIZ];
2216 if (strlen(bstr("ok_button")) == 0) {
2217 strcpy(WC->ImportantMessage,
2218 _("Cancelled. No new room was created."));
2219 display_main_menu();
2222 strcpy(er_name, bstr("er_name"));
2223 strcpy(er_type, bstr("type"));
2224 strcpy(er_password, bstr("er_password"));
2225 er_floor = atoi(bstr("er_floor"));
2226 er_view = atoi(bstr("er_view"));
2229 if (!strcmp(er_type, "hidden"))
2231 if (!strcmp(er_type, "passworded"))
2233 if (!strcmp(er_type, "invonly"))
2235 if (!strcmp(er_type, "personal"))
2238 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2239 er_name, er_num_type, er_password, er_floor, 0, er_view);
2241 serv_getln(buf, sizeof buf);
2242 if (buf[0] != '2') {
2243 strcpy(WC->ImportantMessage, &buf[4]);
2244 display_main_menu();
2248 do_change_view(er_view); /* Now go there */
2253 * \brief display the screen to enter a private room
2255 void display_private(char *rname, int req_pass)
2257 output_headers(1, 1, 2, 0, 0, 0);
2258 wprintf("<div id=\"banner\">\n"
2259 "<TABLE class=\"roomops_banner\"><TR><TD>"
2260 "<SPAN CLASS=\"titlebar\">");
2261 wprintf(_("Go to a hidden room"));
2263 "</TD></TR></TABLE>\n"
2264 "</div>\n<div id=\"content\">\n"
2267 wprintf("<div class=\"fix_scrollbar_bug\">"
2268 "<table class=\"roomops_background\"><tr><td>\n");
2270 wprintf("<CENTER>\n");
2272 wprintf(_("If you know the name of a hidden (guess-name) or "
2273 "passworded room, you can enter that room by typing "
2274 "its name below. Once you gain access to a private "
2275 "room, it will appear in your regular room listings "
2276 "so you don't have to keep returning here."));
2277 wprintf("\n<br /><br />");
2279 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2281 wprintf("<table border=\"0\" cellspacing=\"5\" "
2282 "cellpadding=\"5\" class=\"roomops_background_alt\">\n"
2284 wprintf(_("Enter room name:"));
2286 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2287 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2290 wprintf("</TD></TR><TR><TD>");
2291 wprintf(_("Enter room password:"));
2292 wprintf("</TD><TD>");
2293 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2295 wprintf("</TD></TR></TABLE><br />\n");
2297 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2299 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2303 wprintf("</FORM>\n");
2304 wprintf("</td></tr></table></div>\n");
2309 * \brief goto a private room
2311 void goto_private(void)
2316 if (strlen(bstr("ok_button")) == 0) {
2317 display_main_menu();
2320 strcpy(hold_rm, WC->wc_roomname);
2321 strcpy(buf, "GOTO ");
2322 strcat(buf, bstr("gr_name"));
2324 strcat(buf, bstr("gr_pass"));
2326 serv_getln(buf, sizeof buf);
2328 if (buf[0] == '2') {
2329 smart_goto(bstr("gr_name"));
2332 if (!strncmp(buf, "540", 3)) {
2333 display_private(bstr("gr_name"), 1);
2336 output_headers(1, 1, 1, 0, 0, 0);
2337 wprintf("%s\n", &buf[4]);
2344 * \brief display the screen to zap a room
2346 void display_zap(void)
2348 output_headers(1, 1, 2, 0, 0, 0);
2350 wprintf("<div id=\"banner\">\n");
2351 wprintf("<TABLE class=\"roomops_zap\"><TR><TD>");
2352 wprintf("<SPAN CLASS=\"titlebar\">");
2353 wprintf(_("Zap (forget/unsubscribe) the current room"));
2354 wprintf("</SPAN>\n");
2355 wprintf("</TD></TR></TABLE>\n");
2356 wprintf("</div>\n<div id=\"content\">\n");
2358 wprintf(_("If you select this option, <em>%s</em> will "
2359 "disappear from your room list. Is this what you wish "
2360 "to do?<br />\n"), WC->wc_roomname);
2362 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2363 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2365 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2366 wprintf("</FORM>\n");
2377 char final_destination[SIZ];
2380 * If the forget-room routine fails for any reason, we fall back
2381 * to the current room; otherwise, we go to the Lobby
2383 strcpy(final_destination, WC->wc_roomname);
2385 if (strlen(bstr("ok_button")) > 0) {
2386 serv_printf("GOTO %s", WC->wc_roomname);
2387 serv_getln(buf, sizeof buf);
2388 if (buf[0] == '2') {
2390 serv_getln(buf, sizeof buf);
2391 if (buf[0] == '2') {
2392 strcpy(final_destination, "_BASEROOM_");
2396 smart_goto(final_destination);
2402 * \brief Delete the current room
2404 void delete_room(void)
2408 serv_puts("KILL 1");
2409 serv_getln(buf, sizeof buf);
2410 if (buf[0] != '2') {
2411 strcpy(WC->ImportantMessage, &buf[4]);
2412 display_main_menu();
2415 smart_goto("_BASEROOM_");
2422 * \brief Perform changes to a room's network configuration
2424 void netedit(void) {
2434 if (strlen(bstr("line"))==0) {
2439 strcpy(line, bstr("prefix"));
2440 strcat(line, bstr("line"));
2441 strcat(line, bstr("suffix"));
2450 serv_getln(buf, sizeof buf);
2451 if (buf[0] != '1') {
2457 /** This loop works for add *or* remove. Spiffy, eh? */
2458 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2459 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2460 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2461 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2462 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2463 if ( (strcasecmp(cmpa0, cmpb0))
2464 || (strcasecmp(cmpa1, cmpb1)) ) {
2465 fprintf(fp, "%s\n", buf);
2471 serv_getln(buf, sizeof buf);
2472 if (buf[0] != '4') {
2478 while (fgets(buf, sizeof buf, fp) != NULL) {
2479 buf[strlen(buf)-1] = 0;
2483 if (strlen(bstr("add_button")) > 0) {
2484 num_addrs = num_tokens(bstr("line"), ',');
2485 if (num_addrs < 2) {
2486 /* just adding one node or address */
2490 /* adding multiple addresses separated by commas */
2491 for (i=0; i<num_addrs; ++i) {
2492 strcpy(line, bstr("prefix"));
2493 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2496 strcat(line, bstr("suffix"));
2510 * \brief Convert a room name to a folder-ish-looking name.
2511 * \param folder the folderish name
2512 * \param room the room name
2513 * \param floor the floor name
2514 * \param is_mailbox is it a mailbox?
2516 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2521 * For mailboxes, just do it straight...
2524 sprintf(folder, "My folders|%s", room);
2528 * Otherwise, prefix the floor name as a "public folders" moniker
2531 sprintf(folder, "%s|%s", floorlist[floor], room);
2535 * Replace "\" characters with "|" for pseudo-folder-delimiting
2537 for (i=0; i<strlen(folder); ++i) {
2538 if (folder[i] == '\\') folder[i] = '|';
2546 * \brief Back end for change_view()
2547 * \param newview set newview???
2549 void do_change_view(int newview) {
2552 serv_printf("VIEW %d", newview);
2553 serv_getln(buf, sizeof buf);
2554 WC->wc_view = newview;
2555 smart_goto(WC->wc_roomname);
2561 * \brief Change the view for this room
2563 void change_view(void) {
2566 view = atol(bstr("view"));
2567 do_change_view(view);
2572 * \brief One big expanded tree list view --- like a folder list
2573 * \param fold the folder to view
2574 * \param max_folders how many folders???
2575 * \param num_floors hom many floors???
2577 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2581 int has_subfolders = 0;
2584 parents = malloc(max_folders * sizeof(int));
2586 /** BEGIN TREE MENU */
2587 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2589 /** include NanoTree */
2590 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2592 /** initialize NanoTree */
2593 wprintf("<script type=\"text/javascript\"> \n"
2594 " showRootNode = false; \n"
2595 " sortNodes = false; \n"
2596 " dragable = false; \n"
2598 " function standardClick(treeNode) { \n"
2601 " var closedGif = 'static/folder_closed.gif'; \n"
2602 " var openGif = 'static/folder_open.gif'; \n"
2604 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2608 for (i=0; i<max_folders; ++i) {
2611 if ((i+1) < max_folders) {
2612 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2613 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2618 levels = num_tokens(fold[i].name, '|');
2619 parents[levels] = i;
2621 wprintf("var node%d = new TreeNode(%d, '", i, i);
2623 if (fold[i].selectable) {
2624 wprintf("<a href=\"dotgoto?room=");
2625 urlescputs(fold[i].room);
2630 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2632 else if (fold[i].hasnewmsgs) {
2633 wprintf("<SPAN CLASS=\"roomlist_new\">");
2636 wprintf("<SPAN CLASS=\"roomlist_old\">");
2638 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2643 if (has_subfolders) {
2644 wprintf("new Array(closedGif, openGif)");
2646 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2647 wprintf("'static/viewcontacts_16x.gif'");
2649 else if (fold[i].view == VIEW_CALENDAR) {
2650 wprintf("'static/calarea_16x.gif'");
2652 else if (fold[i].view == VIEW_CALBRIEF) {
2653 wprintf("'static/calarea_16x.gif'");
2655 else if (fold[i].view == VIEW_TASKS) {
2656 wprintf("'static/taskmanag_16x.gif'");
2658 else if (fold[i].view == VIEW_NOTES) {
2659 wprintf("'static/storenotes_16x.gif'");
2661 else if (fold[i].view == VIEW_MAILBOX) {
2662 wprintf("'static/privatemess_16x.gif'");
2665 wprintf("'static/chatrooms_16x.gif'");
2668 urlescputs(fold[i].name);
2672 wprintf("rootNode.addChild(node%d);\n", i);
2675 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2679 wprintf("container = document.getElementById('roomlist_div'); \n"
2685 /** END TREE MENU */
2689 * \brief Boxes and rooms and lists ... oh my!
2690 * \param fold the folder to view
2691 * \param max_folders how many folders???
2692 * \param num_floors hom many floors???
2694 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2696 char floor_name[256];
2697 char old_floor_name[256];
2699 int levels, oldlevels;
2702 static int columns = 3;
2703 int boxes_per_column = 0;
2704 int current_column = 0;
2707 strcpy(floor_name, "");
2708 strcpy(old_floor_name, "");
2711 while (nf % columns != 0) ++nf;
2712 boxes_per_column = (nf / columns);
2713 if (boxes_per_column < 1) boxes_per_column = 1;
2715 /** Outer table (for columnization) */
2716 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2717 "<tr><td valign=top>");
2721 for (i=0; i<max_folders; ++i) {
2723 levels = num_tokens(fold[i].name, '|');
2724 extract_token(floor_name, fold[i].name, 0,
2725 '|', sizeof floor_name);
2727 if ( (strcasecmp(floor_name, old_floor_name))
2728 && (strlen(old_floor_name) > 0) ) {
2730 do_template("endbox");
2733 if ((num_boxes % boxes_per_column) == 0) {
2735 if (current_column < columns) {
2736 wprintf("</td><td valign=top>\n");
2740 strcpy(old_floor_name, floor_name);
2743 /** Begin inner box */
2744 stresc(boxtitle, floor_name, 1, 0);
2745 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2746 do_template("beginbox");
2753 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2754 if (fold[i].selectable) {
2755 wprintf("<a href=\"dotgoto?room=");
2756 urlescputs(fold[i].room);
2762 if (fold[i].hasnewmsgs) {
2763 wprintf("<SPAN CLASS=\"roomlist_new\">");
2766 wprintf("<SPAN CLASS=\"roomlist_old\">");
2768 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2771 if (fold[i].selectable) {
2777 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2778 wprintf(" (INBOX)");
2780 wprintf("<br />\n");
2783 /** End the final inner box */
2784 do_template("endbox");
2786 wprintf("</TD></TR></TABLE>\n");
2790 * \brief print a floor div???
2791 * \param which_floordiv name of the floordiv???
2793 void set_floordiv_expanded(char *which_floordiv) {
2794 begin_ajax_response();
2795 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2796 end_ajax_response();
2800 * \brief view the iconbar
2801 * \param fold the folder to view
2802 * \param max_folders how many folders???
2803 * \param num_floors hom many floors???
2805 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2807 char floor_name[256];
2808 char old_floor_name[256];
2809 char floordivtitle[256];
2810 char floordiv_id[32];
2811 int levels, oldlevels;
2813 int num_drop_targets = 0;
2816 strcpy(floor_name, "");
2817 strcpy(old_floor_name, "");
2821 for (i=0; i<max_folders; ++i) {
2823 levels = num_tokens(fold[i].name, '|');
2824 extract_token(floor_name, fold[i].name, 0,
2825 '|', sizeof floor_name);
2827 if ( (strcasecmp(floor_name, old_floor_name))
2828 && (strlen(old_floor_name) > 0) ) {
2829 /** End inner box */
2831 wprintf("</div>\n"); /** floordiv */
2833 strcpy(old_floor_name, floor_name);
2837 stresc(floordivtitle, floor_name, 0, 0);
2838 sprintf(floordiv_id, "floordiv%d", i);
2839 wprintf("<span class=\"ib_roomlist_floor\" "
2840 "onClick=\"expand_floor('%s')\">"
2841 "%s</span><br>\n", floordiv_id, floordivtitle);
2842 wprintf("<div id=\"%s\" style=\"display:%s\">",
2844 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2851 wprintf("<div id=\"roomdiv%d\">", i);
2853 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2855 /** choose the icon */
2856 if (fold[i].view == VIEW_ADDRESSBOOK) {
2857 icon = "viewcontacts_16x.gif" ;
2859 else if (fold[i].view == VIEW_CALENDAR) {
2860 icon = "calarea_16x.gif" ;
2862 else if (fold[i].view == VIEW_CALBRIEF) {
2863 icon = "calarea_16x.gif" ;
2865 else if (fold[i].view == VIEW_TASKS) {
2866 icon = "taskmanag_16x.gif" ;
2868 else if (fold[i].view == VIEW_NOTES) {
2869 icon = "storenotes_16x.gif" ;
2871 else if (fold[i].view == VIEW_MAILBOX) {
2872 icon = "privatemess_16x.gif" ;
2875 icon = "chatrooms_16x.gif" ;
2878 if (fold[i].selectable) {
2879 wprintf("<a href=\"dotgoto?room=");
2880 urlescputs(fold[i].room);
2882 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2887 if (fold[i].hasnewmsgs) {
2888 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2891 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2893 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2895 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2896 wprintf(" (INBOX)");
2899 if (fold[i].selectable) {
2906 wprintf("</div>\n"); /** roomdiv */
2909 wprintf("</div>\n"); /** floordiv */
2912 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2913 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2915 num_drop_targets = 0;
2917 for (i=0; i<max_folders; ++i) {
2918 levels = num_tokens(fold[i].name, '|');
2920 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2921 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2922 jsescputs(fold[i].room);
2928 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2929 if (strlen(WC->floordiv_expanded) > 1) {
2930 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2934 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2940 * \brief Show the room list.
2941 * (only should get called by
2942 * knrooms() because that's where output_headers() is called from)
2943 * \param viewpref the view preferences???
2946 void list_all_rooms_by_floor(char *viewpref) {
2949 struct folder *fold = NULL;
2951 int max_folders = 0;
2952 int alloc_folders = 0;
2956 int num_floors = 1; /** add an extra one for private folders */
2958 /** If our cached folder list is very old, burn it. */
2959 if (WC->cache_fold != NULL) {
2960 if ((time(NULL) - WC->cache_timestamp) > 300) {
2961 free(WC->cache_fold);
2962 WC->cache_fold = NULL;
2966 /** Can we do the iconbar roomlist from cache? */
2967 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2968 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2972 /** Grab the floor table so we know how to build the list... */
2975 /** Start with the mailboxes */
2978 fold = malloc(sizeof(struct folder));
2979 memset(fold, 0, sizeof(struct folder));
2980 strcpy(fold[0].name, "My folders");
2981 fold[0].is_mailbox = 1;
2983 /** Then add floors */
2985 serv_getln(buf, sizeof buf);
2986 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2987 if (max_folders >= alloc_folders) {
2988 alloc_folders = max_folders + 100;
2989 fold = realloc(fold,
2990 alloc_folders * sizeof(struct folder));
2992 memset(&fold[max_folders], 0, sizeof(struct folder));
2993 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2998 /** refresh the messages index for this room */
2999 // serv_puts("GOTO ");
3000 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3001 /** Now add rooms */
3003 serv_getln(buf, sizeof buf);
3004 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3005 if (max_folders >= alloc_folders) {
3006 alloc_folders = max_folders + 100;
3007 fold = realloc(fold,
3008 alloc_folders * sizeof(struct folder));
3010 memset(&fold[max_folders], 0, sizeof(struct folder));
3011 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3012 ra_flags = extract_int(buf, 5);
3013 flags = extract_int(buf, 1);
3014 fold[max_folders].floor = extract_int(buf, 2);
3015 fold[max_folders].hasnewmsgs =
3016 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3017 if (flags & QR_MAILBOX) {
3018 fold[max_folders].is_mailbox = 1;
3020 fold[max_folders].view = extract_int(buf, 6);
3021 room_to_folder(fold[max_folders].name,
3022 fold[max_folders].room,
3023 fold[max_folders].floor,
3024 fold[max_folders].is_mailbox);
3025 fold[max_folders].selectable = 1;
3029 /** Bubble-sort the folder list */
3030 for (i=0; i<max_folders; ++i) {
3031 for (j=0; j<(max_folders-1)-i; ++j) {
3032 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3033 swap = strcasecmp(fold[j].name, fold[j+1].name);
3036 if ( (fold[j+1].is_mailbox)
3037 && (!fold[j].is_mailbox)) {
3045 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3046 memcpy(&fold[j], &fold[j+1],
3047 sizeof(struct folder));
3048 memcpy(&fold[j+1], &ftmp,
3049 sizeof(struct folder));
3055 if (!strcasecmp(viewpref, "folders")) {
3056 do_folder_view(fold, max_folders, num_floors);
3058 else if (!strcasecmp(viewpref, "hackish_view")) {
3059 for (i=0; i<max_folders; ++i) {
3060 escputs(fold[i].name);
3061 wprintf("<br />\n");
3064 else if (!strcasecmp(viewpref, "iconbar")) {
3065 do_iconbar_view(fold, max_folders, num_floors);
3068 do_rooms_view(fold, max_folders, num_floors);
3071 /* Don't free the folder list ... cache it for future use! */
3072 if (WC->cache_fold != NULL) {
3073 free(WC->cache_fold);
3075 WC->cache_fold = fold;
3076 WC->cache_max_folders = max_folders;
3077 WC->cache_num_floors = num_floors;
3078 WC->cache_timestamp = time(NULL);
3083 * \brief Do either a known rooms list or a folders list, depending on the
3088 char listviewpref[SIZ];
3090 output_headers(1, 1, 2, 0, 0, 0);
3092 /** Determine whether the user is trying to change views */
3093 if (bstr("view") != NULL) {
3094 if (strlen(bstr("view")) > 0) {
3095 set_preference("roomlistview", bstr("view"), 1);
3099 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3101 if ( (strcasecmp(listviewpref, "folders"))
3102 && (strcasecmp(listviewpref, "table")) ) {
3103 strcpy(listviewpref, "rooms");
3107 wprintf("<div id=\"banner\">\n"
3108 "<TABLE class=\"roomops_banner\"><TR><TD>"
3109 "<SPAN CLASS=\"titlebar\">"
3111 if (!strcasecmp(listviewpref, "rooms")) {
3112 wprintf(_("Room list"));
3114 if (!strcasecmp(listviewpref, "folders")) {
3115 wprintf(_("Folder list"));
3117 if (!strcasecmp(listviewpref, "table")) {
3118 wprintf(_("Room list"));
3120 wprintf("</SPAN></TD>\n");
3122 /** offer the ability to switch views */
3123 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
3124 "<SELECT NAME=\"newview\" SIZE=\"1\" "
3125 "OnChange=\"location.href=roomlistomatic.newview.options"
3126 "[selectedIndex].value\">\n");
3128 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3131 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3134 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3135 "View as folder list"
3137 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3140 wprintf("</SELECT><br />");
3142 wprintf("</FORM></TD></TR></TABLE>\n");
3145 "<div id=\"content\">\n");
3147 /** Display the room list in the user's preferred format */
3148 list_all_rooms_by_floor(listviewpref);
3155 * \brief Set the message expire policy for this room and/or floor
3157 void set_room_policy(void) {
3160 if (strlen(bstr("ok_button")) == 0) {
3161 strcpy(WC->ImportantMessage,
3162 _("Cancelled. Changes were not saved."));
3167 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3168 serv_getln(buf, sizeof buf);
3169 strcpy(WC->ImportantMessage, &buf[4]);
3171 if (WC->axlevel >= 6) {
3172 strcat(WC->ImportantMessage, "<br />\n");
3173 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3174 serv_getln(buf, sizeof buf);
3175 strcat(WC->ImportantMessage, &buf[4]);