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");
1179 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1181 wprintf("<UL><LI>");
1182 wprintf(_("Name of room: "));
1183 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1189 wprintf(_("Resides on floor: "));
1190 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1191 for (i = 0; i < 128; ++i)
1192 if (strlen(floorlist[i]) > 0) {
1193 wprintf("<OPTION ");
1195 wprintf("SELECTED ");
1196 wprintf("VALUE=\"%d\">", i);
1197 escputs(floorlist[i]);
1198 wprintf("</OPTION>\n");
1200 wprintf("</SELECT>\n");
1203 wprintf(_("Type of room:"));
1206 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1207 if ((er_flags & QR_PRIVATE) == 0)
1208 wprintf("CHECKED ");
1210 wprintf(_("Public (automatically appears to everyone)"));
1213 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1214 if ((er_flags & QR_PRIVATE) &&
1215 (er_flags & QR_GUESSNAME))
1216 wprintf("CHECKED ");
1218 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1220 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1221 if ((er_flags & QR_PRIVATE) &&
1222 (er_flags & QR_PASSWORDED))
1223 wprintf("CHECKED ");
1225 wprintf(_("Private - require password: "));
1226 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1229 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1230 if ((er_flags & QR_PRIVATE)
1231 && ((er_flags & QR_GUESSNAME) == 0)
1232 && ((er_flags & QR_PASSWORDED) == 0))
1233 wprintf("CHECKED ");
1235 wprintf(_("Private - invitation only"));
1237 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1239 wprintf(_("If private, cause current users to forget room"));
1241 wprintf("\n</UL>\n");
1243 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1244 if (er_flags & QR_PREFONLY)
1245 wprintf("CHECKED ");
1247 wprintf(_("Preferred users only"));
1249 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1250 if (er_flags & QR_READONLY)
1251 wprintf("CHECKED ");
1253 wprintf(_("Read-only room"));
1255 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1256 if (er_flags2 & QR2_COLLABDEL)
1257 wprintf("CHECKED ");
1259 wprintf(_("All users allowed to post may also delete messages"));
1261 /** directory stuff */
1262 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1263 if (er_flags & QR_DIRECTORY)
1264 wprintf("CHECKED ");
1266 wprintf(_("File directory room"));
1268 wprintf("\n<UL><LI>");
1269 wprintf(_("Directory name: "));
1270 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1273 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1274 if (er_flags & QR_UPLOAD)
1275 wprintf("CHECKED ");
1277 wprintf(_("Uploading allowed"));
1279 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1280 if (er_flags & QR_DOWNLOAD)
1281 wprintf("CHECKED ");
1283 wprintf(_("Downloading allowed"));
1285 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1286 if (er_flags & QR_VISDIR)
1287 wprintf("CHECKED ");
1289 wprintf(_("Visible directory"));
1292 /** end of directory stuff */
1294 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1295 if (er_flags & QR_NETWORK)
1296 wprintf("CHECKED ");
1298 wprintf(_("Network shared room"));
1300 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1301 if (er_flags & QR_PERMANENT)
1302 wprintf("CHECKED ");
1304 wprintf(_("Permanent (does not auto-purge)"));
1306 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1307 if (er_flags2 & QR2_SUBJECTREQ)
1308 wprintf("CHECKED ");
1310 wprintf(_("Subject Required (Force users to specify a message subject)"));
1312 /** start of anon options */
1315 wprintf(_("Anonymous messages"));
1318 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1319 if (((er_flags & QR_ANONONLY) == 0)
1320 && ((er_flags & QR_ANONOPT) == 0))
1321 wprintf("CHECKED ");
1323 wprintf(_("No anonymous messages"));
1325 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1326 if (er_flags & QR_ANONONLY)
1327 wprintf("CHECKED ");
1329 wprintf(_("All messages are anonymous"));
1331 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1332 if (er_flags & QR_ANONOPT)
1333 wprintf("CHECKED ");
1335 wprintf(_("Prompt user when entering messages"));
1338 /* end of anon options */
1341 wprintf(_("Room aide: "));
1343 serv_getln(buf, sizeof buf);
1344 if (buf[0] != '2') {
1345 wprintf("<em>%s</em>\n", &buf[4]);
1347 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1348 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1351 wprintf("</UL><CENTER>\n");
1352 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1353 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1355 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1363 /** Sharing the room with other Citadel nodes... */
1364 if (!strcmp(tab, "sharing")) {
1366 shared_with = strdup("");
1367 not_shared_with = strdup("");
1369 /** Learn the current configuration */
1370 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1371 serv_getln(buf, sizeof buf);
1372 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1373 extract_token(node, buf, 0, '|', sizeof node);
1374 not_shared_with = realloc(not_shared_with,
1375 strlen(not_shared_with) + 32);
1376 strcat(not_shared_with, node);
1377 strcat(not_shared_with, "\n");
1381 serv_getln(buf, sizeof buf);
1382 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1383 extract_token(cmd, buf, 0, '|', sizeof cmd);
1384 extract_token(node, buf, 1, '|', sizeof node);
1385 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1386 if (!strcasecmp(cmd, "ignet_push_share")) {
1387 shared_with = realloc(shared_with,
1388 strlen(shared_with) + 32);
1389 strcat(shared_with, node);
1390 if (strlen(remote_room) > 0) {
1391 strcat(shared_with, "|");
1392 strcat(shared_with, remote_room);
1394 strcat(shared_with, "\n");
1398 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1399 extract_token(buf, shared_with, i, '\n', sizeof buf);
1400 extract_token(node, buf, 0, '|', sizeof node);
1401 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1402 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1403 if (!strcasecmp(node, cmd)) {
1404 remove_token(not_shared_with, j, '\n');
1409 /** Display the stuff */
1410 wprintf("<CENTER><br />"
1411 "<TABLE border=1 cellpadding=5><TR>"
1413 wprintf(_("Shared with"));
1414 wprintf("</I></B></TD>"
1416 wprintf(_("Not shared with"));
1417 wprintf("</I></B></TD></TR>\n"
1418 "<TR><TD VALIGN=TOP>\n");
1420 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1421 wprintf(_("Remote node name"));
1422 wprintf("</TD><TD>");
1423 wprintf(_("Remote room name"));
1424 wprintf("</TD><TD>");
1425 wprintf(_("Actions"));
1426 wprintf("</TD></TR>\n");
1428 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1429 extract_token(buf, shared_with, i, '\n', sizeof buf);
1430 extract_token(node, buf, 0, '|', sizeof node);
1431 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1432 if (strlen(node) > 0) {
1433 wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
1434 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1435 wprintf("<TR><TD>%s</TD>\n", node);
1438 if (strlen(remote_room) > 0) {
1439 escputs(remote_room);
1445 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1446 "VALUE=\"ignet_push_share|");
1448 if (strlen(remote_room) > 0) {
1450 urlescputs(remote_room);
1453 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1454 "VALUE=\"sharing\">\n");
1455 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1456 "VALUE=\"remove\">\n");
1457 wprintf("<INPUT TYPE=\"submit\" "
1458 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1459 wprintf("</TD></TR></FORM>\n");
1463 wprintf("</TABLE>\n");
1464 wprintf("</TD><TD VALIGN=TOP>\n");
1465 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1466 wprintf(_("Remote node name"));
1467 wprintf("</TD><TD>");
1468 wprintf(_("Remote room name"));
1469 wprintf("</TD><TD>");
1470 wprintf(_("Actions"));
1471 wprintf("</TD></TR>\n");
1473 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1474 extract_token(node, not_shared_with, i, '\n', sizeof node);
1475 if (strlen(node) > 0) {
1476 wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
1477 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1478 wprintf("<TR><TD>");
1481 "<INPUT TYPE=\"INPUT\" "
1485 wprintf("<INPUT TYPE=\"hidden\" "
1487 "VALUE=\"ignet_push_share|");
1490 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1491 "VALUE=\"sharing\">\n");
1492 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1493 "VALUE=\"add\">\n");
1494 wprintf("<INPUT TYPE=\"submit\" "
1495 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1496 wprintf("</TD></TR></FORM>\n");
1500 wprintf("</TABLE>\n");
1501 wprintf("</TD></TR>"
1502 "</TABLE></CENTER><br />\n"
1503 "<I><B>%s</B><UL><LI>", _("Notes:"));
1504 wprintf(_("When sharing a room, "
1505 "it must be shared from both ends. Adding a node to "
1506 "the 'shared' list sends messages out, but in order to"
1507 " receive messages, the other nodes must be configured"
1508 " to send messages out to your system as well. "
1509 "<LI>If the remote room name is blank, it is assumed "
1510 "that the room name is identical on the remote node."
1511 "<LI>If the remote room name is different, the remote "
1512 "node must also configure the name of the room here."
1518 /** Mailing list management */
1519 if (!strcmp(tab, "listserv")) {
1521 wprintf("<br /><center>"
1522 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1523 "<TR><TD VALIGN=TOP>");
1525 wprintf(_("<i>The contents of this room are being "
1526 "mailed <b>as individual messages</b> "
1527 "to the following list recipients:"
1528 "</i><br /><br />\n"));
1531 serv_getln(buf, sizeof buf);
1532 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1533 extract_token(cmd, buf, 0, '|', sizeof cmd);
1534 if (!strcasecmp(cmd, "listrecp")) {
1535 extract_token(recp, buf, 1, '|', sizeof recp);
1538 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1541 wprintf(_("(remove)"));
1542 wprintf("</A><br />");
1545 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1546 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1547 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1548 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1549 wprintf("<INPUT TYPE=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1550 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1551 wprintf("</FORM>\n");
1553 wprintf("</TD><TD VALIGN=TOP>\n");
1555 wprintf(_("<i>The contents of this room are being "
1556 "mailed <b>in digest form</b> "
1557 "to the following list recipients:"
1558 "</i><br /><br />\n"));
1561 serv_getln(buf, sizeof buf);
1562 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1563 extract_token(cmd, buf, 0, '|', sizeof cmd);
1564 if (!strcasecmp(cmd, "digestrecp")) {
1565 extract_token(recp, buf, 1, '|', sizeof recp);
1568 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1572 wprintf(_("(remove)"));
1573 wprintf("</A><br />");
1576 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1577 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1578 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1579 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1580 wprintf("<INPUT TYPE=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1581 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1582 wprintf("</FORM>\n");
1584 wprintf("</TD></TR></TABLE>\n");
1586 /** Pop open an address book -- begin **/
1587 wprintf("<div align=right>"
1588 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1590 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1595 _("Add recipients from Contacts or other address books"),
1596 _("Add recipients from Contacts or other address books")
1598 /** Pop open an address book -- end **/
1601 if (self_service(999) == 1) {
1602 wprintf(_("This room is configured to allow "
1603 "self-service subscribe/unsubscribe requests."));
1604 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1605 wprintf(_("Click to disable."));
1606 wprintf("</A><br />\n");
1607 wprintf(_("The URL for subscribe/unsubscribe is: "));
1608 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1609 (is_https ? "https" : "http"),
1613 wprintf(_("This room is <i>not</i> configured to allow "
1614 "self-service subscribe/unsubscribe requests."));
1615 wprintf(" <a href=\"toggle_self_service?newval=1&"
1617 wprintf(_("Click to enable."));
1618 wprintf("</A><br />\n");
1622 wprintf("</CENTER>\n");
1626 /** Mailing list management */
1627 if (!strcmp(tab, "expire")) {
1629 serv_puts("GPEX room");
1630 serv_getln(buf, sizeof buf);
1631 if (buf[0] == '2') {
1632 roompolicy = extract_int(&buf[4], 0);
1633 roomvalue = extract_int(&buf[4], 1);
1636 serv_puts("GPEX floor");
1637 serv_getln(buf, sizeof buf);
1638 if (buf[0] == '2') {
1639 floorpolicy = extract_int(&buf[4], 0);
1640 floorvalue = extract_int(&buf[4], 1);
1643 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1644 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1645 wprintf("<TABLE border=0 cellspacing=5>\n");
1646 wprintf("<TR><TD>");
1647 wprintf(_("Message expire policy for this room"));
1649 escputs(WC->wc_roomname);
1650 wprintf(")</TD><TD>");
1651 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1652 ((roompolicy == 0) ? "CHECKED" : "") );
1653 wprintf(_("Use the default policy for this floor"));
1654 wprintf("<br />\n");
1655 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1656 ((roompolicy == 1) ? "CHECKED" : "") );
1657 wprintf(_("Never automatically expire messages"));
1658 wprintf("<br />\n");
1659 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1660 ((roompolicy == 2) ? "CHECKED" : "") );
1661 wprintf(_("Expire by message count"));
1662 wprintf("<br />\n");
1663 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1664 ((roompolicy == 3) ? "CHECKED" : "") );
1665 wprintf(_("Expire by message age"));
1667 wprintf(_("Number of messages or days: "));
1668 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1669 wprintf("</TD></TR>\n");
1671 if (WC->axlevel >= 6) {
1672 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1673 wprintf("<TR><TD>");
1674 wprintf(_("Message expire policy for this floor"));
1676 escputs(floorlist[WC->wc_floor]);
1677 wprintf(")</TD><TD>");
1678 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1679 ((floorpolicy == 0) ? "CHECKED" : "") );
1680 wprintf(_("Use the system default"));
1681 wprintf("<br />\n");
1682 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1683 ((floorpolicy == 1) ? "CHECKED" : "") );
1684 wprintf(_("Never automatically expire messages"));
1685 wprintf("<br />\n");
1686 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1687 ((floorpolicy == 2) ? "CHECKED" : "") );
1688 wprintf(_("Expire by message count"));
1689 wprintf("<br />\n");
1690 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1691 ((floorpolicy == 3) ? "CHECKED" : "") );
1692 wprintf(_("Expire by message age"));
1694 wprintf(_("Number of messages or days: "));
1695 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1699 wprintf("<CENTER>\n");
1700 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1701 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1703 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1704 wprintf("</CENTER></TD><TR>\n");
1706 wprintf("</TABLE>\n"
1707 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1713 /** Mailing list management */
1714 if (!strcmp(tab, "access")) {
1718 /** end content of whatever tab is open now */
1719 wprintf("</TD></TR></TABLE></div>\n");
1721 address_book_popup();
1727 * \brief Toggle self-service list subscription
1729 void toggle_self_service(void) {
1732 newval = atoi(bstr("newval"));
1733 self_service(newval);
1740 * \brief save new parameters for a room
1746 char er_password[10];
1747 char er_dirname[15];
1748 char er_roomaide[26];
1751 int er_listingorder;
1757 if (strlen(bstr("ok_button")) == 0) {
1758 strcpy(WC->ImportantMessage,
1759 _("Cancelled. Changes were not saved."));
1764 serv_getln(buf, sizeof buf);
1766 if (buf[0] != '2') {
1767 strcpy(WC->ImportantMessage, &buf[4]);
1771 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1772 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1773 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1774 er_flags = extract_int(&buf[4], 3);
1775 er_listingorder = extract_int(&buf[4], 5);
1776 er_defaultview = extract_int(&buf[4], 6);
1777 er_flags2 = extract_int(&buf[4], 7);
1779 strcpy(er_roomaide, bstr("er_roomaide"));
1780 if (strlen(er_roomaide) == 0) {
1782 serv_getln(buf, sizeof buf);
1783 if (buf[0] != '2') {
1784 strcpy(er_roomaide, "");
1786 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1789 strcpy(buf, bstr("er_name"));
1791 if (strlen(buf) > 0) {
1792 strcpy(er_name, buf);
1795 strcpy(buf, bstr("er_password"));
1797 if (strlen(buf) > 0)
1798 strcpy(er_password, buf);
1800 strcpy(buf, bstr("er_dirname"));
1802 if (strlen(buf) > 0)
1803 strcpy(er_dirname, buf);
1805 strcpy(buf, bstr("type"));
1806 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1808 if (!strcmp(buf, "invonly")) {
1809 er_flags |= (QR_PRIVATE);
1811 if (!strcmp(buf, "hidden")) {
1812 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1814 if (!strcmp(buf, "passworded")) {
1815 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1817 if (!strcmp(bstr("prefonly"), "yes")) {
1818 er_flags |= QR_PREFONLY;
1820 er_flags &= ~QR_PREFONLY;
1823 if (!strcmp(bstr("readonly"), "yes")) {
1824 er_flags |= QR_READONLY;
1826 er_flags &= ~QR_READONLY;
1829 if (!strcmp(bstr("collabdel"), "yes")) {
1830 er_flags2 |= QR2_COLLABDEL;
1832 er_flags2 &= ~QR2_COLLABDEL;
1835 if (!strcmp(bstr("permanent"), "yes")) {
1836 er_flags |= QR_PERMANENT;
1838 er_flags &= ~QR_PERMANENT;
1841 if (!strcmp(bstr("subjectreq"), "yes")) {
1842 er_flags2 |= QR2_SUBJECTREQ;
1844 er_flags2 &= ~QR2_SUBJECTREQ;
1847 if (!strcmp(bstr("network"), "yes")) {
1848 er_flags |= QR_NETWORK;
1850 er_flags &= ~QR_NETWORK;
1853 if (!strcmp(bstr("directory"), "yes")) {
1854 er_flags |= QR_DIRECTORY;
1856 er_flags &= ~QR_DIRECTORY;
1859 if (!strcmp(bstr("ulallowed"), "yes")) {
1860 er_flags |= QR_UPLOAD;
1862 er_flags &= ~QR_UPLOAD;
1865 if (!strcmp(bstr("dlallowed"), "yes")) {
1866 er_flags |= QR_DOWNLOAD;
1868 er_flags &= ~QR_DOWNLOAD;
1871 if (!strcmp(bstr("visdir"), "yes")) {
1872 er_flags |= QR_VISDIR;
1874 er_flags &= ~QR_VISDIR;
1877 strcpy(buf, bstr("anon"));
1879 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1880 if (!strcmp(buf, "anononly"))
1881 er_flags |= QR_ANONONLY;
1882 if (!strcmp(buf, "anon2"))
1883 er_flags |= QR_ANONOPT;
1886 if (!strcmp(bstr("bump"), "yes"))
1889 er_floor = atoi(bstr("er_floor"));
1891 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
1892 er_name, er_password, er_dirname, er_flags, bump, er_floor,
1893 er_listingorder, er_defaultview, er_flags2);
1895 serv_getln(buf, sizeof buf);
1896 if (buf[0] != '2') {
1897 strcpy(WC->ImportantMessage, &buf[4]);
1903 if (strlen(er_roomaide) > 0) {
1904 sprintf(buf, "SETA %s", er_roomaide);
1906 serv_getln(buf, sizeof buf);
1907 if (buf[0] != '2') {
1908 strcpy(WC->ImportantMessage, &buf[4]);
1909 display_main_menu();
1914 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1921 * \brief Display form for Invite, Kick, and show Who Knows a room
1923 void do_invt_kick(void) {
1924 char buf[SIZ], room[SIZ], username[SIZ];
1927 serv_getln(buf, sizeof buf);
1929 if (buf[0] != '2') {
1933 extract_token(room, &buf[4], 0, '|', sizeof room);
1935 strcpy(username, bstr("username"));
1937 if (strlen(bstr("kick_button")) > 0) {
1938 sprintf(buf, "KICK %s", username);
1940 serv_getln(buf, sizeof buf);
1942 if (buf[0] != '2') {
1943 strcpy(WC->ImportantMessage, &buf[4]);
1945 sprintf(WC->ImportantMessage,
1946 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1951 if (strlen(bstr("invite_button")) > 0) {
1952 sprintf(buf, "INVT %s", username);
1954 serv_getln(buf, sizeof buf);
1956 if (buf[0] != '2') {
1957 strcpy(WC->ImportantMessage, &buf[4]);
1959 sprintf(WC->ImportantMessage,
1960 _("<B><I>User %s invited to room %s.</I></B>\n"),
1971 * \brief Display form for Invite, Kick, and show Who Knows a room
1973 void display_whok(void)
1975 char buf[SIZ], room[SIZ], username[SIZ];
1978 serv_getln(buf, sizeof buf);
1980 if (buf[0] != '2') {
1984 extract_token(room, &buf[4], 0, '|', sizeof room);
1987 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1988 wprintf(_("The users listed below have access to this room. "
1989 "To remove a user from the access list, select the user "
1990 "name from the list and click 'Kick'."));
1991 wprintf("<br /><br />");
1993 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1994 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1995 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1996 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1998 serv_getln(buf, sizeof buf);
1999 if (buf[0] == '1') {
2000 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2001 extract_token(username, buf, 0, '|', sizeof username);
2002 wprintf("<OPTION>");
2007 wprintf("</SELECT><br />\n");
2009 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2010 wprintf("</FORM></CENTER>\n");
2012 wprintf("</TD><TD>");
2013 wprintf(_("To grant another user access to this room, enter the "
2014 "user name in the box below and click 'Invite'."));
2015 wprintf("<br /><br />");
2017 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
2018 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2019 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2020 wprintf(_("Invite:"));
2022 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
2023 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2024 "<input type=\"submit\" value=\"%s\">"
2025 "</FORM></CENTER>\n", _("Invite"));
2027 wprintf("</TD></TR></TABLE>\n");
2034 * \brief display the form for entering a new room
2036 void display_entroom(void)
2041 serv_puts("CRE8 0");
2042 serv_getln(buf, sizeof buf);
2044 if (buf[0] != '2') {
2045 strcpy(WC->ImportantMessage, &buf[4]);
2046 display_main_menu();
2050 output_headers(1, 1, 2, 0, 0, 0);
2051 wprintf("<div id=\"banner\">\n"
2052 "<TABLE class=\"roomops_banner\"><TR><TD>"
2053 "<SPAN CLASS=\"titlebar\">");
2054 wprintf(_("Create a new room"));
2056 "</TD></TR></TABLE>\n"
2057 "</div>\n<div id=\"content\">\n"
2060 wprintf("<div class=\"fix_scrollbar_bug\">"
2061 "<table class=\"roomops_background\"><tr><td>\n");
2063 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2064 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2066 wprintf("<UL><LI>");
2067 wprintf(_("Name of room: "));
2068 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2071 wprintf(_("Resides on floor: "));
2073 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
2074 for (i = 0; i < 128; ++i)
2075 if (strlen(floorlist[i]) > 0) {
2076 wprintf("<OPTION ");
2077 wprintf("VALUE=\"%d\">", i);
2078 escputs(floorlist[i]);
2079 wprintf("</OPTION>\n");
2081 wprintf("</SELECT>\n");
2084 * Our clever little snippet of JavaScript automatically selects
2085 * a public room if the view is set to Bulletin Board or wiki, and
2086 * it selects a mailbox room otherwise. The user can override this,
2087 * of course. We also disable the floor selector for mailboxes.
2090 wprintf(_("Default view for room: "));
2091 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
2092 " if ( (this.form.er_view.value == 0) "
2093 " || (this.form.er_view.value == 6) ) { "
2094 " this.form.type[0].checked=true; "
2095 " this.form.er_floor.disabled = false; "
2098 " this.form.type[4].checked=true; "
2099 " this.form.er_floor.disabled = true; "
2102 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2103 if (is_view_allowed_as_default(i)) {
2104 wprintf("<OPTION %s VALUE=\"%d\">",
2105 ((i == 0) ? "SELECTED" : ""), i );
2106 escputs(viewdefs[i]);
2107 wprintf("</OPTION>\n");
2110 wprintf("</SELECT>\n");
2113 wprintf(_("Type of room:"));
2116 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2117 wprintf("CHECKED OnChange=\""
2118 " if (this.form.type[0].checked == true) { "
2119 " this.form.er_floor.disabled = false; "
2122 wprintf(_("Public (automatically appears to everyone)"));
2124 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2125 " if (this.form.type[1].checked == true) { "
2126 " this.form.er_floor.disabled = false; "
2129 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2131 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2132 " if (this.form.type[2].checked == true) { "
2133 " this.form.er_floor.disabled = false; "
2136 wprintf(_("Private - require password: "));
2137 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2139 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2140 " if (this.form.type[3].checked == true) { "
2141 " this.form.er_floor.disabled = false; "
2144 wprintf(_("Private - invitation only"));
2146 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2148 " if (this.form.type[4].checked == true) { "
2149 " this.form.er_floor.disabled = true; "
2152 wprintf(_("Personal (mailbox for you only)"));
2154 wprintf("\n</UL>\n");
2156 wprintf("<CENTER>\n");
2157 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2159 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2160 wprintf("</CENTER>\n");
2161 wprintf("</FORM>\n<hr />");
2162 serv_printf("MESG roomaccess");
2163 serv_getln(buf, sizeof buf);
2164 if (buf[0] == '1') {
2167 wprintf("</td></tr></table></div>\n");
2175 * \brief support function for entroom() -- sets the default view
2177 void er_set_default_view(int newview) {
2190 serv_getln(buf, sizeof buf);
2191 if (buf[0] != '2') return;
2193 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2194 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2195 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2196 rm_bits1 = extract_int(&buf[4], 3);
2197 rm_floor = extract_int(&buf[4], 4);
2198 rm_listorder = extract_int(&buf[4], 5);
2199 rm_bits2 = extract_int(&buf[4], 7);
2201 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2202 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2203 rm_listorder, newview, rm_bits2
2205 serv_getln(buf, sizeof buf);
2211 * \brief enter a new room
2218 char er_password[SIZ];
2223 if (strlen(bstr("ok_button")) == 0) {
2224 strcpy(WC->ImportantMessage,
2225 _("Cancelled. No new room was created."));
2226 display_main_menu();
2229 strcpy(er_name, bstr("er_name"));
2230 strcpy(er_type, bstr("type"));
2231 strcpy(er_password, bstr("er_password"));
2232 er_floor = atoi(bstr("er_floor"));
2233 er_view = atoi(bstr("er_view"));
2236 if (!strcmp(er_type, "hidden"))
2238 if (!strcmp(er_type, "passworded"))
2240 if (!strcmp(er_type, "invonly"))
2242 if (!strcmp(er_type, "personal"))
2245 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2246 er_name, er_num_type, er_password, er_floor, 0, er_view);
2248 serv_getln(buf, sizeof buf);
2249 if (buf[0] != '2') {
2250 strcpy(WC->ImportantMessage, &buf[4]);
2251 display_main_menu();
2255 do_change_view(er_view); /* Now go there */
2260 * \brief display the screen to enter a private room
2262 void display_private(char *rname, int req_pass)
2264 output_headers(1, 1, 2, 0, 0, 0);
2265 wprintf("<div id=\"banner\">\n"
2266 "<TABLE class=\"roomops_banner\"><TR><TD>"
2267 "<SPAN CLASS=\"titlebar\">");
2268 wprintf(_("Go to a hidden room"));
2270 "</TD></TR></TABLE>\n"
2271 "</div>\n<div id=\"content\">\n"
2274 wprintf("<div class=\"fix_scrollbar_bug\">"
2275 "<table class=\"roomops_background\"><tr><td>\n");
2277 wprintf("<CENTER>\n");
2279 wprintf(_("If you know the name of a hidden (guess-name) or "
2280 "passworded room, you can enter that room by typing "
2281 "its name below. Once you gain access to a private "
2282 "room, it will appear in your regular room listings "
2283 "so you don't have to keep returning here."));
2284 wprintf("\n<br /><br />");
2286 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2287 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2289 wprintf("<table border=\"0\" cellspacing=\"5\" "
2290 "cellpadding=\"5\" class=\"roomops_background_alt\">\n"
2292 wprintf(_("Enter room name:"));
2294 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2295 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2298 wprintf("</TD></TR><TR><TD>");
2299 wprintf(_("Enter room password:"));
2300 wprintf("</TD><TD>");
2301 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2303 wprintf("</TD></TR></TABLE><br />\n");
2305 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2307 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2311 wprintf("</FORM>\n");
2312 wprintf("</td></tr></table></div>\n");
2317 * \brief goto a private room
2319 void goto_private(void)
2324 if (strlen(bstr("ok_button")) == 0) {
2325 display_main_menu();
2328 strcpy(hold_rm, WC->wc_roomname);
2329 strcpy(buf, "GOTO ");
2330 strcat(buf, bstr("gr_name"));
2332 strcat(buf, bstr("gr_pass"));
2334 serv_getln(buf, sizeof buf);
2336 if (buf[0] == '2') {
2337 smart_goto(bstr("gr_name"));
2340 if (!strncmp(buf, "540", 3)) {
2341 display_private(bstr("gr_name"), 1);
2344 output_headers(1, 1, 1, 0, 0, 0);
2345 wprintf("%s\n", &buf[4]);
2352 * \brief display the screen to zap a room
2354 void display_zap(void)
2356 output_headers(1, 1, 2, 0, 0, 0);
2358 wprintf("<div id=\"banner\">\n");
2359 wprintf("<TABLE class=\"roomops_zap\"><TR><TD>");
2360 wprintf("<SPAN CLASS=\"titlebar\">");
2361 wprintf(_("Zap (forget/unsubscribe) the current room"));
2362 wprintf("</SPAN>\n");
2363 wprintf("</TD></TR></TABLE>\n");
2364 wprintf("</div>\n<div id=\"content\">\n");
2366 wprintf(_("If you select this option, <em>%s</em> will "
2367 "disappear from your room list. Is this what you wish "
2368 "to do?<br />\n"), WC->wc_roomname);
2370 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2371 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2372 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2374 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2375 wprintf("</FORM>\n");
2386 char final_destination[SIZ];
2389 * If the forget-room routine fails for any reason, we fall back
2390 * to the current room; otherwise, we go to the Lobby
2392 strcpy(final_destination, WC->wc_roomname);
2394 if (strlen(bstr("ok_button")) > 0) {
2395 serv_printf("GOTO %s", WC->wc_roomname);
2396 serv_getln(buf, sizeof buf);
2397 if (buf[0] == '2') {
2399 serv_getln(buf, sizeof buf);
2400 if (buf[0] == '2') {
2401 strcpy(final_destination, "_BASEROOM_");
2405 smart_goto(final_destination);
2411 * \brief Delete the current room
2413 void delete_room(void)
2417 serv_puts("KILL 1");
2418 serv_getln(buf, sizeof buf);
2419 if (buf[0] != '2') {
2420 strcpy(WC->ImportantMessage, &buf[4]);
2421 display_main_menu();
2424 smart_goto("_BASEROOM_");
2431 * \brief Perform changes to a room's network configuration
2433 void netedit(void) {
2443 if (strlen(bstr("line"))==0) {
2448 strcpy(line, bstr("prefix"));
2449 strcat(line, bstr("line"));
2450 strcat(line, bstr("suffix"));
2459 serv_getln(buf, sizeof buf);
2460 if (buf[0] != '1') {
2466 /** This loop works for add *or* remove. Spiffy, eh? */
2467 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2468 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2469 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2470 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2471 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2472 if ( (strcasecmp(cmpa0, cmpb0))
2473 || (strcasecmp(cmpa1, cmpb1)) ) {
2474 fprintf(fp, "%s\n", buf);
2480 serv_getln(buf, sizeof buf);
2481 if (buf[0] != '4') {
2487 while (fgets(buf, sizeof buf, fp) != NULL) {
2488 buf[strlen(buf)-1] = 0;
2492 if (strlen(bstr("add_button")) > 0) {
2493 num_addrs = num_tokens(bstr("line"), ',');
2494 if (num_addrs < 2) {
2495 /* just adding one node or address */
2499 /* adding multiple addresses separated by commas */
2500 for (i=0; i<num_addrs; ++i) {
2501 strcpy(line, bstr("prefix"));
2502 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2505 strcat(line, bstr("suffix"));
2519 * \brief Convert a room name to a folder-ish-looking name.
2520 * \param folder the folderish name
2521 * \param room the room name
2522 * \param floor the floor name
2523 * \param is_mailbox is it a mailbox?
2525 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2530 * For mailboxes, just do it straight...
2533 sprintf(folder, "My folders|%s", room);
2537 * Otherwise, prefix the floor name as a "public folders" moniker
2540 sprintf(folder, "%s|%s", floorlist[floor], room);
2544 * Replace "\" characters with "|" for pseudo-folder-delimiting
2546 for (i=0; i<strlen(folder); ++i) {
2547 if (folder[i] == '\\') folder[i] = '|';
2555 * \brief Back end for change_view()
2556 * \param newview set newview???
2558 void do_change_view(int newview) {
2561 serv_printf("VIEW %d", newview);
2562 serv_getln(buf, sizeof buf);
2563 WC->wc_view = newview;
2564 smart_goto(WC->wc_roomname);
2570 * \brief Change the view for this room
2572 void change_view(void) {
2575 view = atol(bstr("view"));
2576 do_change_view(view);
2581 * \brief One big expanded tree list view --- like a folder list
2582 * \param fold the folder to view
2583 * \param max_folders how many folders???
2584 * \param num_floors hom many floors???
2586 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2590 int has_subfolders = 0;
2593 parents = malloc(max_folders * sizeof(int));
2595 /** BEGIN TREE MENU */
2596 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2598 /** include NanoTree */
2599 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2601 /** initialize NanoTree */
2602 wprintf("<script type=\"text/javascript\"> \n"
2603 " showRootNode = false; \n"
2604 " sortNodes = false; \n"
2605 " dragable = false; \n"
2607 " function standardClick(treeNode) { \n"
2610 " var closedGif = 'static/folder_closed.gif'; \n"
2611 " var openGif = 'static/folder_open.gif'; \n"
2613 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2617 for (i=0; i<max_folders; ++i) {
2620 if ((i+1) < max_folders) {
2621 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2622 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2627 levels = num_tokens(fold[i].name, '|');
2628 parents[levels] = i;
2630 wprintf("var node%d = new TreeNode(%d, '", i, i);
2632 if (fold[i].selectable) {
2633 wprintf("<a href=\"dotgoto?room=");
2634 urlescputs(fold[i].room);
2639 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2641 else if (fold[i].hasnewmsgs) {
2642 wprintf("<SPAN CLASS=\"roomlist_new\">");
2645 wprintf("<SPAN CLASS=\"roomlist_old\">");
2647 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2652 if (has_subfolders) {
2653 wprintf("new Array(closedGif, openGif)");
2655 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2656 wprintf("'static/viewcontacts_16x.gif'");
2658 else if (fold[i].view == VIEW_CALENDAR) {
2659 wprintf("'static/calarea_16x.gif'");
2661 else if (fold[i].view == VIEW_CALBRIEF) {
2662 wprintf("'static/calarea_16x.gif'");
2664 else if (fold[i].view == VIEW_TASKS) {
2665 wprintf("'static/taskmanag_16x.gif'");
2667 else if (fold[i].view == VIEW_NOTES) {
2668 wprintf("'static/storenotes_16x.gif'");
2670 else if (fold[i].view == VIEW_MAILBOX) {
2671 wprintf("'static/privatemess_16x.gif'");
2674 wprintf("'static/chatrooms_16x.gif'");
2677 urlescputs(fold[i].name);
2681 wprintf("rootNode.addChild(node%d);\n", i);
2684 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2688 wprintf("container = document.getElementById('roomlist_div'); \n"
2694 /** END TREE MENU */
2698 * \brief Boxes and rooms and lists ... oh my!
2699 * \param fold the folder to view
2700 * \param max_folders how many folders???
2701 * \param num_floors hom many floors???
2703 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2705 char floor_name[256];
2706 char old_floor_name[256];
2708 int levels, oldlevels;
2711 static int columns = 3;
2712 int boxes_per_column = 0;
2713 int current_column = 0;
2716 strcpy(floor_name, "");
2717 strcpy(old_floor_name, "");
2720 while (nf % columns != 0) ++nf;
2721 boxes_per_column = (nf / columns);
2722 if (boxes_per_column < 1) boxes_per_column = 1;
2724 /** Outer table (for columnization) */
2725 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2726 "<tr><td valign=top>");
2730 for (i=0; i<max_folders; ++i) {
2732 levels = num_tokens(fold[i].name, '|');
2733 extract_token(floor_name, fold[i].name, 0,
2734 '|', sizeof floor_name);
2736 if ( (strcasecmp(floor_name, old_floor_name))
2737 && (strlen(old_floor_name) > 0) ) {
2739 do_template("endbox");
2742 if ((num_boxes % boxes_per_column) == 0) {
2744 if (current_column < columns) {
2745 wprintf("</td><td valign=top>\n");
2749 strcpy(old_floor_name, floor_name);
2752 /** Begin inner box */
2753 stresc(boxtitle, floor_name, 1, 0);
2754 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2755 do_template("beginbox");
2762 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2763 if (fold[i].selectable) {
2764 wprintf("<a href=\"dotgoto?room=");
2765 urlescputs(fold[i].room);
2771 if (fold[i].hasnewmsgs) {
2772 wprintf("<SPAN CLASS=\"roomlist_new\">");
2775 wprintf("<SPAN CLASS=\"roomlist_old\">");
2777 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2780 if (fold[i].selectable) {
2786 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2787 wprintf(" (INBOX)");
2789 wprintf("<br />\n");
2792 /** End the final inner box */
2793 do_template("endbox");
2795 wprintf("</TD></TR></TABLE>\n");
2799 * \brief print a floor div???
2800 * \param which_floordiv name of the floordiv???
2802 void set_floordiv_expanded(char *which_floordiv) {
2803 begin_ajax_response();
2804 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2805 end_ajax_response();
2809 * \brief view the iconbar
2810 * \param fold the folder to view
2811 * \param max_folders how many folders???
2812 * \param num_floors hom many floors???
2814 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2816 char floor_name[256];
2817 char old_floor_name[256];
2818 char floordivtitle[256];
2819 char floordiv_id[32];
2820 int levels, oldlevels;
2822 int num_drop_targets = 0;
2825 strcpy(floor_name, "");
2826 strcpy(old_floor_name, "");
2830 for (i=0; i<max_folders; ++i) {
2832 levels = num_tokens(fold[i].name, '|');
2833 extract_token(floor_name, fold[i].name, 0,
2834 '|', sizeof floor_name);
2836 if ( (strcasecmp(floor_name, old_floor_name))
2837 && (strlen(old_floor_name) > 0) ) {
2838 /** End inner box */
2840 wprintf("</div>\n"); /** floordiv */
2842 strcpy(old_floor_name, floor_name);
2846 stresc(floordivtitle, floor_name, 0, 0);
2847 sprintf(floordiv_id, "floordiv%d", i);
2848 wprintf("<span class=\"ib_roomlist_floor\" "
2849 "onClick=\"expand_floor('%s')\">"
2850 "%s</span><br>\n", floordiv_id, floordivtitle);
2851 wprintf("<div id=\"%s\" style=\"display:%s\">",
2853 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2860 wprintf("<div id=\"roomdiv%d\">", i);
2862 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2864 /** choose the icon */
2865 if (fold[i].view == VIEW_ADDRESSBOOK) {
2866 icon = "viewcontacts_16x.gif" ;
2868 else if (fold[i].view == VIEW_CALENDAR) {
2869 icon = "calarea_16x.gif" ;
2871 else if (fold[i].view == VIEW_CALBRIEF) {
2872 icon = "calarea_16x.gif" ;
2874 else if (fold[i].view == VIEW_TASKS) {
2875 icon = "taskmanag_16x.gif" ;
2877 else if (fold[i].view == VIEW_NOTES) {
2878 icon = "storenotes_16x.gif" ;
2880 else if (fold[i].view == VIEW_MAILBOX) {
2881 icon = "privatemess_16x.gif" ;
2884 icon = "chatrooms_16x.gif" ;
2887 if (fold[i].selectable) {
2888 wprintf("<a href=\"dotgoto?room=");
2889 urlescputs(fold[i].room);
2891 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2896 if (fold[i].hasnewmsgs) {
2897 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2900 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2902 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2904 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2905 wprintf(" (INBOX)");
2908 if (fold[i].selectable) {
2915 wprintf("</div>\n"); /** roomdiv */
2918 wprintf("</div>\n"); /** floordiv */
2921 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2922 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2924 num_drop_targets = 0;
2926 for (i=0; i<max_folders; ++i) {
2927 levels = num_tokens(fold[i].name, '|');
2929 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2930 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2931 jsescputs(fold[i].room);
2937 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2938 if (strlen(WC->floordiv_expanded) > 1) {
2939 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2943 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2949 * \brief Show the room list.
2950 * (only should get called by
2951 * knrooms() because that's where output_headers() is called from)
2952 * \param viewpref the view preferences???
2955 void list_all_rooms_by_floor(char *viewpref) {
2958 struct folder *fold = NULL;
2960 int max_folders = 0;
2961 int alloc_folders = 0;
2965 int num_floors = 1; /** add an extra one for private folders */
2967 /** If our cached folder list is very old, burn it. */
2968 if (WC->cache_fold != NULL) {
2969 if ((time(NULL) - WC->cache_timestamp) > 300) {
2970 free(WC->cache_fold);
2971 WC->cache_fold = NULL;
2975 /** Can we do the iconbar roomlist from cache? */
2976 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2977 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2981 /** Grab the floor table so we know how to build the list... */
2984 /** Start with the mailboxes */
2987 fold = malloc(sizeof(struct folder));
2988 memset(fold, 0, sizeof(struct folder));
2989 strcpy(fold[0].name, "My folders");
2990 fold[0].is_mailbox = 1;
2992 /** Then add floors */
2994 serv_getln(buf, sizeof buf);
2995 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2996 if (max_folders >= alloc_folders) {
2997 alloc_folders = max_folders + 100;
2998 fold = realloc(fold,
2999 alloc_folders * sizeof(struct folder));
3001 memset(&fold[max_folders], 0, sizeof(struct folder));
3002 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3007 /** refresh the messages index for this room */
3008 // serv_puts("GOTO ");
3009 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3010 /** Now add rooms */
3012 serv_getln(buf, sizeof buf);
3013 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3014 if (max_folders >= alloc_folders) {
3015 alloc_folders = max_folders + 100;
3016 fold = realloc(fold,
3017 alloc_folders * sizeof(struct folder));
3019 memset(&fold[max_folders], 0, sizeof(struct folder));
3020 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3021 ra_flags = extract_int(buf, 5);
3022 flags = extract_int(buf, 1);
3023 fold[max_folders].floor = extract_int(buf, 2);
3024 fold[max_folders].hasnewmsgs =
3025 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3026 if (flags & QR_MAILBOX) {
3027 fold[max_folders].is_mailbox = 1;
3029 fold[max_folders].view = extract_int(buf, 6);
3030 room_to_folder(fold[max_folders].name,
3031 fold[max_folders].room,
3032 fold[max_folders].floor,
3033 fold[max_folders].is_mailbox);
3034 fold[max_folders].selectable = 1;
3038 /** Bubble-sort the folder list */
3039 for (i=0; i<max_folders; ++i) {
3040 for (j=0; j<(max_folders-1)-i; ++j) {
3041 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3042 swap = strcasecmp(fold[j].name, fold[j+1].name);
3045 if ( (fold[j+1].is_mailbox)
3046 && (!fold[j].is_mailbox)) {
3054 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3055 memcpy(&fold[j], &fold[j+1],
3056 sizeof(struct folder));
3057 memcpy(&fold[j+1], &ftmp,
3058 sizeof(struct folder));
3064 if (!strcasecmp(viewpref, "folders")) {
3065 do_folder_view(fold, max_folders, num_floors);
3067 else if (!strcasecmp(viewpref, "hackish_view")) {
3068 for (i=0; i<max_folders; ++i) {
3069 escputs(fold[i].name);
3070 wprintf("<br />\n");
3073 else if (!strcasecmp(viewpref, "iconbar")) {
3074 do_iconbar_view(fold, max_folders, num_floors);
3077 do_rooms_view(fold, max_folders, num_floors);
3080 /* Don't free the folder list ... cache it for future use! */
3081 if (WC->cache_fold != NULL) {
3082 free(WC->cache_fold);
3084 WC->cache_fold = fold;
3085 WC->cache_max_folders = max_folders;
3086 WC->cache_num_floors = num_floors;
3087 WC->cache_timestamp = time(NULL);
3092 * \brief Do either a known rooms list or a folders list, depending on the
3097 char listviewpref[SIZ];
3099 output_headers(1, 1, 2, 0, 0, 0);
3101 /** Determine whether the user is trying to change views */
3102 if (bstr("view") != NULL) {
3103 if (strlen(bstr("view")) > 0) {
3104 set_preference("roomlistview", bstr("view"), 1);
3108 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3110 if ( (strcasecmp(listviewpref, "folders"))
3111 && (strcasecmp(listviewpref, "table")) ) {
3112 strcpy(listviewpref, "rooms");
3116 wprintf("<div id=\"banner\">\n"
3117 "<TABLE class=\"roomops_banner\"><TR><TD>"
3118 "<SPAN CLASS=\"titlebar\">"
3120 if (!strcasecmp(listviewpref, "rooms")) {
3121 wprintf(_("Room list"));
3123 if (!strcasecmp(listviewpref, "folders")) {
3124 wprintf(_("Folder list"));
3126 if (!strcasecmp(listviewpref, "table")) {
3127 wprintf(_("Room list"));
3129 wprintf("</SPAN></TD>\n");
3131 /** offer the ability to switch views */
3132 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
3133 "<SELECT NAME=\"newview\" SIZE=\"1\" "
3134 "OnChange=\"location.href=roomlistomatic.newview.options"
3135 "[selectedIndex].value\">\n");
3137 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3140 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3143 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3144 "View as folder list"
3146 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3149 wprintf("</SELECT><br />");
3151 wprintf("</FORM></TD></TR></TABLE>\n");
3154 "<div id=\"content\">\n");
3156 /** Display the room list in the user's preferred format */
3157 list_all_rooms_by_floor(listviewpref);
3164 * \brief Set the message expire policy for this room and/or floor
3166 void set_room_policy(void) {
3169 if (strlen(bstr("ok_button")) == 0) {
3170 strcpy(WC->ImportantMessage,
3171 _("Cancelled. Changes were not saved."));
3176 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3177 serv_getln(buf, sizeof buf);
3178 strcpy(WC->ImportantMessage, &buf[4]);
3180 if (WC->axlevel >= 6) {
3181 strcat(WC->ImportantMessage, "<br />\n");
3182 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3183 serv_getln(buf, sizeof buf);
3184 strcat(WC->ImportantMessage, &buf[4]);