5 * \defgroup RoomOps Lots of different room-related operations.
6 * \ingroup CitadelCommunitacion
11 char floorlist[128][SIZ]; /**< list of our floor names */
13 char *viewdefs[8]; /**< the different kinds of available views */
16 * \brief initialize the viewdefs with localized strings
18 void initialize_viewdefs(void) {
19 viewdefs[0] = _("Bulletin Board");
20 viewdefs[1] = _("Mail Folder");
21 viewdefs[2] = _("Address Book");
22 viewdefs[3] = _("Calendar");
23 viewdefs[4] = _("Task List");
24 viewdefs[5] = _("Notes List");
25 viewdefs[6] = _("Wiki");
26 viewdefs[7] = _("Calendar List");
30 * \brief Determine which views are allowed as the default for creating a new room.
32 * \param which_view The view ID being queried.
34 int is_view_allowed_as_default(int which_view)
37 case VIEW_BBS: return(1);
38 case VIEW_MAILBOX: return(1);
39 case VIEW_ADDRESSBOOK: return(1);
40 case VIEW_CALENDAR: return(1);
41 case VIEW_TASKS: return(1);
42 case VIEW_NOTES: return(1);
43 case VIEW_WIKI: return(0); /**< because it isn't finished yet */
44 case VIEW_CALBRIEF: return(0);
45 default: return(0); /**< should never get here */
51 * \brief load the list of floors
53 void load_floorlist(void)
58 for (a = 0; a < 128; ++a)
62 serv_getln(buf, sizeof buf);
64 strcpy(floorlist[0], "Main Floor");
67 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
68 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
74 * \brief Free a session's march list
76 * \param wcf Pointer to session being cleared
78 void free_march_list(struct wcsession *wcf)
82 while (wcf->march != NULL) {
83 mptr = wcf->march->next;
93 * \brief remove a room from the march list
95 void remove_march(char *aaa)
97 struct march *mptr, *mptr2;
99 if (WC->march == NULL)
102 if (!strcasecmp(WC->march->march_name, aaa)) {
103 mptr = WC->march->next;
109 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
110 if (!strcasecmp(mptr->march_name, aaa)) {
111 mptr2->next = mptr->next;
124 * \brief display rooms in tree structure???
125 * \param rp the roomlist to build a tree from
127 void room_tree_list(struct roomlisting *rp)
136 room_tree_list(rp->lnext);
138 strcpy(rmname, rp->rlname);
141 wprintf("<a href=\"dotgoto&room=");
145 escputs1(rmname, 1, 1);
146 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
148 else if (f & QR_DIRECTORY)
150 else if (f & QR_NETWORK)
154 wprintf("</A><TT> </TT>\n");
156 room_tree_list(rp->rnext);
162 * \brief Room ordering stuff (compare first by floor, then by order)
163 * \param r1 first roomlist to compare
164 * \param r2 second roomlist co compare
165 * \return are they the same???
167 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
169 if ((r1 == NULL) && (r2 == NULL))
175 if (r1->rlfloor < r2->rlfloor)
177 if (r1->rlfloor > r2->rlfloor)
179 if (r1->rlorder < r2->rlorder)
181 if (r1->rlorder > r2->rlorder)
188 * \brief Common code for all room listings
189 * \param variety what???
191 void listrms(char *variety)
196 struct roomlisting *rl = NULL;
197 struct roomlisting *rp;
198 struct roomlisting *rs;
201 /** Ask the server for a room list */
203 serv_getln(buf, sizeof buf);
208 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
210 rp = malloc(sizeof(struct roomlisting));
211 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
212 rp->rlflags = extract_int(buf, 1);
213 rp->rlfloor = extract_int(buf, 2);
214 rp->rlorder = extract_int(buf, 3);
223 if (rordercmp(rp, rs) < 0) {
224 if (rs->lnext == NULL) {
231 if (rs->rnext == NULL) {
244 * If no rooms were listed, print an nbsp to make the cell
245 * borders show up anyway.
247 if (num_rooms == 0) wprintf(" ");
252 * \brief list all forgotten rooms
254 void zapped_list(void)
256 output_headers(1, 1, 0, 0, 0, 0);
258 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
259 do_template("beginbox");
263 wprintf("<br /><br />\n");
264 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
265 do_template("endbox");
271 * \brief read this room's info file (set v to 1 for verbose mode)
278 serv_getln(buf, sizeof buf);
291 * \brief Display room banner icon.
292 * The server doesn't actually
293 * need the room name, but we supply it in order to
294 * keep the browser from using a cached icon from
297 void embed_room_graphic(void) {
300 serv_puts("OIMG _roompic_");
301 serv_getln(buf, sizeof buf);
303 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
304 urlescputs(WC->wc_roomname);
307 serv_getln(buf, sizeof buf);
309 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
310 wprintf("<img height=48 width=48 src=\""
311 "static/viewcontacts_48x.gif"
315 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
316 wprintf("<img height=48 width=48 src=\""
317 "static/calarea_48x.gif"
321 else if (WC->wc_view == VIEW_TASKS) {
322 wprintf("<img height=48 width=48 src=\""
323 "static/taskmanag_48x.gif"
327 else if (WC->wc_view == VIEW_NOTES) {
328 wprintf("<img height=48 width=48 src=\""
329 "static/storenotes_48x.gif"
333 else if (WC->wc_view == VIEW_MAILBOX) {
334 wprintf("<img height=48 width=48 src=\""
335 "static/privatemess_48x.gif"
340 wprintf("<img height=48 width=48 src=\""
341 "static/chatrooms_48x.gif"
351 * \brief Display the current view and offer an option to change it
353 void embed_view_o_matic(void) {
356 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
357 "<span class=\"room_banner_new_messages\">");
358 wprintf(_("View as:"));
360 "<SELECT NAME=\"newview\" SIZE=\"1\" "
361 "STYLE=\"font-size: 7pt; background: #444455; color: #ddddcc;\" "
362 "OnChange=\"location.href=viewomatic.newview.options"
363 "[selectedIndex].value\">\n");
365 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
367 * Only offer the views that make sense, given the default
368 * view for the room. For example, don't offer a Calendar
369 * view in a non-Calendar room.
373 || (i == WC->wc_default_view) /**< default */
374 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
375 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
376 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
379 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
380 ((i == WC->wc_view) ? "SELECTED" : ""),
382 escputs(viewdefs[i]);
383 wprintf("</OPTION>\n");
386 wprintf("</select></span></form>\n");
391 * \brief view room banner
393 * \param navbar_style
395 void embed_room_banner(char *got, int navbar_style) {
399 * We need to have the information returned by a GOTO server command.
400 * If it isn't supplied, we fake it by issuing our own GOTO.
403 serv_printf("GOTO %s", WC->wc_roomname);
404 serv_getln(buf, sizeof buf);
408 /** The browser needs some information for its own use */
409 wprintf("<script type=\"text/javascript\"> \n"
410 " room_is_trash = %d; \n"
416 * If the user happens to select the "make this my start page" link,
417 * we want it to remember the URL as a "/dotskip" one instead of
418 * a "skip" or "gotonext" or something like that.
420 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
423 /** Check for new mail. */
424 WC->new_mail = extract_int(&got[4], 9);
425 WC->wc_view = extract_int(&got[4], 11);
427 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
428 svprintf("NUMMSGS", WCS_STRING,
429 _("%d new of %d messages"),
430 extract_int(&got[4], 1),
431 extract_int(&got[4], 2)
433 svcallback("ROOMPIC", embed_room_graphic);
434 svcallback("ROOMINFO", readinfo);
435 svcallback("VIEWOMATIC", embed_view_o_matic);
436 svcallback("START", offer_start_page);
438 do_template("roombanner");
439 if (navbar_style != navbar_none) {
441 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
442 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
445 if (navbar_style == navbar_default) wprintf(
447 "<a href=\"ungoto\">"
448 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
449 "<span class=\"navbar_link\">%s</span></A>"
450 "</td>\n", _("Ungoto")
453 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
456 "<a href=\"readnew\">"
457 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
458 "<span class=\"navbar_link\">%s</span></A>"
459 "</td>\n", _("Read new messages")
463 if (navbar_style == navbar_default) {
464 switch(WC->wc_view) {
465 case VIEW_ADDRESSBOOK:
468 "<a href=\"readfwd\">"
469 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
471 "<span class=\"navbar_link\">"
473 "</span></a></td>\n", _("View contacts")
479 "<a href=\"readfwd?calview=day\">"
480 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
482 "<span class=\"navbar_link\">"
484 "</span></a></td>\n", _("Day view")
488 "<a href=\"readfwd?calview=month\">"
489 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
491 "<span class=\"navbar_link\">"
493 "</span></a></td>\n", _("Month view")
499 "<a href=\"readfwd?calview=month\">"
500 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
502 "<span class=\"navbar_link\">"
504 "</span></a></td>\n", _("Calendar list")
510 "<a href=\"readfwd\">"
511 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
513 "<span class=\"navbar_link\">"
515 "</span></a></td>\n", _("View tasks")
521 "<a href=\"readfwd\">"
522 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
524 "<span class=\"navbar_link\">"
526 "</span></a></td>\n", _("View notes")
532 "<a href=\"readfwd\">"
533 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
535 "<span class=\"navbar_link\">"
537 "</span></a></td>\n", _("View message list")
543 "<a href=\"readfwd\">"
544 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
546 "<span class=\"navbar_link\">"
548 "</span></a></td>\n", _("Wiki home")
554 "<a href=\"readfwd\">"
555 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
557 "<span class=\"navbar_link\">"
559 "</span></a></td>\n", _("Read all messages")
565 if (navbar_style == navbar_default) {
566 switch(WC->wc_view) {
567 case VIEW_ADDRESSBOOK:
569 "<td><a href=\"display_enter\">"
570 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
571 "border=\"0\"><span class=\"navbar_link\">"
573 "</span></a></td>\n", _("Add new contact")
578 wprintf("<td><a href=\"display_enter");
579 if (strlen(bstr("year")) > 0) wprintf("?year=%s", bstr("year"));
580 if (strlen(bstr("month")) > 0) wprintf("?month=%s", bstr("month"));
581 if (strlen(bstr("day")) > 0) wprintf("?day=%s", bstr("day"));
583 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
584 "border=\"0\"><span class=\"navbar_link\">"
586 "</span></a></td>\n", _("Add new event")
591 "<td><a href=\"display_enter\">"
592 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
593 "border=\"0\"><span class=\"navbar_link\">"
595 "</span></a></td>\n", _("Add new task")
600 "<td><a href=\"javascript:add_new_note();\">"
601 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
602 "border=\"0\"><span class=\"navbar_link\">"
604 "</span></a></td>\n", _("Add new note")
608 safestrncpy(buf, bstr("page"), sizeof buf);
611 "<td><a href=\"display_enter?wikipage=%s\">"
612 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
613 "border=\"0\"><span class=\"navbar_link\">"
615 "</span></a></td>\n", buf, _("Edit this page")
620 "<td><a href=\"display_enter\">"
621 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
622 "border=\"0\"><span class=\"navbar_link\">"
624 "</span></a></td>\n", _("Enter a message")
630 if (navbar_style == navbar_default) wprintf(
634 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
635 "<span class=\"navbar_link\">%s</span></a>"
637 _("Leave all messages marked as unread, go to next room with unread messages"),
641 if (navbar_style == navbar_default) wprintf(
643 "<a href=\"gotonext\" "
645 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
646 "<span class=\"navbar_link\">%s</span></a>"
648 _("Mark all messages as read, go to next room with unread messages"),
652 wprintf("</tr></table></div>\n");
662 * \brief back end routine to take the session to a new room
663 * \param gname room to go to
666 int gotoroom(char *gname)
669 static long ls = (-1L);
672 /** store ungoto information */
673 strcpy(WC->ugname, WC->wc_roomname);
676 /** move to the new room */
677 serv_printf("GOTO %s", gname);
678 serv_getln(buf, sizeof buf);
682 serv_puts("GOTO _BASEROOM_");
683 serv_getln(buf, sizeof buf);
690 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
691 WC->room_flags = extract_int(&buf[4], 4);
692 /* highest_msg_read = extract_int(&buf[4],6);
693 maxmsgnum = extract_int(&buf[4],5);
695 WC->is_mailbox = extract_int(&buf[4],7);
696 ls = extract_long(&buf[4], 6);
697 WC->wc_floor = extract_int(&buf[4], 10);
698 WC->wc_view = extract_int(&buf[4], 11);
699 WC->wc_default_view = extract_int(&buf[4], 12);
700 WC->wc_is_trash = extract_int(&buf[4], 13);
703 WC->is_room_aide = WC->is_aide;
705 WC->is_room_aide = (char) extract_int(&buf[4], 8);
707 remove_march(WC->wc_roomname);
708 if (!strcasecmp(gname, "_BASEROOM_"))
716 * \brief Locate the room on the march list which we most want to go to.
718 * is measured given a "weight" of preference based on various factors.
719 * \param desired_floor the room number on the citadel server
720 * \return the roomname
722 char *pop_march(int desired_floor)
724 static char TheRoom[128];
726 int TheOrder = 32767;
729 struct march *mptr = NULL;
731 strcpy(TheRoom, "_BASEROOM_");
732 if (WC->march == NULL)
735 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
737 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
738 weight = weight + 10000;
739 if (mptr->march_floor == desired_floor)
740 weight = weight + 5000;
742 weight = weight + ((128 - (mptr->march_floor)) * 128);
743 weight = weight + (128 - (mptr->march_order));
745 if (weight > TheWeight) {
747 strcpy(TheRoom, mptr->march_name);
748 TheFloor = mptr->march_floor;
749 TheOrder = mptr->march_order;
758 *\brief Goto next room having unread messages.
759 * We want to skip over rooms that the user has already been to, and take the
760 * user back to the lobby when done. The room we end up in is placed in
761 * newroom - which is set to 0 (the lobby) initially.
762 * We start the search in the current room rather than the beginning to prevent
763 * two or more concurrent users from dragging each other back to the same room.
768 struct march *mptr, *mptr2;
772 * First check to see if the march-mode list is already allocated.
773 * If it is, pop the first room off the list and go there.
776 if (WC->march == NULL) {
778 serv_getln(buf, sizeof buf);
780 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
781 mptr = (struct march *) malloc(sizeof(struct march));
783 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
784 mptr->march_floor = extract_int(buf, 2);
785 mptr->march_order = extract_int(buf, 3);
786 if (WC->march == NULL) {
790 while (mptr2->next != NULL)
796 * add _BASEROOM_ to the end of the march list, so the user will end up
797 * in the system base room (usually the Lobby>) at the end of the loop
799 mptr = (struct march *) malloc(sizeof(struct march));
801 strcpy(mptr->march_name, "_BASEROOM_");
802 if (WC->march == NULL) {
806 while (mptr2->next != NULL)
811 * ...and remove the room we're currently in, so a <G>oto doesn't make us
812 * walk around in circles
814 remove_march(WC->wc_roomname);
816 if (WC->march != NULL) {
817 strcpy(next_room, pop_march(-1));
819 strcpy(next_room, "_BASEROOM_");
823 smart_goto(next_room);
828 * \brief goto next room
829 * \param next_room next room to go to
831 void smart_goto(char *next_room) {
839 * \brief mark all messages in current room as having been read
841 void slrp_highest(void)
845 serv_puts("SLRP HIGHEST");
846 serv_getln(buf, sizeof buf);
851 * \brief un-goto the previous room
857 if (!strcmp(WC->ugname, "")) {
858 smart_goto(WC->wc_roomname);
861 serv_printf("GOTO %s", WC->ugname);
862 serv_getln(buf, sizeof buf);
864 smart_goto(WC->wc_roomname);
867 if (WC->uglsn >= 0L) {
868 serv_printf("SLRP %ld", WC->uglsn);
869 serv_getln(buf, sizeof buf);
871 strcpy(buf, WC->ugname);
872 strcpy(WC->ugname, "");
881 * \brief Set/clear/read the "self-service list subscribe" flag for a room
883 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
884 * \return return the new value.
887 int self_service(int newval) {
888 int current_value = 0;
894 int flags, floor, order, view, flags2;
897 serv_getln(buf, sizeof buf);
898 if (buf[0] != '2') return(0);
900 extract_token(name, &buf[4], 0, '|', sizeof name);
901 extract_token(password, &buf[4], 1, '|', sizeof password);
902 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
903 flags = extract_int(&buf[4], 3);
904 floor = extract_int(&buf[4], 4);
905 order = extract_int(&buf[4], 5);
906 view = extract_int(&buf[4], 6);
907 flags2 = extract_int(&buf[4], 7);
909 if (flags2 & QR2_SELFLIST) {
917 flags2 = flags2 | QR2_SELFLIST;
919 else if (newval == 0) {
920 flags2 = flags2 & ~QR2_SELFLIST;
923 return(current_value);
926 if (newval != current_value) {
927 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
928 name, password, dirname, flags,
929 floor, order, view, flags2);
930 serv_getln(buf, sizeof buf);
943 * \brief display the form for editing a room
945 void display_editroom(void)
950 char remote_room[SIZ];
953 char er_password[10];
955 char er_roomaide[26];
961 char *not_shared_with;
968 if (strlen(tab) == 0) tab = "admin";
972 serv_getln(buf, sizeof buf);
975 strcpy(WC->ImportantMessage, &buf[4]);
979 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
980 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
981 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
982 er_flags = extract_int(&buf[4], 3);
983 er_floor = extract_int(&buf[4], 4);
985 output_headers(1, 1, 1, 0, 0, 0);
987 /** print the tabbed dialog */
989 "<div class=\"fix_scrollbar_bug\">"
990 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
992 "<TD> </TD>\n");
994 if (!strcmp(tab, "admin")) {
995 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
998 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
1000 wprintf(_("Administration"));
1001 if (!strcmp(tab, "admin")) {
1002 wprintf("</SPAN></TD>\n");
1005 wprintf("</A></TD>\n");
1008 wprintf("<TD> </TD>\n");
1010 if (!strcmp(tab, "config")) {
1011 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1014 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
1016 wprintf(_("Configuration"));
1017 if (!strcmp(tab, "config")) {
1018 wprintf("</SPAN></TD>\n");
1021 wprintf("</A></TD>\n");
1024 wprintf("<TD> </TD>\n");
1026 if (!strcmp(tab, "expire")) {
1027 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1030 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
1032 wprintf(_("Message expire policy"));
1033 if (!strcmp(tab, "expire")) {
1034 wprintf("</SPAN></TD>\n");
1037 wprintf("</A></TD>\n");
1040 wprintf("<TD> </TD>\n");
1042 if (!strcmp(tab, "access")) {
1043 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1046 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
1048 wprintf(_("Access controls"));
1049 if (!strcmp(tab, "access")) {
1050 wprintf("</SPAN></TD>\n");
1053 wprintf("</A></TD>\n");
1056 wprintf("<TD> </TD>\n");
1058 if (!strcmp(tab, "sharing")) {
1059 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1062 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
1064 wprintf(_("Sharing"));
1065 if (!strcmp(tab, "sharing")) {
1066 wprintf("</SPAN></TD>\n");
1069 wprintf("</A></TD>\n");
1072 wprintf("<TD> </TD>\n");
1074 if (!strcmp(tab, "listserv")) {
1075 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1078 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
1080 wprintf(_("Mailing list service"));
1081 if (!strcmp(tab, "listserv")) {
1082 wprintf("</SPAN></TD>\n");
1085 wprintf("</A></TD>\n");
1088 wprintf("<TD> </TD>\n");
1090 wprintf("</TR></TABLE></div>\n");
1091 /** end tabbed dialog */
1093 /** begin content of whatever tab is open now */
1094 wprintf("<div class=\"fix_scrollbar_bug\">"
1095 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
1098 if (!strcmp(tab, "admin")) {
1100 "<LI><a href=\"delete_room\" "
1101 "onClick=\"return confirm('");
1102 wprintf(_("Are you sure you want to delete this room?"));
1103 wprintf("');\">\n");
1104 wprintf(_("Delete this room"));
1106 "<LI><a href=\"display_editroompic\">\n");
1107 wprintf(_("Set or change the icon for this room's banner"));
1109 "<LI><a href=\"display_editinfo\">\n");
1110 wprintf(_("Edit this room's Info file"));
1115 if (!strcmp(tab, "config")) {
1116 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1118 wprintf("<UL><LI>");
1119 wprintf(_("Name of room: "));
1120 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1126 wprintf(_("Resides on floor: "));
1127 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1128 for (i = 0; i < 128; ++i)
1129 if (strlen(floorlist[i]) > 0) {
1130 wprintf("<OPTION ");
1132 wprintf("SELECTED ");
1133 wprintf("VALUE=\"%d\">", i);
1134 escputs(floorlist[i]);
1135 wprintf("</OPTION>\n");
1137 wprintf("</SELECT>\n");
1140 wprintf(_("Type of room:"));
1143 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1144 if ((er_flags & QR_PRIVATE) == 0)
1145 wprintf("CHECKED ");
1147 wprintf(_("Public room"));
1150 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1151 if ((er_flags & QR_PRIVATE) &&
1152 (er_flags & QR_GUESSNAME))
1153 wprintf("CHECKED ");
1155 wprintf(_("Private - guess name"));
1157 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1158 if ((er_flags & QR_PRIVATE) &&
1159 (er_flags & QR_PASSWORDED))
1160 wprintf("CHECKED ");
1162 wprintf(_("Private - require password:"));
1163 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1166 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1167 if ((er_flags & QR_PRIVATE)
1168 && ((er_flags & QR_GUESSNAME) == 0)
1169 && ((er_flags & QR_PASSWORDED) == 0))
1170 wprintf("CHECKED ");
1172 wprintf(_("Private - invitation only"));
1174 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1176 wprintf(_("If private, cause current users to forget room"));
1178 wprintf("\n</UL>\n");
1180 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1181 if (er_flags & QR_PREFONLY)
1182 wprintf("CHECKED ");
1184 wprintf(_("Preferred users only"));
1186 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1187 if (er_flags & QR_READONLY)
1188 wprintf("CHECKED ");
1190 wprintf(_("Read-only room"));
1192 /** directory stuff */
1193 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1194 if (er_flags & QR_DIRECTORY)
1195 wprintf("CHECKED ");
1197 wprintf(_("File directory room"));
1199 wprintf("\n<UL><LI>");
1200 wprintf(_("Directory name: "));
1201 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1204 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1205 if (er_flags & QR_UPLOAD)
1206 wprintf("CHECKED ");
1208 wprintf(_("Uploading allowed"));
1210 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1211 if (er_flags & QR_DOWNLOAD)
1212 wprintf("CHECKED ");
1214 wprintf(_("Downloading allowed"));
1216 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1217 if (er_flags & QR_VISDIR)
1218 wprintf("CHECKED ");
1220 wprintf(_("Visible directory"));
1223 /** end of directory stuff */
1225 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1226 if (er_flags & QR_NETWORK)
1227 wprintf("CHECKED ");
1229 wprintf(_("Network shared room"));
1231 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1232 if (er_flags & QR_PERMANENT)
1233 wprintf("CHECKED ");
1235 wprintf(_("Permanent (does not auto-purge)"));
1237 /** start of anon options */
1240 wprintf(_("Anonymous messages"));
1243 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1244 if (((er_flags & QR_ANONONLY) == 0)
1245 && ((er_flags & QR_ANONOPT) == 0))
1246 wprintf("CHECKED ");
1248 wprintf(_("No anonymous messages"));
1250 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1251 if (er_flags & QR_ANONONLY)
1252 wprintf("CHECKED ");
1254 wprintf(_("All messages are anonymous"));
1256 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1257 if (er_flags & QR_ANONOPT)
1258 wprintf("CHECKED ");
1260 wprintf(_("Prompt user when entering messages"));
1263 /* end of anon options */
1266 wprintf(_("Room aide: "));
1268 serv_getln(buf, sizeof buf);
1269 if (buf[0] != '2') {
1270 wprintf("<em>%s</em>\n", &buf[4]);
1272 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1273 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1276 wprintf("</UL><CENTER>\n");
1277 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1278 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1280 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1288 /** Sharing the room with other Citadel nodes... */
1289 if (!strcmp(tab, "sharing")) {
1291 shared_with = strdup("");
1292 not_shared_with = strdup("");
1294 /** Learn the current configuration */
1295 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1296 serv_getln(buf, sizeof buf);
1297 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1298 extract_token(node, buf, 0, '|', sizeof node);
1299 not_shared_with = realloc(not_shared_with,
1300 strlen(not_shared_with) + 32);
1301 strcat(not_shared_with, node);
1302 strcat(not_shared_with, "\n");
1306 serv_getln(buf, sizeof buf);
1307 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1308 extract_token(cmd, buf, 0, '|', sizeof cmd);
1309 extract_token(node, buf, 1, '|', sizeof node);
1310 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1311 if (!strcasecmp(cmd, "ignet_push_share")) {
1312 shared_with = realloc(shared_with,
1313 strlen(shared_with) + 32);
1314 strcat(shared_with, node);
1315 if (strlen(remote_room) > 0) {
1316 strcat(shared_with, "|");
1317 strcat(shared_with, remote_room);
1319 strcat(shared_with, "\n");
1323 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1324 extract_token(buf, shared_with, i, '\n', sizeof buf);
1325 extract_token(node, buf, 0, '|', sizeof node);
1326 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1327 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1328 if (!strcasecmp(node, cmd)) {
1329 remove_token(not_shared_with, j, '\n');
1334 /** Display the stuff */
1335 wprintf("<CENTER><br />"
1336 "<TABLE border=1 cellpadding=5><TR>"
1338 wprintf(_("Shared with"));
1339 wprintf("</I></B></TD>"
1341 wprintf(_("Not shared with"));
1342 wprintf("</I></B></TD></TR>\n"
1343 "<TR><TD VALIGN=TOP>\n");
1345 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1346 wprintf(_("Remote node name"));
1347 wprintf("</TD><TD>");
1348 wprintf(_("Remote room name"));
1349 wprintf("</TD><TD>");
1350 wprintf(_("Actions"));
1351 wprintf("</TD></TR>\n");
1353 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1354 extract_token(buf, shared_with, i, '\n', sizeof buf);
1355 extract_token(node, buf, 0, '|', sizeof node);
1356 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1357 if (strlen(node) > 0) {
1358 wprintf("<FORM METHOD=\"POST\" "
1359 "action=\"netedit\">"
1360 "<TR><TD>%s</TD>\n", node);
1363 if (strlen(remote_room) > 0) {
1364 escputs(remote_room);
1370 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1371 "VALUE=\"ignet_push_share|");
1373 if (strlen(remote_room) > 0) {
1375 urlescputs(remote_room);
1378 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1379 "VALUE=\"sharing\">\n");
1380 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1381 "VALUE=\"remove\">\n");
1382 wprintf("<INPUT TYPE=\"submit\" "
1383 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1384 wprintf("</TD></TR></FORM>\n");
1388 wprintf("</TABLE>\n");
1389 wprintf("</TD><TD VALIGN=TOP>\n");
1390 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1391 wprintf(_("Remote node name"));
1392 wprintf("</TD><TD>");
1393 wprintf(_("Remote room name"));
1394 wprintf("</TD><TD>");
1395 wprintf(_("Actions"));
1396 wprintf("</TD></TR>\n");
1398 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1399 extract_token(node, not_shared_with, i, '\n', sizeof node);
1400 if (strlen(node) > 0) {
1401 wprintf("<FORM METHOD=\"POST\" "
1402 "action=\"netedit\">"
1406 "<INPUT TYPE=\"INPUT\" "
1410 wprintf("<INPUT TYPE=\"hidden\" "
1412 "VALUE=\"ignet_push_share|");
1415 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1416 "VALUE=\"sharing\">\n");
1417 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1418 "VALUE=\"add\">\n");
1419 wprintf("<INPUT TYPE=\"submit\" "
1420 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1421 wprintf("</TD></TR></FORM>\n");
1425 wprintf("</TABLE>\n");
1426 wprintf("</TD></TR>"
1427 "</TABLE></CENTER><br />\n"
1428 "<I><B>%s</B><UL><LI>", _("Notes:"));
1429 wprintf(_("When sharing a room, "
1430 "it must be shared from both ends. Adding a node to "
1431 "the 'shared' list sends messages out, but in order to"
1432 " receive messages, the other nodes must be configured"
1433 " to send messages out to your system as well. "
1434 "<LI>If the remote room name is blank, it is assumed "
1435 "that the room name is identical on the remote node."
1436 "<LI>If the remote room name is different, the remote "
1437 "node must also configure the name of the room here."
1443 /** Mailing list management */
1444 if (!strcmp(tab, "listserv")) {
1446 wprintf("<br /><center>"
1447 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1448 "<TR><TD VALIGN=TOP>");
1450 wprintf(_("<i>The contents of this room are being "
1451 "mailed <b>as individual messages</b> "
1452 "to the following list recipients:"
1453 "</i><br /><br />\n"));
1456 serv_getln(buf, sizeof buf);
1457 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1458 extract_token(cmd, buf, 0, '|', sizeof cmd);
1459 if (!strcasecmp(cmd, "listrecp")) {
1460 extract_token(recp, buf, 1, '|', sizeof recp);
1463 wprintf(" <a href=\"netedit&cmd=remove&line="
1466 wprintf("&tab=listserv\">");
1467 wprintf(_("(remove)"));
1468 wprintf("</A><br />");
1471 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1472 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1473 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1474 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1475 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1476 wprintf("</FORM>\n");
1478 wprintf("</TD><TD VALIGN=TOP>\n");
1480 wprintf(_("<i>The contents of this room are being "
1481 "mailed <b>in digest form</b> "
1482 "to the following list recipients:"
1483 "</i><br /><br />\n"));
1486 serv_getln(buf, sizeof buf);
1487 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1488 extract_token(cmd, buf, 0, '|', sizeof cmd);
1489 if (!strcasecmp(cmd, "digestrecp")) {
1490 extract_token(recp, buf, 1, '|', sizeof recp);
1493 wprintf(" <a href=\"netedit&cmd=remove&line="
1496 wprintf("&tab=listserv\">");
1497 wprintf(_("(remove)"));
1498 wprintf("</A><br />");
1501 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1502 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1503 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1504 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1505 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1506 wprintf("</FORM>\n");
1508 wprintf("</TD></TR></TABLE><hr />\n");
1510 if (self_service(999) == 1) {
1511 wprintf(_("This room is configured to allow "
1512 "self-service subscribe/unsubscribe requests."));
1513 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1514 wprintf(_("Click to disable."));
1515 wprintf("</A><br />\n");
1516 wprintf(_("The URL for subscribe/unsubscribe is: "));
1517 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1518 (is_https ? "https" : "http"),
1522 wprintf(_("This room is <i>not</i> configured to allow "
1523 "self-service subscribe/unsubscribe requests."));
1524 wprintf(" <a href=\"toggle_self_service?newval=1&"
1526 wprintf(_("Click to enable."));
1527 wprintf("</A><br />\n");
1531 wprintf("</CENTER>\n");
1535 /** Mailing list management */
1536 if (!strcmp(tab, "expire")) {
1538 serv_puts("GPEX room");
1539 serv_getln(buf, sizeof buf);
1540 if (buf[0] == '2') {
1541 roompolicy = extract_int(&buf[4], 0);
1542 roomvalue = extract_int(&buf[4], 1);
1545 serv_puts("GPEX floor");
1546 serv_getln(buf, sizeof buf);
1547 if (buf[0] == '2') {
1548 floorpolicy = extract_int(&buf[4], 0);
1549 floorvalue = extract_int(&buf[4], 1);
1552 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1553 wprintf("<TABLE border=0 cellspacing=5>\n");
1554 wprintf("<TR><TD>");
1555 wprintf(_("Message expire policy for this room"));
1557 escputs(WC->wc_roomname);
1558 wprintf(")</TD><TD>");
1559 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1560 ((roompolicy == 0) ? "CHECKED" : "") );
1561 wprintf(_("Use the default policy for this floor"));
1562 wprintf("<br />\n");
1563 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1564 ((roompolicy == 1) ? "CHECKED" : "") );
1565 wprintf(_("Never automatically expire messages"));
1566 wprintf("<br />\n");
1567 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1568 ((roompolicy == 2) ? "CHECKED" : "") );
1569 wprintf(_("Expire by message count"));
1570 wprintf("<br />\n");
1571 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1572 ((roompolicy == 3) ? "CHECKED" : "") );
1573 wprintf(_("Expire by message age"));
1575 wprintf(_("Number of messages or days: "));
1576 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1577 wprintf("</TD></TR>\n");
1579 if (WC->axlevel >= 6) {
1580 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1581 wprintf("<TR><TD>");
1582 wprintf(_("Message expire policy for this floor"));
1584 escputs(floorlist[WC->wc_floor]);
1585 wprintf(")</TD><TD>");
1586 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1587 ((floorpolicy == 0) ? "CHECKED" : "") );
1588 wprintf(_("Use the system default"));
1589 wprintf("<br />\n");
1590 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1591 ((floorpolicy == 1) ? "CHECKED" : "") );
1592 wprintf(_("Never automatically expire messages"));
1593 wprintf("<br />\n");
1594 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1595 ((floorpolicy == 2) ? "CHECKED" : "") );
1596 wprintf(_("Expire by message count"));
1597 wprintf("<br />\n");
1598 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1599 ((floorpolicy == 3) ? "CHECKED" : "") );
1600 wprintf(_("Expire by message age"));
1602 wprintf(_("Number of messages or days: "));
1603 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1607 wprintf("<CENTER>\n");
1608 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1609 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1611 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1612 wprintf("</CENTER></TD><TR>\n");
1614 wprintf("</TABLE>\n"
1615 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1621 /** Mailing list management */
1622 if (!strcmp(tab, "access")) {
1626 /** end content of whatever tab is open now */
1627 wprintf("</TD></TR></TABLE></div>\n");
1634 * \brief Toggle self-service list subscription
1636 void toggle_self_service(void) {
1639 newval = atoi(bstr("newval"));
1640 self_service(newval);
1647 * \brief save new parameters for a room
1653 char er_password[10];
1654 char er_dirname[15];
1655 char er_roomaide[26];
1661 if (strlen(bstr("ok_button")) == 0) {
1662 strcpy(WC->ImportantMessage,
1663 _("Cancelled. Changes were not saved."));
1668 serv_getln(buf, sizeof buf);
1670 if (buf[0] != '2') {
1671 strcpy(WC->ImportantMessage, &buf[4]);
1675 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1676 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1677 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1678 er_flags = extract_int(&buf[4], 3);
1680 strcpy(er_roomaide, bstr("er_roomaide"));
1681 if (strlen(er_roomaide) == 0) {
1683 serv_getln(buf, sizeof buf);
1684 if (buf[0] != '2') {
1685 strcpy(er_roomaide, "");
1687 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1690 strcpy(buf, bstr("er_name"));
1692 if (strlen(buf) > 0) {
1693 strcpy(er_name, buf);
1696 strcpy(buf, bstr("er_password"));
1698 if (strlen(buf) > 0)
1699 strcpy(er_password, buf);
1701 strcpy(buf, bstr("er_dirname"));
1703 if (strlen(buf) > 0)
1704 strcpy(er_dirname, buf);
1706 strcpy(buf, bstr("type"));
1707 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1709 if (!strcmp(buf, "invonly")) {
1710 er_flags |= (QR_PRIVATE);
1712 if (!strcmp(buf, "hidden")) {
1713 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1715 if (!strcmp(buf, "passworded")) {
1716 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1718 if (!strcmp(bstr("prefonly"), "yes")) {
1719 er_flags |= QR_PREFONLY;
1721 er_flags &= ~QR_PREFONLY;
1724 if (!strcmp(bstr("readonly"), "yes")) {
1725 er_flags |= QR_READONLY;
1727 er_flags &= ~QR_READONLY;
1730 if (!strcmp(bstr("permanent"), "yes")) {
1731 er_flags |= QR_PERMANENT;
1733 er_flags &= ~QR_PERMANENT;
1736 if (!strcmp(bstr("network"), "yes")) {
1737 er_flags |= QR_NETWORK;
1739 er_flags &= ~QR_NETWORK;
1742 if (!strcmp(bstr("directory"), "yes")) {
1743 er_flags |= QR_DIRECTORY;
1745 er_flags &= ~QR_DIRECTORY;
1748 if (!strcmp(bstr("ulallowed"), "yes")) {
1749 er_flags |= QR_UPLOAD;
1751 er_flags &= ~QR_UPLOAD;
1754 if (!strcmp(bstr("dlallowed"), "yes")) {
1755 er_flags |= QR_DOWNLOAD;
1757 er_flags &= ~QR_DOWNLOAD;
1760 if (!strcmp(bstr("visdir"), "yes")) {
1761 er_flags |= QR_VISDIR;
1763 er_flags &= ~QR_VISDIR;
1766 strcpy(buf, bstr("anon"));
1768 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1769 if (!strcmp(buf, "anononly"))
1770 er_flags |= QR_ANONONLY;
1771 if (!strcmp(buf, "anon2"))
1772 er_flags |= QR_ANONOPT;
1775 if (!strcmp(bstr("bump"), "yes"))
1778 er_floor = atoi(bstr("er_floor"));
1780 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1781 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1783 serv_getln(buf, sizeof buf);
1784 if (buf[0] != '2') {
1785 strcpy(WC->ImportantMessage, &buf[4]);
1791 if (strlen(er_roomaide) > 0) {
1792 sprintf(buf, "SETA %s", er_roomaide);
1794 serv_getln(buf, sizeof buf);
1795 if (buf[0] != '2') {
1796 strcpy(WC->ImportantMessage, &buf[4]);
1797 display_main_menu();
1802 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1809 * \brief Display form for Invite, Kick, and show Who Knows a room
1811 void do_invt_kick(void) {
1812 char buf[SIZ], room[SIZ], username[SIZ];
1815 serv_getln(buf, sizeof buf);
1817 if (buf[0] != '2') {
1821 extract_token(room, &buf[4], 0, '|', sizeof room);
1823 strcpy(username, bstr("username"));
1825 if (strlen(bstr("kick_button")) > 0) {
1826 sprintf(buf, "KICK %s", username);
1828 serv_getln(buf, sizeof buf);
1830 if (buf[0] != '2') {
1831 strcpy(WC->ImportantMessage, &buf[4]);
1833 sprintf(WC->ImportantMessage,
1834 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1839 if (strlen(bstr("invite_button")) > 0) {
1840 sprintf(buf, "INVT %s", username);
1842 serv_getln(buf, sizeof buf);
1844 if (buf[0] != '2') {
1845 strcpy(WC->ImportantMessage, &buf[4]);
1847 sprintf(WC->ImportantMessage,
1848 _("<B><I>User %s invited to room %s.</I></B>\n"),
1859 * \brief Display form for Invite, Kick, and show Who Knows a room
1861 void display_whok(void)
1863 char buf[SIZ], room[SIZ], username[SIZ];
1866 serv_getln(buf, sizeof buf);
1868 if (buf[0] != '2') {
1872 extract_token(room, &buf[4], 0, '|', sizeof room);
1875 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1876 wprintf(_("The users listed below have access to this room. "
1877 "To remove a user from the access list, select the user "
1878 "name from the list and click 'Kick'."));
1879 wprintf("<br /><br />");
1881 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1882 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1883 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1885 serv_getln(buf, sizeof buf);
1886 if (buf[0] == '1') {
1887 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1888 extract_token(username, buf, 0, '|', sizeof username);
1889 wprintf("<OPTION>");
1894 wprintf("</SELECT><br />\n");
1896 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1897 wprintf("</FORM></CENTER>\n");
1899 wprintf("</TD><TD>");
1900 wprintf(_("To grant another user access to this room, enter the "
1901 "user name in the box below and click 'Invite'."));
1902 wprintf("<br /><br />");
1904 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1905 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1906 wprintf(_("Invite:"));
1908 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1909 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1910 "<input type=\"submit\" value=\"%s\">"
1911 "</FORM></CENTER>\n", _("Invite"));
1913 wprintf("</TD></TR></TABLE>\n");
1920 * \brief display the form for entering a new room
1922 void display_entroom(void)
1927 serv_puts("CRE8 0");
1928 serv_getln(buf, sizeof buf);
1930 if (buf[0] != '2') {
1931 strcpy(WC->ImportantMessage, &buf[4]);
1932 display_main_menu();
1936 output_headers(1, 1, 2, 0, 0, 0);
1937 wprintf("<div id=\"banner\">\n"
1938 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1939 "<SPAN CLASS=\"titlebar\">");
1940 wprintf(_("Create a new room"));
1942 "</TD></TR></TABLE>\n"
1943 "</div>\n<div id=\"content\">\n"
1946 wprintf("<div class=\"fix_scrollbar_bug\">"
1947 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1949 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1951 wprintf("<UL><LI>");
1952 wprintf(_("Name of room: "));
1953 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1956 wprintf(_("Resides on floor: "));
1958 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1959 for (i = 0; i < 128; ++i)
1960 if (strlen(floorlist[i]) > 0) {
1961 wprintf("<OPTION ");
1962 wprintf("VALUE=\"%d\">", i);
1963 escputs(floorlist[i]);
1964 wprintf("</OPTION>\n");
1966 wprintf("</SELECT>\n");
1969 * Our clever little snippet of JavaScript automatically selects
1970 * a public room if the view is set to Bulletin Board or wiki, and
1971 * it selects a mailbox room otherwise. The user can override this,
1972 * of course. We also disable the floor selector for mailboxes.
1975 wprintf(_("Default view for room: "));
1976 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1977 " if ( (this.form.er_view.value == 0) "
1978 " || (this.form.er_view.value == 6) ) { "
1979 " this.form.type[0].checked=true; "
1980 " this.form.er_floor.disabled = false; "
1983 " this.form.type[4].checked=true; "
1984 " this.form.er_floor.disabled = true; "
1987 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1988 if (is_view_allowed_as_default(i)) {
1989 wprintf("<OPTION %s VALUE=\"%d\">",
1990 ((i == 0) ? "SELECTED" : ""), i );
1991 escputs(viewdefs[i]);
1992 wprintf("</OPTION>\n");
1995 wprintf("</SELECT>\n");
1998 wprintf(_("Type of room:"));
2001 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2002 wprintf("CHECKED OnChange=\""
2003 " if (this.form.type[0].checked == true) { "
2004 " this.form.er_floor.disabled = false; "
2007 wprintf(_("Public (automatically appears to everyone)"));
2009 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2010 " if (this.form.type[1].checked == true) { "
2011 " this.form.er_floor.disabled = false; "
2014 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2016 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2017 " if (this.form.type[2].checked == true) { "
2018 " this.form.er_floor.disabled = false; "
2021 wprintf(_("Private - require password: "));
2022 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2024 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2025 " if (this.form.type[3].checked == true) { "
2026 " this.form.er_floor.disabled = false; "
2029 wprintf(_("Private - invitation only"));
2031 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2033 " if (this.form.type[4].checked == true) { "
2034 " this.form.er_floor.disabled = true; "
2037 wprintf(_("Personal (mailbox for you only)"));
2039 wprintf("\n</UL>\n");
2041 wprintf("<CENTER>\n");
2042 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2044 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2045 wprintf("</CENTER>\n");
2046 wprintf("</FORM>\n<hr />");
2047 serv_printf("MESG roomaccess");
2048 serv_getln(buf, sizeof buf);
2049 if (buf[0] == '1') {
2052 wprintf("</td></tr></table></div>\n");
2060 * \brief support function for entroom() -- sets the default view
2062 void er_set_default_view(int newview) {
2075 serv_getln(buf, sizeof buf);
2076 if (buf[0] != '2') return;
2078 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2079 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2080 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2081 rm_bits1 = extract_int(&buf[4], 3);
2082 rm_floor = extract_int(&buf[4], 4);
2083 rm_listorder = extract_int(&buf[4], 5);
2084 rm_bits2 = extract_int(&buf[4], 7);
2086 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2087 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2088 rm_listorder, newview, rm_bits2
2090 serv_getln(buf, sizeof buf);
2096 * \brief enter a new room
2103 char er_password[SIZ];
2108 if (strlen(bstr("ok_button")) == 0) {
2109 strcpy(WC->ImportantMessage,
2110 _("Cancelled. No new room was created."));
2111 display_main_menu();
2114 strcpy(er_name, bstr("er_name"));
2115 strcpy(er_type, bstr("type"));
2116 strcpy(er_password, bstr("er_password"));
2117 er_floor = atoi(bstr("er_floor"));
2118 er_view = atoi(bstr("er_view"));
2121 if (!strcmp(er_type, "hidden"))
2123 if (!strcmp(er_type, "passworded"))
2125 if (!strcmp(er_type, "invonly"))
2127 if (!strcmp(er_type, "personal"))
2130 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2131 er_name, er_num_type, er_password, er_floor, 0, er_view);
2133 serv_getln(buf, sizeof buf);
2134 if (buf[0] != '2') {
2135 strcpy(WC->ImportantMessage, &buf[4]);
2136 display_main_menu();
2140 do_change_view(er_view); /* Now go there */
2145 * \brief display the screen to enter a private room
2147 void display_private(char *rname, int req_pass)
2149 output_headers(1, 1, 2, 0, 0, 0);
2150 wprintf("<div id=\"banner\">\n"
2151 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2152 "<SPAN CLASS=\"titlebar\">");
2153 wprintf(_("Go to a hidden room"));
2155 "</TD></TR></TABLE>\n"
2156 "</div>\n<div id=\"content\">\n"
2159 wprintf("<div class=\"fix_scrollbar_bug\">"
2160 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2162 wprintf("<CENTER>\n");
2164 wprintf(_("If you know the name of a hidden (guess-name) or "
2165 "passworded room, you can enter that room by typing "
2166 "its name below. Once you gain access to a private "
2167 "room, it will appear in your regular room listings "
2168 "so you don't have to keep returning here."));
2169 wprintf("\n<br /><br />");
2171 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2173 wprintf("<table border=\"0\" cellspacing=\"5\" "
2174 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2176 wprintf(_("Enter room name:"));
2178 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2179 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2182 wprintf("</TD></TR><TR><TD>");
2183 wprintf(_("Enter room password:"));
2184 wprintf("</TD><TD>");
2185 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2187 wprintf("</TD></TR></TABLE><br />\n");
2189 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2191 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2195 wprintf("</FORM>\n");
2196 wprintf("</td></tr></table></div>\n");
2201 * \brief goto a private room
2203 void goto_private(void)
2208 if (strlen(bstr("ok_button")) == 0) {
2209 display_main_menu();
2212 strcpy(hold_rm, WC->wc_roomname);
2213 strcpy(buf, "GOTO ");
2214 strcat(buf, bstr("gr_name"));
2216 strcat(buf, bstr("gr_pass"));
2218 serv_getln(buf, sizeof buf);
2220 if (buf[0] == '2') {
2221 smart_goto(bstr("gr_name"));
2224 if (!strncmp(buf, "540", 3)) {
2225 display_private(bstr("gr_name"), 1);
2228 output_headers(1, 1, 1, 0, 0, 0);
2229 wprintf("%s\n", &buf[4]);
2236 * \brief display the screen to zap a room
2238 void display_zap(void)
2240 output_headers(1, 1, 2, 0, 0, 0);
2242 wprintf("<div id=\"banner\">\n");
2243 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2244 wprintf("<SPAN CLASS=\"titlebar\">");
2245 wprintf(_("Zap (forget/unsubscribe) the current room"));
2246 wprintf("</SPAN>\n");
2247 wprintf("</TD></TR></TABLE>\n");
2248 wprintf("</div>\n<div id=\"content\">\n");
2250 wprintf(_("If you select this option, <em>%s</em> will "
2251 "disappear from your room list. Is this what you wish "
2252 "to do?<br />\n"), WC->wc_roomname);
2254 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2255 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2257 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2258 wprintf("</FORM>\n");
2269 char final_destination[SIZ];
2272 * If the forget-room routine fails for any reason, we fall back
2273 * to the current room; otherwise, we go to the Lobby
2275 strcpy(final_destination, WC->wc_roomname);
2277 if (strlen(bstr("ok_button")) > 0) {
2278 serv_printf("GOTO %s", WC->wc_roomname);
2279 serv_getln(buf, sizeof buf);
2280 if (buf[0] == '2') {
2282 serv_getln(buf, sizeof buf);
2283 if (buf[0] == '2') {
2284 strcpy(final_destination, "_BASEROOM_");
2288 smart_goto(final_destination);
2294 * \brief Delete the current room
2296 void delete_room(void)
2300 serv_puts("KILL 1");
2301 serv_getln(buf, sizeof buf);
2302 if (buf[0] != '2') {
2303 strcpy(WC->ImportantMessage, &buf[4]);
2304 display_main_menu();
2307 smart_goto("_BASEROOM_");
2314 * \brief Perform changes to a room's network configuration
2316 void netedit(void) {
2325 if (strlen(bstr("line"))==0) {
2330 strcpy(line, bstr("prefix"));
2331 strcat(line, bstr("line"));
2332 strcat(line, bstr("suffix"));
2341 serv_getln(buf, sizeof buf);
2342 if (buf[0] != '1') {
2348 /** This loop works for add *or* remove. Spiffy, eh? */
2349 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2350 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2351 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2352 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2353 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2354 if ( (strcasecmp(cmpa0, cmpb0))
2355 || (strcasecmp(cmpa1, cmpb1)) ) {
2356 fprintf(fp, "%s\n", buf);
2362 serv_getln(buf, sizeof buf);
2363 if (buf[0] != '4') {
2369 while (fgets(buf, sizeof buf, fp) != NULL) {
2370 buf[strlen(buf)-1] = 0;
2374 if (strlen(bstr("add_button")) > 0) {
2386 * \brief Convert a room name to a folder-ish-looking name.
2387 * \param folder the folderish name
2388 * \param room the room name
2389 * \param floor the floor name
2390 * \param is_mailbox is it a mailbox?
2392 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2397 * For mailboxes, just do it straight...
2400 sprintf(folder, "My folders|%s", room);
2404 * Otherwise, prefix the floor name as a "public folders" moniker
2407 sprintf(folder, "%s|%s", floorlist[floor], room);
2411 * Replace "\" characters with "|" for pseudo-folder-delimiting
2413 for (i=0; i<strlen(folder); ++i) {
2414 if (folder[i] == '\\') folder[i] = '|';
2422 * \brief Back end for change_view()
2423 * \param newview set newview???
2425 void do_change_view(int newview) {
2428 serv_printf("VIEW %d", newview);
2429 serv_getln(buf, sizeof buf);
2430 WC->wc_view = newview;
2431 smart_goto(WC->wc_roomname);
2437 * \brief Change the view for this room
2439 void change_view(void) {
2442 view = atol(bstr("view"));
2443 do_change_view(view);
2448 * \brief One big expanded tree list view --- like a folder list
2449 * \param fold the folder to view
2450 * \param max_folders how many folders???
2451 * \param num_floors hom many floors???
2453 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2457 int has_subfolders = 0;
2460 parents = malloc(max_folders * sizeof(int));
2462 /** BEGIN TREE MENU */
2463 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2465 /** include NanoTree */
2466 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2468 /** initialize NanoTree */
2469 wprintf("<script type=\"text/javascript\"> \n"
2470 " showRootNode = false; \n"
2471 " sortNodes = false; \n"
2472 " dragable = false; \n"
2474 " function standardClick(treeNode) { \n"
2477 " var closedGif = 'static/folder_closed.gif'; \n"
2478 " var openGif = 'static/folder_open.gif'; \n"
2480 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2484 for (i=0; i<max_folders; ++i) {
2487 if ((i+1) < max_folders) {
2488 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2489 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2494 levels = num_tokens(fold[i].name, '|');
2495 parents[levels] = i;
2497 wprintf("var node%d = new TreeNode(%d, '", i, i);
2499 if (fold[i].selectable) {
2500 wprintf("<a href=\"dotgoto?room=");
2501 urlescputs(fold[i].room);
2506 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2508 else if (fold[i].hasnewmsgs) {
2509 wprintf("<SPAN CLASS=\"roomlist_new\">");
2512 wprintf("<SPAN CLASS=\"roomlist_old\">");
2514 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2519 if (has_subfolders) {
2520 wprintf("new Array(closedGif, openGif)");
2522 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2523 wprintf("'static/viewcontacts_16x.gif'");
2525 else if (fold[i].view == VIEW_CALENDAR) {
2526 wprintf("'static/calarea_16x.gif'");
2528 else if (fold[i].view == VIEW_CALBRIEF) {
2529 wprintf("'static/calarea_16x.gif'");
2531 else if (fold[i].view == VIEW_TASKS) {
2532 wprintf("'static/taskmanag_16x.gif'");
2534 else if (fold[i].view == VIEW_NOTES) {
2535 wprintf("'static/storenotes_16x.gif'");
2537 else if (fold[i].view == VIEW_MAILBOX) {
2538 wprintf("'static/privatemess_16x.gif'");
2541 wprintf("'static/chatrooms_16x.gif'");
2544 urlescputs(fold[i].name);
2548 wprintf("rootNode.addChild(node%d);\n", i);
2551 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2555 wprintf("container = document.getElementById('roomlist_div'); \n"
2561 /** END TREE MENU */
2565 * \brief Boxes and rooms and lists ... oh my!
2566 * \param fold the folder to view
2567 * \param max_folders how many folders???
2568 * \param num_floors hom many floors???
2570 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2572 char floor_name[256];
2573 char old_floor_name[256];
2575 int levels, oldlevels;
2578 static int columns = 3;
2579 int boxes_per_column = 0;
2580 int current_column = 0;
2583 strcpy(floor_name, "");
2584 strcpy(old_floor_name, "");
2587 while (nf % columns != 0) ++nf;
2588 boxes_per_column = (nf / columns);
2589 if (boxes_per_column < 1) boxes_per_column = 1;
2591 /** Outer table (for columnization) */
2592 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2593 "<tr><td valign=top>");
2597 for (i=0; i<max_folders; ++i) {
2599 levels = num_tokens(fold[i].name, '|');
2600 extract_token(floor_name, fold[i].name, 0,
2601 '|', sizeof floor_name);
2603 if ( (strcasecmp(floor_name, old_floor_name))
2604 && (strlen(old_floor_name) > 0) ) {
2606 do_template("endbox");
2609 if ((num_boxes % boxes_per_column) == 0) {
2611 if (current_column < columns) {
2612 wprintf("</td><td valign=top>\n");
2616 strcpy(old_floor_name, floor_name);
2619 /** Begin inner box */
2620 stresc(boxtitle, floor_name, 1, 0);
2621 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2622 do_template("beginbox");
2629 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2630 if (fold[i].selectable) {
2631 wprintf("<a href=\"dotgoto?room=");
2632 urlescputs(fold[i].room);
2638 if (fold[i].hasnewmsgs) {
2639 wprintf("<SPAN CLASS=\"roomlist_new\">");
2642 wprintf("<SPAN CLASS=\"roomlist_old\">");
2644 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2647 if (fold[i].selectable) {
2653 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2654 wprintf(" (INBOX)");
2656 wprintf("<br />\n");
2659 /** End the final inner box */
2660 do_template("endbox");
2662 wprintf("</TD></TR></TABLE>\n");
2666 * \brief print a floor div???
2667 * \param which_floordiv name of the floordiv???
2669 void set_floordiv_expanded(char *which_floordiv) {
2670 begin_ajax_response();
2671 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2672 end_ajax_response();
2676 * \brief view the iconbar
2677 * \param fold the folder to view
2678 * \param max_folders how many folders???
2679 * \param num_floors hom many floors???
2681 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2683 char floor_name[256];
2684 char old_floor_name[256];
2685 char floordivtitle[256];
2686 char floordiv_id[32];
2687 int levels, oldlevels;
2689 int num_drop_targets = 0;
2692 strcpy(floor_name, "");
2693 strcpy(old_floor_name, "");
2697 for (i=0; i<max_folders; ++i) {
2699 levels = num_tokens(fold[i].name, '|');
2700 extract_token(floor_name, fold[i].name, 0,
2701 '|', sizeof floor_name);
2703 if ( (strcasecmp(floor_name, old_floor_name))
2704 && (strlen(old_floor_name) > 0) ) {
2705 /** End inner box */
2707 wprintf("</div>\n"); /** floordiv */
2709 strcpy(old_floor_name, floor_name);
2713 stresc(floordivtitle, floor_name, 0, 0);
2714 sprintf(floordiv_id, "floordiv%d", i);
2715 wprintf("<span class=\"ib_roomlist_floor\" "
2716 "onClick=\"expand_floor('%s')\">"
2717 "%s</span><br>\n", floordiv_id, floordivtitle);
2718 wprintf("<div id=\"%s\" style=\"display:%s\">",
2720 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2727 wprintf("<div id=\"roomdiv%d\">", i);
2729 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2731 /** choose the icon */
2732 if (fold[i].view == VIEW_ADDRESSBOOK) {
2733 icon = "viewcontacts_16x.gif" ;
2735 else if (fold[i].view == VIEW_CALENDAR) {
2736 icon = "calarea_16x.gif" ;
2738 else if (fold[i].view == VIEW_CALBRIEF) {
2739 icon = "calarea_16x.gif" ;
2741 else if (fold[i].view == VIEW_TASKS) {
2742 icon = "taskmanag_16x.gif" ;
2744 else if (fold[i].view == VIEW_NOTES) {
2745 icon = "storenotes_16x.gif" ;
2747 else if (fold[i].view == VIEW_MAILBOX) {
2748 icon = "privatemess_16x.gif" ;
2751 icon = "chatrooms_16x.gif" ;
2754 if (fold[i].selectable) {
2755 wprintf("<a href=\"dotgoto?room=");
2756 urlescputs(fold[i].room);
2758 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2763 if (fold[i].hasnewmsgs) {
2764 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2767 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2769 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2771 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2772 wprintf(" (INBOX)");
2775 if (fold[i].selectable) {
2782 wprintf("</div>\n"); /** roomdiv */
2785 wprintf("</div>\n"); /** floordiv */
2788 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2789 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2791 num_drop_targets = 0;
2793 for (i=0; i<max_folders; ++i) {
2794 levels = num_tokens(fold[i].name, '|');
2796 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2797 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2798 jsescputs(fold[i].room);
2804 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2805 if (strlen(WC->floordiv_expanded) > 1) {
2806 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2810 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2816 * \brief Show the room list.
2817 * (only should get called by
2818 * knrooms() because that's where output_headers() is called from)
2819 * \param viewpref the view preferences???
2822 void list_all_rooms_by_floor(char *viewpref) {
2825 struct folder *fold = NULL;
2827 int max_folders = 0;
2828 int alloc_folders = 0;
2832 int num_floors = 1; /** add an extra one for private folders */
2834 /** If our cached folder list is very old, burn it. */
2835 if (WC->cache_fold != NULL) {
2836 if ((time(NULL) - WC->cache_timestamp) > 300) {
2837 free(WC->cache_fold);
2838 WC->cache_fold = NULL;
2842 /** Can we do the iconbar roomlist from cache? */
2843 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2844 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2848 /** Grab the floor table so we know how to build the list... */
2851 /** Start with the mailboxes */
2854 fold = malloc(sizeof(struct folder));
2855 memset(fold, 0, sizeof(struct folder));
2856 strcpy(fold[0].name, "My folders");
2857 fold[0].is_mailbox = 1;
2859 /** Then add floors */
2861 serv_getln(buf, sizeof buf);
2862 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2863 if (max_folders >= alloc_folders) {
2864 alloc_folders = max_folders + 100;
2865 fold = realloc(fold,
2866 alloc_folders * sizeof(struct folder));
2868 memset(&fold[max_folders], 0, sizeof(struct folder));
2869 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2874 /** Now add rooms */
2876 serv_getln(buf, sizeof buf);
2877 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2878 if (max_folders >= alloc_folders) {
2879 alloc_folders = max_folders + 100;
2880 fold = realloc(fold,
2881 alloc_folders * sizeof(struct folder));
2883 memset(&fold[max_folders], 0, sizeof(struct folder));
2884 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2885 ra_flags = extract_int(buf, 5);
2886 flags = extract_int(buf, 1);
2887 fold[max_folders].floor = extract_int(buf, 2);
2888 fold[max_folders].hasnewmsgs =
2889 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2890 if (flags & QR_MAILBOX) {
2891 fold[max_folders].is_mailbox = 1;
2893 fold[max_folders].view = extract_int(buf, 6);
2894 room_to_folder(fold[max_folders].name,
2895 fold[max_folders].room,
2896 fold[max_folders].floor,
2897 fold[max_folders].is_mailbox);
2898 fold[max_folders].selectable = 1;
2902 /** Bubble-sort the folder list */
2903 for (i=0; i<max_folders; ++i) {
2904 for (j=0; j<(max_folders-1)-i; ++j) {
2905 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2906 swap = strcasecmp(fold[j].name, fold[j+1].name);
2909 if ( (fold[j+1].is_mailbox)
2910 && (!fold[j].is_mailbox)) {
2918 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2919 memcpy(&fold[j], &fold[j+1],
2920 sizeof(struct folder));
2921 memcpy(&fold[j+1], &ftmp,
2922 sizeof(struct folder));
2928 if (!strcasecmp(viewpref, "folders")) {
2929 do_folder_view(fold, max_folders, num_floors);
2931 else if (!strcasecmp(viewpref, "hackish_view")) {
2932 for (i=0; i<max_folders; ++i) {
2933 escputs(fold[i].name);
2934 wprintf("<br />\n");
2937 else if (!strcasecmp(viewpref, "iconbar")) {
2938 do_iconbar_view(fold, max_folders, num_floors);
2941 do_rooms_view(fold, max_folders, num_floors);
2944 /* Don't free the folder list ... cache it for future use! */
2945 if (WC->cache_fold != NULL) {
2946 free(WC->cache_fold);
2948 WC->cache_fold = fold;
2949 WC->cache_max_folders = max_folders;
2950 WC->cache_num_floors = num_floors;
2951 WC->cache_timestamp = time(NULL);
2956 * \brief Do either a known rooms list or a folders list, depending on the
2961 char listviewpref[SIZ];
2963 output_headers(1, 1, 2, 0, 0, 0);
2965 /** Determine whether the user is trying to change views */
2966 if (bstr("view") != NULL) {
2967 if (strlen(bstr("view")) > 0) {
2968 set_preference("roomlistview", bstr("view"), 1);
2972 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2974 if ( (strcasecmp(listviewpref, "folders"))
2975 && (strcasecmp(listviewpref, "table")) ) {
2976 strcpy(listviewpref, "rooms");
2980 wprintf("<div id=\"banner\">\n"
2981 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2982 "<SPAN CLASS=\"titlebar\">"
2984 if (!strcasecmp(listviewpref, "rooms")) {
2985 wprintf(_("Room list"));
2987 if (!strcasecmp(listviewpref, "folders")) {
2988 wprintf(_("Folder list"));
2990 if (!strcasecmp(listviewpref, "table")) {
2991 wprintf(_("Room list"));
2993 wprintf("</SPAN></TD>\n");
2995 /** offer the ability to switch views */
2996 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2997 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2998 "OnChange=\"location.href=roomlistomatic.newview.options"
2999 "[selectedIndex].value\">\n");
3001 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3004 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3007 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3008 "View as folder list"
3010 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3013 wprintf("</SELECT><br />");
3015 wprintf("</FORM></TD></TR></TABLE>\n");
3018 "<div id=\"content\">\n");
3020 /** Display the room list in the user's preferred format */
3021 list_all_rooms_by_floor(listviewpref);
3028 * \brief Set the message expire policy for this room and/or floor
3030 void set_room_policy(void) {
3033 if (strlen(bstr("ok_button")) == 0) {
3034 strcpy(WC->ImportantMessage,
3035 _("Cancelled. Changes were not saved."));
3040 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3041 serv_getln(buf, sizeof buf);
3042 strcpy(WC->ImportantMessage, &buf[4]);
3044 if (WC->axlevel >= 6) {
3045 strcat(WC->ImportantMessage, "<br />\n");
3046 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3047 serv_getln(buf, sizeof buf);
3048 strcat(WC->ImportantMessage, &buf[4]);