5 * \defgroup RoomOps Lots of different room-related operations.
6 * \ingroup CitadelCommunitacion
11 char floorlist[128][SIZ]; /**< list of our floor names */
13 char *viewdefs[8]; /**< the different kinds of available views */
16 * \brief initialize the viewdefs with localized strings
18 void initialize_viewdefs(void) {
19 viewdefs[0] = _("Bulletin Board");
20 viewdefs[1] = _("Mail Folder");
21 viewdefs[2] = _("Address Book");
22 viewdefs[3] = _("Calendar");
23 viewdefs[4] = _("Task List");
24 viewdefs[5] = _("Notes List");
25 viewdefs[6] = _("Wiki");
26 viewdefs[7] = _("Calendar List");
30 * \brief Determine which views are allowed as the default for creating a new room.
32 * \param which_view The view ID being queried.
34 int is_view_allowed_as_default(int which_view)
37 case VIEW_BBS: return(1);
38 case VIEW_MAILBOX: return(1);
39 case VIEW_ADDRESSBOOK: return(1);
40 case VIEW_CALENDAR: return(1);
41 case VIEW_TASKS: return(1);
42 case VIEW_NOTES: return(1);
43 case VIEW_WIKI: return(0); /**< because it isn't finished yet */
44 case VIEW_CALBRIEF: return(0);
45 default: return(0); /**< should never get here */
51 * \brief load the list of floors
53 void load_floorlist(void)
58 for (a = 0; a < 128; ++a)
62 serv_getln(buf, sizeof buf);
64 strcpy(floorlist[0], "Main Floor");
67 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
68 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
74 * \brief Free a session's march list
76 * \param wcf Pointer to session being cleared
78 void free_march_list(struct wcsession *wcf)
82 while (wcf->march == NULL) {
83 mptr = wcf->march->next;
93 * \brief remove a room from the march list
95 void remove_march(char *aaa)
97 struct march *mptr, *mptr2;
99 if (WC->march == NULL)
102 if (!strcasecmp(WC->march->march_name, aaa)) {
103 mptr = WC->march->next;
109 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
110 if (!strcasecmp(mptr->march_name, aaa)) {
111 mptr2->next = mptr->next;
124 * \brief display rooms in tree structure???
125 * \param rp the roomlist to build a tree from
127 void room_tree_list(struct roomlisting *rp)
136 room_tree_list(rp->lnext);
138 strcpy(rmname, rp->rlname);
141 wprintf("<a href=\"dotgoto&room=");
145 escputs1(rmname, 1, 1);
146 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
148 else if (f & QR_DIRECTORY)
150 else if (f & QR_NETWORK)
154 wprintf("</A><TT> </TT>\n");
156 room_tree_list(rp->rnext);
162 * \brief Room ordering stuff (compare first by floor, then by order)
163 * \param r1 first roomlist to compare
164 * \param r2 second roomlist co compare
165 * \return are they the same???
167 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
169 if ((r1 == NULL) && (r2 == NULL))
175 if (r1->rlfloor < r2->rlfloor)
177 if (r1->rlfloor > r2->rlfloor)
179 if (r1->rlorder < r2->rlorder)
181 if (r1->rlorder > r2->rlorder)
188 * \brief Common code for all room listings
189 * \param variety what???
191 void listrms(char *variety)
196 struct roomlisting *rl = NULL;
197 struct roomlisting *rp;
198 struct roomlisting *rs;
201 /** Ask the server for a room list */
203 serv_getln(buf, sizeof buf);
208 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
210 rp = malloc(sizeof(struct roomlisting));
211 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
212 rp->rlflags = extract_int(buf, 1);
213 rp->rlfloor = extract_int(buf, 2);
214 rp->rlorder = extract_int(buf, 3);
223 if (rordercmp(rp, rs) < 0) {
224 if (rs->lnext == NULL) {
231 if (rs->rnext == NULL) {
244 * If no rooms were listed, print an nbsp to make the cell
245 * borders show up anyway.
247 if (num_rooms == 0) wprintf(" ");
252 * \brief list all forgotten rooms
254 void zapped_list(void)
256 output_headers(1, 1, 0, 0, 0, 0);
258 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
259 do_template("beginbox");
263 wprintf("<br /><br />\n");
264 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
265 do_template("endbox");
271 * \brief read this room's info file (set v to 1 for verbose mode)
278 serv_getln(buf, sizeof buf);
291 * \brief Display room banner icon.
292 * The server doesn't actually
293 * need the room name, but we supply it in order to
294 * keep the browser from using a cached icon from
297 void embed_room_graphic(void) {
300 serv_puts("OIMG _roompic_");
301 serv_getln(buf, sizeof buf);
303 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
304 urlescputs(WC->wc_roomname);
307 serv_getln(buf, sizeof buf);
309 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
310 wprintf("<img height=48 width=48 src=\""
311 "static/viewcontacts_48x.gif"
315 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
316 wprintf("<img height=48 width=48 src=\""
317 "static/calarea_48x.gif"
321 else if (WC->wc_view == VIEW_TASKS) {
322 wprintf("<img height=48 width=48 src=\""
323 "static/taskmanag_48x.gif"
327 else if (WC->wc_view == VIEW_NOTES) {
328 wprintf("<img height=48 width=48 src=\""
329 "static/storenotes_48x.gif"
333 else if (WC->wc_view == VIEW_MAILBOX) {
334 wprintf("<img height=48 width=48 src=\""
335 "static/privatemess_48x.gif"
340 wprintf("<img height=48 width=48 src=\""
341 "static/chatrooms_48x.gif"
351 * \brief Display the current view and offer an option to change it
353 void embed_view_o_matic(void) {
356 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
357 "<span class=\"room_banner_new_messages\">");
358 wprintf(_("View as:"));
360 "<SELECT NAME=\"newview\" SIZE=\"1\" "
361 "STYLE=\"font-size: 7pt; background: #444455; color: #ddddcc;\" "
362 "OnChange=\"location.href=viewomatic.newview.options"
363 "[selectedIndex].value\">\n");
365 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
367 * Only offer the views that make sense, given the default
368 * view for the room. For example, don't offer a Calendar
369 * view in a non-Calendar room.
373 || (i == WC->wc_default_view) /**< default */
374 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
375 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
376 || ( (i == 7) && (WC->wc_default_view == 3) ) /**< calendar */
379 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
380 ((i == WC->wc_view) ? "SELECTED" : ""),
382 escputs(viewdefs[i]);
383 wprintf("</OPTION>\n");
386 wprintf("</select></span></form>\n");
391 * \brief view room banner
393 * \param navbar_style
395 void embed_room_banner(char *got, int navbar_style) {
399 * We need to have the information returned by a GOTO server command.
400 * If it isn't supplied, we fake it by issuing our own GOTO.
403 serv_printf("GOTO %s", WC->wc_roomname);
404 serv_getln(buf, sizeof buf);
408 /** The browser needs some information for its own use */
409 wprintf("<script type=\"text/javascript\"> \n"
410 " room_is_trash = %d; \n"
416 * If the user happens to select the "make this my start page" link,
417 * we want it to remember the URL as a "/dotskip" one instead of
418 * a "skip" or "gotonext" or something like that.
420 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
423 /** Check for new mail. */
424 WC->new_mail = extract_int(&got[4], 9);
425 WC->wc_view = extract_int(&got[4], 11);
427 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
428 svprintf("NUMMSGS", WCS_STRING,
429 _("%d new of %d messages"),
430 extract_int(&got[4], 1),
431 extract_int(&got[4], 2)
433 svcallback("ROOMPIC", embed_room_graphic);
434 svcallback("ROOMINFO", readinfo);
435 svcallback("VIEWOMATIC", embed_view_o_matic);
436 svcallback("START", offer_start_page);
438 do_template("roombanner");
439 if (navbar_style != navbar_none) {
441 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
442 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
445 if (navbar_style == navbar_default) wprintf(
447 "<a href=\"ungoto\">"
448 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
449 "<span class=\"navbar_link\">%s</span></A>"
450 "</td>\n", _("Ungoto")
453 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
456 "<a href=\"readnew\">"
457 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
458 "<span class=\"navbar_link\">%s</span></A>"
459 "</td>\n", _("Read new messages")
463 if (navbar_style == navbar_default) {
464 switch(WC->wc_view) {
465 case VIEW_ADDRESSBOOK:
468 "<a href=\"readfwd\">"
469 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
471 "<span class=\"navbar_link\">"
473 "</span></a></td>\n", _("View contacts")
479 "<a href=\"readfwd?calview=day\">"
480 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
482 "<span class=\"navbar_link\">"
484 "</span></a></td>\n", _("Day view")
488 "<a href=\"readfwd?calview=month\">"
489 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
491 "<span class=\"navbar_link\">"
493 "</span></a></td>\n", _("Month view")
499 "<a href=\"readfwd?calview=month\">"
500 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
502 "<span class=\"navbar_link\">"
504 "</span></a></td>\n", _("Calendar list")
510 "<a href=\"readfwd\">"
511 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
513 "<span class=\"navbar_link\">"
515 "</span></a></td>\n", _("View tasks")
521 "<a href=\"readfwd\">"
522 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
524 "<span class=\"navbar_link\">"
526 "</span></a></td>\n", _("View notes")
532 "<a href=\"readfwd\">"
533 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
535 "<span class=\"navbar_link\">"
537 "</span></a></td>\n", _("View message list")
543 "<a href=\"readfwd\">"
544 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
546 "<span class=\"navbar_link\">"
548 "</span></a></td>\n", _("Wiki home")
554 "<a href=\"readfwd\">"
555 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
557 "<span class=\"navbar_link\">"
559 "</span></a></td>\n", _("Read all messages")
565 if (navbar_style == navbar_default) {
566 switch(WC->wc_view) {
567 case VIEW_ADDRESSBOOK:
569 "<td><a href=\"display_enter\">"
570 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
571 "border=\"0\"><span class=\"navbar_link\">"
573 "</span></a></td>\n", _("Add new contact")
579 "<td><a href=\"display_enter\">"
580 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
581 "border=\"0\"><span class=\"navbar_link\">"
583 "</span></a></td>\n", _("Add new event")
588 "<td><a href=\"display_enter\">"
589 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
590 "border=\"0\"><span class=\"navbar_link\">"
592 "</span></a></td>\n", _("Add new task")
597 "<td><a href=\"javascript:add_new_note();\">"
598 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
599 "border=\"0\"><span class=\"navbar_link\">"
601 "</span></a></td>\n", _("Add new note")
605 safestrncpy(buf, bstr("page"), sizeof buf);
608 "<td><a href=\"display_enter?wikipage=%s\">"
609 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
610 "border=\"0\"><span class=\"navbar_link\">"
612 "</span></a></td>\n", buf, _("Edit this page")
617 "<td><a href=\"display_enter\">"
618 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
619 "border=\"0\"><span class=\"navbar_link\">"
621 "</span></a></td>\n", _("Enter a message")
627 if (navbar_style == navbar_default) wprintf(
631 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
632 "<span class=\"navbar_link\">%s</span></a>"
634 _("Leave all messages marked as unread, go to next room with unread messages"),
638 if (navbar_style == navbar_default) wprintf(
640 "<a href=\"gotonext\" "
642 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
643 "<span class=\"navbar_link\">%s</span></a>"
645 _("Mark all messages as read, go to next room with unread messages"),
649 wprintf("</tr></table></div>\n");
659 * \brief back end routine to take the session to a new room
660 * \param gname room to go to
663 int gotoroom(char *gname)
666 static long ls = (-1L);
669 /** store ungoto information */
670 strcpy(WC->ugname, WC->wc_roomname);
673 /** move to the new room */
674 serv_printf("GOTO %s", gname);
675 serv_getln(buf, sizeof buf);
679 serv_puts("GOTO _BASEROOM_");
680 serv_getln(buf, sizeof buf);
687 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
688 WC->room_flags = extract_int(&buf[4], 4);
689 /* highest_msg_read = extract_int(&buf[4],6);
690 maxmsgnum = extract_int(&buf[4],5);
692 WC->is_mailbox = extract_int(&buf[4],7);
693 ls = extract_long(&buf[4], 6);
694 WC->wc_floor = extract_int(&buf[4], 10);
695 WC->wc_view = extract_int(&buf[4], 11);
696 WC->wc_default_view = extract_int(&buf[4], 12);
697 WC->wc_is_trash = extract_int(&buf[4], 13);
700 WC->is_room_aide = WC->is_aide;
702 WC->is_room_aide = (char) extract_int(&buf[4], 8);
704 remove_march(WC->wc_roomname);
705 if (!strcasecmp(gname, "_BASEROOM_"))
713 * \brief Locate the room on the march list which we most want to go to.
715 * is measured given a "weight" of preference based on various factors.
716 * \param desired_floor the room number on the citadel server
717 * \return the roomname
719 char *pop_march(int desired_floor)
721 static char TheRoom[128];
723 int TheOrder = 32767;
726 struct march *mptr = NULL;
728 strcpy(TheRoom, "_BASEROOM_");
729 if (WC->march == NULL)
732 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
734 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
735 weight = weight + 10000;
736 if (mptr->march_floor == desired_floor)
737 weight = weight + 5000;
739 weight = weight + ((128 - (mptr->march_floor)) * 128);
740 weight = weight + (128 - (mptr->march_order));
742 if (weight > TheWeight) {
744 strcpy(TheRoom, mptr->march_name);
745 TheFloor = mptr->march_floor;
746 TheOrder = mptr->march_order;
755 *\brief Goto next room having unread messages.
756 * We want to skip over rooms that the user has already been to, and take the
757 * user back to the lobby when done. The room we end up in is placed in
758 * newroom - which is set to 0 (the lobby) initially.
759 * We start the search in the current room rather than the beginning to prevent
760 * two or more concurrent users from dragging each other back to the same room.
765 struct march *mptr, *mptr2;
769 * First check to see if the march-mode list is already allocated.
770 * If it is, pop the first room off the list and go there.
773 if (WC->march == NULL) {
775 serv_getln(buf, sizeof buf);
777 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
778 mptr = (struct march *) malloc(sizeof(struct march));
780 extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
781 mptr->march_floor = extract_int(buf, 2);
782 mptr->march_order = extract_int(buf, 3);
783 if (WC->march == NULL) {
787 while (mptr2->next != NULL)
793 * add _BASEROOM_ to the end of the march list, so the user will end up
794 * in the system base room (usually the Lobby>) at the end of the loop
796 mptr = (struct march *) malloc(sizeof(struct march));
798 strcpy(mptr->march_name, "_BASEROOM_");
799 if (WC->march == NULL) {
803 while (mptr2->next != NULL)
808 * ...and remove the room we're currently in, so a <G>oto doesn't make us
809 * walk around in circles
811 remove_march(WC->wc_roomname);
813 if (WC->march != NULL) {
814 strcpy(next_room, pop_march(-1));
816 strcpy(next_room, "_BASEROOM_");
820 smart_goto(next_room);
825 * \brief goto next room
826 * \param next_room next room to go to
828 void smart_goto(char *next_room) {
836 * \brief mark all messages in current room as having been read
838 void slrp_highest(void)
843 serv_puts("SLRP HIGHEST");
844 serv_getln(buf, sizeof buf);
846 wprintf("<EM>%s</EM><br />\n", &buf[4]);
853 * \brief un-goto the previous room
859 if (!strcmp(WC->ugname, "")) {
860 smart_goto(WC->wc_roomname);
863 serv_printf("GOTO %s", WC->ugname);
864 serv_getln(buf, sizeof buf);
866 smart_goto(WC->wc_roomname);
869 if (WC->uglsn >= 0L) {
870 serv_printf("SLRP %ld", WC->uglsn);
871 serv_getln(buf, sizeof buf);
873 strcpy(buf, WC->ugname);
874 strcpy(WC->ugname, "");
883 * \brief Set/clear/read the "self-service list subscribe" flag for a room
885 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
886 * \return return the new value.
889 int self_service(int newval) {
890 int current_value = 0;
896 int flags, floor, order, view, flags2;
899 serv_getln(buf, sizeof buf);
900 if (buf[0] != '2') return(0);
902 extract_token(name, &buf[4], 0, '|', sizeof name);
903 extract_token(password, &buf[4], 1, '|', sizeof password);
904 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
905 flags = extract_int(&buf[4], 3);
906 floor = extract_int(&buf[4], 4);
907 order = extract_int(&buf[4], 5);
908 view = extract_int(&buf[4], 6);
909 flags2 = extract_int(&buf[4], 7);
911 if (flags2 & QR2_SELFLIST) {
919 flags2 = flags2 | QR2_SELFLIST;
921 else if (newval == 0) {
922 flags2 = flags2 & ~QR2_SELFLIST;
925 return(current_value);
928 if (newval != current_value) {
929 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
930 name, password, dirname, flags,
931 floor, order, view, flags2);
932 serv_getln(buf, sizeof buf);
945 * \brief display the form for editing a room
947 void display_editroom(void)
952 char remote_room[SIZ];
955 char er_password[10];
957 char er_roomaide[26];
963 char *not_shared_with;
970 if (strlen(tab) == 0) tab = "admin";
974 serv_getln(buf, sizeof buf);
977 strcpy(WC->ImportantMessage, &buf[4]);
981 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
982 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
983 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
984 er_flags = extract_int(&buf[4], 3);
985 er_floor = extract_int(&buf[4], 4);
987 output_headers(1, 1, 1, 0, 0, 0);
989 /** print the tabbed dialog */
991 "<div class=\"fix_scrollbar_bug\">"
992 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
994 "<TD> </TD>\n");
996 if (!strcmp(tab, "admin")) {
997 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1000 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
1002 wprintf(_("Administration"));
1003 if (!strcmp(tab, "admin")) {
1004 wprintf("</SPAN></TD>\n");
1007 wprintf("</A></TD>\n");
1010 wprintf("<TD> </TD>\n");
1012 if (!strcmp(tab, "config")) {
1013 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1016 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
1018 wprintf(_("Configuration"));
1019 if (!strcmp(tab, "config")) {
1020 wprintf("</SPAN></TD>\n");
1023 wprintf("</A></TD>\n");
1026 wprintf("<TD> </TD>\n");
1028 if (!strcmp(tab, "expire")) {
1029 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1032 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
1034 wprintf(_("Message expire policy"));
1035 if (!strcmp(tab, "expire")) {
1036 wprintf("</SPAN></TD>\n");
1039 wprintf("</A></TD>\n");
1042 wprintf("<TD> </TD>\n");
1044 if (!strcmp(tab, "access")) {
1045 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1048 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
1050 wprintf(_("Access controls"));
1051 if (!strcmp(tab, "access")) {
1052 wprintf("</SPAN></TD>\n");
1055 wprintf("</A></TD>\n");
1058 wprintf("<TD> </TD>\n");
1060 if (!strcmp(tab, "sharing")) {
1061 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1064 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
1066 wprintf(_("Sharing"));
1067 if (!strcmp(tab, "sharing")) {
1068 wprintf("</SPAN></TD>\n");
1071 wprintf("</A></TD>\n");
1074 wprintf("<TD> </TD>\n");
1076 if (!strcmp(tab, "listserv")) {
1077 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1080 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
1082 wprintf(_("Mailing list service"));
1083 if (!strcmp(tab, "listserv")) {
1084 wprintf("</SPAN></TD>\n");
1087 wprintf("</A></TD>\n");
1090 wprintf("<TD> </TD>\n");
1092 wprintf("</TR></TABLE></div>\n");
1093 /** end tabbed dialog */
1095 /** begin content of whatever tab is open now */
1096 wprintf("<div class=\"fix_scrollbar_bug\">"
1097 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
1100 if (!strcmp(tab, "admin")) {
1102 "<LI><a href=\"delete_room\" "
1103 "onClick=\"return confirm('");
1104 wprintf(_("Are you sure you want to delete this room?"));
1105 wprintf("');\">\n");
1106 wprintf(_("Delete this room"));
1108 "<LI><a href=\"display_editroompic\">\n");
1109 wprintf(_("Set or change the icon for this room's banner"));
1111 "<LI><a href=\"display_editinfo\">\n");
1112 wprintf(_("Edit this room's Info file"));
1117 if (!strcmp(tab, "config")) {
1118 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1120 wprintf("<UL><LI>");
1121 wprintf(_("Name of room: "));
1122 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1128 wprintf(_("Resides on floor: "));
1129 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1130 for (i = 0; i < 128; ++i)
1131 if (strlen(floorlist[i]) > 0) {
1132 wprintf("<OPTION ");
1134 wprintf("SELECTED ");
1135 wprintf("VALUE=\"%d\">", i);
1136 escputs(floorlist[i]);
1137 wprintf("</OPTION>\n");
1139 wprintf("</SELECT>\n");
1142 wprintf(_("Type of room:"));
1145 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1146 if ((er_flags & QR_PRIVATE) == 0)
1147 wprintf("CHECKED ");
1149 wprintf(_("Public room"));
1152 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1153 if ((er_flags & QR_PRIVATE) &&
1154 (er_flags & QR_GUESSNAME))
1155 wprintf("CHECKED ");
1157 wprintf(_("Private - guess name"));
1159 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1160 if ((er_flags & QR_PRIVATE) &&
1161 (er_flags & QR_PASSWORDED))
1162 wprintf("CHECKED ");
1164 wprintf(_("Private - require password:"));
1165 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1168 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1169 if ((er_flags & QR_PRIVATE)
1170 && ((er_flags & QR_GUESSNAME) == 0)
1171 && ((er_flags & QR_PASSWORDED) == 0))
1172 wprintf("CHECKED ");
1174 wprintf(_("Private - invitation only"));
1176 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1178 wprintf(_("If private, cause current users to forget room"));
1180 wprintf("\n</UL>\n");
1182 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1183 if (er_flags & QR_PREFONLY)
1184 wprintf("CHECKED ");
1186 wprintf(_("Preferred users only"));
1188 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1189 if (er_flags & QR_READONLY)
1190 wprintf("CHECKED ");
1192 wprintf(_("Read-only room"));
1194 /** directory stuff */
1195 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1196 if (er_flags & QR_DIRECTORY)
1197 wprintf("CHECKED ");
1199 wprintf(_("File directory room"));
1201 wprintf("\n<UL><LI>");
1202 wprintf(_("Directory name: "));
1203 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1206 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1207 if (er_flags & QR_UPLOAD)
1208 wprintf("CHECKED ");
1210 wprintf(_("Uploading allowed"));
1212 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1213 if (er_flags & QR_DOWNLOAD)
1214 wprintf("CHECKED ");
1216 wprintf(_("Downloading allowed"));
1218 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1219 if (er_flags & QR_VISDIR)
1220 wprintf("CHECKED ");
1222 wprintf(_("Visible directory"));
1225 /** end of directory stuff */
1227 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1228 if (er_flags & QR_NETWORK)
1229 wprintf("CHECKED ");
1231 wprintf(_("Network shared room"));
1233 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1234 if (er_flags & QR_PERMANENT)
1235 wprintf("CHECKED ");
1237 wprintf(_("Permanent (does not auto-purge)"));
1239 /** start of anon options */
1242 wprintf(_("Anonymous messages"));
1245 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1246 if (((er_flags & QR_ANONONLY) == 0)
1247 && ((er_flags & QR_ANONOPT) == 0))
1248 wprintf("CHECKED ");
1250 wprintf(_("No anonymous messages"));
1252 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1253 if (er_flags & QR_ANONONLY)
1254 wprintf("CHECKED ");
1256 wprintf(_("All messages are anonymous"));
1258 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1259 if (er_flags & QR_ANONOPT)
1260 wprintf("CHECKED ");
1262 wprintf(_("Prompt user when entering messages"));
1265 /* end of anon options */
1268 wprintf(_("Room aide: "));
1270 serv_getln(buf, sizeof buf);
1271 if (buf[0] != '2') {
1272 wprintf("<EM>%s</EM>\n", &buf[4]);
1274 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1275 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1278 wprintf("</UL><CENTER>\n");
1279 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1280 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1282 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1290 /** Sharing the room with other Citadel nodes... */
1291 if (!strcmp(tab, "sharing")) {
1293 shared_with = strdup("");
1294 not_shared_with = strdup("");
1296 /** Learn the current configuration */
1297 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1298 serv_getln(buf, sizeof buf);
1299 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1300 extract_token(node, buf, 0, '|', sizeof node);
1301 not_shared_with = realloc(not_shared_with,
1302 strlen(not_shared_with) + 32);
1303 strcat(not_shared_with, node);
1304 strcat(not_shared_with, "\n");
1308 serv_getln(buf, sizeof buf);
1309 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1310 extract_token(cmd, buf, 0, '|', sizeof cmd);
1311 extract_token(node, buf, 1, '|', sizeof node);
1312 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1313 if (!strcasecmp(cmd, "ignet_push_share")) {
1314 shared_with = realloc(shared_with,
1315 strlen(shared_with) + 32);
1316 strcat(shared_with, node);
1317 if (strlen(remote_room) > 0) {
1318 strcat(shared_with, "|");
1319 strcat(shared_with, remote_room);
1321 strcat(shared_with, "\n");
1325 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1326 extract_token(buf, shared_with, i, '\n', sizeof buf);
1327 extract_token(node, buf, 0, '|', sizeof node);
1328 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1329 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1330 if (!strcasecmp(node, cmd)) {
1331 remove_token(not_shared_with, j, '\n');
1336 /** Display the stuff */
1337 wprintf("<CENTER><br />"
1338 "<TABLE border=1 cellpadding=5><TR>"
1340 wprintf(_("Shared with"));
1341 wprintf("</I></B></TD>"
1343 wprintf(_("Not shared with"));
1344 wprintf("</I></B></TD></TR>\n"
1345 "<TR><TD VALIGN=TOP>\n");
1347 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1348 wprintf(_("Remote node name"));
1349 wprintf("</TD><TD>");
1350 wprintf(_("Remote room name"));
1351 wprintf("</TD><TD>");
1352 wprintf(_("Actions"));
1353 wprintf("</TD></TR>\n");
1355 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1356 extract_token(buf, shared_with, i, '\n', sizeof buf);
1357 extract_token(node, buf, 0, '|', sizeof node);
1358 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1359 if (strlen(node) > 0) {
1360 wprintf("<FORM METHOD=\"POST\" "
1361 "action=\"netedit\">"
1362 "<TR><TD>%s</TD>\n", node);
1365 if (strlen(remote_room) > 0) {
1366 escputs(remote_room);
1372 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1373 "VALUE=\"ignet_push_share|");
1375 if (strlen(remote_room) > 0) {
1377 urlescputs(remote_room);
1380 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1381 "VALUE=\"sharing\">\n");
1382 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1383 "VALUE=\"remove\">\n");
1384 wprintf("<INPUT TYPE=\"submit\" "
1385 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1386 wprintf("</TD></TR></FORM>\n");
1390 wprintf("</TABLE>\n");
1391 wprintf("</TD><TD VALIGN=TOP>\n");
1392 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1393 wprintf(_("Remote node name"));
1394 wprintf("</TD><TD>");
1395 wprintf(_("Remote room name"));
1396 wprintf("</TD><TD>");
1397 wprintf(_("Actions"));
1398 wprintf("</TD></TR>\n");
1400 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1401 extract_token(node, not_shared_with, i, '\n', sizeof node);
1402 if (strlen(node) > 0) {
1403 wprintf("<FORM METHOD=\"POST\" "
1404 "action=\"netedit\">"
1408 "<INPUT TYPE=\"INPUT\" "
1412 wprintf("<INPUT TYPE=\"hidden\" "
1414 "VALUE=\"ignet_push_share|");
1417 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1418 "VALUE=\"sharing\">\n");
1419 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1420 "VALUE=\"add\">\n");
1421 wprintf("<INPUT TYPE=\"submit\" "
1422 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1423 wprintf("</TD></TR></FORM>\n");
1427 wprintf("</TABLE>\n");
1428 wprintf("</TD></TR>"
1429 "</TABLE></CENTER><br />\n"
1430 "<I><B>%s</B><UL><LI>", _("Notes:"));
1431 wprintf(_("When sharing a room, "
1432 "it must be shared from both ends. Adding a node to "
1433 "the 'shared' list sends messages out, but in order to"
1434 " receive messages, the other nodes must be configured"
1435 " to send messages out to your system as well. "
1436 "<LI>If the remote room name is blank, it is assumed "
1437 "that the room name is identical on the remote node."
1438 "<LI>If the remote room name is different, the remote "
1439 "node must also configure the name of the room here."
1445 /** Mailing list management */
1446 if (!strcmp(tab, "listserv")) {
1448 wprintf("<br /><center>"
1449 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1450 "<TR><TD VALIGN=TOP>");
1452 wprintf(_("<i>The contents of this room are being "
1453 "mailed <b>as individual messages</b> "
1454 "to the following list recipients:"
1455 "</i><br /><br />\n"));
1458 serv_getln(buf, sizeof buf);
1459 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1460 extract_token(cmd, buf, 0, '|', sizeof cmd);
1461 if (!strcasecmp(cmd, "listrecp")) {
1462 extract_token(recp, buf, 1, '|', sizeof recp);
1465 wprintf(" <a href=\"netedit&cmd=remove&line="
1468 wprintf("&tab=listserv\">");
1469 wprintf(_("(remove)"));
1470 wprintf("</A><br />");
1473 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1474 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1475 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1476 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1477 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1478 wprintf("</FORM>\n");
1480 wprintf("</TD><TD VALIGN=TOP>\n");
1482 wprintf(_("<i>The contents of this room are being "
1483 "mailed <b>in digest form</b> "
1484 "to the following list recipients:"
1485 "</i><br /><br />\n"));
1488 serv_getln(buf, sizeof buf);
1489 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1490 extract_token(cmd, buf, 0, '|', sizeof cmd);
1491 if (!strcasecmp(cmd, "digestrecp")) {
1492 extract_token(recp, buf, 1, '|', sizeof recp);
1495 wprintf(" <a href=\"netedit&cmd=remove&line="
1498 wprintf("&tab=listserv\">");
1499 wprintf(_("(remove)"));
1500 wprintf("</A><br />");
1503 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1504 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1505 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1506 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1507 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1508 wprintf("</FORM>\n");
1510 wprintf("</TD></TR></TABLE><hr />\n");
1512 if (self_service(999) == 1) {
1513 wprintf(_("This room is configured to allow "
1514 "self-service subscribe/unsubscribe requests."));
1515 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1516 wprintf(_("Click to disable."));
1517 wprintf("</A><br />\n");
1518 wprintf(_("The URL for subscribe/unsubscribe is: "));
1519 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1520 (is_https ? "https" : "http"),
1524 wprintf(_("This room is <i>not</i> configured to allow "
1525 "self-service subscribe/unsubscribe requests."));
1526 wprintf(" <a href=\"toggle_self_service?newval=1&"
1528 wprintf(_("Click to enable."));
1529 wprintf("</A><br />\n");
1533 wprintf("</CENTER>\n");
1537 /** Mailing list management */
1538 if (!strcmp(tab, "expire")) {
1540 serv_puts("GPEX room");
1541 serv_getln(buf, sizeof buf);
1542 if (buf[0] == '2') {
1543 roompolicy = extract_int(&buf[4], 0);
1544 roomvalue = extract_int(&buf[4], 1);
1547 serv_puts("GPEX floor");
1548 serv_getln(buf, sizeof buf);
1549 if (buf[0] == '2') {
1550 floorpolicy = extract_int(&buf[4], 0);
1551 floorvalue = extract_int(&buf[4], 1);
1554 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1555 wprintf("<TABLE border=0 cellspacing=5>\n");
1556 wprintf("<TR><TD>");
1557 wprintf(_("Message expire policy for this room"));
1559 escputs(WC->wc_roomname);
1560 wprintf(")</TD><TD>");
1561 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1562 ((roompolicy == 0) ? "CHECKED" : "") );
1563 wprintf(_("Use the default policy for this floor"));
1564 wprintf("<br />\n");
1565 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1566 ((roompolicy == 1) ? "CHECKED" : "") );
1567 wprintf(_("Never automatically expire messages"));
1568 wprintf("<br />\n");
1569 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1570 ((roompolicy == 2) ? "CHECKED" : "") );
1571 wprintf(_("Expire by message count"));
1572 wprintf("<br />\n");
1573 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1574 ((roompolicy == 3) ? "CHECKED" : "") );
1575 wprintf(_("Expire by message age"));
1577 wprintf(_("Number of messages or days: "));
1578 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1579 wprintf("</TD></TR>\n");
1581 if (WC->axlevel >= 6) {
1582 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1583 wprintf("<TR><TD>");
1584 wprintf(_("Message expire policy for this floor"));
1586 escputs(floorlist[WC->wc_floor]);
1587 wprintf(")</TD><TD>");
1588 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1589 ((floorpolicy == 0) ? "CHECKED" : "") );
1590 wprintf(_("Use the system default"));
1591 wprintf("<br />\n");
1592 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1593 ((floorpolicy == 1) ? "CHECKED" : "") );
1594 wprintf(_("Never automatically expire messages"));
1595 wprintf("<br />\n");
1596 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1597 ((floorpolicy == 2) ? "CHECKED" : "") );
1598 wprintf(_("Expire by message count"));
1599 wprintf("<br />\n");
1600 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1601 ((floorpolicy == 3) ? "CHECKED" : "") );
1602 wprintf(_("Expire by message age"));
1604 wprintf(_("Number of messages or days: "));
1605 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1609 wprintf("<CENTER>\n");
1610 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1611 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1613 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1614 wprintf("</CENTER></TD><TR>\n");
1616 wprintf("</TABLE>\n"
1617 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1623 /** Mailing list management */
1624 if (!strcmp(tab, "access")) {
1628 /** end content of whatever tab is open now */
1629 wprintf("</TD></TR></TABLE></div>\n");
1636 * \brief Toggle self-service list subscription
1638 void toggle_self_service(void) {
1641 newval = atoi(bstr("newval"));
1642 self_service(newval);
1649 * \brief save new parameters for a room
1655 char er_password[10];
1656 char er_dirname[15];
1657 char er_roomaide[26];
1663 if (strlen(bstr("ok_button")) == 0) {
1664 strcpy(WC->ImportantMessage,
1665 _("Cancelled. Changes were not saved."));
1670 serv_getln(buf, sizeof buf);
1672 if (buf[0] != '2') {
1673 strcpy(WC->ImportantMessage, &buf[4]);
1677 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1678 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1679 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1680 er_flags = extract_int(&buf[4], 3);
1682 strcpy(er_roomaide, bstr("er_roomaide"));
1683 if (strlen(er_roomaide) == 0) {
1685 serv_getln(buf, sizeof buf);
1686 if (buf[0] != '2') {
1687 strcpy(er_roomaide, "");
1689 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1692 strcpy(buf, bstr("er_name"));
1694 if (strlen(buf) > 0) {
1695 strcpy(er_name, buf);
1698 strcpy(buf, bstr("er_password"));
1700 if (strlen(buf) > 0)
1701 strcpy(er_password, buf);
1703 strcpy(buf, bstr("er_dirname"));
1705 if (strlen(buf) > 0)
1706 strcpy(er_dirname, buf);
1708 strcpy(buf, bstr("type"));
1709 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1711 if (!strcmp(buf, "invonly")) {
1712 er_flags |= (QR_PRIVATE);
1714 if (!strcmp(buf, "hidden")) {
1715 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1717 if (!strcmp(buf, "passworded")) {
1718 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1720 if (!strcmp(bstr("prefonly"), "yes")) {
1721 er_flags |= QR_PREFONLY;
1723 er_flags &= ~QR_PREFONLY;
1726 if (!strcmp(bstr("readonly"), "yes")) {
1727 er_flags |= QR_READONLY;
1729 er_flags &= ~QR_READONLY;
1732 if (!strcmp(bstr("permanent"), "yes")) {
1733 er_flags |= QR_PERMANENT;
1735 er_flags &= ~QR_PERMANENT;
1738 if (!strcmp(bstr("network"), "yes")) {
1739 er_flags |= QR_NETWORK;
1741 er_flags &= ~QR_NETWORK;
1744 if (!strcmp(bstr("directory"), "yes")) {
1745 er_flags |= QR_DIRECTORY;
1747 er_flags &= ~QR_DIRECTORY;
1750 if (!strcmp(bstr("ulallowed"), "yes")) {
1751 er_flags |= QR_UPLOAD;
1753 er_flags &= ~QR_UPLOAD;
1756 if (!strcmp(bstr("dlallowed"), "yes")) {
1757 er_flags |= QR_DOWNLOAD;
1759 er_flags &= ~QR_DOWNLOAD;
1762 if (!strcmp(bstr("visdir"), "yes")) {
1763 er_flags |= QR_VISDIR;
1765 er_flags &= ~QR_VISDIR;
1768 strcpy(buf, bstr("anon"));
1770 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1771 if (!strcmp(buf, "anononly"))
1772 er_flags |= QR_ANONONLY;
1773 if (!strcmp(buf, "anon2"))
1774 er_flags |= QR_ANONOPT;
1777 if (!strcmp(bstr("bump"), "yes"))
1780 er_floor = atoi(bstr("er_floor"));
1782 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1783 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1785 serv_getln(buf, sizeof buf);
1786 if (buf[0] != '2') {
1787 strcpy(WC->ImportantMessage, &buf[4]);
1793 if (strlen(er_roomaide) > 0) {
1794 sprintf(buf, "SETA %s", er_roomaide);
1796 serv_getln(buf, sizeof buf);
1797 if (buf[0] != '2') {
1798 strcpy(WC->ImportantMessage, &buf[4]);
1799 display_main_menu();
1804 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1811 * \brief Display form for Invite, Kick, and show Who Knows a room
1813 void do_invt_kick(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);
1825 strcpy(username, bstr("username"));
1827 if (strlen(bstr("kick_button")) > 0) {
1828 sprintf(buf, "KICK %s", username);
1830 serv_getln(buf, sizeof buf);
1832 if (buf[0] != '2') {
1833 strcpy(WC->ImportantMessage, &buf[4]);
1835 sprintf(WC->ImportantMessage,
1836 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1841 if (strlen(bstr("invite_button")) > 0) {
1842 sprintf(buf, "INVT %s", username);
1844 serv_getln(buf, sizeof buf);
1846 if (buf[0] != '2') {
1847 strcpy(WC->ImportantMessage, &buf[4]);
1849 sprintf(WC->ImportantMessage,
1850 _("<B><I>User %s invited to room %s.</I></B>\n"),
1861 * \brief Display form for Invite, Kick, and show Who Knows a room
1863 void display_whok(void)
1865 char buf[SIZ], room[SIZ], username[SIZ];
1868 serv_getln(buf, sizeof buf);
1870 if (buf[0] != '2') {
1874 extract_token(room, &buf[4], 0, '|', sizeof room);
1877 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1878 wprintf(_("The users listed below have access to this room. "
1879 "To remove a user from the access list, select the user "
1880 "name from the list and click 'Kick'."));
1881 wprintf("<br /><br />");
1883 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1884 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1885 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1887 serv_getln(buf, sizeof buf);
1888 if (buf[0] == '1') {
1889 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1890 extract_token(username, buf, 0, '|', sizeof username);
1891 wprintf("<OPTION>");
1896 wprintf("</SELECT><br />\n");
1898 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1899 wprintf("</FORM></CENTER>\n");
1901 wprintf("</TD><TD>");
1902 wprintf(_("To grant another user access to this room, enter the "
1903 "user name in the box below and click 'Invite'."));
1904 wprintf("<br /><br />");
1906 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1907 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1908 wprintf(_("Invite:"));
1910 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1911 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1912 "<input type=\"submit\" value=\"%s\">"
1913 "</FORM></CENTER>\n", _("Invite"));
1915 wprintf("</TD></TR></TABLE>\n");
1922 * \brief display the form for entering a new room
1924 void display_entroom(void)
1929 serv_puts("CRE8 0");
1930 serv_getln(buf, sizeof buf);
1932 if (buf[0] != '2') {
1933 strcpy(WC->ImportantMessage, &buf[4]);
1934 display_main_menu();
1938 output_headers(1, 1, 2, 0, 0, 0);
1939 wprintf("<div id=\"banner\">\n"
1940 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1941 "<SPAN CLASS=\"titlebar\">");
1942 wprintf(_("Create a new room"));
1944 "</TD></TR></TABLE>\n"
1945 "</div>\n<div id=\"content\">\n"
1948 wprintf("<div class=\"fix_scrollbar_bug\">"
1949 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1951 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1953 wprintf("<UL><LI>");
1954 wprintf(_("Name of room: "));
1955 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1958 wprintf(_("Resides on floor: "));
1960 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1961 for (i = 0; i < 128; ++i)
1962 if (strlen(floorlist[i]) > 0) {
1963 wprintf("<OPTION ");
1964 wprintf("VALUE=\"%d\">", i);
1965 escputs(floorlist[i]);
1966 wprintf("</OPTION>\n");
1968 wprintf("</SELECT>\n");
1971 * Our clever little snippet of JavaScript automatically selects
1972 * a public room if the view is set to Bulletin Board or wiki, and
1973 * it selects a mailbox room otherwise. The user can override this,
1974 * of course. We also disable the floor selector for mailboxes.
1977 wprintf(_("Default view for room: "));
1978 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1979 " if ( (this.form.er_view.value == 0) "
1980 " || (this.form.er_view.value == 6) ) { "
1981 " this.form.type[0].checked=true; "
1982 " this.form.er_floor.disabled = false; "
1985 " this.form.type[4].checked=true; "
1986 " this.form.er_floor.disabled = true; "
1989 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1990 if (is_view_allowed_as_default(i)) {
1991 wprintf("<OPTION %s VALUE=\"%d\">",
1992 ((i == 0) ? "SELECTED" : ""), i );
1993 escputs(viewdefs[i]);
1994 wprintf("</OPTION>\n");
1997 wprintf("</SELECT>\n");
2000 wprintf(_("Type of room:"));
2003 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2004 wprintf("CHECKED OnChange=\""
2005 " if (this.form.type[0].checked == true) { "
2006 " this.form.er_floor.disabled = false; "
2009 wprintf(_("Public (automatically appears to everyone)"));
2011 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2012 " if (this.form.type[1].checked == true) { "
2013 " this.form.er_floor.disabled = false; "
2016 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2018 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2019 " if (this.form.type[2].checked == true) { "
2020 " this.form.er_floor.disabled = false; "
2023 wprintf(_("Private - require password: "));
2024 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2026 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2027 " if (this.form.type[3].checked == true) { "
2028 " this.form.er_floor.disabled = false; "
2031 wprintf(_("Private - invitation only"));
2033 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2035 " if (this.form.type[4].checked == true) { "
2036 " this.form.er_floor.disabled = true; "
2039 wprintf(_("Personal (mailbox for you only)"));
2041 wprintf("\n</UL>\n");
2043 wprintf("<CENTER>\n");
2044 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2046 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2047 wprintf("</CENTER>\n");
2048 wprintf("</FORM>\n<hr />");
2049 serv_printf("MESG roomaccess");
2050 serv_getln(buf, sizeof buf);
2051 if (buf[0] == '1') {
2054 wprintf("</td></tr></table></div>\n");
2062 * \brief support function for entroom() -- sets the default view
2064 void er_set_default_view(int newview) {
2077 serv_getln(buf, sizeof buf);
2078 if (buf[0] != '2') return;
2080 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2081 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2082 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2083 rm_bits1 = extract_int(&buf[4], 3);
2084 rm_floor = extract_int(&buf[4], 4);
2085 rm_listorder = extract_int(&buf[4], 5);
2086 rm_bits2 = extract_int(&buf[4], 7);
2088 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2089 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2090 rm_listorder, newview, rm_bits2
2092 serv_getln(buf, sizeof buf);
2098 * \brief enter a new room
2105 char er_password[SIZ];
2110 if (strlen(bstr("ok_button")) == 0) {
2111 strcpy(WC->ImportantMessage,
2112 _("Cancelled. No new room was created."));
2113 display_main_menu();
2116 strcpy(er_name, bstr("er_name"));
2117 strcpy(er_type, bstr("type"));
2118 strcpy(er_password, bstr("er_password"));
2119 er_floor = atoi(bstr("er_floor"));
2120 er_view = atoi(bstr("er_view"));
2123 if (!strcmp(er_type, "hidden"))
2125 if (!strcmp(er_type, "passworded"))
2127 if (!strcmp(er_type, "invonly"))
2129 if (!strcmp(er_type, "personal"))
2132 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2133 er_name, er_num_type, er_password, er_floor, 0, er_view);
2135 serv_getln(buf, sizeof buf);
2136 if (buf[0] != '2') {
2137 strcpy(WC->ImportantMessage, &buf[4]);
2138 display_main_menu();
2142 do_change_view(er_view); /* Now go there */
2147 * \brief display the screen to enter a private room
2149 void display_private(char *rname, int req_pass)
2151 output_headers(1, 1, 2, 0, 0, 0);
2152 wprintf("<div id=\"banner\">\n"
2153 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2154 "<SPAN CLASS=\"titlebar\">");
2155 wprintf(_("Go to a hidden room"));
2157 "</TD></TR></TABLE>\n"
2158 "</div>\n<div id=\"content\">\n"
2161 wprintf("<div class=\"fix_scrollbar_bug\">"
2162 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2164 wprintf("<CENTER>\n");
2166 wprintf(_("If you know the name of a hidden (guess-name) or "
2167 "passworded room, you can enter that room by typing "
2168 "its name below. Once you gain access to a private "
2169 "room, it will appear in your regular room listings "
2170 "so you don't have to keep returning here."));
2171 wprintf("\n<br /><br />");
2173 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2175 wprintf("<table border=\"0\" cellspacing=\"5\" "
2176 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2178 wprintf(_("Enter room name:"));
2180 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2181 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2184 wprintf("</TD></TR><TR><TD>");
2185 wprintf(_("Enter room password:"));
2186 wprintf("</TD><TD>");
2187 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2189 wprintf("</TD></TR></TABLE><br />\n");
2191 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2193 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2197 wprintf("</FORM>\n");
2198 wprintf("</td></tr></table></div>\n");
2203 * \brief goto a private room
2205 void goto_private(void)
2210 if (strlen(bstr("ok_button")) == 0) {
2211 display_main_menu();
2214 strcpy(hold_rm, WC->wc_roomname);
2215 strcpy(buf, "GOTO ");
2216 strcat(buf, bstr("gr_name"));
2218 strcat(buf, bstr("gr_pass"));
2220 serv_getln(buf, sizeof buf);
2222 if (buf[0] == '2') {
2223 smart_goto(bstr("gr_name"));
2226 if (!strncmp(buf, "540", 3)) {
2227 display_private(bstr("gr_name"), 1);
2230 output_headers(1, 1, 1, 0, 0, 0);
2231 wprintf("%s\n", &buf[4]);
2238 * \brief display the screen to zap a room
2240 void display_zap(void)
2242 output_headers(1, 1, 2, 0, 0, 0);
2244 wprintf("<div id=\"banner\">\n");
2245 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2246 wprintf("<SPAN CLASS=\"titlebar\">");
2247 wprintf(_("Zap (forget/unsubscribe) the current room"));
2248 wprintf("</SPAN>\n");
2249 wprintf("</TD></TR></TABLE>\n");
2250 wprintf("</div>\n<div id=\"content\">\n");
2252 wprintf(_("If you select this option, <em>%s</em> will "
2253 "disappear from your room list. Is this what you wish "
2254 "to do?<br />\n"), WC->wc_roomname);
2256 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2257 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2259 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2260 wprintf("</FORM>\n");
2271 char final_destination[SIZ];
2274 * If the forget-room routine fails for any reason, we fall back
2275 * to the current room; otherwise, we go to the Lobby
2277 strcpy(final_destination, WC->wc_roomname);
2279 if (strlen(bstr("ok_button")) > 0) {
2280 serv_printf("GOTO %s", WC->wc_roomname);
2281 serv_getln(buf, sizeof buf);
2282 if (buf[0] == '2') {
2284 serv_getln(buf, sizeof buf);
2285 if (buf[0] == '2') {
2286 strcpy(final_destination, "_BASEROOM_");
2290 smart_goto(final_destination);
2296 * \brief Delete the current room
2298 void delete_room(void)
2302 serv_puts("KILL 1");
2303 serv_getln(buf, sizeof buf);
2304 if (buf[0] != '2') {
2305 strcpy(WC->ImportantMessage, &buf[4]);
2306 display_main_menu();
2309 smart_goto("_BASEROOM_");
2316 * \brief Perform changes to a room's network configuration
2318 void netedit(void) {
2327 if (strlen(bstr("line"))==0) {
2332 strcpy(line, bstr("prefix"));
2333 strcat(line, bstr("line"));
2334 strcat(line, bstr("suffix"));
2343 serv_getln(buf, sizeof buf);
2344 if (buf[0] != '1') {
2350 /** This loop works for add *or* remove. Spiffy, eh? */
2351 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2352 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2353 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2354 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2355 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2356 if ( (strcasecmp(cmpa0, cmpb0))
2357 || (strcasecmp(cmpa1, cmpb1)) ) {
2358 fprintf(fp, "%s\n", buf);
2364 serv_getln(buf, sizeof buf);
2365 if (buf[0] != '4') {
2371 while (fgets(buf, sizeof buf, fp) != NULL) {
2372 buf[strlen(buf)-1] = 0;
2376 if (strlen(bstr("add_button")) > 0) {
2388 * \brief Convert a room name to a folder-ish-looking name.
2389 * \param folder the folderish name
2390 * \param room the room name
2391 * \param floor the floor name
2392 * \param is_mailbox is it a mailbox?
2394 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2399 * For mailboxes, just do it straight...
2402 sprintf(folder, "My folders|%s", room);
2406 * Otherwise, prefix the floor name as a "public folders" moniker
2409 sprintf(folder, "%s|%s", floorlist[floor], room);
2413 * Replace "\" characters with "|" for pseudo-folder-delimiting
2415 for (i=0; i<strlen(folder); ++i) {
2416 if (folder[i] == '\\') folder[i] = '|';
2424 * \brief Back end for change_view()
2425 * \param newview set newview???
2427 void do_change_view(int newview) {
2430 serv_printf("VIEW %d", newview);
2431 serv_getln(buf, sizeof buf);
2432 WC->wc_view = newview;
2433 smart_goto(WC->wc_roomname);
2439 * \brief Change the view for this room
2441 void change_view(void) {
2444 view = atol(bstr("view"));
2445 do_change_view(view);
2450 * \brief One big expanded tree list view --- like a folder list
2451 * \param fold the folder to view
2452 * \param max_folders how many folders???
2453 * \param num_floors hom many floors???
2455 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2459 int has_subfolders = 0;
2462 parents = malloc(max_folders * sizeof(int));
2464 /** BEGIN TREE MENU */
2465 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2467 /** include NanoTree */
2468 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2470 /** initialize NanoTree */
2471 wprintf("<script type=\"text/javascript\"> \n"
2472 " showRootNode = false; \n"
2473 " sortNodes = false; \n"
2474 " dragable = false; \n"
2476 " function standardClick(treeNode) { \n"
2479 " var closedGif = 'static/folder_closed.gif'; \n"
2480 " var openGif = 'static/folder_open.gif'; \n"
2482 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2486 for (i=0; i<max_folders; ++i) {
2489 if ((i+1) < max_folders) {
2490 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2491 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2496 levels = num_tokens(fold[i].name, '|');
2497 parents[levels] = i;
2499 wprintf("var node%d = new TreeNode(%d, '", i, i);
2501 if (fold[i].selectable) {
2502 wprintf("<a href=\"dotgoto?room=");
2503 urlescputs(fold[i].room);
2508 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2510 else if (fold[i].hasnewmsgs) {
2511 wprintf("<SPAN CLASS=\"roomlist_new\">");
2514 wprintf("<SPAN CLASS=\"roomlist_old\">");
2516 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2521 if (has_subfolders) {
2522 wprintf("new Array(closedGif, openGif)");
2524 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2525 wprintf("'static/viewcontacts_16x.gif'");
2527 else if (fold[i].view == VIEW_CALENDAR) {
2528 wprintf("'static/calarea_16x.gif'");
2530 else if (fold[i].view == VIEW_CALBRIEF) {
2531 wprintf("'static/calarea_16x.gif'");
2533 else if (fold[i].view == VIEW_TASKS) {
2534 wprintf("'static/taskmanag_16x.gif'");
2536 else if (fold[i].view == VIEW_NOTES) {
2537 wprintf("'static/storenotes_16x.gif'");
2539 else if (fold[i].view == VIEW_MAILBOX) {
2540 wprintf("'static/privatemess_16x.gif'");
2543 wprintf("'static/chatrooms_16x.gif'");
2546 urlescputs(fold[i].name);
2550 wprintf("rootNode.addChild(node%d);\n", i);
2553 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2557 wprintf("container = document.getElementById('roomlist_div'); \n"
2563 /** END TREE MENU */
2567 * \brief Boxes and rooms and lists ... oh my!
2568 * \param fold the folder to view
2569 * \param max_folders how many folders???
2570 * \param num_floors hom many floors???
2572 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2574 char floor_name[256];
2575 char old_floor_name[256];
2577 int levels, oldlevels;
2580 static int columns = 3;
2581 int boxes_per_column = 0;
2582 int current_column = 0;
2585 strcpy(floor_name, "");
2586 strcpy(old_floor_name, "");
2589 while (nf % columns != 0) ++nf;
2590 boxes_per_column = (nf / columns);
2591 if (boxes_per_column < 1) boxes_per_column = 1;
2593 /** Outer table (for columnization) */
2594 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2595 "<tr><td valign=top>");
2599 for (i=0; i<max_folders; ++i) {
2601 levels = num_tokens(fold[i].name, '|');
2602 extract_token(floor_name, fold[i].name, 0,
2603 '|', sizeof floor_name);
2605 if ( (strcasecmp(floor_name, old_floor_name))
2606 && (strlen(old_floor_name) > 0) ) {
2608 do_template("endbox");
2611 if ((num_boxes % boxes_per_column) == 0) {
2613 if (current_column < columns) {
2614 wprintf("</td><td valign=top>\n");
2618 strcpy(old_floor_name, floor_name);
2621 /** Begin inner box */
2622 stresc(boxtitle, floor_name, 1, 0);
2623 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2624 do_template("beginbox");
2631 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2632 if (fold[i].selectable) {
2633 wprintf("<a href=\"dotgoto?room=");
2634 urlescputs(fold[i].room);
2640 if (fold[i].hasnewmsgs) {
2641 wprintf("<SPAN CLASS=\"roomlist_new\">");
2644 wprintf("<SPAN CLASS=\"roomlist_old\">");
2646 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2649 if (fold[i].selectable) {
2655 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2656 wprintf(" (INBOX)");
2658 wprintf("<br />\n");
2661 /** End the final inner box */
2662 do_template("endbox");
2664 wprintf("</TD></TR></TABLE>\n");
2668 * \brief print a floor div???
2669 * \param which_floordiv name of the floordiv???
2671 void set_floordiv_expanded(char *which_floordiv) {
2672 begin_ajax_response();
2673 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2674 end_ajax_response();
2678 * \brief view the iconbar
2679 * \param fold the folder to view
2680 * \param max_folders how many folders???
2681 * \param num_floors hom many floors???
2683 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2685 char floor_name[256];
2686 char old_floor_name[256];
2687 char floordivtitle[256];
2688 char floordiv_id[32];
2689 int levels, oldlevels;
2691 int num_drop_targets = 0;
2694 strcpy(floor_name, "");
2695 strcpy(old_floor_name, "");
2699 for (i=0; i<max_folders; ++i) {
2701 levels = num_tokens(fold[i].name, '|');
2702 extract_token(floor_name, fold[i].name, 0,
2703 '|', sizeof floor_name);
2705 if ( (strcasecmp(floor_name, old_floor_name))
2706 && (strlen(old_floor_name) > 0) ) {
2707 /** End inner box */
2709 wprintf("</div>\n"); /** floordiv */
2711 strcpy(old_floor_name, floor_name);
2715 stresc(floordivtitle, floor_name, 0, 0);
2716 sprintf(floordiv_id, "floordiv%d", i);
2717 wprintf("<span class=\"ib_roomlist_floor\" "
2718 "onClick=\"expand_floor('%s')\">"
2719 "%s</span><br>\n", floordiv_id, floordivtitle);
2720 wprintf("<div id=\"%s\" style=\"display:%s\">",
2722 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2729 wprintf("<div id=\"roomdiv%d\">", i);
2731 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2733 /** choose the icon */
2734 if (fold[i].view == VIEW_ADDRESSBOOK) {
2735 icon = "viewcontacts_16x.gif" ;
2737 else if (fold[i].view == VIEW_CALENDAR) {
2738 icon = "calarea_16x.gif" ;
2740 else if (fold[i].view == VIEW_CALBRIEF) {
2741 icon = "calarea_16x.gif" ;
2743 else if (fold[i].view == VIEW_TASKS) {
2744 icon = "taskmanag_16x.gif" ;
2746 else if (fold[i].view == VIEW_NOTES) {
2747 icon = "storenotes_16x.gif" ;
2749 else if (fold[i].view == VIEW_MAILBOX) {
2750 icon = "privatemess_16x.gif" ;
2753 icon = "chatrooms_16x.gif" ;
2756 if (fold[i].selectable) {
2757 wprintf("<a href=\"dotgoto?room=");
2758 urlescputs(fold[i].room);
2760 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2765 if (fold[i].hasnewmsgs) {
2766 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2769 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2771 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2773 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2774 wprintf(" (INBOX)");
2777 if (fold[i].selectable) {
2784 wprintf("</div>\n"); /** roomdiv */
2787 wprintf("</div>\n"); /** floordiv */
2790 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2791 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2793 num_drop_targets = 0;
2795 for (i=0; i<max_folders; ++i) {
2796 levels = num_tokens(fold[i].name, '|');
2798 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2799 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2800 jsescputs(fold[i].room);
2806 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2807 if (strlen(WC->floordiv_expanded) > 1) {
2808 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2812 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2818 * \brief Show the room list.
2819 * (only should get called by
2820 * knrooms() because that's where output_headers() is called from)
2821 * \param viewpref the view preferences???
2824 void list_all_rooms_by_floor(char *viewpref) {
2827 struct folder *fold = NULL;
2829 int max_folders = 0;
2830 int alloc_folders = 0;
2834 int num_floors = 1; /** add an extra one for private folders */
2836 /** If our cached folder list is very old, burn it. */
2837 if (WC->cache_fold != NULL) {
2838 if ((time(NULL) - WC->cache_timestamp) > 300) {
2839 free(WC->cache_fold);
2840 WC->cache_fold = NULL;
2844 /** Can we do the iconbar roomlist from cache? */
2845 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2846 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2850 /** Grab the floor table so we know how to build the list... */
2853 /** Start with the mailboxes */
2856 fold = malloc(sizeof(struct folder));
2857 memset(fold, 0, sizeof(struct folder));
2858 strcpy(fold[0].name, "My folders");
2859 fold[0].is_mailbox = 1;
2861 /** Then add floors */
2863 serv_getln(buf, sizeof buf);
2864 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2865 if (max_folders >= alloc_folders) {
2866 alloc_folders = max_folders + 100;
2867 fold = realloc(fold,
2868 alloc_folders * sizeof(struct folder));
2870 memset(&fold[max_folders], 0, sizeof(struct folder));
2871 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2876 /** Now add rooms */
2878 serv_getln(buf, sizeof buf);
2879 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2880 if (max_folders >= alloc_folders) {
2881 alloc_folders = max_folders + 100;
2882 fold = realloc(fold,
2883 alloc_folders * sizeof(struct folder));
2885 memset(&fold[max_folders], 0, sizeof(struct folder));
2886 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2887 ra_flags = extract_int(buf, 5);
2888 flags = extract_int(buf, 1);
2889 fold[max_folders].floor = extract_int(buf, 2);
2890 fold[max_folders].hasnewmsgs =
2891 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2892 if (flags & QR_MAILBOX) {
2893 fold[max_folders].is_mailbox = 1;
2895 fold[max_folders].view = extract_int(buf, 6);
2896 room_to_folder(fold[max_folders].name,
2897 fold[max_folders].room,
2898 fold[max_folders].floor,
2899 fold[max_folders].is_mailbox);
2900 fold[max_folders].selectable = 1;
2904 /** Bubble-sort the folder list */
2905 for (i=0; i<max_folders; ++i) {
2906 for (j=0; j<(max_folders-1)-i; ++j) {
2907 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2908 swap = strcasecmp(fold[j].name, fold[j+1].name);
2911 if ( (fold[j+1].is_mailbox)
2912 && (!fold[j].is_mailbox)) {
2920 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2921 memcpy(&fold[j], &fold[j+1],
2922 sizeof(struct folder));
2923 memcpy(&fold[j+1], &ftmp,
2924 sizeof(struct folder));
2930 if (!strcasecmp(viewpref, "folders")) {
2931 do_folder_view(fold, max_folders, num_floors);
2933 else if (!strcasecmp(viewpref, "hackish_view")) {
2934 for (i=0; i<max_folders; ++i) {
2935 escputs(fold[i].name);
2936 wprintf("<br />\n");
2939 else if (!strcasecmp(viewpref, "iconbar")) {
2940 do_iconbar_view(fold, max_folders, num_floors);
2943 do_rooms_view(fold, max_folders, num_floors);
2946 /* Don't free the folder list ... cache it for future use! */
2947 if (WC->cache_fold != NULL) {
2948 free(WC->cache_fold);
2950 WC->cache_fold = fold;
2951 WC->cache_max_folders = max_folders;
2952 WC->cache_num_floors = num_floors;
2953 WC->cache_timestamp = time(NULL);
2958 * \brief Do either a known rooms list or a folders list, depending on the
2963 char listviewpref[SIZ];
2965 output_headers(1, 1, 2, 0, 0, 0);
2967 /** Determine whether the user is trying to change views */
2968 if (bstr("view") != NULL) {
2969 if (strlen(bstr("view")) > 0) {
2970 set_preference("roomlistview", bstr("view"), 1);
2974 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2976 if ( (strcasecmp(listviewpref, "folders"))
2977 && (strcasecmp(listviewpref, "table")) ) {
2978 strcpy(listviewpref, "rooms");
2982 wprintf("<div id=\"banner\">\n"
2983 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2984 "<SPAN CLASS=\"titlebar\">"
2986 if (!strcasecmp(listviewpref, "rooms")) {
2987 wprintf(_("Room list"));
2989 if (!strcasecmp(listviewpref, "folders")) {
2990 wprintf(_("Folder list"));
2992 if (!strcasecmp(listviewpref, "table")) {
2993 wprintf(_("Room list"));
2995 wprintf("</SPAN></TD>\n");
2997 /** offer the ability to switch views */
2998 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2999 "<SELECT NAME=\"newview\" SIZE=\"1\" "
3000 "OnChange=\"location.href=roomlistomatic.newview.options"
3001 "[selectedIndex].value\">\n");
3003 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3006 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3009 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3010 "View as folder list"
3012 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3015 wprintf("</SELECT><br />");
3017 wprintf("</FORM></TD></TR></TABLE>\n");
3020 "<div id=\"content\">\n");
3022 /** Display the room list in the user's preferred format */
3023 list_all_rooms_by_floor(listviewpref);
3030 * \brief Set the message expire policy for this room and/or floor
3032 void set_room_policy(void) {
3035 if (strlen(bstr("ok_button")) == 0) {
3036 strcpy(WC->ImportantMessage,
3037 _("Cancelled. Changes were not saved."));
3042 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3043 serv_getln(buf, sizeof buf);
3044 strcpy(WC->ImportantMessage, &buf[4]);
3046 if (WC->axlevel >= 6) {
3047 strcat(WC->ImportantMessage, "<br />\n");
3048 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3049 serv_getln(buf, sizeof buf);
3050 strcat(WC->ImportantMessage, &buf[4]);