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");
31 * \brief load the list of floors
33 void load_floorlist(void)
38 for (a = 0; a < 128; ++a)
42 serv_getln(buf, sizeof buf);
44 strcpy(floorlist[0], "Main Floor");
47 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
48 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
54 * \brief remove a room from the march list
56 void remove_march(char *aaa)
58 struct march *mptr, *mptr2;
60 if (WC->march == NULL)
63 if (!strcasecmp(WC->march->march_name, aaa)) {
64 mptr = WC->march->next;
70 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
71 if (!strcasecmp(mptr->march_name, aaa)) {
72 mptr2->next = mptr->next;
85 * \brief display rooms in tree structure???
86 * \param rp the roomlist to build a tree from
88 void room_tree_list(struct roomlisting *rp)
97 room_tree_list(rp->lnext);
99 strcpy(rmname, rp->rlname);
102 wprintf("<a href=\"dotgoto&room=");
106 escputs1(rmname, 1, 1);
107 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
109 else if (f & QR_DIRECTORY)
111 else if (f & QR_NETWORK)
115 wprintf("</A><TT> </TT>\n");
117 room_tree_list(rp->rnext);
123 * \brief Room ordering stuff (compare first by floor, then by order)
124 * \param r1 first roomlist to compare
125 * \param r2 second roomlist co compare
126 * \return are they the same???
128 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
130 if ((r1 == NULL) && (r2 == NULL))
136 if (r1->rlfloor < r2->rlfloor)
138 if (r1->rlfloor > r2->rlfloor)
140 if (r1->rlorder < r2->rlorder)
142 if (r1->rlorder > r2->rlorder)
149 * \brief Common code for all room listings
150 * \param variety what???
152 void listrms(char *variety)
157 struct roomlisting *rl = NULL;
158 struct roomlisting *rp;
159 struct roomlisting *rs;
162 /** Ask the server for a room list */
164 serv_getln(buf, sizeof buf);
169 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
171 rp = malloc(sizeof(struct roomlisting));
172 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
173 rp->rlflags = extract_int(buf, 1);
174 rp->rlfloor = extract_int(buf, 2);
175 rp->rlorder = extract_int(buf, 3);
184 if (rordercmp(rp, rs) < 0) {
185 if (rs->lnext == NULL) {
192 if (rs->rnext == NULL) {
205 * If no rooms were listed, print an nbsp to make the cell
206 * borders show up anyway.
208 if (num_rooms == 0) wprintf(" ");
213 * \brief list all forgotten rooms
215 void zapped_list(void)
217 output_headers(1, 1, 0, 0, 0, 0);
219 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
220 do_template("beginbox");
224 wprintf("<br /><br />\n");
225 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
226 do_template("endbox");
232 * \brief read this room's info file (set v to 1 for verbose mode)
239 serv_getln(buf, sizeof buf);
252 * \brief Display room banner icon.
253 * The server doesn't actually
254 * need the room name, but we supply it in order to
255 * keep the browser from using a cached icon from
258 void embed_room_graphic(void) {
261 serv_puts("OIMG _roompic_");
262 serv_getln(buf, sizeof buf);
264 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
265 urlescputs(WC->wc_roomname);
268 serv_getln(buf, sizeof buf);
270 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
271 wprintf("<img height=48 width=48 src=\""
272 "static/viewcontacts_48x.gif"
276 else if (WC->wc_view == VIEW_CALENDAR) {
277 wprintf("<img height=48 width=48 src=\""
278 "static/calarea_48x.gif"
282 else if (WC->wc_view == VIEW_TASKS) {
283 wprintf("<img height=48 width=48 src=\""
284 "static/taskmanag_48x.gif"
288 else if (WC->wc_view == VIEW_NOTES) {
289 wprintf("<img height=48 width=48 src=\""
290 "static/storenotes_48x.gif"
294 else if (WC->wc_view == VIEW_MAILBOX) {
295 wprintf("<img height=48 width=48 src=\""
296 "static/privatemess_48x.gif"
301 wprintf("<img height=48 width=48 src=\""
302 "static/chatrooms_48x.gif"
312 * \brief Display the current view and offer an option to change it
314 void embed_view_o_matic(void) {
317 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
318 "<span class=\"room_banner_new_messages\">");
319 wprintf(_("View as:"));
321 "<SELECT NAME=\"newview\" SIZE=\"1\" "
322 "STYLE=\"font-size: 7pt; background: #444455; color: #ddddcc;\" "
323 "OnChange=\"location.href=viewomatic.newview.options"
324 "[selectedIndex].value\">\n");
326 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
328 * Only offer the views that make sense, given the default
329 * view for the room. For example, don't offer a Calendar
330 * view in a non-Calendar room.
334 || (i == WC->wc_default_view) /**< default */
335 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
336 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
337 || ( (i == 7) && (WC->wc_default_view == 3) ) /**< calendar */
340 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
341 ((i == WC->wc_view) ? "SELECTED" : ""),
343 escputs(viewdefs[i]);
344 wprintf("</OPTION>\n");
347 wprintf("</select></span></form>\n");
352 * \brief view room banner
354 * \param navbar_style
356 void embed_room_banner(char *got, int navbar_style) {
360 * We need to have the information returned by a GOTO server command.
361 * If it isn't supplied, we fake it by issuing our own GOTO.
364 serv_printf("GOTO %s", WC->wc_roomname);
365 serv_getln(buf, sizeof buf);
369 /** The browser needs some information for its own use */
370 wprintf("<script type=\"text/javascript\"> \n"
371 " room_is_trash = %d; \n"
377 * If the user happens to select the "make this my start page" link,
378 * we want it to remember the URL as a "/dotskip" one instead of
379 * a "skip" or "gotonext" or something like that.
381 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
384 /** Check for new mail. */
385 WC->new_mail = extract_int(&got[4], 9);
386 WC->wc_view = extract_int(&got[4], 11);
388 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
389 svprintf("NUMMSGS", WCS_STRING,
390 _("%d new of %d messages"),
391 extract_int(&got[4], 1),
392 extract_int(&got[4], 2)
394 svcallback("ROOMPIC", embed_room_graphic);
395 svcallback("ROOMINFO", readinfo);
396 svcallback("VIEWOMATIC", embed_view_o_matic);
397 svcallback("START", offer_start_page);
399 do_template("roombanner");
400 if (navbar_style != navbar_none) {
402 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
403 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
406 if (navbar_style == navbar_default) wprintf(
408 "<a href=\"ungoto\">"
409 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
410 "<span class=\"navbar_link\">%s</span></A>"
411 "</td>\n", _("Ungoto")
414 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
417 "<a href=\"readnew\">"
418 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
419 "<span class=\"navbar_link\">%s</span></A>"
420 "</td>\n", _("Read new messages")
424 if (navbar_style == navbar_default) {
425 switch(WC->wc_view) {
426 case VIEW_ADDRESSBOOK:
429 "<a href=\"readfwd\">"
430 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
432 "<span class=\"navbar_link\">"
434 "</span></a></td>\n", _("View contacts")
440 "<a href=\"readfwd?calview=day\">"
441 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
443 "<span class=\"navbar_link\">"
445 "</span></a></td>\n", _("Day view")
449 "<a href=\"readfwd?calview=month\">"
450 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
452 "<span class=\"navbar_link\">"
454 "</span></a></td>\n", _("Month view")
460 "<a href=\"readfwd\">"
461 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
463 "<span class=\"navbar_link\">"
465 "</span></a></td>\n", _("View tasks")
471 "<a href=\"readfwd\">"
472 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
474 "<span class=\"navbar_link\">"
476 "</span></a></td>\n", _("View notes")
482 "<a href=\"readfwd\">"
483 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
485 "<span class=\"navbar_link\">"
487 "</span></a></td>\n", _("View message list")
493 "<a href=\"readfwd\">"
494 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
496 "<span class=\"navbar_link\">"
498 "</span></a></td>\n", _("Wiki home")
504 "<a href=\"readfwd\">"
505 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
507 "<span class=\"navbar_link\">"
509 "</span></a></td>\n", _("Read all messages")
515 if (navbar_style == navbar_default) {
516 switch(WC->wc_view) {
517 case VIEW_ADDRESSBOOK:
519 "<td><a href=\"display_enter\">"
520 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
521 "border=\"0\"><span class=\"navbar_link\">"
523 "</span></a></td>\n", _("Add new contact")
528 "<td><a href=\"display_enter\">"
529 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
530 "border=\"0\"><span class=\"navbar_link\">"
532 "</span></a></td>\n", _("Add new event")
537 "<td><a href=\"display_enter\">"
538 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
539 "border=\"0\"><span class=\"navbar_link\">"
541 "</span></a></td>\n", _("Add new task")
546 "<td><a href=\"javascript:add_new_note();\">"
547 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
548 "border=\"0\"><span class=\"navbar_link\">"
550 "</span></a></td>\n", _("Add new note")
554 safestrncpy(buf, bstr("page"), sizeof buf);
557 "<td><a href=\"display_enter?wikipage=%s\">"
558 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
559 "border=\"0\"><span class=\"navbar_link\">"
561 "</span></a></td>\n", buf, _("Edit this page")
566 "<td><a href=\"display_enter\">"
567 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
568 "border=\"0\"><span class=\"navbar_link\">"
570 "</span></a></td>\n", _("Enter a message")
576 if (navbar_style == navbar_default) wprintf(
580 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
581 "<span class=\"navbar_link\">%s</span></a>"
583 _("Leave all messages marked as unread, go to next room with unread messages"),
587 if (navbar_style == navbar_default) wprintf(
589 "<a href=\"gotonext\" "
591 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
592 "<span class=\"navbar_link\">%s</span></a>"
594 _("Mark all messages as read, go to next room with unread messages"),
598 wprintf("</tr></table></div>\n");
608 * \brief back end routine to take the session to a new room
609 * \param gname room to go to
612 int gotoroom(char *gname)
615 static long ls = (-1L);
618 /** store ungoto information */
619 strcpy(WC->ugname, WC->wc_roomname);
622 /** move to the new room */
623 serv_printf("GOTO %s", gname);
624 serv_getln(buf, sizeof buf);
628 serv_puts("GOTO _BASEROOM_");
629 serv_getln(buf, sizeof buf);
636 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
637 WC->room_flags = extract_int(&buf[4], 4);
638 /* highest_msg_read = extract_int(&buf[4],6);
639 maxmsgnum = extract_int(&buf[4],5);
641 WC->is_mailbox = extract_int(&buf[4],7);
642 ls = extract_long(&buf[4], 6);
643 WC->wc_floor = extract_int(&buf[4], 10);
644 WC->wc_view = extract_int(&buf[4], 11);
645 WC->wc_default_view = extract_int(&buf[4], 12);
646 WC->wc_is_trash = extract_int(&buf[4], 13);
649 WC->is_room_aide = WC->is_aide;
651 WC->is_room_aide = (char) extract_int(&buf[4], 8);
653 remove_march(WC->wc_roomname);
654 if (!strcasecmp(gname, "_BASEROOM_"))
662 * \brief Locate the room on the march list which we most want to go to.
664 * is measured given a "weight" of preference based on various factors.
665 * \param desired_floor the room number on the citadel server
666 * \return the roomname
668 char *pop_march(int desired_floor)
670 static char TheRoom[128];
672 int TheOrder = 32767;
675 struct march *mptr = NULL;
677 strcpy(TheRoom, "_BASEROOM_");
678 if (WC->march == NULL)
681 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
683 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
684 weight = weight + 10000;
685 if (mptr->march_floor == desired_floor)
686 weight = weight + 5000;
688 weight = weight + ((128 - (mptr->march_floor)) * 128);
689 weight = weight + (128 - (mptr->march_order));
691 if (weight > TheWeight) {
693 strcpy(TheRoom, mptr->march_name);
694 TheFloor = mptr->march_floor;
695 TheOrder = mptr->march_order;
704 *\brief Goto next room having unread messages.
705 * We want to skip over rooms that the user has already been to, and take the
706 * user back to the lobby when done. The room we end up in is placed in
707 * newroom - which is set to 0 (the lobby) initially.
708 * We start the search in the current room rather than the beginning to prevent
709 * two or more concurrent users from dragging each other back to the same room.
714 struct march *mptr, *mptr2;
718 * First check to see if the march-mode list is already allocated.
719 * If it is, pop the first room off the list and go there.
722 if (WC->march == NULL) {
724 serv_getln(buf, sizeof buf);
726 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
727 mptr = (struct march *) malloc(sizeof(struct march));
729 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
730 mptr->march_floor = extract_int(buf, 2);
731 mptr->march_order = extract_int(buf, 3);
732 if (WC->march == NULL) {
736 while (mptr2->next != NULL)
742 * add _BASEROOM_ to the end of the march list, so the user will end up
743 * in the system base room (usually the Lobby>) at the end of the loop
745 mptr = (struct march *) malloc(sizeof(struct march));
747 strcpy(mptr->march_name, "_BASEROOM_");
748 if (WC->march == NULL) {
752 while (mptr2->next != NULL)
757 * ...and remove the room we're currently in, so a <G>oto doesn't make us
758 * walk around in circles
760 remove_march(WC->wc_roomname);
762 if (WC->march != NULL) {
763 strcpy(next_room, pop_march(-1));
765 strcpy(next_room, "_BASEROOM_");
769 smart_goto(next_room);
774 * \brief goto next room
775 * \param next_room next room to go to
777 void smart_goto(char *next_room) {
785 * \brief mark all messages in current room as having been read
787 void slrp_highest(void)
792 serv_puts("SLRP HIGHEST");
793 serv_getln(buf, sizeof buf);
795 wprintf("<EM>%s</EM><br />\n", &buf[4]);
802 * \brief un-goto the previous room
808 if (!strcmp(WC->ugname, "")) {
809 smart_goto(WC->wc_roomname);
812 serv_printf("GOTO %s", WC->ugname);
813 serv_getln(buf, sizeof buf);
815 smart_goto(WC->wc_roomname);
818 if (WC->uglsn >= 0L) {
819 serv_printf("SLRP %ld", WC->uglsn);
820 serv_getln(buf, sizeof buf);
822 strcpy(buf, WC->ugname);
823 strcpy(WC->ugname, "");
832 * \brief Set/clear/read the "self-service list subscribe" flag for a room
834 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
835 * \return return the new value.
838 int self_service(int newval) {
839 int current_value = 0;
845 int flags, floor, order, view, flags2;
848 serv_getln(buf, sizeof buf);
849 if (buf[0] != '2') return(0);
851 extract_token(name, &buf[4], 0, '|', sizeof name);
852 extract_token(password, &buf[4], 1, '|', sizeof password);
853 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
854 flags = extract_int(&buf[4], 3);
855 floor = extract_int(&buf[4], 4);
856 order = extract_int(&buf[4], 5);
857 view = extract_int(&buf[4], 6);
858 flags2 = extract_int(&buf[4], 7);
860 if (flags2 & QR2_SELFLIST) {
868 flags2 = flags2 | QR2_SELFLIST;
870 else if (newval == 0) {
871 flags2 = flags2 & ~QR2_SELFLIST;
874 return(current_value);
877 if (newval != current_value) {
878 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
879 name, password, dirname, flags,
880 floor, order, view, flags2);
881 serv_getln(buf, sizeof buf);
894 * \brief display the form for editing a room
896 void display_editroom(void)
901 char remote_room[SIZ];
904 char er_password[10];
906 char er_roomaide[26];
912 char *not_shared_with;
919 if (strlen(tab) == 0) tab = "admin";
923 serv_getln(buf, sizeof buf);
926 strcpy(WC->ImportantMessage, &buf[4]);
930 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
931 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
932 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
933 er_flags = extract_int(&buf[4], 3);
934 er_floor = extract_int(&buf[4], 4);
936 output_headers(1, 1, 1, 0, 0, 0);
938 /** print the tabbed dialog */
940 "<div class=\"fix_scrollbar_bug\">"
941 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
943 "<TD> </TD>\n");
945 if (!strcmp(tab, "admin")) {
946 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
949 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
951 wprintf(_("Administration"));
952 if (!strcmp(tab, "admin")) {
953 wprintf("</SPAN></TD>\n");
956 wprintf("</A></TD>\n");
959 wprintf("<TD> </TD>\n");
961 if (!strcmp(tab, "config")) {
962 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
965 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
967 wprintf(_("Configuration"));
968 if (!strcmp(tab, "config")) {
969 wprintf("</SPAN></TD>\n");
972 wprintf("</A></TD>\n");
975 wprintf("<TD> </TD>\n");
977 if (!strcmp(tab, "expire")) {
978 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
981 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
983 wprintf(_("Message expire policy"));
984 if (!strcmp(tab, "expire")) {
985 wprintf("</SPAN></TD>\n");
988 wprintf("</A></TD>\n");
991 wprintf("<TD> </TD>\n");
993 if (!strcmp(tab, "access")) {
994 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
997 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
999 wprintf(_("Access controls"));
1000 if (!strcmp(tab, "access")) {
1001 wprintf("</SPAN></TD>\n");
1004 wprintf("</A></TD>\n");
1007 wprintf("<TD> </TD>\n");
1009 if (!strcmp(tab, "sharing")) {
1010 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1013 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
1015 wprintf(_("Sharing"));
1016 if (!strcmp(tab, "sharing")) {
1017 wprintf("</SPAN></TD>\n");
1020 wprintf("</A></TD>\n");
1023 wprintf("<TD> </TD>\n");
1025 if (!strcmp(tab, "listserv")) {
1026 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1029 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
1031 wprintf(_("Mailing list service"));
1032 if (!strcmp(tab, "listserv")) {
1033 wprintf("</SPAN></TD>\n");
1036 wprintf("</A></TD>\n");
1039 wprintf("<TD> </TD>\n");
1041 wprintf("</TR></TABLE></div>\n");
1042 /** end tabbed dialog */
1044 /** begin content of whatever tab is open now */
1045 wprintf("<div class=\"fix_scrollbar_bug\">"
1046 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
1049 if (!strcmp(tab, "admin")) {
1051 "<LI><a href=\"delete_room\" "
1052 "onClick=\"return confirm('");
1053 wprintf(_("Are you sure you want to delete this room?"));
1054 wprintf("');\">\n");
1055 wprintf(_("Delete this room"));
1057 "<LI><a href=\"display_editroompic\">\n");
1058 wprintf(_("Set or change the icon for this room's banner"));
1060 "<LI><a href=\"display_editinfo\">\n");
1061 wprintf(_("Edit this room's Info file"));
1066 if (!strcmp(tab, "config")) {
1067 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1069 wprintf("<UL><LI>");
1070 wprintf(_("Name of room: "));
1071 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1077 wprintf(_("Resides on floor: "));
1078 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1079 for (i = 0; i < 128; ++i)
1080 if (strlen(floorlist[i]) > 0) {
1081 wprintf("<OPTION ");
1083 wprintf("SELECTED ");
1084 wprintf("VALUE=\"%d\">", i);
1085 escputs(floorlist[i]);
1086 wprintf("</OPTION>\n");
1088 wprintf("</SELECT>\n");
1091 wprintf(_("Type of room:"));
1094 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1095 if ((er_flags & QR_PRIVATE) == 0)
1096 wprintf("CHECKED ");
1098 wprintf(_("Public room"));
1101 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1102 if ((er_flags & QR_PRIVATE) &&
1103 (er_flags & QR_GUESSNAME))
1104 wprintf("CHECKED ");
1106 wprintf(_("Private - guess name"));
1108 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1109 if ((er_flags & QR_PRIVATE) &&
1110 (er_flags & QR_PASSWORDED))
1111 wprintf("CHECKED ");
1113 wprintf(_("Private - require password:"));
1114 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1117 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1118 if ((er_flags & QR_PRIVATE)
1119 && ((er_flags & QR_GUESSNAME) == 0)
1120 && ((er_flags & QR_PASSWORDED) == 0))
1121 wprintf("CHECKED ");
1123 wprintf(_("Private - invitation only"));
1125 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1127 wprintf(_("If private, cause current users to forget room"));
1129 wprintf("\n</UL>\n");
1131 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1132 if (er_flags & QR_PREFONLY)
1133 wprintf("CHECKED ");
1135 wprintf(_("Preferred users only"));
1137 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1138 if (er_flags & QR_READONLY)
1139 wprintf("CHECKED ");
1141 wprintf(_("Read-only room"));
1143 /** directory stuff */
1144 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1145 if (er_flags & QR_DIRECTORY)
1146 wprintf("CHECKED ");
1148 wprintf(_("File directory room"));
1150 wprintf("\n<UL><LI>");
1151 wprintf(_("Directory name: "));
1152 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1155 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1156 if (er_flags & QR_UPLOAD)
1157 wprintf("CHECKED ");
1159 wprintf(_("Uploading allowed"));
1161 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1162 if (er_flags & QR_DOWNLOAD)
1163 wprintf("CHECKED ");
1165 wprintf(_("Downloading allowed"));
1167 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1168 if (er_flags & QR_VISDIR)
1169 wprintf("CHECKED ");
1171 wprintf(_("Visible directory"));
1174 /** end of directory stuff */
1176 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1177 if (er_flags & QR_NETWORK)
1178 wprintf("CHECKED ");
1180 wprintf(_("Network shared room"));
1182 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1183 if (er_flags & QR_PERMANENT)
1184 wprintf("CHECKED ");
1186 wprintf(_("Permanent (does not auto-purge)"));
1188 /** start of anon options */
1191 wprintf(_("Anonymous messages"));
1194 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1195 if (((er_flags & QR_ANONONLY) == 0)
1196 && ((er_flags & QR_ANONOPT) == 0))
1197 wprintf("CHECKED ");
1199 wprintf(_("No anonymous messages"));
1201 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1202 if (er_flags & QR_ANONONLY)
1203 wprintf("CHECKED ");
1205 wprintf(_("All messages are anonymous"));
1207 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1208 if (er_flags & QR_ANONOPT)
1209 wprintf("CHECKED ");
1211 wprintf(_("Prompt user when entering messages"));
1214 /* end of anon options */
1217 wprintf(_("Room aide: "));
1219 serv_getln(buf, sizeof buf);
1220 if (buf[0] != '2') {
1221 wprintf("<EM>%s</EM>\n", &buf[4]);
1223 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1224 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1227 wprintf("</UL><CENTER>\n");
1228 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1229 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1231 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1239 /** Sharing the room with other Citadel nodes... */
1240 if (!strcmp(tab, "sharing")) {
1242 shared_with = strdup("");
1243 not_shared_with = strdup("");
1245 /** Learn the current configuration */
1246 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1247 serv_getln(buf, sizeof buf);
1248 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1249 extract_token(node, buf, 0, '|', sizeof node);
1250 not_shared_with = realloc(not_shared_with,
1251 strlen(not_shared_with) + 32);
1252 strcat(not_shared_with, node);
1253 strcat(not_shared_with, "\n");
1257 serv_getln(buf, sizeof buf);
1258 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1259 extract_token(cmd, buf, 0, '|', sizeof cmd);
1260 extract_token(node, buf, 1, '|', sizeof node);
1261 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1262 if (!strcasecmp(cmd, "ignet_push_share")) {
1263 shared_with = realloc(shared_with,
1264 strlen(shared_with) + 32);
1265 strcat(shared_with, node);
1266 if (strlen(remote_room) > 0) {
1267 strcat(shared_with, "|");
1268 strcat(shared_with, remote_room);
1270 strcat(shared_with, "\n");
1274 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1275 extract_token(buf, shared_with, i, '\n', sizeof buf);
1276 extract_token(node, buf, 0, '|', sizeof node);
1277 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1278 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1279 if (!strcasecmp(node, cmd)) {
1280 remove_token(not_shared_with, j, '\n');
1285 /** Display the stuff */
1286 wprintf("<CENTER><br />"
1287 "<TABLE border=1 cellpadding=5><TR>"
1289 wprintf(_("Shared with"));
1290 wprintf("</I></B></TD>"
1292 wprintf(_("Not shared with"));
1293 wprintf("</I></B></TD></TR>\n"
1294 "<TR><TD VALIGN=TOP>\n");
1296 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1297 wprintf(_("Remote node name"));
1298 wprintf("</TD><TD>");
1299 wprintf(_("Remote room name"));
1300 wprintf("</TD><TD>");
1301 wprintf(_("Actions"));
1302 wprintf("</TD></TR>\n");
1304 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1305 extract_token(buf, shared_with, i, '\n', sizeof buf);
1306 extract_token(node, buf, 0, '|', sizeof node);
1307 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1308 if (strlen(node) > 0) {
1309 wprintf("<FORM METHOD=\"POST\" "
1310 "action=\"netedit\">"
1311 "<TR><TD>%s</TD>\n", node);
1314 if (strlen(remote_room) > 0) {
1315 escputs(remote_room);
1321 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1322 "VALUE=\"ignet_push_share|");
1324 if (strlen(remote_room) > 0) {
1326 urlescputs(remote_room);
1329 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1330 "VALUE=\"sharing\">\n");
1331 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1332 "VALUE=\"remove\">\n");
1333 wprintf("<INPUT TYPE=\"submit\" "
1334 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1335 wprintf("</TD></TR></FORM>\n");
1339 wprintf("</TABLE>\n");
1340 wprintf("</TD><TD VALIGN=TOP>\n");
1341 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1342 wprintf(_("Remote node name"));
1343 wprintf("</TD><TD>");
1344 wprintf(_("Remote room name"));
1345 wprintf("</TD><TD>");
1346 wprintf(_("Actions"));
1347 wprintf("</TD></TR>\n");
1349 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1350 extract_token(node, not_shared_with, i, '\n', sizeof node);
1351 if (strlen(node) > 0) {
1352 wprintf("<FORM METHOD=\"POST\" "
1353 "action=\"netedit\">"
1357 "<INPUT TYPE=\"INPUT\" "
1361 wprintf("<INPUT TYPE=\"hidden\" "
1363 "VALUE=\"ignet_push_share|");
1366 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1367 "VALUE=\"sharing\">\n");
1368 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1369 "VALUE=\"add\">\n");
1370 wprintf("<INPUT TYPE=\"submit\" "
1371 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1372 wprintf("</TD></TR></FORM>\n");
1376 wprintf("</TABLE>\n");
1377 wprintf("</TD></TR>"
1378 "</TABLE></CENTER><br />\n"
1379 "<I><B>%s</B><UL><LI>", _("Notes:"));
1380 wprintf(_("When sharing a room, "
1381 "it must be shared from both ends. Adding a node to "
1382 "the 'shared' list sends messages out, but in order to"
1383 " receive messages, the other nodes must be configured"
1384 " to send messages out to your system as well. "
1385 "<LI>If the remote room name is blank, it is assumed "
1386 "that the room name is identical on the remote node."
1387 "<LI>If the remote room name is different, the remote "
1388 "node must also configure the name of the room here."
1394 /** Mailing list management */
1395 if (!strcmp(tab, "listserv")) {
1397 wprintf("<br /><center>"
1398 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1399 "<TR><TD VALIGN=TOP>");
1401 wprintf(_("<i>The contents of this room are being "
1402 "mailed <b>as individual messages</b> "
1403 "to the following list recipients:"
1404 "</i><br /><br />\n"));
1407 serv_getln(buf, sizeof buf);
1408 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1409 extract_token(cmd, buf, 0, '|', sizeof cmd);
1410 if (!strcasecmp(cmd, "listrecp")) {
1411 extract_token(recp, buf, 1, '|', sizeof recp);
1414 wprintf(" <a href=\"netedit&cmd=remove&line="
1417 wprintf("&tab=listserv\">");
1418 wprintf(_("(remove)"));
1419 wprintf("</A><br />");
1422 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1423 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1424 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1425 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1426 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1427 wprintf("</FORM>\n");
1429 wprintf("</TD><TD VALIGN=TOP>\n");
1431 wprintf(_("<i>The contents of this room are being "
1432 "mailed <b>in digest form</b> "
1433 "to the following list recipients:"
1434 "</i><br /><br />\n"));
1437 serv_getln(buf, sizeof buf);
1438 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1439 extract_token(cmd, buf, 0, '|', sizeof cmd);
1440 if (!strcasecmp(cmd, "digestrecp")) {
1441 extract_token(recp, buf, 1, '|', sizeof recp);
1444 wprintf(" <a href=\"netedit&cmd=remove&line="
1447 wprintf("&tab=listserv\">");
1448 wprintf(_("(remove)"));
1449 wprintf("</A><br />");
1452 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1453 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1454 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1455 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1456 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1457 wprintf("</FORM>\n");
1459 wprintf("</TD></TR></TABLE><hr />\n");
1461 if (self_service(999) == 1) {
1462 wprintf(_("This room is configured to allow "
1463 "self-service subscribe/unsubscribe requests."));
1464 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1465 wprintf(_("Click to disable."));
1466 wprintf("</A><br />\n");
1467 wprintf(_("The URL for subscribe/unsubscribe is: "));
1468 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1469 (is_https ? "https" : "http"),
1473 wprintf(_("This room is <i>not</i> configured to allow "
1474 "self-service subscribe/unsubscribe requests."));
1475 wprintf(" <a href=\"toggle_self_service?newval=1&"
1477 wprintf(_("Click to enable."));
1478 wprintf("</A><br />\n");
1482 wprintf("</CENTER>\n");
1486 /** Mailing list management */
1487 if (!strcmp(tab, "expire")) {
1489 serv_puts("GPEX room");
1490 serv_getln(buf, sizeof buf);
1491 if (buf[0] == '2') {
1492 roompolicy = extract_int(&buf[4], 0);
1493 roomvalue = extract_int(&buf[4], 1);
1496 serv_puts("GPEX floor");
1497 serv_getln(buf, sizeof buf);
1498 if (buf[0] == '2') {
1499 floorpolicy = extract_int(&buf[4], 0);
1500 floorvalue = extract_int(&buf[4], 1);
1503 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1504 wprintf("<TABLE border=0 cellspacing=5>\n");
1505 wprintf("<TR><TD>");
1506 wprintf(_("Message expire policy for this room"));
1508 escputs(WC->wc_roomname);
1509 wprintf(")</TD><TD>");
1510 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1511 ((roompolicy == 0) ? "CHECKED" : "") );
1512 wprintf(_("Use the default policy for this floor"));
1513 wprintf("<br />\n");
1514 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1515 ((roompolicy == 1) ? "CHECKED" : "") );
1516 wprintf(_("Never automatically expire messages"));
1517 wprintf("<br />\n");
1518 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1519 ((roompolicy == 2) ? "CHECKED" : "") );
1520 wprintf(_("Expire by message count"));
1521 wprintf("<br />\n");
1522 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1523 ((roompolicy == 3) ? "CHECKED" : "") );
1524 wprintf(_("Expire by message age"));
1526 wprintf(_("Number of messages or days: "));
1527 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1528 wprintf("</TD></TR>\n");
1530 if (WC->axlevel >= 6) {
1531 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1532 wprintf("<TR><TD>");
1533 wprintf(_("Message expire policy for this floor"));
1535 escputs(floorlist[WC->wc_floor]);
1536 wprintf(")</TD><TD>");
1537 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1538 ((floorpolicy == 0) ? "CHECKED" : "") );
1539 wprintf(_("Use the system default"));
1540 wprintf("<br />\n");
1541 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1542 ((floorpolicy == 1) ? "CHECKED" : "") );
1543 wprintf(_("Never automatically expire messages"));
1544 wprintf("<br />\n");
1545 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1546 ((floorpolicy == 2) ? "CHECKED" : "") );
1547 wprintf(_("Expire by message count"));
1548 wprintf("<br />\n");
1549 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1550 ((floorpolicy == 3) ? "CHECKED" : "") );
1551 wprintf(_("Expire by message age"));
1553 wprintf(_("Number of messages or days: "));
1554 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1558 wprintf("<CENTER>\n");
1559 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1560 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1562 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1563 wprintf("</CENTER></TD><TR>\n");
1565 wprintf("</TABLE>\n"
1566 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1572 /** Mailing list management */
1573 if (!strcmp(tab, "access")) {
1577 /** end content of whatever tab is open now */
1578 wprintf("</TD></TR></TABLE></div>\n");
1585 * \brief Toggle self-service list subscription
1587 void toggle_self_service(void) {
1590 newval = atoi(bstr("newval"));
1591 self_service(newval);
1598 * \brief save new parameters for a room
1604 char er_password[10];
1605 char er_dirname[15];
1606 char er_roomaide[26];
1612 if (strlen(bstr("ok_button")) == 0) {
1613 strcpy(WC->ImportantMessage,
1614 _("Cancelled. Changes were not saved."));
1619 serv_getln(buf, sizeof buf);
1621 if (buf[0] != '2') {
1622 strcpy(WC->ImportantMessage, &buf[4]);
1626 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1627 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1628 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1629 er_flags = extract_int(&buf[4], 3);
1631 strcpy(er_roomaide, bstr("er_roomaide"));
1632 if (strlen(er_roomaide) == 0) {
1634 serv_getln(buf, sizeof buf);
1635 if (buf[0] != '2') {
1636 strcpy(er_roomaide, "");
1638 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1641 strcpy(buf, bstr("er_name"));
1643 if (strlen(buf) > 0) {
1644 strcpy(er_name, buf);
1647 strcpy(buf, bstr("er_password"));
1649 if (strlen(buf) > 0)
1650 strcpy(er_password, buf);
1652 strcpy(buf, bstr("er_dirname"));
1654 if (strlen(buf) > 0)
1655 strcpy(er_dirname, buf);
1657 strcpy(buf, bstr("type"));
1658 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1660 if (!strcmp(buf, "invonly")) {
1661 er_flags |= (QR_PRIVATE);
1663 if (!strcmp(buf, "hidden")) {
1664 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1666 if (!strcmp(buf, "passworded")) {
1667 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1669 if (!strcmp(bstr("prefonly"), "yes")) {
1670 er_flags |= QR_PREFONLY;
1672 er_flags &= ~QR_PREFONLY;
1675 if (!strcmp(bstr("readonly"), "yes")) {
1676 er_flags |= QR_READONLY;
1678 er_flags &= ~QR_READONLY;
1681 if (!strcmp(bstr("permanent"), "yes")) {
1682 er_flags |= QR_PERMANENT;
1684 er_flags &= ~QR_PERMANENT;
1687 if (!strcmp(bstr("network"), "yes")) {
1688 er_flags |= QR_NETWORK;
1690 er_flags &= ~QR_NETWORK;
1693 if (!strcmp(bstr("directory"), "yes")) {
1694 er_flags |= QR_DIRECTORY;
1696 er_flags &= ~QR_DIRECTORY;
1699 if (!strcmp(bstr("ulallowed"), "yes")) {
1700 er_flags |= QR_UPLOAD;
1702 er_flags &= ~QR_UPLOAD;
1705 if (!strcmp(bstr("dlallowed"), "yes")) {
1706 er_flags |= QR_DOWNLOAD;
1708 er_flags &= ~QR_DOWNLOAD;
1711 if (!strcmp(bstr("visdir"), "yes")) {
1712 er_flags |= QR_VISDIR;
1714 er_flags &= ~QR_VISDIR;
1717 strcpy(buf, bstr("anon"));
1719 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1720 if (!strcmp(buf, "anononly"))
1721 er_flags |= QR_ANONONLY;
1722 if (!strcmp(buf, "anon2"))
1723 er_flags |= QR_ANONOPT;
1726 if (!strcmp(bstr("bump"), "yes"))
1729 er_floor = atoi(bstr("er_floor"));
1731 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1732 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1734 serv_getln(buf, sizeof buf);
1735 if (buf[0] != '2') {
1736 strcpy(WC->ImportantMessage, &buf[4]);
1742 if (strlen(er_roomaide) > 0) {
1743 sprintf(buf, "SETA %s", er_roomaide);
1745 serv_getln(buf, sizeof buf);
1746 if (buf[0] != '2') {
1747 strcpy(WC->ImportantMessage, &buf[4]);
1748 display_main_menu();
1753 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1760 * \brief Display form for Invite, Kick, and show Who Knows a room
1762 void do_invt_kick(void) {
1763 char buf[SIZ], room[SIZ], username[SIZ];
1766 serv_getln(buf, sizeof buf);
1768 if (buf[0] != '2') {
1772 extract_token(room, &buf[4], 0, '|', sizeof room);
1774 strcpy(username, bstr("username"));
1776 if (strlen(bstr("kick_button")) > 0) {
1777 sprintf(buf, "KICK %s", username);
1779 serv_getln(buf, sizeof buf);
1781 if (buf[0] != '2') {
1782 strcpy(WC->ImportantMessage, &buf[4]);
1784 sprintf(WC->ImportantMessage,
1785 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1790 if (strlen(bstr("invite_button")) > 0) {
1791 sprintf(buf, "INVT %s", username);
1793 serv_getln(buf, sizeof buf);
1795 if (buf[0] != '2') {
1796 strcpy(WC->ImportantMessage, &buf[4]);
1798 sprintf(WC->ImportantMessage,
1799 _("<B><I>User %s invited to room %s.</I></B>\n"),
1810 * \brief Display form for Invite, Kick, and show Who Knows a room
1812 void display_whok(void)
1814 char buf[SIZ], room[SIZ], username[SIZ];
1817 serv_getln(buf, sizeof buf);
1819 if (buf[0] != '2') {
1823 extract_token(room, &buf[4], 0, '|', sizeof room);
1826 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1827 wprintf(_("The users listed below have access to this room. "
1828 "To remove a user from the access list, select the user "
1829 "name from the list and click 'Kick'."));
1830 wprintf("<br /><br />");
1832 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1833 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1834 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1836 serv_getln(buf, sizeof buf);
1837 if (buf[0] == '1') {
1838 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1839 extract_token(username, buf, 0, '|', sizeof username);
1840 wprintf("<OPTION>");
1845 wprintf("</SELECT><br />\n");
1847 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1848 wprintf("</FORM></CENTER>\n");
1850 wprintf("</TD><TD>");
1851 wprintf(_("To grant another user access to this room, enter the "
1852 "user name in the box below and click 'Invite'."));
1853 wprintf("<br /><br />");
1855 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1856 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1857 wprintf(_("Invite:"));
1859 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1860 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1861 "<input type=\"submit\" value=\"%s\">"
1862 "</FORM></CENTER>\n", _("Invite"));
1864 wprintf("</TD></TR></TABLE>\n");
1871 * \brief display the form for entering a new room
1873 void display_entroom(void)
1878 serv_puts("CRE8 0");
1879 serv_getln(buf, sizeof buf);
1881 if (buf[0] != '2') {
1882 strcpy(WC->ImportantMessage, &buf[4]);
1883 display_main_menu();
1887 output_headers(1, 1, 2, 0, 0, 0);
1888 wprintf("<div id=\"banner\">\n"
1889 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1890 "<SPAN CLASS=\"titlebar\">");
1891 wprintf(_("Create a new room"));
1893 "</TD></TR></TABLE>\n"
1894 "</div>\n<div id=\"content\">\n"
1897 wprintf("<div class=\"fix_scrollbar_bug\">"
1898 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1900 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1902 wprintf("<UL><LI>");
1903 wprintf(_("Name of room: "));
1904 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1907 wprintf(_("Resides on floor: "));
1909 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1910 for (i = 0; i < 128; ++i)
1911 if (strlen(floorlist[i]) > 0) {
1912 wprintf("<OPTION ");
1913 wprintf("VALUE=\"%d\">", i);
1914 escputs(floorlist[i]);
1915 wprintf("</OPTION>\n");
1917 wprintf("</SELECT>\n");
1920 * Our clever little snippet of JavaScript automatically selects
1921 * a public room if the view is set to Bulletin Board or wiki, and
1922 * it selects a mailbox room otherwise. The user can override this,
1923 * of course. We also disable the floor selector for mailboxes.
1926 wprintf(_("Default view for room: "));
1927 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1928 " if ( (this.form.er_view.value == 0) "
1929 " || (this.form.er_view.value == 6) ) { "
1930 " this.form.type[0].checked=true; "
1931 " this.form.er_floor.disabled = false; "
1934 " this.form.type[4].checked=true; "
1935 " this.form.er_floor.disabled = true; "
1938 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1939 wprintf("<OPTION %s VALUE=\"%d\">",
1940 ((i == 0) ? "SELECTED" : ""), i );
1941 escputs(viewdefs[i]);
1942 wprintf("</OPTION>\n");
1944 wprintf("</SELECT>\n");
1947 wprintf(_("Type of room:"));
1950 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1951 wprintf("CHECKED OnChange=\""
1952 " if (this.form.type[0].checked == true) { "
1953 " this.form.er_floor.disabled = false; "
1956 wprintf(_("Public (automatically appears to everyone)"));
1958 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1959 " if (this.form.type[1].checked == true) { "
1960 " this.form.er_floor.disabled = false; "
1963 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1965 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1966 " if (this.form.type[2].checked == true) { "
1967 " this.form.er_floor.disabled = false; "
1970 wprintf(_("Private - require password: "));
1971 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1973 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1974 " if (this.form.type[3].checked == true) { "
1975 " this.form.er_floor.disabled = false; "
1978 wprintf(_("Private - invitation only"));
1980 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1982 " if (this.form.type[4].checked == true) { "
1983 " this.form.er_floor.disabled = true; "
1986 wprintf(_("Personal (mailbox for you only)"));
1988 wprintf("\n</UL>\n");
1990 wprintf("<CENTER>\n");
1991 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1993 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1994 wprintf("</CENTER>\n");
1995 wprintf("</FORM>\n<hr />");
1996 serv_printf("MESG roomaccess");
1997 serv_getln(buf, sizeof buf);
1998 if (buf[0] == '1') {
2001 wprintf("</td></tr></table></div>\n");
2009 * \brief support function for entroom() -- sets the default view
2011 void er_set_default_view(int newview) {
2024 serv_getln(buf, sizeof buf);
2025 if (buf[0] != '2') return;
2027 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2028 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2029 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2030 rm_bits1 = extract_int(&buf[4], 3);
2031 rm_floor = extract_int(&buf[4], 4);
2032 rm_listorder = extract_int(&buf[4], 5);
2033 rm_bits2 = extract_int(&buf[4], 7);
2035 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2036 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2037 rm_listorder, newview, rm_bits2
2039 serv_getln(buf, sizeof buf);
2045 * \brief enter a new room
2052 char er_password[SIZ];
2057 if (strlen(bstr("ok_button")) == 0) {
2058 strcpy(WC->ImportantMessage,
2059 _("Cancelled. No new room was created."));
2060 display_main_menu();
2063 strcpy(er_name, bstr("er_name"));
2064 strcpy(er_type, bstr("type"));
2065 strcpy(er_password, bstr("er_password"));
2066 er_floor = atoi(bstr("er_floor"));
2067 er_view = atoi(bstr("er_view"));
2070 if (!strcmp(er_type, "hidden"))
2072 if (!strcmp(er_type, "passworded"))
2074 if (!strcmp(er_type, "invonly"))
2076 if (!strcmp(er_type, "personal"))
2079 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2080 er_name, er_num_type, er_password, er_floor, 0, er_view);
2082 serv_getln(buf, sizeof buf);
2083 if (buf[0] != '2') {
2084 strcpy(WC->ImportantMessage, &buf[4]);
2085 display_main_menu();
2089 do_change_view(er_view); /* Now go there */
2094 * \brief display the screen to enter a private room
2096 void display_private(char *rname, int req_pass)
2098 output_headers(1, 1, 2, 0, 0, 0);
2099 wprintf("<div id=\"banner\">\n"
2100 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2101 "<SPAN CLASS=\"titlebar\">");
2102 wprintf(_("Go to a hidden room"));
2104 "</TD></TR></TABLE>\n"
2105 "</div>\n<div id=\"content\">\n"
2108 wprintf("<div class=\"fix_scrollbar_bug\">"
2109 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2111 wprintf("<CENTER>\n");
2113 wprintf(_("If you know the name of a hidden (guess-name) or "
2114 "passworded room, you can enter that room by typing "
2115 "its name below. Once you gain access to a private "
2116 "room, it will appear in your regular room listings "
2117 "so you don't have to keep returning here."));
2118 wprintf("\n<br /><br />");
2120 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2122 wprintf("<table border=\"0\" cellspacing=\"5\" "
2123 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2125 wprintf(_("Enter room name:"));
2127 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2128 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2131 wprintf("</TD></TR><TR><TD>");
2132 wprintf(_("Enter room password:"));
2133 wprintf("</TD><TD>");
2134 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2136 wprintf("</TD></TR></TABLE><br />\n");
2138 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2140 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2144 wprintf("</FORM>\n");
2145 wprintf("</td></tr></table></div>\n");
2150 * \brief goto a private room
2152 void goto_private(void)
2157 if (strlen(bstr("ok_button")) == 0) {
2158 display_main_menu();
2161 strcpy(hold_rm, WC->wc_roomname);
2162 strcpy(buf, "GOTO ");
2163 strcat(buf, bstr("gr_name"));
2165 strcat(buf, bstr("gr_pass"));
2167 serv_getln(buf, sizeof buf);
2169 if (buf[0] == '2') {
2170 smart_goto(bstr("gr_name"));
2173 if (!strncmp(buf, "540", 3)) {
2174 display_private(bstr("gr_name"), 1);
2177 output_headers(1, 1, 1, 0, 0, 0);
2178 wprintf("%s\n", &buf[4]);
2185 * \brief display the screen to zap a room
2187 void display_zap(void)
2189 output_headers(1, 1, 2, 0, 0, 0);
2191 wprintf("<div id=\"banner\">\n");
2192 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2193 wprintf("<SPAN CLASS=\"titlebar\">");
2194 wprintf(_("Zap (forget/unsubscribe) the current room"));
2195 wprintf("</SPAN>\n");
2196 wprintf("</TD></TR></TABLE>\n");
2197 wprintf("</div>\n<div id=\"content\">\n");
2199 wprintf(_("If you select this option, <em>%s</em> will "
2200 "disappear from your room list. Is this what you wish "
2201 "to do?<br />\n"), WC->wc_roomname);
2203 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2204 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2206 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2207 wprintf("</FORM>\n");
2218 char final_destination[SIZ];
2221 * If the forget-room routine fails for any reason, we fall back
2222 * to the current room; otherwise, we go to the Lobby
2224 strcpy(final_destination, WC->wc_roomname);
2226 if (strlen(bstr("ok_button")) > 0) {
2227 serv_printf("GOTO %s", WC->wc_roomname);
2228 serv_getln(buf, sizeof buf);
2229 if (buf[0] == '2') {
2231 serv_getln(buf, sizeof buf);
2232 if (buf[0] == '2') {
2233 strcpy(final_destination, "_BASEROOM_");
2237 smart_goto(final_destination);
2243 * \brief Delete the current room
2245 void delete_room(void)
2249 serv_puts("KILL 1");
2250 serv_getln(buf, sizeof buf);
2251 if (buf[0] != '2') {
2252 strcpy(WC->ImportantMessage, &buf[4]);
2253 display_main_menu();
2256 smart_goto("_BASEROOM_");
2263 * \brief Perform changes to a room's network configuration
2265 void netedit(void) {
2274 if (strlen(bstr("line"))==0) {
2279 strcpy(line, bstr("prefix"));
2280 strcat(line, bstr("line"));
2281 strcat(line, bstr("suffix"));
2290 serv_getln(buf, sizeof buf);
2291 if (buf[0] != '1') {
2297 /** This loop works for add *or* remove. Spiffy, eh? */
2298 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2299 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2300 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2301 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2302 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2303 if ( (strcasecmp(cmpa0, cmpb0))
2304 || (strcasecmp(cmpa1, cmpb1)) ) {
2305 fprintf(fp, "%s\n", buf);
2311 serv_getln(buf, sizeof buf);
2312 if (buf[0] != '4') {
2318 while (fgets(buf, sizeof buf, fp) != NULL) {
2319 buf[strlen(buf)-1] = 0;
2323 if (strlen(bstr("add_button")) > 0) {
2335 * \brief Convert a room name to a folder-ish-looking name.
2336 * \param folder the folderish name
2337 * \param room the room name
2338 * \param floor the floor name
2339 * \param is_mailbox is it a mailbox?
2341 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2346 * For mailboxes, just do it straight...
2349 sprintf(folder, "My folders|%s", room);
2353 * Otherwise, prefix the floor name as a "public folders" moniker
2356 sprintf(folder, "%s|%s", floorlist[floor], room);
2360 * Replace "\" characters with "|" for pseudo-folder-delimiting
2362 for (i=0; i<strlen(folder); ++i) {
2363 if (folder[i] == '\\') folder[i] = '|';
2371 * \brief Back end for change_view()
2372 * \param newview set newview???
2374 void do_change_view(int newview) {
2377 serv_printf("VIEW %d", newview);
2378 serv_getln(buf, sizeof buf);
2379 WC->wc_view = newview;
2380 smart_goto(WC->wc_roomname);
2386 * \brief Change the view for this room
2388 void change_view(void) {
2391 view = atol(bstr("view"));
2392 do_change_view(view);
2397 * \brief One big expanded tree list view --- like a folder list
2398 * \param fold the folder to view
2399 * \param max_folders how many folders???
2400 * \param num_floors hom many floors???
2402 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2406 int has_subfolders = 0;
2409 parents = malloc(max_folders * sizeof(int));
2411 /** BEGIN TREE MENU */
2412 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2414 /** include NanoTree */
2415 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2417 /** initialize NanoTree */
2418 wprintf("<script type=\"text/javascript\"> \n"
2419 " showRootNode = false; \n"
2420 " sortNodes = false; \n"
2421 " dragable = false; \n"
2423 " function standardClick(treeNode) { \n"
2426 " var closedGif = 'static/folder_closed.gif'; \n"
2427 " var openGif = 'static/folder_open.gif'; \n"
2429 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2433 for (i=0; i<max_folders; ++i) {
2436 if ((i+1) < max_folders) {
2437 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2438 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2443 levels = num_tokens(fold[i].name, '|');
2444 parents[levels] = i;
2446 wprintf("var node%d = new TreeNode(%d, '", i, i);
2448 if (fold[i].selectable) {
2449 wprintf("<a href=\"dotgoto?room=");
2450 urlescputs(fold[i].room);
2455 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2457 else if (fold[i].hasnewmsgs) {
2458 wprintf("<SPAN CLASS=\"roomlist_new\">");
2461 wprintf("<SPAN CLASS=\"roomlist_old\">");
2463 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2468 if (has_subfolders) {
2469 wprintf("new Array(closedGif, openGif)");
2471 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2472 wprintf("'static/viewcontacts_16x.gif'");
2474 else if (fold[i].view == VIEW_CALENDAR) {
2475 wprintf("'static/calarea_16x.gif'");
2477 else if (fold[i].view == VIEW_TASKS) {
2478 wprintf("'static/taskmanag_16x.gif'");
2480 else if (fold[i].view == VIEW_NOTES) {
2481 wprintf("'static/storenotes_16x.gif'");
2483 else if (fold[i].view == VIEW_MAILBOX) {
2484 wprintf("'static/privatemess_16x.gif'");
2487 wprintf("'static/chatrooms_16x.gif'");
2490 urlescputs(fold[i].name);
2494 wprintf("rootNode.addChild(node%d);\n", i);
2497 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2501 wprintf("container = document.getElementById('roomlist_div'); \n"
2507 /** END TREE MENU */
2511 * \brief Boxes and rooms and lists ... oh my!
2512 * \param fold the folder to view
2513 * \param max_folders how many folders???
2514 * \param num_floors hom many floors???
2516 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2518 char floor_name[256];
2519 char old_floor_name[256];
2521 int levels, oldlevels;
2524 static int columns = 3;
2525 int boxes_per_column = 0;
2526 int current_column = 0;
2529 strcpy(floor_name, "");
2530 strcpy(old_floor_name, "");
2533 while (nf % columns != 0) ++nf;
2534 boxes_per_column = (nf / columns);
2535 if (boxes_per_column < 1) boxes_per_column = 1;
2537 /** Outer table (for columnization) */
2538 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2539 "<tr><td valign=top>");
2543 for (i=0; i<max_folders; ++i) {
2545 levels = num_tokens(fold[i].name, '|');
2546 extract_token(floor_name, fold[i].name, 0,
2547 '|', sizeof floor_name);
2549 if ( (strcasecmp(floor_name, old_floor_name))
2550 && (strlen(old_floor_name) > 0) ) {
2552 do_template("endbox");
2555 if ((num_boxes % boxes_per_column) == 0) {
2557 if (current_column < columns) {
2558 wprintf("</td><td valign=top>\n");
2562 strcpy(old_floor_name, floor_name);
2565 /** Begin inner box */
2566 stresc(boxtitle, floor_name, 1, 0);
2567 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2568 do_template("beginbox");
2575 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2576 if (fold[i].selectable) {
2577 wprintf("<a href=\"dotgoto?room=");
2578 urlescputs(fold[i].room);
2584 if (fold[i].hasnewmsgs) {
2585 wprintf("<SPAN CLASS=\"roomlist_new\">");
2588 wprintf("<SPAN CLASS=\"roomlist_old\">");
2590 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2593 if (fold[i].selectable) {
2599 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2600 wprintf(" (INBOX)");
2602 wprintf("<br />\n");
2605 /** End the final inner box */
2606 do_template("endbox");
2608 wprintf("</TD></TR></TABLE>\n");
2612 * \brief print a floor div???
2613 * \param which_floordiv name of the floordiv???
2615 void set_floordiv_expanded(char *which_floordiv) {
2616 begin_ajax_response();
2617 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2618 end_ajax_response();
2622 * \brief view the iconbar
2623 * \param fold the folder to view
2624 * \param max_folders how many folders???
2625 * \param num_floors hom many floors???
2627 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2629 char floor_name[256];
2630 char old_floor_name[256];
2631 char floordivtitle[256];
2632 char floordiv_id[32];
2633 int levels, oldlevels;
2635 int num_drop_targets = 0;
2638 strcpy(floor_name, "");
2639 strcpy(old_floor_name, "");
2643 for (i=0; i<max_folders; ++i) {
2645 levels = num_tokens(fold[i].name, '|');
2646 extract_token(floor_name, fold[i].name, 0,
2647 '|', sizeof floor_name);
2649 if ( (strcasecmp(floor_name, old_floor_name))
2650 && (strlen(old_floor_name) > 0) ) {
2651 /** End inner box */
2653 wprintf("</div>\n"); /** floordiv */
2655 strcpy(old_floor_name, floor_name);
2659 stresc(floordivtitle, floor_name, 0, 0);
2660 sprintf(floordiv_id, "floordiv%d", i);
2661 wprintf("<span class=\"ib_roomlist_floor\" "
2662 "onClick=\"expand_floor('%s')\">"
2663 "%s</span><br>\n", floordiv_id, floordivtitle);
2664 wprintf("<div id=\"%s\" style=\"display:%s\">",
2666 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2673 wprintf("<div id=\"roomdiv%d\">", i);
2675 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2677 /** choose the icon */
2678 if (fold[i].view == VIEW_ADDRESSBOOK) {
2679 icon = "viewcontacts_16x.gif" ;
2681 else if (fold[i].view == VIEW_CALENDAR) {
2682 icon = "calarea_16x.gif" ;
2684 else if (fold[i].view == VIEW_TASKS) {
2685 icon = "taskmanag_16x.gif" ;
2687 else if (fold[i].view == VIEW_NOTES) {
2688 icon = "storenotes_16x.gif" ;
2690 else if (fold[i].view == VIEW_MAILBOX) {
2691 icon = "privatemess_16x.gif" ;
2694 icon = "chatrooms_16x.gif" ;
2697 if (fold[i].selectable) {
2698 wprintf("<a href=\"dotgoto?room=");
2699 urlescputs(fold[i].room);
2701 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2706 if (fold[i].hasnewmsgs) {
2707 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2710 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2712 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2714 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2715 wprintf(" (INBOX)");
2718 if (fold[i].selectable) {
2725 wprintf("</div>\n"); /** roomdiv */
2728 wprintf("</div>\n"); /** floordiv */
2731 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2732 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2734 num_drop_targets = 0;
2736 for (i=0; i<max_folders; ++i) {
2737 levels = num_tokens(fold[i].name, '|');
2739 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2740 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2741 jsescputs(fold[i].room);
2747 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2748 if (strlen(WC->floordiv_expanded) > 1) {
2749 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2753 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2759 * \brief Show the room list.
2760 * (only should get called by
2761 * knrooms() because that's where output_headers() is called from)
2762 * \param viewpref the view preferences???
2765 void list_all_rooms_by_floor(char *viewpref) {
2768 struct folder *fold = NULL;
2770 int max_folders = 0;
2771 int alloc_folders = 0;
2775 int num_floors = 1; /** add an extra one for private folders */
2777 /** If our cached folder list is very old, burn it. */
2778 if (WC->cache_fold != NULL) {
2779 if ((time(NULL) - WC->cache_timestamp) > 300) {
2780 free(WC->cache_fold);
2781 WC->cache_fold = NULL;
2785 /** Can we do the iconbar roomlist from cache? */
2786 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2787 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2791 /** Grab the floor table so we know how to build the list... */
2794 /** Start with the mailboxes */
2797 fold = malloc(sizeof(struct folder));
2798 memset(fold, 0, sizeof(struct folder));
2799 strcpy(fold[0].name, "My folders");
2800 fold[0].is_mailbox = 1;
2802 /** Then add floors */
2804 serv_getln(buf, sizeof buf);
2805 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2806 if (max_folders >= alloc_folders) {
2807 alloc_folders = max_folders + 100;
2808 fold = realloc(fold,
2809 alloc_folders * sizeof(struct folder));
2811 memset(&fold[max_folders], 0, sizeof(struct folder));
2812 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2817 /** Now add rooms */
2819 serv_getln(buf, sizeof buf);
2820 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2821 if (max_folders >= alloc_folders) {
2822 alloc_folders = max_folders + 100;
2823 fold = realloc(fold,
2824 alloc_folders * sizeof(struct folder));
2826 memset(&fold[max_folders], 0, sizeof(struct folder));
2827 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2828 ra_flags = extract_int(buf, 5);
2829 flags = extract_int(buf, 1);
2830 fold[max_folders].floor = extract_int(buf, 2);
2831 fold[max_folders].hasnewmsgs =
2832 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2833 if (flags & QR_MAILBOX) {
2834 fold[max_folders].is_mailbox = 1;
2836 fold[max_folders].view = extract_int(buf, 6);
2837 room_to_folder(fold[max_folders].name,
2838 fold[max_folders].room,
2839 fold[max_folders].floor,
2840 fold[max_folders].is_mailbox);
2841 fold[max_folders].selectable = 1;
2845 /** Bubble-sort the folder list */
2846 for (i=0; i<max_folders; ++i) {
2847 for (j=0; j<(max_folders-1)-i; ++j) {
2848 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2849 swap = strcasecmp(fold[j].name, fold[j+1].name);
2852 if ( (fold[j+1].is_mailbox)
2853 && (!fold[j].is_mailbox)) {
2861 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2862 memcpy(&fold[j], &fold[j+1],
2863 sizeof(struct folder));
2864 memcpy(&fold[j+1], &ftmp,
2865 sizeof(struct folder));
2871 if (!strcasecmp(viewpref, "folders")) {
2872 do_folder_view(fold, max_folders, num_floors);
2874 else if (!strcasecmp(viewpref, "hackish_view")) {
2875 for (i=0; i<max_folders; ++i) {
2876 escputs(fold[i].name);
2877 wprintf("<br />\n");
2880 else if (!strcasecmp(viewpref, "iconbar")) {
2881 do_iconbar_view(fold, max_folders, num_floors);
2884 do_rooms_view(fold, max_folders, num_floors);
2887 /* Don't free the folder list ... cache it for future use! */
2888 if (WC->cache_fold != NULL) {
2889 free(WC->cache_fold);
2891 WC->cache_fold = fold;
2892 WC->cache_max_folders = max_folders;
2893 WC->cache_num_floors = num_floors;
2894 WC->cache_timestamp = time(NULL);
2899 * \brief Do either a known rooms list or a folders list, depending on the
2904 char listviewpref[SIZ];
2906 output_headers(1, 1, 2, 0, 0, 0);
2908 /** Determine whether the user is trying to change views */
2909 if (bstr("view") != NULL) {
2910 if (strlen(bstr("view")) > 0) {
2911 set_preference("roomlistview", bstr("view"), 1);
2915 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2917 if ( (strcasecmp(listviewpref, "folders"))
2918 && (strcasecmp(listviewpref, "table")) ) {
2919 strcpy(listviewpref, "rooms");
2923 wprintf("<div id=\"banner\">\n"
2924 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2925 "<SPAN CLASS=\"titlebar\">"
2927 if (!strcasecmp(listviewpref, "rooms")) {
2928 wprintf(_("Room list"));
2930 if (!strcasecmp(listviewpref, "folders")) {
2931 wprintf(_("Folder list"));
2933 if (!strcasecmp(listviewpref, "table")) {
2934 wprintf(_("Room list"));
2936 wprintf("</SPAN></TD>\n");
2938 /** offer the ability to switch views */
2939 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2940 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2941 "OnChange=\"location.href=roomlistomatic.newview.options"
2942 "[selectedIndex].value\">\n");
2944 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
2947 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2950 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
2951 "View as folder list"
2953 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2956 wprintf("</SELECT><br />");
2958 wprintf("</FORM></TD></TR></TABLE>\n");
2961 "<div id=\"content\">\n");
2963 /** Display the room list in the user's preferred format */
2964 list_all_rooms_by_floor(listviewpref);
2971 * \brief Set the message expire policy for this room and/or floor
2973 void set_room_policy(void) {
2976 if (strlen(bstr("ok_button")) == 0) {
2977 strcpy(WC->ImportantMessage,
2978 _("Cancelled. Changes were not saved."));
2983 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2984 serv_getln(buf, sizeof buf);
2985 strcpy(WC->ImportantMessage, &buf[4]);
2987 if (WC->axlevel >= 6) {
2988 strcat(WC->ImportantMessage, "<br />\n");
2989 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2990 serv_getln(buf, sizeof buf);
2991 strcat(WC->ImportantMessage, &buf[4]);