5 * \defgroup RoomOps Lots of different room-related operations.
10 char floorlist[128][SIZ]; /**< list of our floor names */
12 char *viewdefs[7]; /**< the different kinds of available views */
15 * \brief initialize the viewdefs with localized strings
17 void initialize_viewdefs(void) {
18 viewdefs[0] = _("Bulletin Board");
19 viewdefs[1] = _("Mail Folder");
20 viewdefs[2] = _("Address Book");
21 viewdefs[3] = _("Calendar");
22 viewdefs[4] = _("Task List");
23 viewdefs[5] = _("Notes List");
24 viewdefs[6] = _("Wiki");
29 * \brief load the list of floors
31 void load_floorlist(void)
36 for (a = 0; a < 128; ++a)
40 serv_getln(buf, sizeof buf);
42 strcpy(floorlist[0], "Main Floor");
45 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
46 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
52 * \brief remove a room from the march list
54 void remove_march(char *aaa)
56 struct march *mptr, *mptr2;
58 if (WC->march == NULL)
61 if (!strcasecmp(WC->march->march_name, aaa)) {
62 mptr = WC->march->next;
68 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
69 if (!strcasecmp(mptr->march_name, aaa)) {
70 mptr2->next = mptr->next;
83 * \brief display rooms in tree structure???
84 * \param rp the roomlist to build a tree from
86 void room_tree_list(struct roomlisting *rp)
95 room_tree_list(rp->lnext);
97 strcpy(rmname, rp->rlname);
100 wprintf("<a href=\"dotgoto&room=");
104 escputs1(rmname, 1, 1);
105 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
107 else if (f & QR_DIRECTORY)
109 else if (f & QR_NETWORK)
113 wprintf("</A><TT> </TT>\n");
115 room_tree_list(rp->rnext);
121 * \brief Room ordering stuff (compare first by floor, then by order)
122 * \param r1 first roomlist to compare
123 * \param r2 second roomlist co compare
124 * \return are they the same???
126 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
128 if ((r1 == NULL) && (r2 == NULL))
134 if (r1->rlfloor < r2->rlfloor)
136 if (r1->rlfloor > r2->rlfloor)
138 if (r1->rlorder < r2->rlorder)
140 if (r1->rlorder > r2->rlorder)
147 * \brief Common code for all room listings
148 * \param variety what???
150 void listrms(char *variety)
155 struct roomlisting *rl = NULL;
156 struct roomlisting *rp;
157 struct roomlisting *rs;
160 /** Ask the server for a room list */
162 serv_getln(buf, sizeof buf);
167 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
169 rp = malloc(sizeof(struct roomlisting));
170 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
171 rp->rlflags = extract_int(buf, 1);
172 rp->rlfloor = extract_int(buf, 2);
173 rp->rlorder = extract_int(buf, 3);
182 if (rordercmp(rp, rs) < 0) {
183 if (rs->lnext == NULL) {
190 if (rs->rnext == NULL) {
203 * If no rooms were listed, print an nbsp to make the cell
204 * borders show up anyway.
206 if (num_rooms == 0) wprintf(" ");
211 * \brief list all forgotten rooms
213 void zapped_list(void)
215 output_headers(1, 1, 0, 0, 0, 0);
217 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
218 do_template("beginbox");
222 wprintf("<br /><br />\n");
223 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
224 do_template("endbox");
230 * \brief read this room's info file (set v to 1 for verbose mode)
237 serv_getln(buf, sizeof buf);
250 * \brief Display room banner icon.
251 * The server doesn't actually
252 * need the room name, but we supply it in order to
253 * keep the browser from using a cached icon from
256 void embed_room_graphic(void) {
259 serv_puts("OIMG _roompic_");
260 serv_getln(buf, sizeof buf);
262 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
263 urlescputs(WC->wc_roomname);
266 serv_getln(buf, sizeof buf);
268 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
269 wprintf("<img height=48 width=48 src=\""
270 "static/viewcontacts_48x.gif"
274 else if (WC->wc_view == VIEW_CALENDAR) {
275 wprintf("<img height=48 width=48 src=\""
276 "static/calarea_48x.gif"
280 else if (WC->wc_view == VIEW_TASKS) {
281 wprintf("<img height=48 width=48 src=\""
282 "static/taskmanag_48x.gif"
286 else if (WC->wc_view == VIEW_NOTES) {
287 wprintf("<img height=48 width=48 src=\""
288 "static/storenotes_48x.gif"
292 else if (WC->wc_view == VIEW_MAILBOX) {
293 wprintf("<img height=48 width=48 src=\""
294 "static/privatemess_48x.gif"
299 wprintf("<img height=48 width=48 src=\""
300 "static/chatrooms_48x.gif"
310 * \brief Display the current view and offer an option to change it
312 void embed_view_o_matic(void) {
315 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
316 "<span class=\"room_banner_new_messages\">");
317 wprintf(_("View as:"));
319 "<SELECT NAME=\"newview\" SIZE=\"1\" "
320 "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif;"
321 " font-size: 7pt; background: #444455; color: #ddddcc;\" "
322 "OnChange=\"location.href=viewomatic.newview.options"
323 "[selectedIndex].value\">\n");
325 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
327 * Only offer the views that make sense, given the default
328 * view for the room. For example, don't offer a Calendar
329 * view in a non-Calendar room.
333 || (i == WC->wc_default_view)
334 || ( (i == 0) && (WC->wc_default_view == 1) )
335 || ( (i == 1) && (WC->wc_default_view == 0) )
338 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
339 ((i == WC->wc_view) ? "SELECTED" : ""),
341 escputs(viewdefs[i]);
342 wprintf("</OPTION>\n");
345 wprintf("</select></span></form>\n");
350 * \brief view room banner
352 * \param navbar_style
354 void embed_room_banner(char *got, int navbar_style) {
358 * We need to have the information returned by a GOTO server command.
359 * If it isn't supplied, we fake it by issuing our own GOTO.
362 serv_printf("GOTO %s", WC->wc_roomname);
363 serv_getln(fakegot, sizeof fakegot);
367 /** The browser needs some information for its own use */
368 wprintf("<script type=\"text/javascript\"> \n"
369 " room_is_trash = %d; \n"
375 * If the user happens to select the "make this my start page" link,
376 * we want it to remember the URL as a "/dotskip" one instead of
377 * a "skip" or "gotonext" or something like that.
379 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
382 /** Check for new mail. */
383 WC->new_mail = extract_int(&got[4], 9);
384 WC->wc_view = extract_int(&got[4], 11);
386 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
387 svprintf("NUMMSGS", WCS_STRING,
388 _("%d new of %d messages"),
389 extract_int(&got[4], 1),
390 extract_int(&got[4], 2)
392 svcallback("ROOMPIC", embed_room_graphic);
393 svcallback("ROOMINFO", readinfo);
394 svcallback("VIEWOMATIC", embed_view_o_matic);
395 svcallback("START", offer_start_page);
397 do_template("roombanner");
398 if (navbar_style != navbar_none) {
400 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
401 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
404 if (navbar_style == navbar_default) wprintf(
406 "<a href=\"ungoto\">"
407 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
408 "<span class=\"navbar_link\">%s</span></A>"
409 "</td>\n", _("Ungoto")
412 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
415 "<a href=\"readnew\">"
416 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
417 "<span class=\"navbar_link\">%s</span></A>"
418 "</td>\n", _("Read new messages")
422 if (navbar_style == navbar_default) {
423 switch(WC->wc_view) {
424 case VIEW_ADDRESSBOOK:
427 "<a href=\"readfwd\">"
428 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
430 "<span class=\"navbar_link\">"
432 "</span></a></td>\n", _("View contacts")
438 "<a href=\"readfwd?calview=day\">"
439 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
441 "<span class=\"navbar_link\">"
443 "</span></a></td>\n", _("Day view")
447 "<a href=\"readfwd?calview=month\">"
448 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
450 "<span class=\"navbar_link\">"
452 "</span></a></td>\n", _("Month view")
458 "<a href=\"readfwd\">"
459 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
461 "<span class=\"navbar_link\">"
463 "</span></a></td>\n", _("View tasks")
469 "<a href=\"readfwd\">"
470 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
472 "<span class=\"navbar_link\">"
474 "</span></a></td>\n", _("View notes")
480 "<a href=\"readfwd\">"
481 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
483 "<span class=\"navbar_link\">"
485 "</span></a></td>\n", _("View message list")
491 "<a href=\"readfwd\">"
492 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
494 "<span class=\"navbar_link\">"
496 "</span></a></td>\n", _("Read all messages")
502 if (navbar_style == navbar_default) {
503 switch(WC->wc_view) {
504 case VIEW_ADDRESSBOOK:
506 "<td><a href=\"display_enter\">"
507 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
508 "border=\"0\"><span class=\"navbar_link\">"
510 "</span></a></td>\n", _("Add new contact")
515 "<td><a href=\"display_enter\">"
516 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
517 "border=\"0\"><span class=\"navbar_link\">"
519 "</span></a></td>\n", _("Add new event")
524 "<td><a href=\"display_enter\">"
525 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
526 "border=\"0\"><span class=\"navbar_link\">"
528 "</span></a></td>\n", _("Add new task")
533 "<td><a href=\"display_enter\">"
534 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
535 "border=\"0\"><span class=\"navbar_link\">"
537 "</span></a></td>\n", _("Add new note")
541 /* Don't let users create unlinked pages. */
545 "<td><a href=\"display_enter\">"
546 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
547 "border=\"0\"><span class=\"navbar_link\">"
549 "</span></a></td>\n", _("Enter a message")
555 if (navbar_style == navbar_default) wprintf(
559 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
560 "<span class=\"navbar_link\">%s</span></a>"
562 _("Leave all messages marked as unread, go to next room with unread messages"),
566 if (navbar_style == navbar_default) wprintf(
568 "<a href=\"gotonext\" "
570 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
571 "<span class=\"navbar_link\">%s</span></a>"
573 _("Mark all messages as read, go to next room with unread messages"),
577 wprintf("</tr></table></div>\n");
587 * \brief back end routine to take the session to a new room
588 * \param gname room to go to
591 int gotoroom(char *gname)
594 static long ls = (-1L);
597 /** store ungoto information */
598 strcpy(WC->ugname, WC->wc_roomname);
601 /** move to the new room */
602 serv_printf("GOTO %s", gname);
603 serv_getln(buf, sizeof buf);
607 serv_puts("GOTO _BASEROOM_");
608 serv_getln(buf, sizeof buf);
615 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
616 WC->room_flags = extract_int(&buf[4], 4);
617 /* highest_msg_read = extract_int(&buf[4],6);
618 maxmsgnum = extract_int(&buf[4],5);
620 WC->is_mailbox = extract_int(&buf[4],7);
621 ls = extract_long(&buf[4], 6);
622 WC->wc_floor = extract_int(&buf[4], 10);
623 WC->wc_view = extract_int(&buf[4], 11);
624 WC->wc_default_view = extract_int(&buf[4], 12);
625 WC->wc_is_trash = extract_int(&buf[4], 13);
628 WC->is_room_aide = WC->is_aide;
630 WC->is_room_aide = (char) extract_int(&buf[4], 8);
632 remove_march(WC->wc_roomname);
633 if (!strcasecmp(gname, "_BASEROOM_"))
641 * \brief Locate the room on the march list which we most want to go to.
643 * is measured given a "weight" of preference based on various factors.
644 * \param desired_floor the room number on the citadel server
645 * \return the roomname
647 char *pop_march(int desired_floor)
649 static char TheRoom[128];
651 int TheOrder = 32767;
654 struct march *mptr = NULL;
656 strcpy(TheRoom, "_BASEROOM_");
657 if (WC->march == NULL)
660 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
662 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
663 weight = weight + 10000;
664 if (mptr->march_floor == desired_floor)
665 weight = weight + 5000;
667 weight = weight + ((128 - (mptr->march_floor)) * 128);
668 weight = weight + (128 - (mptr->march_order));
670 if (weight > TheWeight) {
672 strcpy(TheRoom, mptr->march_name);
673 TheFloor = mptr->march_floor;
674 TheOrder = mptr->march_order;
683 *\brief Goto next room having unread messages.
684 * We want to skip over rooms that the user has already been to, and take the
685 * user back to the lobby when done. The room we end up in is placed in
686 * newroom - which is set to 0 (the lobby) initially.
687 * We start the search in the current room rather than the beginning to prevent
688 * two or more concurrent users from dragging each other back to the same room.
693 struct march *mptr, *mptr2;
697 * First check to see if the march-mode list is already allocated.
698 * If it is, pop the first room off the list and go there.
701 if (WC->march == NULL) {
703 serv_getln(buf, sizeof buf);
705 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
706 mptr = (struct march *) malloc(sizeof(struct march));
708 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
709 mptr->march_floor = extract_int(buf, 2);
710 mptr->march_order = extract_int(buf, 3);
711 if (WC->march == NULL) {
715 while (mptr2->next != NULL)
721 * add _BASEROOM_ to the end of the march list, so the user will end up
722 * in the system base room (usually the Lobby>) at the end of the loop
724 mptr = (struct march *) malloc(sizeof(struct march));
726 strcpy(mptr->march_name, "_BASEROOM_");
727 if (WC->march == NULL) {
731 while (mptr2->next != NULL)
736 * ...and remove the room we're currently in, so a <G>oto doesn't make us
737 * walk around in circles
739 remove_march(WC->wc_roomname);
741 if (WC->march != NULL) {
742 strcpy(next_room, pop_march(-1));
744 strcpy(next_room, "_BASEROOM_");
748 smart_goto(next_room);
753 * \brief goto next room
754 * \param next_room next room to go to
756 void smart_goto(char *next_room) {
764 * \brief mark all messages in current room as having been read
766 void slrp_highest(void)
771 serv_puts("SLRP HIGHEST");
772 serv_getln(buf, sizeof buf);
774 wprintf("<EM>%s</EM><br />\n", &buf[4]);
781 * \brief un-goto the previous room
787 if (!strcmp(WC->ugname, "")) {
788 smart_goto(WC->wc_roomname);
791 serv_printf("GOTO %s", WC->ugname);
792 serv_getln(buf, sizeof buf);
794 smart_goto(WC->wc_roomname);
797 if (WC->uglsn >= 0L) {
798 serv_printf("SLRP %ld", WC->uglsn);
799 serv_getln(buf, sizeof buf);
801 strcpy(buf, WC->ugname);
802 strcpy(WC->ugname, "");
811 * \brief Set/clear/read the "self-service list subscribe" flag for a room
813 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
814 * \return return the new value.
817 int self_service(int newval) {
818 int current_value = 0;
824 int flags, floor, order, view, flags2;
827 serv_getln(buf, sizeof buf);
828 if (buf[0] != '2') return(0);
830 extract_token(name, &buf[4], 0, '|', sizeof name);
831 extract_token(password, &buf[4], 1, '|', sizeof password);
832 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
833 flags = extract_int(&buf[4], 3);
834 floor = extract_int(&buf[4], 4);
835 order = extract_int(&buf[4], 5);
836 view = extract_int(&buf[4], 6);
837 flags2 = extract_int(&buf[4], 7);
839 if (flags2 & QR2_SELFLIST) {
847 flags2 = flags2 | QR2_SELFLIST;
849 else if (newval == 0) {
850 flags2 = flags2 & ~QR2_SELFLIST;
853 return(current_value);
856 if (newval != current_value) {
857 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
858 name, password, dirname, flags,
859 floor, order, view, flags2);
860 serv_getln(buf, sizeof buf);
873 * \brief display the form for editing a room
875 void display_editroom(void)
880 char remote_room[SIZ];
883 char er_password[10];
885 char er_roomaide[26];
891 char *not_shared_with;
898 if (strlen(tab) == 0) tab = "admin";
902 serv_getln(buf, sizeof buf);
905 strcpy(WC->ImportantMessage, &buf[4]);
909 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
910 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
911 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
912 er_flags = extract_int(&buf[4], 3);
913 er_floor = extract_int(&buf[4], 4);
915 output_headers(1, 1, 1, 0, 0, 0);
917 /** print the tabbed dialog */
919 "<div class=\"fix_scrollbar_bug\">"
920 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
922 "<TD> </TD>\n");
924 if (!strcmp(tab, "admin")) {
925 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
928 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
930 wprintf(_("Administration"));
931 if (!strcmp(tab, "admin")) {
932 wprintf("</SPAN></TD>\n");
935 wprintf("</A></TD>\n");
938 wprintf("<TD> </TD>\n");
940 if (!strcmp(tab, "config")) {
941 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
944 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
946 wprintf(_("Configuration"));
947 if (!strcmp(tab, "config")) {
948 wprintf("</SPAN></TD>\n");
951 wprintf("</A></TD>\n");
954 wprintf("<TD> </TD>\n");
956 if (!strcmp(tab, "expire")) {
957 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
960 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
962 wprintf(_("Message expire policy"));
963 if (!strcmp(tab, "expire")) {
964 wprintf("</SPAN></TD>\n");
967 wprintf("</A></TD>\n");
970 wprintf("<TD> </TD>\n");
972 if (!strcmp(tab, "access")) {
973 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
976 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
978 wprintf(_("Access controls"));
979 if (!strcmp(tab, "access")) {
980 wprintf("</SPAN></TD>\n");
983 wprintf("</A></TD>\n");
986 wprintf("<TD> </TD>\n");
988 if (!strcmp(tab, "sharing")) {
989 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
992 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
994 wprintf(_("Sharing"));
995 if (!strcmp(tab, "sharing")) {
996 wprintf("</SPAN></TD>\n");
999 wprintf("</A></TD>\n");
1002 wprintf("<TD> </TD>\n");
1004 if (!strcmp(tab, "listserv")) {
1005 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1008 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
1010 wprintf(_("Mailing list service"));
1011 if (!strcmp(tab, "listserv")) {
1012 wprintf("</SPAN></TD>\n");
1015 wprintf("</A></TD>\n");
1018 wprintf("<TD> </TD>\n");
1020 wprintf("</TR></TABLE></div>\n");
1021 /** end tabbed dialog */
1023 /** begin content of whatever tab is open now */
1024 wprintf("<div class=\"fix_scrollbar_bug\">"
1025 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
1028 if (!strcmp(tab, "admin")) {
1030 "<LI><a href=\"delete_room\" "
1031 "onClick=\"return confirm('");
1032 wprintf(_("Are you sure you want to delete this room?"));
1033 wprintf("');\">\n");
1034 wprintf(_("Delete this room"));
1036 "<LI><a href=\"display_editroompic\">\n");
1037 wprintf(_("Set or change the icon for this room's banner"));
1039 "<LI><a href=\"display_editinfo\">\n");
1040 wprintf(_("Edit this room's Info file"));
1045 if (!strcmp(tab, "config")) {
1046 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1048 wprintf("<UL><LI>");
1049 wprintf(_("Name of room: "));
1050 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1056 wprintf(_("Resides on floor: "));
1057 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1058 for (i = 0; i < 128; ++i)
1059 if (strlen(floorlist[i]) > 0) {
1060 wprintf("<OPTION ");
1062 wprintf("SELECTED ");
1063 wprintf("VALUE=\"%d\">", i);
1064 escputs(floorlist[i]);
1065 wprintf("</OPTION>\n");
1067 wprintf("</SELECT>\n");
1070 wprintf(_("Type of room:"));
1073 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1074 if ((er_flags & QR_PRIVATE) == 0)
1075 wprintf("CHECKED ");
1077 wprintf(_("Public room"));
1080 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1081 if ((er_flags & QR_PRIVATE) &&
1082 (er_flags & QR_GUESSNAME))
1083 wprintf("CHECKED ");
1085 wprintf(_("Private - guess name"));
1087 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1088 if ((er_flags & QR_PRIVATE) &&
1089 (er_flags & QR_PASSWORDED))
1090 wprintf("CHECKED ");
1092 wprintf(_("Private - require password:"));
1093 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1096 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1097 if ((er_flags & QR_PRIVATE)
1098 && ((er_flags & QR_GUESSNAME) == 0)
1099 && ((er_flags & QR_PASSWORDED) == 0))
1100 wprintf("CHECKED ");
1102 wprintf(_("Private - invitation only"));
1104 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1106 wprintf(_("If private, cause current users to forget room"));
1108 wprintf("\n</UL>\n");
1110 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1111 if (er_flags & QR_PREFONLY)
1112 wprintf("CHECKED ");
1114 wprintf(_("Preferred users only"));
1116 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1117 if (er_flags & QR_READONLY)
1118 wprintf("CHECKED ");
1120 wprintf(_("Read-only room"));
1122 /** directory stuff */
1123 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1124 if (er_flags & QR_DIRECTORY)
1125 wprintf("CHECKED ");
1127 wprintf(_("File directory room"));
1129 wprintf("\n<UL><LI>");
1130 wprintf(_("Directory name: "));
1131 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1134 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1135 if (er_flags & QR_UPLOAD)
1136 wprintf("CHECKED ");
1138 wprintf(_("Uploading allowed"));
1140 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1141 if (er_flags & QR_DOWNLOAD)
1142 wprintf("CHECKED ");
1144 wprintf(_("Downloading allowed"));
1146 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1147 if (er_flags & QR_VISDIR)
1148 wprintf("CHECKED ");
1150 wprintf(_("Visible directory"));
1153 /** end of directory stuff */
1155 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1156 if (er_flags & QR_NETWORK)
1157 wprintf("CHECKED ");
1159 wprintf(_("Network shared room"));
1161 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1162 if (er_flags & QR_PERMANENT)
1163 wprintf("CHECKED ");
1165 wprintf(_("Permanent (does not auto-purge)"));
1167 /** start of anon options */
1170 wprintf(_("Anonymous messages"));
1173 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1174 if (((er_flags & QR_ANONONLY) == 0)
1175 && ((er_flags & QR_ANONOPT) == 0))
1176 wprintf("CHECKED ");
1178 wprintf(_("No anonymous messages"));
1180 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1181 if (er_flags & QR_ANONONLY)
1182 wprintf("CHECKED ");
1184 wprintf(_("All messages are anonymous"));
1186 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1187 if (er_flags & QR_ANONOPT)
1188 wprintf("CHECKED ");
1190 wprintf(_("Prompt user when entering messages"));
1193 /* end of anon options */
1196 wprintf(_("Room aide: "));
1198 serv_getln(buf, sizeof buf);
1199 if (buf[0] != '2') {
1200 wprintf("<EM>%s</EM>\n", &buf[4]);
1202 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1203 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1206 wprintf("</UL><CENTER>\n");
1207 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1208 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1210 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1218 /** Sharing the room with other Citadel nodes... */
1219 if (!strcmp(tab, "sharing")) {
1221 shared_with = strdup("");
1222 not_shared_with = strdup("");
1224 /** Learn the current configuration */
1225 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1226 serv_getln(buf, sizeof buf);
1227 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1228 extract_token(node, buf, 0, '|', sizeof node);
1229 not_shared_with = realloc(not_shared_with,
1230 strlen(not_shared_with) + 32);
1231 strcat(not_shared_with, node);
1232 strcat(not_shared_with, "\n");
1236 serv_getln(buf, sizeof buf);
1237 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1238 extract_token(cmd, buf, 0, '|', sizeof cmd);
1239 extract_token(node, buf, 1, '|', sizeof node);
1240 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1241 if (!strcasecmp(cmd, "ignet_push_share")) {
1242 shared_with = realloc(shared_with,
1243 strlen(shared_with) + 32);
1244 strcat(shared_with, node);
1245 if (strlen(remote_room) > 0) {
1246 strcat(shared_with, "|");
1247 strcat(shared_with, remote_room);
1249 strcat(shared_with, "\n");
1253 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1254 extract_token(buf, shared_with, i, '\n', sizeof buf);
1255 extract_token(node, buf, 0, '|', sizeof node);
1256 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1257 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1258 if (!strcasecmp(node, cmd)) {
1259 remove_token(not_shared_with, j, '\n');
1264 /** Display the stuff */
1265 wprintf("<CENTER><br />"
1266 "<TABLE border=1 cellpadding=5><TR>"
1268 wprintf(_("Shared with"));
1269 wprintf("</I></B></TD>"
1271 wprintf(_("Not shared with"));
1272 wprintf("</I></B></TD></TR>\n"
1273 "<TR><TD VALIGN=TOP>\n");
1275 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1276 wprintf(_("Remote node name"));
1277 wprintf("</TD><TD>");
1278 wprintf(_("Remote room name"));
1279 wprintf("</TD><TD>");
1280 wprintf(_("Actions"));
1281 wprintf("</TD></TR>\n");
1283 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1284 extract_token(buf, shared_with, i, '\n', sizeof buf);
1285 extract_token(node, buf, 0, '|', sizeof node);
1286 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1287 if (strlen(node) > 0) {
1288 wprintf("<FORM METHOD=\"POST\" "
1289 "action=\"netedit\">"
1290 "<TR><TD>%s</TD>\n", node);
1293 if (strlen(remote_room) > 0) {
1294 escputs(remote_room);
1300 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1301 "VALUE=\"ignet_push_share|");
1303 if (strlen(remote_room) > 0) {
1305 urlescputs(remote_room);
1308 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1309 "VALUE=\"sharing\">\n");
1310 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1311 "VALUE=\"remove\">\n");
1312 wprintf("<INPUT TYPE=\"submit\" "
1313 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1314 wprintf("</TD></TR></FORM>\n");
1318 wprintf("</TABLE>\n");
1319 wprintf("</TD><TD VALIGN=TOP>\n");
1320 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1321 wprintf(_("Remote node name"));
1322 wprintf("</TD><TD>");
1323 wprintf(_("Remote room name"));
1324 wprintf("</TD><TD>");
1325 wprintf(_("Actions"));
1326 wprintf("</TD></TR>\n");
1328 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1329 extract_token(node, not_shared_with, i, '\n', sizeof node);
1330 if (strlen(node) > 0) {
1331 wprintf("<FORM METHOD=\"POST\" "
1332 "action=\"netedit\">"
1336 "<INPUT TYPE=\"INPUT\" "
1340 wprintf("<INPUT TYPE=\"hidden\" "
1342 "VALUE=\"ignet_push_share|");
1345 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1346 "VALUE=\"sharing\">\n");
1347 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1348 "VALUE=\"add\">\n");
1349 wprintf("<INPUT TYPE=\"submit\" "
1350 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1351 wprintf("</TD></TR></FORM>\n");
1355 wprintf("</TABLE>\n");
1356 wprintf("</TD></TR>"
1357 "</TABLE></CENTER><br />\n"
1358 "<I><B>%s</B><UL><LI>", _("Notes:"));
1359 wprintf(_("When sharing a room, "
1360 "it must be shared from both ends. Adding a node to "
1361 "the 'shared' list sends messages out, but in order to"
1362 " receive messages, the other nodes must be configured"
1363 " to send messages out to your system as well. "
1364 "<LI>If the remote room name is blank, it is assumed "
1365 "that the room name is identical on the remote node."
1366 "<LI>If the remote room name is different, the remote "
1367 "node must also configure the name of the room here."
1373 /** Mailing list management */
1374 if (!strcmp(tab, "listserv")) {
1376 wprintf("<br /><center>"
1377 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1378 "<TR><TD VALIGN=TOP>");
1380 wprintf(_("<i>The contents of this room are being "
1381 "mailed <b>as individual messages</b> "
1382 "to the following list recipients:"
1383 "</i><br /><br />\n"));
1386 serv_getln(buf, sizeof buf);
1387 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1388 extract_token(cmd, buf, 0, '|', sizeof cmd);
1389 if (!strcasecmp(cmd, "listrecp")) {
1390 extract_token(recp, buf, 1, '|', sizeof recp);
1393 wprintf(" <a href=\"netedit&cmd=remove&line="
1396 wprintf("&tab=listserv\">");
1397 wprintf(_("(remove)"));
1398 wprintf("</A><br />");
1401 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1402 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1403 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1404 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1405 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1406 wprintf("</FORM>\n");
1408 wprintf("</TD><TD VALIGN=TOP>\n");
1410 wprintf(_("<i>The contents of this room are being "
1411 "mailed <b>in digest form</b> "
1412 "to the following list recipients:"
1413 "</i><br /><br />\n"));
1416 serv_getln(buf, sizeof buf);
1417 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1418 extract_token(cmd, buf, 0, '|', sizeof cmd);
1419 if (!strcasecmp(cmd, "digestrecp")) {
1420 extract_token(recp, buf, 1, '|', sizeof recp);
1423 wprintf(" <a href=\"netedit&cmd=remove&line="
1426 wprintf("&tab=listserv\">");
1427 wprintf(_("(remove)"));
1428 wprintf("</A><br />");
1431 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1432 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1433 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1434 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1435 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1436 wprintf("</FORM>\n");
1438 wprintf("</TD></TR></TABLE><hr />\n");
1440 if (self_service(999) == 1) {
1441 wprintf(_("This room is configured to allow "
1442 "self-service subscribe/unsubscribe requests."));
1443 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1444 wprintf(_("Click to disable."));
1445 wprintf("</A><br />\n");
1446 wprintf(_("The URL for subscribe/unsubscribe is: "));
1447 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1448 (is_https ? "https" : "http"),
1452 wprintf(_("This room is <i>not</i> configured to allow "
1453 "self-service subscribe/unsubscribe requests."));
1454 wprintf(" <a href=\"toggle_self_service?newval=1&"
1456 wprintf(_("Click to enable."));
1457 wprintf("</A><br />\n");
1461 wprintf("</CENTER>\n");
1465 /** Mailing list management */
1466 if (!strcmp(tab, "expire")) {
1468 serv_puts("GPEX room");
1469 serv_getln(buf, sizeof buf);
1470 if (buf[0] == '2') {
1471 roompolicy = extract_int(&buf[4], 0);
1472 roomvalue = extract_int(&buf[4], 1);
1475 serv_puts("GPEX floor");
1476 serv_getln(buf, sizeof buf);
1477 if (buf[0] == '2') {
1478 floorpolicy = extract_int(&buf[4], 0);
1479 floorvalue = extract_int(&buf[4], 1);
1482 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1483 wprintf("<TABLE border=0 cellspacing=5>\n");
1484 wprintf("<TR><TD>");
1485 wprintf(_("Message expire policy for this room"));
1487 escputs(WC->wc_roomname);
1488 wprintf(")</TD><TD>");
1489 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1490 ((roompolicy == 0) ? "CHECKED" : "") );
1491 wprintf(_("Use the default policy for this floor"));
1492 wprintf("<br />\n");
1493 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1494 ((roompolicy == 1) ? "CHECKED" : "") );
1495 wprintf(_("Never automatically expire messages"));
1496 wprintf("<br />\n");
1497 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1498 ((roompolicy == 2) ? "CHECKED" : "") );
1499 wprintf(_("Expire by message count"));
1500 wprintf("<br />\n");
1501 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1502 ((roompolicy == 3) ? "CHECKED" : "") );
1503 wprintf(_("Expire by message age"));
1505 wprintf(_("Number of messages or days: "));
1506 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1507 wprintf("</TD></TR>\n");
1509 if (WC->axlevel >= 6) {
1510 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1511 wprintf("<TR><TD>");
1512 wprintf(_("Message expire policy for this floor"));
1514 escputs(floorlist[WC->wc_floor]);
1515 wprintf(")</TD><TD>");
1516 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1517 ((floorpolicy == 0) ? "CHECKED" : "") );
1518 wprintf(_("Use the system default"));
1519 wprintf("<br />\n");
1520 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1521 ((floorpolicy == 1) ? "CHECKED" : "") );
1522 wprintf(_("Never automatically expire messages"));
1523 wprintf("<br />\n");
1524 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1525 ((floorpolicy == 2) ? "CHECKED" : "") );
1526 wprintf(_("Expire by message count"));
1527 wprintf("<br />\n");
1528 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1529 ((floorpolicy == 3) ? "CHECKED" : "") );
1530 wprintf(_("Expire by message age"));
1532 wprintf(_("Number of messages or days: "));
1533 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1537 wprintf("<CENTER>\n");
1538 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1539 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1541 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1542 wprintf("</CENTER></TD><TR>\n");
1544 wprintf("</TABLE>\n"
1545 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1551 /** Mailing list management */
1552 if (!strcmp(tab, "access")) {
1556 /** end content of whatever tab is open now */
1557 wprintf("</TD></TR></TABLE></div>\n");
1564 * \brief Toggle self-service list subscription
1566 void toggle_self_service(void) {
1569 newval = atoi(bstr("newval"));
1570 self_service(newval);
1577 * \brief save new parameters for a room
1583 char er_password[10];
1584 char er_dirname[15];
1585 char er_roomaide[26];
1591 if (strlen(bstr("ok_button")) == 0) {
1592 strcpy(WC->ImportantMessage,
1593 _("Cancelled. Changes were not saved."));
1598 serv_getln(buf, sizeof buf);
1600 if (buf[0] != '2') {
1601 strcpy(WC->ImportantMessage, &buf[4]);
1605 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1606 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1607 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1608 er_flags = extract_int(&buf[4], 3);
1610 strcpy(er_roomaide, bstr("er_roomaide"));
1611 if (strlen(er_roomaide) == 0) {
1613 serv_getln(buf, sizeof buf);
1614 if (buf[0] != '2') {
1615 strcpy(er_roomaide, "");
1617 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1620 strcpy(buf, bstr("er_name"));
1622 if (strlen(buf) > 0) {
1623 strcpy(er_name, buf);
1626 strcpy(buf, bstr("er_password"));
1628 if (strlen(buf) > 0)
1629 strcpy(er_password, buf);
1631 strcpy(buf, bstr("er_dirname"));
1633 if (strlen(buf) > 0)
1634 strcpy(er_dirname, buf);
1636 strcpy(buf, bstr("type"));
1637 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1639 if (!strcmp(buf, "invonly")) {
1640 er_flags |= (QR_PRIVATE);
1642 if (!strcmp(buf, "hidden")) {
1643 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1645 if (!strcmp(buf, "passworded")) {
1646 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1648 if (!strcmp(bstr("prefonly"), "yes")) {
1649 er_flags |= QR_PREFONLY;
1651 er_flags &= ~QR_PREFONLY;
1654 if (!strcmp(bstr("readonly"), "yes")) {
1655 er_flags |= QR_READONLY;
1657 er_flags &= ~QR_READONLY;
1660 if (!strcmp(bstr("permanent"), "yes")) {
1661 er_flags |= QR_PERMANENT;
1663 er_flags &= ~QR_PERMANENT;
1666 if (!strcmp(bstr("network"), "yes")) {
1667 er_flags |= QR_NETWORK;
1669 er_flags &= ~QR_NETWORK;
1672 if (!strcmp(bstr("directory"), "yes")) {
1673 er_flags |= QR_DIRECTORY;
1675 er_flags &= ~QR_DIRECTORY;
1678 if (!strcmp(bstr("ulallowed"), "yes")) {
1679 er_flags |= QR_UPLOAD;
1681 er_flags &= ~QR_UPLOAD;
1684 if (!strcmp(bstr("dlallowed"), "yes")) {
1685 er_flags |= QR_DOWNLOAD;
1687 er_flags &= ~QR_DOWNLOAD;
1690 if (!strcmp(bstr("visdir"), "yes")) {
1691 er_flags |= QR_VISDIR;
1693 er_flags &= ~QR_VISDIR;
1696 strcpy(buf, bstr("anon"));
1698 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1699 if (!strcmp(buf, "anononly"))
1700 er_flags |= QR_ANONONLY;
1701 if (!strcmp(buf, "anon2"))
1702 er_flags |= QR_ANONOPT;
1705 if (!strcmp(bstr("bump"), "yes"))
1708 er_floor = atoi(bstr("er_floor"));
1710 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1711 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1713 serv_getln(buf, sizeof buf);
1714 if (buf[0] != '2') {
1715 strcpy(WC->ImportantMessage, &buf[4]);
1721 if (strlen(er_roomaide) > 0) {
1722 sprintf(buf, "SETA %s", er_roomaide);
1724 serv_getln(buf, sizeof buf);
1725 if (buf[0] != '2') {
1726 strcpy(WC->ImportantMessage, &buf[4]);
1727 display_main_menu();
1732 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1739 * \brief Display form for Invite, Kick, and show Who Knows a room
1741 void do_invt_kick(void) {
1742 char buf[SIZ], room[SIZ], username[SIZ];
1745 serv_getln(buf, sizeof buf);
1747 if (buf[0] != '2') {
1751 extract_token(room, &buf[4], 0, '|', sizeof room);
1753 strcpy(username, bstr("username"));
1755 if (strlen(bstr("kick_button")) > 0) {
1756 sprintf(buf, "KICK %s", username);
1758 serv_getln(buf, sizeof buf);
1760 if (buf[0] != '2') {
1761 strcpy(WC->ImportantMessage, &buf[4]);
1763 sprintf(WC->ImportantMessage,
1764 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1769 if (strlen(bstr("invite_button")) > 0) {
1770 sprintf(buf, "INVT %s", username);
1772 serv_getln(buf, sizeof buf);
1774 if (buf[0] != '2') {
1775 strcpy(WC->ImportantMessage, &buf[4]);
1777 sprintf(WC->ImportantMessage,
1778 _("<B><I>User %s invited to room %s.</I></B>\n"),
1789 * \brief Display form for Invite, Kick, and show Who Knows a room
1791 void display_whok(void)
1793 char buf[SIZ], room[SIZ], username[SIZ];
1796 serv_getln(buf, sizeof buf);
1798 if (buf[0] != '2') {
1802 extract_token(room, &buf[4], 0, '|', sizeof room);
1805 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1806 wprintf(_("The users listed below have access to this room. "
1807 "To remove a user from the access list, select the user "
1808 "name from the list and click 'Kick'."));
1809 wprintf("<br /><br />");
1811 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1812 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1813 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1815 serv_getln(buf, sizeof buf);
1816 if (buf[0] == '1') {
1817 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1818 extract_token(username, buf, 0, '|', sizeof username);
1819 wprintf("<OPTION>");
1824 wprintf("</SELECT><br />\n");
1826 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1827 wprintf("</FORM></CENTER>\n");
1829 wprintf("</TD><TD>");
1830 wprintf(_("To grant another user access to this room, enter the "
1831 "user name in the box below and click 'Invite'."));
1832 wprintf("<br /><br />");
1834 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1835 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1836 wprintf(_("Invite:"));
1838 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1839 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1840 "<input type=\"submit\" value=\"%s\">"
1841 "</FORM></CENTER>\n", _("Invite"));
1843 wprintf("</TD></TR></TABLE>\n");
1850 * \brief display the form for entering a new room
1852 void display_entroom(void)
1857 serv_puts("CRE8 0");
1858 serv_getln(buf, sizeof buf);
1860 if (buf[0] != '2') {
1861 strcpy(WC->ImportantMessage, &buf[4]);
1862 display_main_menu();
1866 output_headers(1, 1, 2, 0, 0, 0);
1867 wprintf("<div id=\"banner\">\n"
1868 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1869 "<SPAN CLASS=\"titlebar\">");
1870 wprintf(_("Create a new room"));
1872 "</TD></TR></TABLE>\n"
1873 "</div>\n<div id=\"content\">\n"
1876 wprintf("<div class=\"fix_scrollbar_bug\">"
1877 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1879 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1881 wprintf("<UL><LI>");
1882 wprintf(_("Name of room: "));
1883 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1886 wprintf(_("Resides on floor: "));
1888 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1889 for (i = 0; i < 128; ++i)
1890 if (strlen(floorlist[i]) > 0) {
1891 wprintf("<OPTION ");
1892 wprintf("VALUE=\"%d\">", i);
1893 escputs(floorlist[i]);
1894 wprintf("</OPTION>\n");
1896 wprintf("</SELECT>\n");
1899 * Our clever little snippet of JavaScript automatically selects
1900 * a public room if the view is set to Bulletin Board or wiki, and
1901 * it selects a mailbox room otherwise. The user can override this,
1902 * of course. We also disable the floor selector for mailboxes.
1905 wprintf(_("Default view for room: "));
1906 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1907 " if ( (this.form.er_view.value == 0) "
1908 " || (this.form.er_view.value == 6) ) { "
1909 " this.form.type[0].checked=true; "
1910 " this.form.er_floor.disabled = false; "
1913 " this.form.type[4].checked=true; "
1914 " this.form.er_floor.disabled = true; "
1917 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1918 wprintf("<OPTION %s VALUE=\"%d\">",
1919 ((i == 0) ? "SELECTED" : ""), i );
1920 escputs(viewdefs[i]);
1921 wprintf("</OPTION>\n");
1923 wprintf("</SELECT>\n");
1926 wprintf(_("Type of room:"));
1929 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1930 wprintf("CHECKED OnChange=\""
1931 " if (this.form.type[0].checked == true) { "
1932 " this.form.er_floor.disabled = false; "
1935 wprintf(_("Public (automatically appears to everyone)"));
1937 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
1938 " if (this.form.type[1].checked == true) { "
1939 " this.form.er_floor.disabled = false; "
1942 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1944 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
1945 " if (this.form.type[2].checked == true) { "
1946 " this.form.er_floor.disabled = false; "
1949 wprintf(_("Private - require password: "));
1950 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
1952 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
1953 " if (this.form.type[3].checked == true) { "
1954 " this.form.er_floor.disabled = false; "
1957 wprintf(_("Private - invitation only"));
1959 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
1961 " if (this.form.type[4].checked == true) { "
1962 " this.form.er_floor.disabled = true; "
1965 wprintf(_("Personal (mailbox for you only)"));
1967 wprintf("\n</UL>\n");
1969 wprintf("<CENTER>\n");
1970 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
1972 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1973 wprintf("</CENTER>\n");
1974 wprintf("</FORM>\n<hr />");
1975 serv_printf("MESG roomaccess");
1976 serv_getln(buf, sizeof buf);
1977 if (buf[0] == '1') {
1980 wprintf("</td></tr></table></div>\n");
1988 * \brief support function for entroom() -- sets the default view
1990 void er_set_default_view(int newview) {
2003 serv_getln(buf, sizeof buf);
2004 if (buf[0] != '2') return;
2006 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2007 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2008 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2009 rm_bits1 = extract_int(&buf[4], 3);
2010 rm_floor = extract_int(&buf[4], 4);
2011 rm_listorder = extract_int(&buf[4], 5);
2012 rm_bits2 = extract_int(&buf[4], 7);
2014 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2015 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2016 rm_listorder, newview, rm_bits2
2018 serv_getln(buf, sizeof buf);
2024 * \brief enter a new room
2031 char er_password[SIZ];
2036 if (strlen(bstr("ok_button")) == 0) {
2037 strcpy(WC->ImportantMessage,
2038 _("Cancelled. No new room was created."));
2039 display_main_menu();
2042 strcpy(er_name, bstr("er_name"));
2043 strcpy(er_type, bstr("type"));
2044 strcpy(er_password, bstr("er_password"));
2045 er_floor = atoi(bstr("er_floor"));
2046 er_view = atoi(bstr("er_view"));
2049 if (!strcmp(er_type, "hidden"))
2051 if (!strcmp(er_type, "passworded"))
2053 if (!strcmp(er_type, "invonly"))
2055 if (!strcmp(er_type, "personal"))
2058 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2059 er_name, er_num_type, er_password, er_floor, 0, er_view);
2061 serv_getln(buf, sizeof buf);
2062 if (buf[0] != '2') {
2063 strcpy(WC->ImportantMessage, &buf[4]);
2064 display_main_menu();
2068 do_change_view(er_view); /* Now go there */
2073 * \brief display the screen to enter a private room
2075 void display_private(char *rname, int req_pass)
2077 output_headers(1, 1, 2, 0, 0, 0);
2078 wprintf("<div id=\"banner\">\n"
2079 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2080 "<SPAN CLASS=\"titlebar\">");
2081 wprintf(_("Go to a hidden room"));
2083 "</TD></TR></TABLE>\n"
2084 "</div>\n<div id=\"content\">\n"
2087 wprintf("<div class=\"fix_scrollbar_bug\">"
2088 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2090 wprintf("<CENTER>\n");
2092 wprintf(_("If you know the name of a hidden (guess-name) or "
2093 "passworded room, you can enter that room by typing "
2094 "its name below. Once you gain access to a private "
2095 "room, it will appear in your regular room listings "
2096 "so you don't have to keep returning here."));
2097 wprintf("\n<br /><br />");
2099 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2101 wprintf("<table border=\"0\" cellspacing=\"5\" "
2102 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2104 wprintf(_("Enter room name:"));
2106 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2107 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2110 wprintf("</TD></TR><TR><TD>");
2111 wprintf(_("Enter room password:"));
2112 wprintf("</TD><TD>");
2113 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2115 wprintf("</TD></TR></TABLE><br />\n");
2117 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2119 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2123 wprintf("</FORM>\n");
2124 wprintf("</td></tr></table></div>\n");
2129 * \brief goto a private room
2131 void goto_private(void)
2136 if (strlen(bstr("ok_button")) == 0) {
2137 display_main_menu();
2140 strcpy(hold_rm, WC->wc_roomname);
2141 strcpy(buf, "GOTO ");
2142 strcat(buf, bstr("gr_name"));
2144 strcat(buf, bstr("gr_pass"));
2146 serv_getln(buf, sizeof buf);
2148 if (buf[0] == '2') {
2149 smart_goto(bstr("gr_name"));
2152 if (!strncmp(buf, "540", 3)) {
2153 display_private(bstr("gr_name"), 1);
2156 output_headers(1, 1, 1, 0, 0, 0);
2157 wprintf("%s\n", &buf[4]);
2164 * \brief display the screen to zap a room
2166 void display_zap(void)
2168 output_headers(1, 1, 2, 0, 0, 0);
2170 wprintf("<div id=\"banner\">\n");
2171 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2172 wprintf("<SPAN CLASS=\"titlebar\">");
2173 wprintf(_("Zap (forget/unsubscribe) the current room"));
2174 wprintf("</SPAN>\n");
2175 wprintf("</TD></TR></TABLE>\n");
2176 wprintf("</div>\n<div id=\"content\">\n");
2178 wprintf(_("If you select this option, <em>%s</em> will "
2179 "disappear from your room list. Is this what you wish "
2180 "to do?<br />\n"), WC->wc_roomname);
2182 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2183 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2185 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2186 wprintf("</FORM>\n");
2197 char final_destination[SIZ];
2200 * If the forget-room routine fails for any reason, we fall back
2201 * to the current room; otherwise, we go to the Lobby
2203 strcpy(final_destination, WC->wc_roomname);
2205 if (strlen(bstr("ok_button")) > 0) {
2206 serv_printf("GOTO %s", WC->wc_roomname);
2207 serv_getln(buf, sizeof buf);
2208 if (buf[0] == '2') {
2210 serv_getln(buf, sizeof buf);
2211 if (buf[0] == '2') {
2212 strcpy(final_destination, "_BASEROOM_");
2216 smart_goto(final_destination);
2222 * \brief Delete the current room
2224 void delete_room(void)
2228 serv_puts("KILL 1");
2229 serv_getln(buf, sizeof buf);
2230 if (buf[0] != '2') {
2231 strcpy(WC->ImportantMessage, &buf[4]);
2232 display_main_menu();
2235 smart_goto("_BASEROOM_");
2242 * \brief Perform changes to a room's network configuration
2244 void netedit(void) {
2253 if (strlen(bstr("line"))==0) {
2258 strcpy(line, bstr("prefix"));
2259 strcat(line, bstr("line"));
2260 strcat(line, bstr("suffix"));
2269 serv_getln(buf, sizeof buf);
2270 if (buf[0] != '1') {
2276 /** This loop works for add *or* remove. Spiffy, eh? */
2277 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2278 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2279 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2280 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2281 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2282 if ( (strcasecmp(cmpa0, cmpb0))
2283 || (strcasecmp(cmpa1, cmpb1)) ) {
2284 fprintf(fp, "%s\n", buf);
2290 serv_getln(buf, sizeof buf);
2291 if (buf[0] != '4') {
2297 while (fgets(buf, sizeof buf, fp) != NULL) {
2298 buf[strlen(buf)-1] = 0;
2302 if (strlen(bstr("add_button")) > 0) {
2314 * \brief Convert a room name to a folder-ish-looking name.
2315 * \param folder the folderish name
2316 * \param room the room name
2317 * \param floor the floor name
2318 * \param is_mailbox is it a mailbox?
2320 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2325 * For mailboxes, just do it straight...
2328 sprintf(folder, "My folders|%s", room);
2332 * Otherwise, prefix the floor name as a "public folders" moniker
2335 sprintf(folder, "%s|%s", floorlist[floor], room);
2339 * Replace "\" characters with "|" for pseudo-folder-delimiting
2341 for (i=0; i<strlen(folder); ++i) {
2342 if (folder[i] == '\\') folder[i] = '|';
2350 * \brief Back end for change_view()
2351 * \param newview set newview???
2353 void do_change_view(int newview) {
2356 serv_printf("VIEW %d", newview);
2357 serv_getln(buf, sizeof buf);
2358 WC->wc_view = newview;
2359 smart_goto(WC->wc_roomname);
2365 * \brief Change the view for this room
2367 void change_view(void) {
2370 view = atol(bstr("view"));
2371 do_change_view(view);
2376 * \brief One big expanded tree list view --- like a folder list
2377 * \param fold the folder to view
2378 * \param max_folders how many folders???
2379 * \param num_floors hom many floors???
2381 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2385 int has_subfolders = 0;
2388 parents = malloc(max_folders * sizeof(int));
2390 /** BEGIN TREE MENU */
2391 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2393 /** include NanoTree */
2394 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2396 /** initialize NanoTree */
2397 wprintf("<script type=\"text/javascript\"> \n"
2398 " showRootNode = false; \n"
2399 " sortNodes = false; \n"
2400 " dragable = false; \n"
2402 " function standardClick(treeNode) { \n"
2405 " var closedGif = 'static/folder_closed.gif'; \n"
2406 " var openGif = 'static/folder_open.gif'; \n"
2408 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2412 for (i=0; i<max_folders; ++i) {
2415 if ((i+1) < max_folders) {
2416 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2417 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2422 levels = num_tokens(fold[i].name, '|');
2423 parents[levels] = i;
2425 wprintf("var node%d = new TreeNode(%d, '", i, i);
2427 if (fold[i].selectable) {
2428 wprintf("<a href=\"dotgoto?room=");
2429 urlescputs(fold[i].room);
2434 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2436 else if (fold[i].hasnewmsgs) {
2437 wprintf("<SPAN CLASS=\"roomlist_new\">");
2440 wprintf("<SPAN CLASS=\"roomlist_old\">");
2442 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2447 if (has_subfolders) {
2448 wprintf("new Array(closedGif, openGif)");
2450 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2451 wprintf("'static/viewcontacts_16x.gif'");
2453 else if (fold[i].view == VIEW_CALENDAR) {
2454 wprintf("'static/calarea_16x.gif'");
2456 else if (fold[i].view == VIEW_TASKS) {
2457 wprintf("'static/taskmanag_16x.gif'");
2459 else if (fold[i].view == VIEW_NOTES) {
2460 wprintf("'static/storenotes_16x.gif'");
2462 else if (fold[i].view == VIEW_MAILBOX) {
2463 wprintf("'static/privatemess_16x.gif'");
2466 wprintf("'static/chatrooms_16x.gif'");
2469 urlescputs(fold[i].name);
2473 wprintf("rootNode.addChild(node%d);\n", i);
2476 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2480 wprintf("container = document.getElementById('roomlist_div'); \n"
2486 /** END TREE MENU */
2490 * \brief Boxes and rooms and lists ... oh my!
2491 * \param fold the folder to view
2492 * \param max_folders how many folders???
2493 * \param num_floors hom many floors???
2495 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2497 char floor_name[256];
2498 char old_floor_name[256];
2500 int levels, oldlevels;
2503 static int columns = 3;
2504 int boxes_per_column = 0;
2505 int current_column = 0;
2508 strcpy(floor_name, "");
2509 strcpy(old_floor_name, "");
2512 while (nf % columns != 0) ++nf;
2513 boxes_per_column = (nf / columns);
2514 if (boxes_per_column < 1) boxes_per_column = 1;
2516 /** Outer table (for columnization) */
2517 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2518 "<tr><td valign=top>");
2522 for (i=0; i<max_folders; ++i) {
2524 levels = num_tokens(fold[i].name, '|');
2525 extract_token(floor_name, fold[i].name, 0,
2526 '|', sizeof floor_name);
2528 if ( (strcasecmp(floor_name, old_floor_name))
2529 && (strlen(old_floor_name) > 0) ) {
2531 do_template("endbox");
2534 if ((num_boxes % boxes_per_column) == 0) {
2536 if (current_column < columns) {
2537 wprintf("</td><td valign=top>\n");
2541 strcpy(old_floor_name, floor_name);
2544 /** Begin inner box */
2545 stresc(boxtitle, floor_name, 1, 0);
2546 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2547 do_template("beginbox");
2554 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2555 if (fold[i].selectable) {
2556 wprintf("<a href=\"dotgoto?room=");
2557 urlescputs(fold[i].room);
2563 if (fold[i].hasnewmsgs) {
2564 wprintf("<SPAN CLASS=\"roomlist_new\">");
2567 wprintf("<SPAN CLASS=\"roomlist_old\">");
2569 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2572 if (fold[i].selectable) {
2578 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2579 wprintf(" (INBOX)");
2581 wprintf("<br />\n");
2584 /** End the final inner box */
2585 do_template("endbox");
2587 wprintf("</TD></TR></TABLE>\n");
2591 * \brief print a floor div???
2592 * \param which_floordiv name of the floordiv???
2594 void set_floordiv_expanded(char *which_floordiv) {
2595 begin_ajax_response();
2596 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2597 end_ajax_response();
2601 * \brief view the iconbar
2602 * \param fold the folder to view
2603 * \param max_folders how many folders???
2604 * \param num_floors hom many floors???
2606 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2608 char floor_name[256];
2609 char old_floor_name[256];
2610 char floordivtitle[256];
2611 char floordiv_id[32];
2612 int levels, oldlevels;
2614 int num_drop_targets = 0;
2617 strcpy(floor_name, "");
2618 strcpy(old_floor_name, "");
2622 for (i=0; i<max_folders; ++i) {
2624 levels = num_tokens(fold[i].name, '|');
2625 extract_token(floor_name, fold[i].name, 0,
2626 '|', sizeof floor_name);
2628 if ( (strcasecmp(floor_name, old_floor_name))
2629 && (strlen(old_floor_name) > 0) ) {
2630 /** End inner box */
2632 wprintf("</div>\n"); /** floordiv */
2634 strcpy(old_floor_name, floor_name);
2638 stresc(floordivtitle, floor_name, 0, 0);
2639 sprintf(floordiv_id, "floordiv%d", i);
2640 wprintf("<span class=\"ib_roomlist_floor\" "
2641 "onClick=\"expand_floor('%s')\">"
2642 "%s</span><br>\n", floordiv_id, floordivtitle);
2643 wprintf("<div id=\"%s\" style=\"display:%s\">",
2645 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2652 wprintf("<div id=\"roomdiv%d\">", i);
2654 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2656 /** choose the icon */
2657 if (fold[i].view == VIEW_ADDRESSBOOK) {
2658 icon = "viewcontacts_16x.gif" ;
2660 else if (fold[i].view == VIEW_CALENDAR) {
2661 icon = "calarea_16x.gif" ;
2663 else if (fold[i].view == VIEW_TASKS) {
2664 icon = "taskmanag_16x.gif" ;
2666 else if (fold[i].view == VIEW_NOTES) {
2667 icon = "storenotes_16x.gif" ;
2669 else if (fold[i].view == VIEW_MAILBOX) {
2670 icon = "privatemess_16x.gif" ;
2673 icon = "chatrooms_16x.gif" ;
2676 if (fold[i].selectable) {
2677 wprintf("<a href=\"dotgoto?room=");
2678 urlescputs(fold[i].room);
2680 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2685 if (fold[i].hasnewmsgs) {
2686 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2689 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2691 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2693 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2694 wprintf(" (INBOX)");
2697 if (fold[i].selectable) {
2704 wprintf("</div>\n"); /** roomdiv */
2707 wprintf("</div>\n"); /** floordiv */
2710 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2711 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2713 num_drop_targets = 0;
2715 for (i=0; i<max_folders; ++i) {
2716 levels = num_tokens(fold[i].name, '|');
2718 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2719 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2720 jsescputs(fold[i].room);
2726 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2727 if (strlen(WC->floordiv_expanded) > 1) {
2728 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2732 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2738 * \brief Show the room list.
2739 * (only should get called by
2740 * knrooms() because that's where output_headers() is called from)
2741 * \param viewpref the view preferences???
2744 void list_all_rooms_by_floor(char *viewpref) {
2747 struct folder *fold = NULL;
2749 int max_folders = 0;
2750 int alloc_folders = 0;
2754 int num_floors = 1; /** add an extra one for private folders */
2756 /** If our cached folder list is very old, burn it. */
2757 if (WC->cache_fold != NULL) {
2758 if ((time(NULL) - WC->cache_timestamp) > 300) {
2759 free(WC->cache_fold);
2760 WC->cache_fold = NULL;
2764 /** Can we do the iconbar roomlist from cache? */
2765 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2766 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2770 /** Grab the floor table so we know how to build the list... */
2773 /** Start with the mailboxes */
2776 fold = malloc(sizeof(struct folder));
2777 memset(fold, 0, sizeof(struct folder));
2778 strcpy(fold[0].name, "My folders");
2779 fold[0].is_mailbox = 1;
2781 /** Then add floors */
2783 serv_getln(buf, sizeof buf);
2784 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2785 if (max_folders >= alloc_folders) {
2786 alloc_folders = max_folders + 100;
2787 fold = realloc(fold,
2788 alloc_folders * sizeof(struct folder));
2790 memset(&fold[max_folders], 0, sizeof(struct folder));
2791 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2796 /** Now add rooms */
2798 serv_getln(buf, sizeof buf);
2799 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2800 if (max_folders >= alloc_folders) {
2801 alloc_folders = max_folders + 100;
2802 fold = realloc(fold,
2803 alloc_folders * sizeof(struct folder));
2805 memset(&fold[max_folders], 0, sizeof(struct folder));
2806 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2807 ra_flags = extract_int(buf, 5);
2808 flags = extract_int(buf, 1);
2809 fold[max_folders].floor = extract_int(buf, 2);
2810 fold[max_folders].hasnewmsgs =
2811 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2812 if (flags & QR_MAILBOX) {
2813 fold[max_folders].is_mailbox = 1;
2815 fold[max_folders].view = extract_int(buf, 6);
2816 room_to_folder(fold[max_folders].name,
2817 fold[max_folders].room,
2818 fold[max_folders].floor,
2819 fold[max_folders].is_mailbox);
2820 fold[max_folders].selectable = 1;
2824 /** Bubble-sort the folder list */
2825 for (i=0; i<max_folders; ++i) {
2826 for (j=0; j<(max_folders-1)-i; ++j) {
2827 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2828 swap = strcasecmp(fold[j].name, fold[j+1].name);
2831 if ( (fold[j+1].is_mailbox)
2832 && (!fold[j].is_mailbox)) {
2840 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2841 memcpy(&fold[j], &fold[j+1],
2842 sizeof(struct folder));
2843 memcpy(&fold[j+1], &ftmp,
2844 sizeof(struct folder));
2850 if (!strcasecmp(viewpref, "folders")) {
2851 do_folder_view(fold, max_folders, num_floors);
2853 else if (!strcasecmp(viewpref, "hackish_view")) {
2854 for (i=0; i<max_folders; ++i) {
2855 escputs(fold[i].name);
2856 wprintf("<br />\n");
2859 else if (!strcasecmp(viewpref, "iconbar")) {
2860 do_iconbar_view(fold, max_folders, num_floors);
2863 do_rooms_view(fold, max_folders, num_floors);
2866 /* Don't free the folder list ... cache it for future use! */
2867 if (WC->cache_fold != NULL) {
2868 free(WC->cache_fold);
2870 WC->cache_fold = fold;
2871 WC->cache_max_folders = max_folders;
2872 WC->cache_num_floors = num_floors;
2873 WC->cache_timestamp = time(NULL);
2878 * \brief Do either a known rooms list or a folders list, depending on the
2883 char listviewpref[SIZ];
2885 output_headers(1, 1, 2, 0, 0, 0);
2887 /** Determine whether the user is trying to change views */
2888 if (bstr("view") != NULL) {
2889 if (strlen(bstr("view")) > 0) {
2890 set_preference("roomlistview", bstr("view"), 1);
2894 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2896 if ( (strcasecmp(listviewpref, "folders"))
2897 && (strcasecmp(listviewpref, "table")) ) {
2898 strcpy(listviewpref, "rooms");
2902 wprintf("<div id=\"banner\">\n"
2903 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2904 "<SPAN CLASS=\"titlebar\">"
2906 if (!strcasecmp(listviewpref, "rooms")) {
2907 wprintf(_("Room list"));
2909 if (!strcasecmp(listviewpref, "folders")) {
2910 wprintf(_("Folder list"));
2912 if (!strcasecmp(listviewpref, "table")) {
2913 wprintf(_("Room list"));
2915 wprintf("</SPAN></TD>\n");
2917 /** offer the ability to switch views */
2918 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2919 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2920 "OnChange=\"location.href=roomlistomatic.newview.options"
2921 "[selectedIndex].value\">\n");
2923 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
2926 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
2929 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
2930 "View as folder list"
2932 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
2935 wprintf("</SELECT><br />");
2937 wprintf("</FORM></TD></TR></TABLE>\n");
2940 "<div id=\"content\">\n");
2942 /** Display the room list in the user's preferred format */
2943 list_all_rooms_by_floor(listviewpref);
2950 * \brief Set the message expire policy for this room and/or floor
2952 void set_room_policy(void) {
2955 if (strlen(bstr("ok_button")) == 0) {
2956 strcpy(WC->ImportantMessage,
2957 _("Cancelled. Changes were not saved."));
2962 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
2963 serv_getln(buf, sizeof buf);
2964 strcpy(WC->ImportantMessage, &buf[4]);
2966 if (WC->axlevel >= 6) {
2967 strcat(WC->ImportantMessage, "<br />\n");
2968 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
2969 serv_getln(buf, sizeof buf);
2970 strcat(WC->ImportantMessage, &buf[4]);