5 * \defgroup RoomOps Lots of different room-related operations.
6 * \ingroup CitadelCommunitacion
11 char floorlist[128][SIZ]; /**< list of our floor names */
13 char *viewdefs[8]; /**< the different kinds of available views */
16 * \brief initialize the viewdefs with localized strings
18 void initialize_viewdefs(void) {
19 viewdefs[0] = _("Bulletin Board");
20 viewdefs[1] = _("Mail Folder");
21 viewdefs[2] = _("Address Book");
22 viewdefs[3] = _("Calendar");
23 viewdefs[4] = _("Task List");
24 viewdefs[5] = _("Notes List");
25 viewdefs[6] = _("Wiki");
26 viewdefs[7] = _("Calendar List");
30 * \brief Determine which views are allowed as the default for creating a new room.
32 * \param which_view The view ID being queried.
34 int is_view_allowed_as_default(int which_view)
37 case VIEW_BBS: return(1);
38 case VIEW_MAILBOX: return(1);
39 case VIEW_ADDRESSBOOK: return(1);
40 case VIEW_CALENDAR: return(1);
41 case VIEW_TASKS: return(1);
42 case VIEW_NOTES: return(1);
43 case VIEW_WIKI: return(0); /**< because it isn't finished yet */
44 case VIEW_CALBRIEF: return(0);
45 default: return(0); /**< should never get here */
51 * \brief load the list of floors
53 void load_floorlist(void)
58 for (a = 0; a < 128; ++a)
62 serv_getln(buf, sizeof buf);
64 strcpy(floorlist[0], "Main Floor");
67 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
68 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
74 * \brief Free a session's march list
76 * \param wcf Pointer to session being cleared
78 void free_march_list(struct wcsession *wcf)
82 while (wcf->march != NULL) {
83 mptr = wcf->march->next;
93 * \brief remove a room from the march list
95 void remove_march(char *aaa)
97 struct march *mptr, *mptr2;
99 if (WC->march == NULL)
102 if (!strcasecmp(WC->march->march_name, aaa)) {
103 mptr = WC->march->next;
109 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
110 if (!strcasecmp(mptr->march_name, aaa)) {
111 mptr2->next = mptr->next;
124 * \brief display rooms in tree structure???
125 * \param rp the roomlist to build a tree from
127 void room_tree_list(struct roomlisting *rp)
136 room_tree_list(rp->lnext);
138 strcpy(rmname, rp->rlname);
141 wprintf("<a href=\"dotgoto&room=");
145 escputs1(rmname, 1, 1);
146 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
148 else if (f & QR_DIRECTORY)
150 else if (f & QR_NETWORK)
154 wprintf("</A><TT> </TT>\n");
156 room_tree_list(rp->rnext);
162 * \brief Room ordering stuff (compare first by floor, then by order)
163 * \param r1 first roomlist to compare
164 * \param r2 second roomlist co compare
165 * \return are they the same???
167 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
169 if ((r1 == NULL) && (r2 == NULL))
175 if (r1->rlfloor < r2->rlfloor)
177 if (r1->rlfloor > r2->rlfloor)
179 if (r1->rlorder < r2->rlorder)
181 if (r1->rlorder > r2->rlorder)
188 * \brief Common code for all room listings
189 * \param variety what???
191 void listrms(char *variety)
196 struct roomlisting *rl = NULL;
197 struct roomlisting *rp;
198 struct roomlisting *rs;
201 /** Ask the server for a room list */
203 serv_getln(buf, sizeof buf);
208 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
210 rp = malloc(sizeof(struct roomlisting));
211 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
212 rp->rlflags = extract_int(buf, 1);
213 rp->rlfloor = extract_int(buf, 2);
214 rp->rlorder = extract_int(buf, 3);
223 if (rordercmp(rp, rs) < 0) {
224 if (rs->lnext == NULL) {
231 if (rs->rnext == NULL) {
244 * If no rooms were listed, print an nbsp to make the cell
245 * borders show up anyway.
247 if (num_rooms == 0) wprintf(" ");
252 * \brief list all forgotten rooms
254 void zapped_list(void)
256 output_headers(1, 1, 0, 0, 0, 0);
258 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
259 do_template("beginbox");
263 wprintf("<br /><br />\n");
264 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
265 do_template("endbox");
271 * \brief read this room's info file (set v to 1 for verbose mode)
278 serv_getln(buf, sizeof buf);
291 * \brief Display room banner icon.
292 * The server doesn't actually
293 * need the room name, but we supply it in order to
294 * keep the browser from using a cached icon from
297 void embed_room_graphic(void) {
300 serv_puts("OIMG _roompic_");
301 serv_getln(buf, sizeof buf);
303 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
304 urlescputs(WC->wc_roomname);
307 serv_getln(buf, sizeof buf);
309 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
310 wprintf("<img height=48 width=48 src=\""
311 "static/viewcontacts_48x.gif"
315 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
316 wprintf("<img height=48 width=48 src=\""
317 "static/calarea_48x.gif"
321 else if (WC->wc_view == VIEW_TASKS) {
322 wprintf("<img height=48 width=48 src=\""
323 "static/taskmanag_48x.gif"
327 else if (WC->wc_view == VIEW_NOTES) {
328 wprintf("<img height=48 width=48 src=\""
329 "static/storenotes_48x.gif"
333 else if (WC->wc_view == VIEW_MAILBOX) {
334 wprintf("<img height=48 width=48 src=\""
335 "static/privatemess_48x.gif"
340 wprintf("<img height=48 width=48 src=\""
341 "static/chatrooms_48x.gif"
351 * \brief Display the current view and offer an option to change it
353 void embed_view_o_matic(void) {
356 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
357 "<span class=\"room_banner_new_messages\">");
358 wprintf(_("View as:"));
360 "<SELECT NAME=\"newview\" SIZE=\"1\" "
361 "STYLE=\"font-size: 7pt; background: #444455; color: #ddddcc;\" "
362 "OnChange=\"location.href=viewomatic.newview.options"
363 "[selectedIndex].value\">\n");
365 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
367 * Only offer the views that make sense, given the default
368 * view for the room. For example, don't offer a Calendar
369 * view in a non-Calendar room.
373 || (i == WC->wc_default_view) /**< default */
374 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
375 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
376 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
379 wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
380 ((i == WC->wc_view) ? "SELECTED" : ""),
382 escputs(viewdefs[i]);
383 wprintf("</OPTION>\n");
386 wprintf("</select></span></form>\n");
391 * \brief view room banner
393 * \param navbar_style
395 void embed_room_banner(char *got, int navbar_style) {
399 * We need to have the information returned by a GOTO server command.
400 * If it isn't supplied, we fake it by issuing our own GOTO.
403 serv_printf("GOTO %s", WC->wc_roomname);
404 serv_getln(buf, sizeof buf);
408 /** The browser needs some information for its own use */
409 wprintf("<script type=\"text/javascript\"> \n"
410 " room_is_trash = %d; \n"
416 * If the user happens to select the "make this my start page" link,
417 * we want it to remember the URL as a "/dotskip" one instead of
418 * a "skip" or "gotonext" or something like that.
420 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
423 /** Check for new mail. */
424 WC->new_mail = extract_int(&got[4], 9);
425 WC->wc_view = extract_int(&got[4], 11);
427 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
428 svprintf("NUMMSGS", WCS_STRING,
429 _("%d new of %d messages"),
430 extract_int(&got[4], 1),
431 extract_int(&got[4], 2)
433 svcallback("ROOMPIC", embed_room_graphic);
434 svcallback("ROOMINFO", readinfo);
435 svcallback("VIEWOMATIC", embed_view_o_matic);
436 svcallback("START", offer_start_page);
438 do_template("roombanner");
439 if (navbar_style != navbar_none) {
441 wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
442 "<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
445 if (navbar_style == navbar_default) wprintf(
447 "<a href=\"ungoto\">"
448 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
449 "<span class=\"navbar_link\">%s</span></A>"
450 "</td>\n", _("Ungoto")
453 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
456 "<a href=\"readnew\">"
457 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
458 "<span class=\"navbar_link\">%s</span></A>"
459 "</td>\n", _("Read new messages")
463 if (navbar_style == navbar_default) {
464 switch(WC->wc_view) {
465 case VIEW_ADDRESSBOOK:
468 "<a href=\"readfwd\">"
469 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
471 "<span class=\"navbar_link\">"
473 "</span></a></td>\n", _("View contacts")
479 "<a href=\"readfwd?calview=day\">"
480 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
482 "<span class=\"navbar_link\">"
484 "</span></a></td>\n", _("Day view")
488 "<a href=\"readfwd?calview=month\">"
489 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
491 "<span class=\"navbar_link\">"
493 "</span></a></td>\n", _("Month view")
499 "<a href=\"readfwd?calview=month\">"
500 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
502 "<span class=\"navbar_link\">"
504 "</span></a></td>\n", _("Calendar list")
510 "<a href=\"readfwd\">"
511 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
513 "<span class=\"navbar_link\">"
515 "</span></a></td>\n", _("View tasks")
521 "<a href=\"readfwd\">"
522 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
524 "<span class=\"navbar_link\">"
526 "</span></a></td>\n", _("View notes")
532 "<a href=\"readfwd\">"
533 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
535 "<span class=\"navbar_link\">"
537 "</span></a></td>\n", _("View message list")
543 "<a href=\"readfwd\">"
544 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
546 "<span class=\"navbar_link\">"
548 "</span></a></td>\n", _("Wiki home")
554 "<a href=\"readfwd\">"
555 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
557 "<span class=\"navbar_link\">"
559 "</span></a></td>\n", _("Read all messages")
565 if (navbar_style == navbar_default) {
566 switch(WC->wc_view) {
567 case VIEW_ADDRESSBOOK:
569 "<td><a href=\"display_enter\">"
570 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
571 "border=\"0\"><span class=\"navbar_link\">"
573 "</span></a></td>\n", _("Add new contact")
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)
842 serv_puts("SLRP HIGHEST");
843 serv_getln(buf, sizeof buf);
848 * \brief un-goto the previous room
854 if (!strcmp(WC->ugname, "")) {
855 smart_goto(WC->wc_roomname);
858 serv_printf("GOTO %s", WC->ugname);
859 serv_getln(buf, sizeof buf);
861 smart_goto(WC->wc_roomname);
864 if (WC->uglsn >= 0L) {
865 serv_printf("SLRP %ld", WC->uglsn);
866 serv_getln(buf, sizeof buf);
868 strcpy(buf, WC->ugname);
869 strcpy(WC->ugname, "");
878 * \brief Set/clear/read the "self-service list subscribe" flag for a room
880 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
881 * \return return the new value.
884 int self_service(int newval) {
885 int current_value = 0;
891 int flags, floor, order, view, flags2;
894 serv_getln(buf, sizeof buf);
895 if (buf[0] != '2') return(0);
897 extract_token(name, &buf[4], 0, '|', sizeof name);
898 extract_token(password, &buf[4], 1, '|', sizeof password);
899 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
900 flags = extract_int(&buf[4], 3);
901 floor = extract_int(&buf[4], 4);
902 order = extract_int(&buf[4], 5);
903 view = extract_int(&buf[4], 6);
904 flags2 = extract_int(&buf[4], 7);
906 if (flags2 & QR2_SELFLIST) {
914 flags2 = flags2 | QR2_SELFLIST;
916 else if (newval == 0) {
917 flags2 = flags2 & ~QR2_SELFLIST;
920 return(current_value);
923 if (newval != current_value) {
924 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
925 name, password, dirname, flags,
926 floor, order, view, flags2);
927 serv_getln(buf, sizeof buf);
940 * \brief display the form for editing a room
942 void display_editroom(void)
947 char remote_room[SIZ];
950 char er_password[10];
952 char er_roomaide[26];
958 char *not_shared_with;
965 if (strlen(tab) == 0) tab = "admin";
969 serv_getln(buf, sizeof buf);
972 strcpy(WC->ImportantMessage, &buf[4]);
976 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
977 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
978 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
979 er_flags = extract_int(&buf[4], 3);
980 er_floor = extract_int(&buf[4], 4);
982 output_headers(1, 1, 1, 0, 0, 0);
984 /** print the tabbed dialog */
986 "<div class=\"fix_scrollbar_bug\">"
987 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
989 "<TD> </TD>\n");
991 if (!strcmp(tab, "admin")) {
992 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
995 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=admin\">");
997 wprintf(_("Administration"));
998 if (!strcmp(tab, "admin")) {
999 wprintf("</SPAN></TD>\n");
1002 wprintf("</A></TD>\n");
1005 wprintf("<TD> </TD>\n");
1007 if (!strcmp(tab, "config")) {
1008 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1011 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=config\">");
1013 wprintf(_("Configuration"));
1014 if (!strcmp(tab, "config")) {
1015 wprintf("</SPAN></TD>\n");
1018 wprintf("</A></TD>\n");
1021 wprintf("<TD> </TD>\n");
1023 if (!strcmp(tab, "expire")) {
1024 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1027 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=expire\">");
1029 wprintf(_("Message expire policy"));
1030 if (!strcmp(tab, "expire")) {
1031 wprintf("</SPAN></TD>\n");
1034 wprintf("</A></TD>\n");
1037 wprintf("<TD> </TD>\n");
1039 if (!strcmp(tab, "access")) {
1040 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1043 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=access\">");
1045 wprintf(_("Access controls"));
1046 if (!strcmp(tab, "access")) {
1047 wprintf("</SPAN></TD>\n");
1050 wprintf("</A></TD>\n");
1053 wprintf("<TD> </TD>\n");
1055 if (!strcmp(tab, "sharing")) {
1056 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1059 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=sharing\">");
1061 wprintf(_("Sharing"));
1062 if (!strcmp(tab, "sharing")) {
1063 wprintf("</SPAN></TD>\n");
1066 wprintf("</A></TD>\n");
1069 wprintf("<TD> </TD>\n");
1071 if (!strcmp(tab, "listserv")) {
1072 wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
1075 wprintf("<TD BGCOLOR=\"#CCCCCC\"><a href=\"display_editroom&tab=listserv\">");
1077 wprintf(_("Mailing list service"));
1078 if (!strcmp(tab, "listserv")) {
1079 wprintf("</SPAN></TD>\n");
1082 wprintf("</A></TD>\n");
1085 wprintf("<TD> </TD>\n");
1087 wprintf("</TR></TABLE></div>\n");
1088 /** end tabbed dialog */
1090 /** begin content of whatever tab is open now */
1091 wprintf("<div class=\"fix_scrollbar_bug\">"
1092 "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
1095 if (!strcmp(tab, "admin")) {
1097 "<LI><a href=\"delete_room\" "
1098 "onClick=\"return confirm('");
1099 wprintf(_("Are you sure you want to delete this room?"));
1100 wprintf("');\">\n");
1101 wprintf(_("Delete this room"));
1103 "<LI><a href=\"display_editroompic\">\n");
1104 wprintf(_("Set or change the icon for this room's banner"));
1106 "<LI><a href=\"display_editinfo\">\n");
1107 wprintf(_("Edit this room's Info file"));
1112 if (!strcmp(tab, "config")) {
1113 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1115 wprintf("<UL><LI>");
1116 wprintf(_("Name of room: "));
1117 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1123 wprintf(_("Resides on floor: "));
1124 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1125 for (i = 0; i < 128; ++i)
1126 if (strlen(floorlist[i]) > 0) {
1127 wprintf("<OPTION ");
1129 wprintf("SELECTED ");
1130 wprintf("VALUE=\"%d\">", i);
1131 escputs(floorlist[i]);
1132 wprintf("</OPTION>\n");
1134 wprintf("</SELECT>\n");
1137 wprintf(_("Type of room:"));
1140 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1141 if ((er_flags & QR_PRIVATE) == 0)
1142 wprintf("CHECKED ");
1144 wprintf(_("Public room"));
1147 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1148 if ((er_flags & QR_PRIVATE) &&
1149 (er_flags & QR_GUESSNAME))
1150 wprintf("CHECKED ");
1152 wprintf(_("Private - guess name"));
1154 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1155 if ((er_flags & QR_PRIVATE) &&
1156 (er_flags & QR_PASSWORDED))
1157 wprintf("CHECKED ");
1159 wprintf(_("Private - require password:"));
1160 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1163 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1164 if ((er_flags & QR_PRIVATE)
1165 && ((er_flags & QR_GUESSNAME) == 0)
1166 && ((er_flags & QR_PASSWORDED) == 0))
1167 wprintf("CHECKED ");
1169 wprintf(_("Private - invitation only"));
1171 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1173 wprintf(_("If private, cause current users to forget room"));
1175 wprintf("\n</UL>\n");
1177 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1178 if (er_flags & QR_PREFONLY)
1179 wprintf("CHECKED ");
1181 wprintf(_("Preferred users only"));
1183 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1184 if (er_flags & QR_READONLY)
1185 wprintf("CHECKED ");
1187 wprintf(_("Read-only room"));
1189 /** directory stuff */
1190 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1191 if (er_flags & QR_DIRECTORY)
1192 wprintf("CHECKED ");
1194 wprintf(_("File directory room"));
1196 wprintf("\n<UL><LI>");
1197 wprintf(_("Directory name: "));
1198 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1201 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1202 if (er_flags & QR_UPLOAD)
1203 wprintf("CHECKED ");
1205 wprintf(_("Uploading allowed"));
1207 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1208 if (er_flags & QR_DOWNLOAD)
1209 wprintf("CHECKED ");
1211 wprintf(_("Downloading allowed"));
1213 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1214 if (er_flags & QR_VISDIR)
1215 wprintf("CHECKED ");
1217 wprintf(_("Visible directory"));
1220 /** end of directory stuff */
1222 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1223 if (er_flags & QR_NETWORK)
1224 wprintf("CHECKED ");
1226 wprintf(_("Network shared room"));
1228 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1229 if (er_flags & QR_PERMANENT)
1230 wprintf("CHECKED ");
1232 wprintf(_("Permanent (does not auto-purge)"));
1234 /** start of anon options */
1237 wprintf(_("Anonymous messages"));
1240 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1241 if (((er_flags & QR_ANONONLY) == 0)
1242 && ((er_flags & QR_ANONOPT) == 0))
1243 wprintf("CHECKED ");
1245 wprintf(_("No anonymous messages"));
1247 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1248 if (er_flags & QR_ANONONLY)
1249 wprintf("CHECKED ");
1251 wprintf(_("All messages are anonymous"));
1253 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1254 if (er_flags & QR_ANONOPT)
1255 wprintf("CHECKED ");
1257 wprintf(_("Prompt user when entering messages"));
1260 /* end of anon options */
1263 wprintf(_("Room aide: "));
1265 serv_getln(buf, sizeof buf);
1266 if (buf[0] != '2') {
1267 wprintf("<em>%s</em>\n", &buf[4]);
1269 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1270 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1273 wprintf("</UL><CENTER>\n");
1274 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1275 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1277 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1285 /** Sharing the room with other Citadel nodes... */
1286 if (!strcmp(tab, "sharing")) {
1288 shared_with = strdup("");
1289 not_shared_with = strdup("");
1291 /** Learn the current configuration */
1292 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1293 serv_getln(buf, sizeof buf);
1294 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1295 extract_token(node, buf, 0, '|', sizeof node);
1296 not_shared_with = realloc(not_shared_with,
1297 strlen(not_shared_with) + 32);
1298 strcat(not_shared_with, node);
1299 strcat(not_shared_with, "\n");
1303 serv_getln(buf, sizeof buf);
1304 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1305 extract_token(cmd, buf, 0, '|', sizeof cmd);
1306 extract_token(node, buf, 1, '|', sizeof node);
1307 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1308 if (!strcasecmp(cmd, "ignet_push_share")) {
1309 shared_with = realloc(shared_with,
1310 strlen(shared_with) + 32);
1311 strcat(shared_with, node);
1312 if (strlen(remote_room) > 0) {
1313 strcat(shared_with, "|");
1314 strcat(shared_with, remote_room);
1316 strcat(shared_with, "\n");
1320 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1321 extract_token(buf, shared_with, i, '\n', sizeof buf);
1322 extract_token(node, buf, 0, '|', sizeof node);
1323 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1324 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1325 if (!strcasecmp(node, cmd)) {
1326 remove_token(not_shared_with, j, '\n');
1331 /** Display the stuff */
1332 wprintf("<CENTER><br />"
1333 "<TABLE border=1 cellpadding=5><TR>"
1335 wprintf(_("Shared with"));
1336 wprintf("</I></B></TD>"
1338 wprintf(_("Not shared with"));
1339 wprintf("</I></B></TD></TR>\n"
1340 "<TR><TD VALIGN=TOP>\n");
1342 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1343 wprintf(_("Remote node name"));
1344 wprintf("</TD><TD>");
1345 wprintf(_("Remote room name"));
1346 wprintf("</TD><TD>");
1347 wprintf(_("Actions"));
1348 wprintf("</TD></TR>\n");
1350 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1351 extract_token(buf, shared_with, i, '\n', sizeof buf);
1352 extract_token(node, buf, 0, '|', sizeof node);
1353 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1354 if (strlen(node) > 0) {
1355 wprintf("<FORM METHOD=\"POST\" "
1356 "action=\"netedit\">"
1357 "<TR><TD>%s</TD>\n", node);
1360 if (strlen(remote_room) > 0) {
1361 escputs(remote_room);
1367 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1368 "VALUE=\"ignet_push_share|");
1370 if (strlen(remote_room) > 0) {
1372 urlescputs(remote_room);
1375 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1376 "VALUE=\"sharing\">\n");
1377 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1378 "VALUE=\"remove\">\n");
1379 wprintf("<INPUT TYPE=\"submit\" "
1380 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1381 wprintf("</TD></TR></FORM>\n");
1385 wprintf("</TABLE>\n");
1386 wprintf("</TD><TD VALIGN=TOP>\n");
1387 wprintf("<TABLE border=0 cellpadding=5><TR BGCOLOR=\"#CCCCCC\"><TD>");
1388 wprintf(_("Remote node name"));
1389 wprintf("</TD><TD>");
1390 wprintf(_("Remote room name"));
1391 wprintf("</TD><TD>");
1392 wprintf(_("Actions"));
1393 wprintf("</TD></TR>\n");
1395 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1396 extract_token(node, not_shared_with, i, '\n', sizeof node);
1397 if (strlen(node) > 0) {
1398 wprintf("<FORM METHOD=\"POST\" "
1399 "action=\"netedit\">"
1403 "<INPUT TYPE=\"INPUT\" "
1407 wprintf("<INPUT TYPE=\"hidden\" "
1409 "VALUE=\"ignet_push_share|");
1412 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1413 "VALUE=\"sharing\">\n");
1414 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1415 "VALUE=\"add\">\n");
1416 wprintf("<INPUT TYPE=\"submit\" "
1417 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1418 wprintf("</TD></TR></FORM>\n");
1422 wprintf("</TABLE>\n");
1423 wprintf("</TD></TR>"
1424 "</TABLE></CENTER><br />\n"
1425 "<I><B>%s</B><UL><LI>", _("Notes:"));
1426 wprintf(_("When sharing a room, "
1427 "it must be shared from both ends. Adding a node to "
1428 "the 'shared' list sends messages out, but in order to"
1429 " receive messages, the other nodes must be configured"
1430 " to send messages out to your system as well. "
1431 "<LI>If the remote room name is blank, it is assumed "
1432 "that the room name is identical on the remote node."
1433 "<LI>If the remote room name is different, the remote "
1434 "node must also configure the name of the room here."
1440 /** Mailing list management */
1441 if (!strcmp(tab, "listserv")) {
1443 wprintf("<br /><center>"
1444 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1445 "<TR><TD VALIGN=TOP>");
1447 wprintf(_("<i>The contents of this room are being "
1448 "mailed <b>as individual messages</b> "
1449 "to the following list recipients:"
1450 "</i><br /><br />\n"));
1453 serv_getln(buf, sizeof buf);
1454 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1455 extract_token(cmd, buf, 0, '|', sizeof cmd);
1456 if (!strcasecmp(cmd, "listrecp")) {
1457 extract_token(recp, buf, 1, '|', sizeof recp);
1460 wprintf(" <a href=\"netedit&cmd=remove&line="
1463 wprintf("&tab=listserv\">");
1464 wprintf(_("(remove)"));
1465 wprintf("</A><br />");
1468 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1469 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1470 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1471 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1472 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1473 wprintf("</FORM>\n");
1475 wprintf("</TD><TD VALIGN=TOP>\n");
1477 wprintf(_("<i>The contents of this room are being "
1478 "mailed <b>in digest form</b> "
1479 "to the following list recipients:"
1480 "</i><br /><br />\n"));
1483 serv_getln(buf, sizeof buf);
1484 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1485 extract_token(cmd, buf, 0, '|', sizeof cmd);
1486 if (!strcasecmp(cmd, "digestrecp")) {
1487 extract_token(recp, buf, 1, '|', sizeof recp);
1490 wprintf(" <a href=\"netedit&cmd=remove&line="
1493 wprintf("&tab=listserv\">");
1494 wprintf(_("(remove)"));
1495 wprintf("</A><br />");
1498 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1499 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1500 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1501 wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
1502 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1503 wprintf("</FORM>\n");
1505 wprintf("</TD></TR></TABLE><hr />\n");
1507 if (self_service(999) == 1) {
1508 wprintf(_("This room is configured to allow "
1509 "self-service subscribe/unsubscribe requests."));
1510 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1511 wprintf(_("Click to disable."));
1512 wprintf("</A><br />\n");
1513 wprintf(_("The URL for subscribe/unsubscribe is: "));
1514 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1515 (is_https ? "https" : "http"),
1519 wprintf(_("This room is <i>not</i> configured to allow "
1520 "self-service subscribe/unsubscribe requests."));
1521 wprintf(" <a href=\"toggle_self_service?newval=1&"
1523 wprintf(_("Click to enable."));
1524 wprintf("</A><br />\n");
1528 wprintf("</CENTER>\n");
1532 /** Mailing list management */
1533 if (!strcmp(tab, "expire")) {
1535 serv_puts("GPEX room");
1536 serv_getln(buf, sizeof buf);
1537 if (buf[0] == '2') {
1538 roompolicy = extract_int(&buf[4], 0);
1539 roomvalue = extract_int(&buf[4], 1);
1542 serv_puts("GPEX floor");
1543 serv_getln(buf, sizeof buf);
1544 if (buf[0] == '2') {
1545 floorpolicy = extract_int(&buf[4], 0);
1546 floorvalue = extract_int(&buf[4], 1);
1549 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1550 wprintf("<TABLE border=0 cellspacing=5>\n");
1551 wprintf("<TR><TD>");
1552 wprintf(_("Message expire policy for this room"));
1554 escputs(WC->wc_roomname);
1555 wprintf(")</TD><TD>");
1556 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1557 ((roompolicy == 0) ? "CHECKED" : "") );
1558 wprintf(_("Use the default policy for this floor"));
1559 wprintf("<br />\n");
1560 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1561 ((roompolicy == 1) ? "CHECKED" : "") );
1562 wprintf(_("Never automatically expire messages"));
1563 wprintf("<br />\n");
1564 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1565 ((roompolicy == 2) ? "CHECKED" : "") );
1566 wprintf(_("Expire by message count"));
1567 wprintf("<br />\n");
1568 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1569 ((roompolicy == 3) ? "CHECKED" : "") );
1570 wprintf(_("Expire by message age"));
1572 wprintf(_("Number of messages or days: "));
1573 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1574 wprintf("</TD></TR>\n");
1576 if (WC->axlevel >= 6) {
1577 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1578 wprintf("<TR><TD>");
1579 wprintf(_("Message expire policy for this floor"));
1581 escputs(floorlist[WC->wc_floor]);
1582 wprintf(")</TD><TD>");
1583 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1584 ((floorpolicy == 0) ? "CHECKED" : "") );
1585 wprintf(_("Use the system default"));
1586 wprintf("<br />\n");
1587 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1588 ((floorpolicy == 1) ? "CHECKED" : "") );
1589 wprintf(_("Never automatically expire messages"));
1590 wprintf("<br />\n");
1591 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1592 ((floorpolicy == 2) ? "CHECKED" : "") );
1593 wprintf(_("Expire by message count"));
1594 wprintf("<br />\n");
1595 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1596 ((floorpolicy == 3) ? "CHECKED" : "") );
1597 wprintf(_("Expire by message age"));
1599 wprintf(_("Number of messages or days: "));
1600 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1604 wprintf("<CENTER>\n");
1605 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1606 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1608 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1609 wprintf("</CENTER></TD><TR>\n");
1611 wprintf("</TABLE>\n"
1612 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1618 /** Mailing list management */
1619 if (!strcmp(tab, "access")) {
1623 /** end content of whatever tab is open now */
1624 wprintf("</TD></TR></TABLE></div>\n");
1631 * \brief Toggle self-service list subscription
1633 void toggle_self_service(void) {
1636 newval = atoi(bstr("newval"));
1637 self_service(newval);
1644 * \brief save new parameters for a room
1650 char er_password[10];
1651 char er_dirname[15];
1652 char er_roomaide[26];
1658 if (strlen(bstr("ok_button")) == 0) {
1659 strcpy(WC->ImportantMessage,
1660 _("Cancelled. Changes were not saved."));
1665 serv_getln(buf, sizeof buf);
1667 if (buf[0] != '2') {
1668 strcpy(WC->ImportantMessage, &buf[4]);
1672 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1673 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1674 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1675 er_flags = extract_int(&buf[4], 3);
1677 strcpy(er_roomaide, bstr("er_roomaide"));
1678 if (strlen(er_roomaide) == 0) {
1680 serv_getln(buf, sizeof buf);
1681 if (buf[0] != '2') {
1682 strcpy(er_roomaide, "");
1684 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1687 strcpy(buf, bstr("er_name"));
1689 if (strlen(buf) > 0) {
1690 strcpy(er_name, buf);
1693 strcpy(buf, bstr("er_password"));
1695 if (strlen(buf) > 0)
1696 strcpy(er_password, buf);
1698 strcpy(buf, bstr("er_dirname"));
1700 if (strlen(buf) > 0)
1701 strcpy(er_dirname, buf);
1703 strcpy(buf, bstr("type"));
1704 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1706 if (!strcmp(buf, "invonly")) {
1707 er_flags |= (QR_PRIVATE);
1709 if (!strcmp(buf, "hidden")) {
1710 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1712 if (!strcmp(buf, "passworded")) {
1713 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1715 if (!strcmp(bstr("prefonly"), "yes")) {
1716 er_flags |= QR_PREFONLY;
1718 er_flags &= ~QR_PREFONLY;
1721 if (!strcmp(bstr("readonly"), "yes")) {
1722 er_flags |= QR_READONLY;
1724 er_flags &= ~QR_READONLY;
1727 if (!strcmp(bstr("permanent"), "yes")) {
1728 er_flags |= QR_PERMANENT;
1730 er_flags &= ~QR_PERMANENT;
1733 if (!strcmp(bstr("network"), "yes")) {
1734 er_flags |= QR_NETWORK;
1736 er_flags &= ~QR_NETWORK;
1739 if (!strcmp(bstr("directory"), "yes")) {
1740 er_flags |= QR_DIRECTORY;
1742 er_flags &= ~QR_DIRECTORY;
1745 if (!strcmp(bstr("ulallowed"), "yes")) {
1746 er_flags |= QR_UPLOAD;
1748 er_flags &= ~QR_UPLOAD;
1751 if (!strcmp(bstr("dlallowed"), "yes")) {
1752 er_flags |= QR_DOWNLOAD;
1754 er_flags &= ~QR_DOWNLOAD;
1757 if (!strcmp(bstr("visdir"), "yes")) {
1758 er_flags |= QR_VISDIR;
1760 er_flags &= ~QR_VISDIR;
1763 strcpy(buf, bstr("anon"));
1765 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1766 if (!strcmp(buf, "anononly"))
1767 er_flags |= QR_ANONONLY;
1768 if (!strcmp(buf, "anon2"))
1769 er_flags |= QR_ANONOPT;
1772 if (!strcmp(bstr("bump"), "yes"))
1775 er_floor = atoi(bstr("er_floor"));
1777 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d",
1778 er_name, er_password, er_dirname, er_flags, bump, er_floor);
1780 serv_getln(buf, sizeof buf);
1781 if (buf[0] != '2') {
1782 strcpy(WC->ImportantMessage, &buf[4]);
1788 if (strlen(er_roomaide) > 0) {
1789 sprintf(buf, "SETA %s", er_roomaide);
1791 serv_getln(buf, sizeof buf);
1792 if (buf[0] != '2') {
1793 strcpy(WC->ImportantMessage, &buf[4]);
1794 display_main_menu();
1799 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1806 * \brief Display form for Invite, Kick, and show Who Knows a room
1808 void do_invt_kick(void) {
1809 char buf[SIZ], room[SIZ], username[SIZ];
1812 serv_getln(buf, sizeof buf);
1814 if (buf[0] != '2') {
1818 extract_token(room, &buf[4], 0, '|', sizeof room);
1820 strcpy(username, bstr("username"));
1822 if (strlen(bstr("kick_button")) > 0) {
1823 sprintf(buf, "KICK %s", username);
1825 serv_getln(buf, sizeof buf);
1827 if (buf[0] != '2') {
1828 strcpy(WC->ImportantMessage, &buf[4]);
1830 sprintf(WC->ImportantMessage,
1831 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1836 if (strlen(bstr("invite_button")) > 0) {
1837 sprintf(buf, "INVT %s", username);
1839 serv_getln(buf, sizeof buf);
1841 if (buf[0] != '2') {
1842 strcpy(WC->ImportantMessage, &buf[4]);
1844 sprintf(WC->ImportantMessage,
1845 _("<B><I>User %s invited to room %s.</I></B>\n"),
1856 * \brief Display form for Invite, Kick, and show Who Knows a room
1858 void display_whok(void)
1860 char buf[SIZ], room[SIZ], username[SIZ];
1863 serv_getln(buf, sizeof buf);
1865 if (buf[0] != '2') {
1869 extract_token(room, &buf[4], 0, '|', sizeof room);
1872 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1873 wprintf(_("The users listed below have access to this room. "
1874 "To remove a user from the access list, select the user "
1875 "name from the list and click 'Kick'."));
1876 wprintf("<br /><br />");
1878 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1879 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1880 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1882 serv_getln(buf, sizeof buf);
1883 if (buf[0] == '1') {
1884 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1885 extract_token(username, buf, 0, '|', sizeof username);
1886 wprintf("<OPTION>");
1891 wprintf("</SELECT><br />\n");
1893 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1894 wprintf("</FORM></CENTER>\n");
1896 wprintf("</TD><TD>");
1897 wprintf(_("To grant another user access to this room, enter the "
1898 "user name in the box below and click 'Invite'."));
1899 wprintf("<br /><br />");
1901 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1902 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1903 wprintf(_("Invite:"));
1905 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
1906 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
1907 "<input type=\"submit\" value=\"%s\">"
1908 "</FORM></CENTER>\n", _("Invite"));
1910 wprintf("</TD></TR></TABLE>\n");
1917 * \brief display the form for entering a new room
1919 void display_entroom(void)
1924 serv_puts("CRE8 0");
1925 serv_getln(buf, sizeof buf);
1927 if (buf[0] != '2') {
1928 strcpy(WC->ImportantMessage, &buf[4]);
1929 display_main_menu();
1933 output_headers(1, 1, 2, 0, 0, 0);
1934 wprintf("<div id=\"banner\">\n"
1935 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
1936 "<SPAN CLASS=\"titlebar\">");
1937 wprintf(_("Create a new room"));
1939 "</TD></TR></TABLE>\n"
1940 "</div>\n<div id=\"content\">\n"
1943 wprintf("<div class=\"fix_scrollbar_bug\">"
1944 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
1946 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
1948 wprintf("<UL><LI>");
1949 wprintf(_("Name of room: "));
1950 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
1953 wprintf(_("Resides on floor: "));
1955 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1956 for (i = 0; i < 128; ++i)
1957 if (strlen(floorlist[i]) > 0) {
1958 wprintf("<OPTION ");
1959 wprintf("VALUE=\"%d\">", i);
1960 escputs(floorlist[i]);
1961 wprintf("</OPTION>\n");
1963 wprintf("</SELECT>\n");
1966 * Our clever little snippet of JavaScript automatically selects
1967 * a public room if the view is set to Bulletin Board or wiki, and
1968 * it selects a mailbox room otherwise. The user can override this,
1969 * of course. We also disable the floor selector for mailboxes.
1972 wprintf(_("Default view for room: "));
1973 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
1974 " if ( (this.form.er_view.value == 0) "
1975 " || (this.form.er_view.value == 6) ) { "
1976 " this.form.type[0].checked=true; "
1977 " this.form.er_floor.disabled = false; "
1980 " this.form.type[4].checked=true; "
1981 " this.form.er_floor.disabled = true; "
1984 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
1985 if (is_view_allowed_as_default(i)) {
1986 wprintf("<OPTION %s VALUE=\"%d\">",
1987 ((i == 0) ? "SELECTED" : ""), i );
1988 escputs(viewdefs[i]);
1989 wprintf("</OPTION>\n");
1992 wprintf("</SELECT>\n");
1995 wprintf(_("Type of room:"));
1998 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1999 wprintf("CHECKED OnChange=\""
2000 " if (this.form.type[0].checked == true) { "
2001 " this.form.er_floor.disabled = false; "
2004 wprintf(_("Public (automatically appears to everyone)"));
2006 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2007 " if (this.form.type[1].checked == true) { "
2008 " this.form.er_floor.disabled = false; "
2011 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2013 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2014 " if (this.form.type[2].checked == true) { "
2015 " this.form.er_floor.disabled = false; "
2018 wprintf(_("Private - require password: "));
2019 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2021 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2022 " if (this.form.type[3].checked == true) { "
2023 " this.form.er_floor.disabled = false; "
2026 wprintf(_("Private - invitation only"));
2028 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2030 " if (this.form.type[4].checked == true) { "
2031 " this.form.er_floor.disabled = true; "
2034 wprintf(_("Personal (mailbox for you only)"));
2036 wprintf("\n</UL>\n");
2038 wprintf("<CENTER>\n");
2039 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2041 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2042 wprintf("</CENTER>\n");
2043 wprintf("</FORM>\n<hr />");
2044 serv_printf("MESG roomaccess");
2045 serv_getln(buf, sizeof buf);
2046 if (buf[0] == '1') {
2049 wprintf("</td></tr></table></div>\n");
2057 * \brief support function for entroom() -- sets the default view
2059 void er_set_default_view(int newview) {
2072 serv_getln(buf, sizeof buf);
2073 if (buf[0] != '2') return;
2075 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2076 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2077 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2078 rm_bits1 = extract_int(&buf[4], 3);
2079 rm_floor = extract_int(&buf[4], 4);
2080 rm_listorder = extract_int(&buf[4], 5);
2081 rm_bits2 = extract_int(&buf[4], 7);
2083 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2084 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2085 rm_listorder, newview, rm_bits2
2087 serv_getln(buf, sizeof buf);
2093 * \brief enter a new room
2100 char er_password[SIZ];
2105 if (strlen(bstr("ok_button")) == 0) {
2106 strcpy(WC->ImportantMessage,
2107 _("Cancelled. No new room was created."));
2108 display_main_menu();
2111 strcpy(er_name, bstr("er_name"));
2112 strcpy(er_type, bstr("type"));
2113 strcpy(er_password, bstr("er_password"));
2114 er_floor = atoi(bstr("er_floor"));
2115 er_view = atoi(bstr("er_view"));
2118 if (!strcmp(er_type, "hidden"))
2120 if (!strcmp(er_type, "passworded"))
2122 if (!strcmp(er_type, "invonly"))
2124 if (!strcmp(er_type, "personal"))
2127 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2128 er_name, er_num_type, er_password, er_floor, 0, er_view);
2130 serv_getln(buf, sizeof buf);
2131 if (buf[0] != '2') {
2132 strcpy(WC->ImportantMessage, &buf[4]);
2133 display_main_menu();
2137 do_change_view(er_view); /* Now go there */
2142 * \brief display the screen to enter a private room
2144 void display_private(char *rname, int req_pass)
2146 output_headers(1, 1, 2, 0, 0, 0);
2147 wprintf("<div id=\"banner\">\n"
2148 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2149 "<SPAN CLASS=\"titlebar\">");
2150 wprintf(_("Go to a hidden room"));
2152 "</TD></TR></TABLE>\n"
2153 "</div>\n<div id=\"content\">\n"
2156 wprintf("<div class=\"fix_scrollbar_bug\">"
2157 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
2159 wprintf("<CENTER>\n");
2161 wprintf(_("If you know the name of a hidden (guess-name) or "
2162 "passworded room, you can enter that room by typing "
2163 "its name below. Once you gain access to a private "
2164 "room, it will appear in your regular room listings "
2165 "so you don't have to keep returning here."));
2166 wprintf("\n<br /><br />");
2168 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2170 wprintf("<table border=\"0\" cellspacing=\"5\" "
2171 "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
2173 wprintf(_("Enter room name:"));
2175 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2176 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2179 wprintf("</TD></TR><TR><TD>");
2180 wprintf(_("Enter room password:"));
2181 wprintf("</TD><TD>");
2182 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2184 wprintf("</TD></TR></TABLE><br />\n");
2186 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2188 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2192 wprintf("</FORM>\n");
2193 wprintf("</td></tr></table></div>\n");
2198 * \brief goto a private room
2200 void goto_private(void)
2205 if (strlen(bstr("ok_button")) == 0) {
2206 display_main_menu();
2209 strcpy(hold_rm, WC->wc_roomname);
2210 strcpy(buf, "GOTO ");
2211 strcat(buf, bstr("gr_name"));
2213 strcat(buf, bstr("gr_pass"));
2215 serv_getln(buf, sizeof buf);
2217 if (buf[0] == '2') {
2218 smart_goto(bstr("gr_name"));
2221 if (!strncmp(buf, "540", 3)) {
2222 display_private(bstr("gr_name"), 1);
2225 output_headers(1, 1, 1, 0, 0, 0);
2226 wprintf("%s\n", &buf[4]);
2233 * \brief display the screen to zap a room
2235 void display_zap(void)
2237 output_headers(1, 1, 2, 0, 0, 0);
2239 wprintf("<div id=\"banner\">\n");
2240 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
2241 wprintf("<SPAN CLASS=\"titlebar\">");
2242 wprintf(_("Zap (forget/unsubscribe) the current room"));
2243 wprintf("</SPAN>\n");
2244 wprintf("</TD></TR></TABLE>\n");
2245 wprintf("</div>\n<div id=\"content\">\n");
2247 wprintf(_("If you select this option, <em>%s</em> will "
2248 "disappear from your room list. Is this what you wish "
2249 "to do?<br />\n"), WC->wc_roomname);
2251 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2252 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2254 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2255 wprintf("</FORM>\n");
2266 char final_destination[SIZ];
2269 * If the forget-room routine fails for any reason, we fall back
2270 * to the current room; otherwise, we go to the Lobby
2272 strcpy(final_destination, WC->wc_roomname);
2274 if (strlen(bstr("ok_button")) > 0) {
2275 serv_printf("GOTO %s", WC->wc_roomname);
2276 serv_getln(buf, sizeof buf);
2277 if (buf[0] == '2') {
2279 serv_getln(buf, sizeof buf);
2280 if (buf[0] == '2') {
2281 strcpy(final_destination, "_BASEROOM_");
2285 smart_goto(final_destination);
2291 * \brief Delete the current room
2293 void delete_room(void)
2297 serv_puts("KILL 1");
2298 serv_getln(buf, sizeof buf);
2299 if (buf[0] != '2') {
2300 strcpy(WC->ImportantMessage, &buf[4]);
2301 display_main_menu();
2304 smart_goto("_BASEROOM_");
2311 * \brief Perform changes to a room's network configuration
2313 void netedit(void) {
2322 if (strlen(bstr("line"))==0) {
2327 strcpy(line, bstr("prefix"));
2328 strcat(line, bstr("line"));
2329 strcat(line, bstr("suffix"));
2338 serv_getln(buf, sizeof buf);
2339 if (buf[0] != '1') {
2345 /** This loop works for add *or* remove. Spiffy, eh? */
2346 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2347 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2348 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2349 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2350 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2351 if ( (strcasecmp(cmpa0, cmpb0))
2352 || (strcasecmp(cmpa1, cmpb1)) ) {
2353 fprintf(fp, "%s\n", buf);
2359 serv_getln(buf, sizeof buf);
2360 if (buf[0] != '4') {
2366 while (fgets(buf, sizeof buf, fp) != NULL) {
2367 buf[strlen(buf)-1] = 0;
2371 if (strlen(bstr("add_button")) > 0) {
2383 * \brief Convert a room name to a folder-ish-looking name.
2384 * \param folder the folderish name
2385 * \param room the room name
2386 * \param floor the floor name
2387 * \param is_mailbox is it a mailbox?
2389 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2394 * For mailboxes, just do it straight...
2397 sprintf(folder, "My folders|%s", room);
2401 * Otherwise, prefix the floor name as a "public folders" moniker
2404 sprintf(folder, "%s|%s", floorlist[floor], room);
2408 * Replace "\" characters with "|" for pseudo-folder-delimiting
2410 for (i=0; i<strlen(folder); ++i) {
2411 if (folder[i] == '\\') folder[i] = '|';
2419 * \brief Back end for change_view()
2420 * \param newview set newview???
2422 void do_change_view(int newview) {
2425 serv_printf("VIEW %d", newview);
2426 serv_getln(buf, sizeof buf);
2427 WC->wc_view = newview;
2428 smart_goto(WC->wc_roomname);
2434 * \brief Change the view for this room
2436 void change_view(void) {
2439 view = atol(bstr("view"));
2440 do_change_view(view);
2445 * \brief One big expanded tree list view --- like a folder list
2446 * \param fold the folder to view
2447 * \param max_folders how many folders???
2448 * \param num_floors hom many floors???
2450 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2454 int has_subfolders = 0;
2457 parents = malloc(max_folders * sizeof(int));
2459 /** BEGIN TREE MENU */
2460 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2462 /** include NanoTree */
2463 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2465 /** initialize NanoTree */
2466 wprintf("<script type=\"text/javascript\"> \n"
2467 " showRootNode = false; \n"
2468 " sortNodes = false; \n"
2469 " dragable = false; \n"
2471 " function standardClick(treeNode) { \n"
2474 " var closedGif = 'static/folder_closed.gif'; \n"
2475 " var openGif = 'static/folder_open.gif'; \n"
2477 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2481 for (i=0; i<max_folders; ++i) {
2484 if ((i+1) < max_folders) {
2485 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2486 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2491 levels = num_tokens(fold[i].name, '|');
2492 parents[levels] = i;
2494 wprintf("var node%d = new TreeNode(%d, '", i, i);
2496 if (fold[i].selectable) {
2497 wprintf("<a href=\"dotgoto?room=");
2498 urlescputs(fold[i].room);
2503 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2505 else if (fold[i].hasnewmsgs) {
2506 wprintf("<SPAN CLASS=\"roomlist_new\">");
2509 wprintf("<SPAN CLASS=\"roomlist_old\">");
2511 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2516 if (has_subfolders) {
2517 wprintf("new Array(closedGif, openGif)");
2519 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2520 wprintf("'static/viewcontacts_16x.gif'");
2522 else if (fold[i].view == VIEW_CALENDAR) {
2523 wprintf("'static/calarea_16x.gif'");
2525 else if (fold[i].view == VIEW_CALBRIEF) {
2526 wprintf("'static/calarea_16x.gif'");
2528 else if (fold[i].view == VIEW_TASKS) {
2529 wprintf("'static/taskmanag_16x.gif'");
2531 else if (fold[i].view == VIEW_NOTES) {
2532 wprintf("'static/storenotes_16x.gif'");
2534 else if (fold[i].view == VIEW_MAILBOX) {
2535 wprintf("'static/privatemess_16x.gif'");
2538 wprintf("'static/chatrooms_16x.gif'");
2541 urlescputs(fold[i].name);
2545 wprintf("rootNode.addChild(node%d);\n", i);
2548 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2552 wprintf("container = document.getElementById('roomlist_div'); \n"
2558 /** END TREE MENU */
2562 * \brief Boxes and rooms and lists ... oh my!
2563 * \param fold the folder to view
2564 * \param max_folders how many folders???
2565 * \param num_floors hom many floors???
2567 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2569 char floor_name[256];
2570 char old_floor_name[256];
2572 int levels, oldlevels;
2575 static int columns = 3;
2576 int boxes_per_column = 0;
2577 int current_column = 0;
2580 strcpy(floor_name, "");
2581 strcpy(old_floor_name, "");
2584 while (nf % columns != 0) ++nf;
2585 boxes_per_column = (nf / columns);
2586 if (boxes_per_column < 1) boxes_per_column = 1;
2588 /** Outer table (for columnization) */
2589 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2590 "<tr><td valign=top>");
2594 for (i=0; i<max_folders; ++i) {
2596 levels = num_tokens(fold[i].name, '|');
2597 extract_token(floor_name, fold[i].name, 0,
2598 '|', sizeof floor_name);
2600 if ( (strcasecmp(floor_name, old_floor_name))
2601 && (strlen(old_floor_name) > 0) ) {
2603 do_template("endbox");
2606 if ((num_boxes % boxes_per_column) == 0) {
2608 if (current_column < columns) {
2609 wprintf("</td><td valign=top>\n");
2613 strcpy(old_floor_name, floor_name);
2616 /** Begin inner box */
2617 stresc(boxtitle, floor_name, 1, 0);
2618 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2619 do_template("beginbox");
2626 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2627 if (fold[i].selectable) {
2628 wprintf("<a href=\"dotgoto?room=");
2629 urlescputs(fold[i].room);
2635 if (fold[i].hasnewmsgs) {
2636 wprintf("<SPAN CLASS=\"roomlist_new\">");
2639 wprintf("<SPAN CLASS=\"roomlist_old\">");
2641 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2644 if (fold[i].selectable) {
2650 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2651 wprintf(" (INBOX)");
2653 wprintf("<br />\n");
2656 /** End the final inner box */
2657 do_template("endbox");
2659 wprintf("</TD></TR></TABLE>\n");
2663 * \brief print a floor div???
2664 * \param which_floordiv name of the floordiv???
2666 void set_floordiv_expanded(char *which_floordiv) {
2667 begin_ajax_response();
2668 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2669 end_ajax_response();
2673 * \brief view the iconbar
2674 * \param fold the folder to view
2675 * \param max_folders how many folders???
2676 * \param num_floors hom many floors???
2678 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2680 char floor_name[256];
2681 char old_floor_name[256];
2682 char floordivtitle[256];
2683 char floordiv_id[32];
2684 int levels, oldlevels;
2686 int num_drop_targets = 0;
2689 strcpy(floor_name, "");
2690 strcpy(old_floor_name, "");
2694 for (i=0; i<max_folders; ++i) {
2696 levels = num_tokens(fold[i].name, '|');
2697 extract_token(floor_name, fold[i].name, 0,
2698 '|', sizeof floor_name);
2700 if ( (strcasecmp(floor_name, old_floor_name))
2701 && (strlen(old_floor_name) > 0) ) {
2702 /** End inner box */
2704 wprintf("</div>\n"); /** floordiv */
2706 strcpy(old_floor_name, floor_name);
2710 stresc(floordivtitle, floor_name, 0, 0);
2711 sprintf(floordiv_id, "floordiv%d", i);
2712 wprintf("<span class=\"ib_roomlist_floor\" "
2713 "onClick=\"expand_floor('%s')\">"
2714 "%s</span><br>\n", floordiv_id, floordivtitle);
2715 wprintf("<div id=\"%s\" style=\"display:%s\">",
2717 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2724 wprintf("<div id=\"roomdiv%d\">", i);
2726 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2728 /** choose the icon */
2729 if (fold[i].view == VIEW_ADDRESSBOOK) {
2730 icon = "viewcontacts_16x.gif" ;
2732 else if (fold[i].view == VIEW_CALENDAR) {
2733 icon = "calarea_16x.gif" ;
2735 else if (fold[i].view == VIEW_CALBRIEF) {
2736 icon = "calarea_16x.gif" ;
2738 else if (fold[i].view == VIEW_TASKS) {
2739 icon = "taskmanag_16x.gif" ;
2741 else if (fold[i].view == VIEW_NOTES) {
2742 icon = "storenotes_16x.gif" ;
2744 else if (fold[i].view == VIEW_MAILBOX) {
2745 icon = "privatemess_16x.gif" ;
2748 icon = "chatrooms_16x.gif" ;
2751 if (fold[i].selectable) {
2752 wprintf("<a href=\"dotgoto?room=");
2753 urlescputs(fold[i].room);
2755 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2760 if (fold[i].hasnewmsgs) {
2761 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2764 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2766 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2768 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2769 wprintf(" (INBOX)");
2772 if (fold[i].selectable) {
2779 wprintf("</div>\n"); /** roomdiv */
2782 wprintf("</div>\n"); /** floordiv */
2785 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2786 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2788 num_drop_targets = 0;
2790 for (i=0; i<max_folders; ++i) {
2791 levels = num_tokens(fold[i].name, '|');
2793 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2794 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2795 jsescputs(fold[i].room);
2801 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2802 if (strlen(WC->floordiv_expanded) > 1) {
2803 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2807 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2813 * \brief Show the room list.
2814 * (only should get called by
2815 * knrooms() because that's where output_headers() is called from)
2816 * \param viewpref the view preferences???
2819 void list_all_rooms_by_floor(char *viewpref) {
2822 struct folder *fold = NULL;
2824 int max_folders = 0;
2825 int alloc_folders = 0;
2829 int num_floors = 1; /** add an extra one for private folders */
2831 /** If our cached folder list is very old, burn it. */
2832 if (WC->cache_fold != NULL) {
2833 if ((time(NULL) - WC->cache_timestamp) > 300) {
2834 free(WC->cache_fold);
2835 WC->cache_fold = NULL;
2839 /** Can we do the iconbar roomlist from cache? */
2840 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2841 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2845 /** Grab the floor table so we know how to build the list... */
2848 /** Start with the mailboxes */
2851 fold = malloc(sizeof(struct folder));
2852 memset(fold, 0, sizeof(struct folder));
2853 strcpy(fold[0].name, "My folders");
2854 fold[0].is_mailbox = 1;
2856 /** Then add floors */
2858 serv_getln(buf, sizeof buf);
2859 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2860 if (max_folders >= alloc_folders) {
2861 alloc_folders = max_folders + 100;
2862 fold = realloc(fold,
2863 alloc_folders * sizeof(struct folder));
2865 memset(&fold[max_folders], 0, sizeof(struct folder));
2866 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2871 /** Now add rooms */
2873 serv_getln(buf, sizeof buf);
2874 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2875 if (max_folders >= alloc_folders) {
2876 alloc_folders = max_folders + 100;
2877 fold = realloc(fold,
2878 alloc_folders * sizeof(struct folder));
2880 memset(&fold[max_folders], 0, sizeof(struct folder));
2881 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
2882 ra_flags = extract_int(buf, 5);
2883 flags = extract_int(buf, 1);
2884 fold[max_folders].floor = extract_int(buf, 2);
2885 fold[max_folders].hasnewmsgs =
2886 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
2887 if (flags & QR_MAILBOX) {
2888 fold[max_folders].is_mailbox = 1;
2890 fold[max_folders].view = extract_int(buf, 6);
2891 room_to_folder(fold[max_folders].name,
2892 fold[max_folders].room,
2893 fold[max_folders].floor,
2894 fold[max_folders].is_mailbox);
2895 fold[max_folders].selectable = 1;
2899 /** Bubble-sort the folder list */
2900 for (i=0; i<max_folders; ++i) {
2901 for (j=0; j<(max_folders-1)-i; ++j) {
2902 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
2903 swap = strcasecmp(fold[j].name, fold[j+1].name);
2906 if ( (fold[j+1].is_mailbox)
2907 && (!fold[j].is_mailbox)) {
2915 memcpy(&ftmp, &fold[j], sizeof(struct folder));
2916 memcpy(&fold[j], &fold[j+1],
2917 sizeof(struct folder));
2918 memcpy(&fold[j+1], &ftmp,
2919 sizeof(struct folder));
2925 if (!strcasecmp(viewpref, "folders")) {
2926 do_folder_view(fold, max_folders, num_floors);
2928 else if (!strcasecmp(viewpref, "hackish_view")) {
2929 for (i=0; i<max_folders; ++i) {
2930 escputs(fold[i].name);
2931 wprintf("<br />\n");
2934 else if (!strcasecmp(viewpref, "iconbar")) {
2935 do_iconbar_view(fold, max_folders, num_floors);
2938 do_rooms_view(fold, max_folders, num_floors);
2941 /* Don't free the folder list ... cache it for future use! */
2942 if (WC->cache_fold != NULL) {
2943 free(WC->cache_fold);
2945 WC->cache_fold = fold;
2946 WC->cache_max_folders = max_folders;
2947 WC->cache_num_floors = num_floors;
2948 WC->cache_timestamp = time(NULL);
2953 * \brief Do either a known rooms list or a folders list, depending on the
2958 char listviewpref[SIZ];
2960 output_headers(1, 1, 2, 0, 0, 0);
2962 /** Determine whether the user is trying to change views */
2963 if (bstr("view") != NULL) {
2964 if (strlen(bstr("view")) > 0) {
2965 set_preference("roomlistview", bstr("view"), 1);
2969 get_preference("roomlistview", listviewpref, sizeof listviewpref);
2971 if ( (strcasecmp(listviewpref, "folders"))
2972 && (strcasecmp(listviewpref, "table")) ) {
2973 strcpy(listviewpref, "rooms");
2977 wprintf("<div id=\"banner\">\n"
2978 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
2979 "<SPAN CLASS=\"titlebar\">"
2981 if (!strcasecmp(listviewpref, "rooms")) {
2982 wprintf(_("Room list"));
2984 if (!strcasecmp(listviewpref, "folders")) {
2985 wprintf(_("Folder list"));
2987 if (!strcasecmp(listviewpref, "table")) {
2988 wprintf(_("Room list"));
2990 wprintf("</SPAN></TD>\n");
2992 /** offer the ability to switch views */
2993 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
2994 "<SELECT NAME=\"newview\" SIZE=\"1\" "
2995 "OnChange=\"location.href=roomlistomatic.newview.options"
2996 "[selectedIndex].value\">\n");
2998 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3001 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3004 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3005 "View as folder list"
3007 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3010 wprintf("</SELECT><br />");
3012 wprintf("</FORM></TD></TR></TABLE>\n");
3015 "<div id=\"content\">\n");
3017 /** Display the room list in the user's preferred format */
3018 list_all_rooms_by_floor(listviewpref);
3025 * \brief Set the message expire policy for this room and/or floor
3027 void set_room_policy(void) {
3030 if (strlen(bstr("ok_button")) == 0) {
3031 strcpy(WC->ImportantMessage,
3032 _("Cancelled. Changes were not saved."));
3037 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3038 serv_getln(buf, sizeof buf);
3039 strcpy(WC->ImportantMessage, &buf[4]);
3041 if (WC->axlevel >= 6) {
3042 strcat(WC->ImportantMessage, "<br />\n");
3043 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3044 serv_getln(buf, sizeof buf);
3045 strcat(WC->ImportantMessage, &buf[4]);