Re-using the 'buf' variable in embed_room_banner() for
[citadel.git] / webcit / roomops.c
1 /*
2  * $Id$
3  */
4 /**
5  * \defgroup RoomOps Lots of different room-related operations.
6  * \ingroup CitadelCommunitacion
7  */
8 /*@{*/
9 #include "webcit.h"
10
11 char floorlist[128][SIZ]; /**< list of our floor names */
12
13 char *viewdefs[8]; /**< the different kinds of available views */
14
15 /**
16  * \brief initialize the viewdefs with localized strings
17  */
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");
27 }
28
29 /**
30  * \brief       Determine which views are allowed as the default for creating a new room.
31  *
32  * \param       which_view      The view ID being queried.
33  */
34 int is_view_allowed_as_default(int which_view)
35 {
36         switch(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 */
46         }
47 }
48
49
50 /**
51  * \brief load the list of floors
52  */
53 void load_floorlist(void)
54 {
55         int a;
56         char buf[SIZ];
57
58         for (a = 0; a < 128; ++a)
59                 floorlist[a][0] = 0;
60
61         serv_puts("LFLR");
62         serv_getln(buf, sizeof buf);
63         if (buf[0] != '1') {
64                 strcpy(floorlist[0], "Main Floor");
65                 return;
66         }
67         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
68                 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
69         }
70 }
71
72
73 /**
74  * \brief       Free a session's march list
75  *
76  * \param       wcf             Pointer to session being cleared
77  */
78 void free_march_list(struct wcsession *wcf)
79 {
80         struct march *mptr;
81
82         while (wcf->march != NULL) {
83                 mptr = wcf->march->next;
84                 free(wcf->march);
85                 wcf->march = mptr;
86         }
87
88 }
89
90
91
92 /**
93  * \brief remove a room from the march list
94  */
95 void remove_march(char *aaa)
96 {
97         struct march *mptr, *mptr2;
98
99         if (WC->march == NULL)
100                 return;
101
102         if (!strcasecmp(WC->march->march_name, aaa)) {
103                 mptr = WC->march->next;
104                 free(WC->march);
105                 WC->march = mptr;
106                 return;
107         }
108         mptr2 = WC->march;
109         for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
110                 if (!strcasecmp(mptr->march_name, aaa)) {
111                         mptr2->next = mptr->next;
112                         free(mptr);
113                         mptr = mptr2;
114                 } else {
115                         mptr2 = mptr;
116                 }
117         }
118 }
119
120
121
122
123 /**
124  * \brief display rooms in tree structure???
125  * \param rp the roomlist to build a tree from
126  */
127 void room_tree_list(struct roomlisting *rp)
128 {
129         char rmname[64];
130         int f;
131
132         if (rp == NULL) {
133                 return;
134         }
135
136         room_tree_list(rp->lnext);
137
138         strcpy(rmname, rp->rlname);
139         f = rp->rlflags;
140
141         wprintf("<a href=\"dotgoto&room=");
142         urlescputs(rmname);
143         wprintf("\"");
144         wprintf(">");
145         escputs1(rmname, 1, 1);
146         if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
147                 wprintf("}");
148         else if (f & QR_DIRECTORY)
149                 wprintf("]");
150         else if (f & QR_NETWORK)
151                 wprintf(")");
152         else
153                 wprintf("&gt;");
154         wprintf("</A><TT> </TT>\n");
155
156         room_tree_list(rp->rnext);
157         free(rp);
158 }
159
160
161 /** 
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???
166  */
167 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
168 {
169         if ((r1 == NULL) && (r2 == NULL))
170                 return (0);
171         if (r1 == NULL)
172                 return (-1);
173         if (r2 == NULL)
174                 return (1);
175         if (r1->rlfloor < r2->rlfloor)
176                 return (-1);
177         if (r1->rlfloor > r2->rlfloor)
178                 return (1);
179         if (r1->rlorder < r2->rlorder)
180                 return (-1);
181         if (r1->rlorder > r2->rlorder)
182                 return (1);
183         return (0);
184 }
185
186
187 /**
188  * \brief Common code for all room listings
189  * \param variety what???
190  */
191 void listrms(char *variety)
192 {
193         char buf[SIZ];
194         int num_rooms = 0;
195
196         struct roomlisting *rl = NULL;
197         struct roomlisting *rp;
198         struct roomlisting *rs;
199
200         /** Ask the server for a room list */
201         serv_puts(variety);
202         serv_getln(buf, sizeof buf);
203         if (buf[0] != '1') {
204                 wprintf("&nbsp;");
205                 return;
206         }
207
208         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
209                 ++num_rooms;
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);
215                 rp->lnext = NULL;
216                 rp->rnext = NULL;
217
218                 rs = rl;
219                 if (rl == NULL) {
220                         rl = rp;
221                 } else
222                         while (rp != NULL) {
223                                 if (rordercmp(rp, rs) < 0) {
224                                         if (rs->lnext == NULL) {
225                                                 rs->lnext = rp;
226                                                 rp = NULL;
227                                         } else {
228                                                 rs = rs->lnext;
229                                         }
230                                 } else {
231                                         if (rs->rnext == NULL) {
232                                                 rs->rnext = rp;
233                                                 rp = NULL;
234                                         } else {
235                                                 rs = rs->rnext;
236                                         }
237                                 }
238                         }
239         }
240
241         room_tree_list(rl);
242
243         /**
244          * If no rooms were listed, print an nbsp to make the cell
245          * borders show up anyway.
246          */
247         if (num_rooms == 0) wprintf("&nbsp;");
248 }
249
250
251 /**
252  * \brief list all forgotten rooms
253  */
254 void zapped_list(void)
255 {
256         output_headers(1, 1, 0, 0, 0, 0);
257
258         svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
259         do_template("beginbox");
260
261         listrms("LZRM -1");
262
263         wprintf("<br /><br />\n");
264         wprintf(_("Click on any room to un-zap it and goto that room.\n"));
265         do_template("endbox");
266         wDumpContent(1);
267 }
268
269
270 /**
271  * \brief read this room's info file (set v to 1 for verbose mode)
272  */
273 void readinfo(void)
274 {
275         char buf[256];
276         char briefinfo[128];
277         char fullinfo[8192];
278         int fullinfo_len = 0;
279
280         serv_puts("RINF");
281         serv_getln(buf, sizeof buf);
282         if (buf[0] == '1') {
283
284                 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
285                         if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
286                                 strcpy(&fullinfo[fullinfo_len], buf);
287                                 fullinfo_len += strlen(buf);
288                         }
289                 }
290
291                 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
292                 strcpy(&briefinfo[50], "...");
293
294                 wprintf("<div class=\"infos\" "
295                 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
296                 ">");
297                 escputs(briefinfo);
298                 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
299                 wprintf("<img class=\"close_infos\" "
300                         "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
301                         "src=\"static/closewindow.gif\" alt=\"%s\">",
302                         _("Close window")
303                 );
304                 escputs(fullinfo);
305                 wprintf("</div>");
306         }
307         else {
308                 wprintf("&nbsp;");
309         }
310 }
311
312
313
314
315 /**
316  * \brief Display room banner icon.  
317  * The server doesn't actually
318  * need the room name, but we supply it in order to
319  * keep the browser from using a cached icon from 
320  * another room.
321  */
322 void embed_room_graphic(void) {
323         char buf[SIZ];
324
325         serv_puts("OIMG _roompic_");
326         serv_getln(buf, sizeof buf);
327         if (buf[0] == '2') {
328                 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
329                 urlescputs(WC->wc_roomname);
330                 wprintf("\">");
331                 serv_puts("CLOS");
332                 serv_getln(buf, sizeof buf);
333         }
334         else if (WC->wc_view == VIEW_ADDRESSBOOK) {
335                 wprintf("<img height=48 width=48 src=\""
336                         "static/viewcontacts_48x.gif"
337                         "\">"
338                 );
339         }
340         else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
341                 wprintf("<img height=48 width=48 src=\""
342                         "static/calarea_48x.gif"
343                         "\">"
344                 );
345         }
346         else if (WC->wc_view == VIEW_TASKS) {
347                 wprintf("<img height=48 width=48 src=\""
348                         "static/taskmanag_48x.gif"
349                         "\">"
350                 );
351         }
352         else if (WC->wc_view == VIEW_NOTES) {
353                 wprintf("<img height=48 width=48 src=\""
354                         "static/storenotes_48x.gif"
355                         "\">"
356                 );
357         }
358         else if (WC->wc_view == VIEW_MAILBOX) {
359                 wprintf("<img height=48 width=48 src=\""
360                         "static/privatemess_48x.gif"
361                         "\">"
362                 );
363         }
364         else {
365                 wprintf("<img height=48 width=48 src=\""
366                         "static/chatrooms_48x.gif"
367                         "\">"
368                 );
369         }
370
371 }
372
373
374
375 /**
376  * \brief Display the current view and offer an option to change it
377  */
378 void embed_view_o_matic(void) {
379         int i;
380
381         wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
382         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
383         wprintf("<label for=\"view_name\">");
384         wprintf(_("View as:"));
385         wprintf("</label> "
386                 "<select name=\"newview\" size=\"1\" "
387                 "id=\"view_name\" class=\"selectbox\" "
388                 "OnChange=\"location.href=viewomatic.newview.options"
389                 "[selectedIndex].value\">\n");
390
391         for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
392                 /**
393                  * Only offer the views that make sense, given the default
394                  * view for the room.  For example, don't offer a Calendar
395                  * view in a non-Calendar room.
396                  */
397                 if (
398                         (i == WC->wc_view)
399                         ||      (i == WC->wc_default_view)                      /**< default */
400                         ||      ( (i == 0) && (WC->wc_default_view == 1) )      /**< mail or bulletin */
401                         ||      ( (i == 1) && (WC->wc_default_view == 0) )      /**< mail or bulletin */
402                         /** ||  ( (i == 7) && (WC->wc_default_view == 3) )      (calendar list temporarily disabled) */
403                 ) {
404
405                         wprintf("<option %s value=\"changeview?view=%d\">",
406                                 ((i == WC->wc_view) ? "selected" : ""),
407                                 i );
408                         escputs(viewdefs[i]);
409                         wprintf("</option>\n");
410                 }
411         }
412         wprintf("</select></form>\n");
413 }
414
415
416 /**
417  * \brief Display a search box
418  */
419 void embed_search_o_matic(void) {
420         wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
421         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
422         wprintf("<label for=\"search_name\">");
423         wprintf(_("Search: "));
424         wprintf("</label> <input "
425                 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
426                 "id=\"search_name\" class=\"inputbox\">\n"
427         );
428         wprintf("</select></form>\n");
429 }
430
431
432 /**
433  * \brief               Embed the room banner
434  *
435  * \param got           The information returned from a GOTO server command
436  * \param navbar_style  Determines which navigation buttons to display
437  *
438  */
439
440 void embed_room_banner(char *got, int navbar_style) {
441         char buf[256];
442         char sanitized_roomname[256];
443
444         /**
445          * We need to have the information returned by a GOTO server command.
446          * If it isn't supplied, we fake it by issuing our own GOTO.
447          */
448         if (got == NULL) {
449                 serv_printf("GOTO %s", WC->wc_roomname);
450                 serv_getln(buf, sizeof buf);
451                 got = buf;
452         }
453
454         /** The browser needs some information for its own use */
455         wprintf("<script type=\"text/javascript\">      \n"
456                 "       room_is_trash = %d;             \n"
457                 "</script>\n",
458                 WC->wc_is_trash
459         );
460
461         /**
462          * If the user happens to select the "make this my start page" link,
463          * we want it to remember the URL as a "/dotskip" one instead of
464          * a "skip" or "gotonext" or something like that.
465          */
466         snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
467                 WC->wc_roomname);
468
469         /** Check for new mail. */
470         WC->new_mail = extract_int(&got[4], 9);
471         WC->wc_view = extract_int(&got[4], 11);
472
473         stresc(sanitized_roomname, WC->wc_roomname, 1, 1);
474         svprintf("ROOMNAME", WCS_STRING, "%s", sanitized_roomname);
475         svprintf("NUMMSGS", WCS_STRING,
476                 _("%d new of %d messages"),
477                 extract_int(&got[4], 1),
478                 extract_int(&got[4], 2)
479         );
480         svcallback("ROOMPIC", embed_room_graphic);
481         svcallback("ROOMINFO", readinfo);
482         svcallback("VIEWOMATIC", embed_view_o_matic);
483         svcallback("SEARCHOMATIC", embed_search_o_matic);
484         svcallback("START", offer_start_page);
485
486         do_template("roombanner");
487         if (navbar_style != navbar_none) {
488
489                 wprintf("<div id=\"navbar\"><ul>");
490
491                 if (navbar_style == navbar_default) wprintf(
492                         "<li class=\"ungoto\">"
493                         "<a href=\"ungoto\">"
494                         "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
495                         "<span class=\"navbar_link\">%s</span></A>"
496                         "</li>\n", _("Ungoto")
497                 );
498
499                 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
500                         wprintf(
501                                 "<li class=\"newmess\">"
502                                 "<a href=\"readnew\">"
503                                 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
504                                 "<span class=\"navbar_link\">%s</span></A>"
505                                 "</li>\n", _("Read new messages")
506                         );
507                 }
508
509                 if (navbar_style == navbar_default) {
510                         switch(WC->wc_view) {
511                                 case VIEW_ADDRESSBOOK:
512                                         wprintf(
513                                                 "<li class=\"viewcontacts\">"
514                                                 "<a href=\"readfwd\">"
515                                                 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
516                                                 "border=\"0\">"
517                                                 "<span class=\"navbar_link\">"
518                                                 "%s"
519                                                 "</span></a></li>\n", _("View contacts")
520                                         );
521                                         break;
522                                 case VIEW_CALENDAR:
523                                         wprintf(
524                                                 "<li class=\"staskday\">"
525                                                 "<a href=\"readfwd?calview=day\">"
526                                                 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
527                                                 "border=\"0\">"
528                                                 "<span class=\"navbar_link\">"
529                                                 "%s"
530                                                 "</span></a></li>\n", _("Day view")
531                                         );
532                                         wprintf(
533                                                 "<li class=\"monthview\">"
534                                                 "<a href=\"readfwd?calview=month\">"
535                                                 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
536                                                 "border=\"0\">"
537                                                 "<span class=\"navbar_link\">"
538                                                 "%s"
539                                                 "</span></a></li>\n", _("Month view")
540                                         );
541                                         break;
542                                 case VIEW_CALBRIEF:
543                                         wprintf(
544                                                 "<li class=\"monthview\">"
545                                                 "<a href=\"readfwd?calview=month\">"
546                                                 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
547                                                 "border=\"0\">"
548                                                 "<span class=\"navbar_link\">"
549                                                 "%s"
550                                                 "</span></a></li>\n", _("Calendar list")
551                                         );
552                                         break;
553                                 case VIEW_TASKS:
554                                         wprintf(
555                                                 "<li class=\"taskmanag\">"
556                                                 "<a href=\"readfwd\">"
557                                                 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
558                                                 "border=\"0\">"
559                                                 "<span class=\"navbar_link\">"
560                                                 "%s"
561                                                 "</span></a></li>\n", _("View tasks")
562                                         );
563                                         break;
564                                 case VIEW_NOTES:
565                                         wprintf(
566                                                 "<li class=\"viewnotes\">"
567                                                 "<a href=\"readfwd\">"
568                                                 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
569                                                 "border=\"0\">"
570                                                 "<span class=\"navbar_link\">"
571                                                 "%s"
572                                                 "</span></a></li>\n", _("View notes")
573                                         );
574                                         break;
575                                 case VIEW_MAILBOX:
576                                         wprintf(
577                                                 "<li class=\"readallmess\">"
578                                                 "<a href=\"readfwd\">"
579                                                 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
580                                                 "border=\"0\">"
581                                                 "<span class=\"navbar_link\">"
582                                                 "%s"
583                                                 "</span></a></li>\n", _("View message list")
584                                         );
585                                         break;
586                                 case VIEW_WIKI:
587                                         wprintf(
588                                                 "<li class=\"readallmess\">"
589                                                 "<a href=\"readfwd\">"
590                                                 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
591                                                 "border=\"0\">"
592                                                 "<span class=\"navbar_link\">"
593                                                 "%s"
594                                                 "</span></a></li>\n", _("Wiki home")
595                                         );
596                                         break;
597                                 default:
598                                         wprintf(
599                                                 "<li class=\"readallmess\">"
600                                                 "<a href=\"readfwd\">"
601                                                 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
602                                                 "border=\"0\">"
603                                                 "<span class=\"navbar_link\">"
604                                                 "%s"
605                                                 "</span></a></li>\n", _("Read all messages")
606                                         );
607                                         break;
608                         }
609                 }
610
611                 if (navbar_style == navbar_default) {
612                         switch(WC->wc_view) {
613                                 case VIEW_ADDRESSBOOK:
614                                         wprintf(
615                                                 "<li class=\"addnewcontact\">"
616                                                 "<a href=\"display_enter\">"
617                                                 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
618                                                 "border=\"0\"><span class=\"navbar_link\">"
619                                                 "%s"
620                                                 "</span></a></li>\n", _("Add new contact")
621                                         );
622                                         break;
623                                 case VIEW_CALENDAR:
624                                 case VIEW_CALBRIEF:
625                                         wprintf("<li class=\"addevent\"><a href=\"display_enter");
626                                         if (strlen(bstr("year")) > 0) wprintf("?year=%s", bstr("year"));
627                                         if (strlen(bstr("month")) > 0) wprintf("?month=%s", bstr("month"));
628                                         if (strlen(bstr("day")) > 0) wprintf("?day=%s", bstr("day"));
629                                         wprintf("\">"
630                                                 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
631                                                 "border=\"0\"><span class=\"navbar_link\">"
632                                                 "%s"
633                                                 "</span></a></li>\n", _("Add new event")
634                                         );
635                                         break;
636                                 case VIEW_TASKS:
637                                         wprintf(
638                                                 "<li class=\"newmess\">"
639                                                 "<a href=\"display_enter\">"
640                                                 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
641                                                 "border=\"0\"><span class=\"navbar_link\">"
642                                                 "%s"
643                                                 "</span></a></li>\n", _("Add new task")
644                                         );
645                                         break;
646                                 case VIEW_NOTES:
647                                         wprintf(
648                                                 "<li class=\"enternewnote\">"
649                                                 "<a href=\"javascript:add_new_note();\">"
650                                                 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
651                                                 "border=\"0\"><span class=\"navbar_link\">"
652                                                 "%s"
653                                                 "</span></a></li>\n", _("Add new note")
654                                         );
655                                         break;
656                                 case VIEW_WIKI:
657                                         safestrncpy(buf, bstr("page"), sizeof buf);
658                                         str_wiki_index(buf);
659                                         wprintf(
660                                                 "<li class=\"newmess\">"
661                                                 "<a href=\"display_enter?wikipage=%s\">"
662                                                 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
663                                                 "border=\"0\"><span class=\"navbar_link\">"
664                                                 "%s"
665                                                 "</span></a></li>\n", buf, _("Edit this page")
666                                         );
667                                         break;
668                                 case VIEW_MAILBOX:
669                                         wprintf(
670                                                 "<li class=\"newmess\">"
671                                                 "<a href=\"display_enter\">"
672                                                 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
673                                                 "border=\"0\"><span class=\"navbar_link\">"
674                                                 "%s"
675                                                 "</span></a></li>\n", _("Write mail")
676                                         );
677                                         break;
678                                 default:
679                                         wprintf(
680                                                 "<li class=\"newmess\">"
681                                                 "<a href=\"display_enter\">"
682                                                 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
683                                                 "border=\"0\"><span class=\"navbar_link\">"
684                                                 "%s"
685                                                 "</span></a></li>\n", _("Enter a message")
686                                         );
687                                         break;
688                         }
689                 }
690
691                 if (navbar_style == navbar_default) wprintf(
692                         "<li class=\"skipthisroom\">"
693                         "<a href=\"skip\" "
694                         "title=\"%s\">"
695                         "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
696                         "<span class=\"navbar_link\">%s</span></a>"
697                         "</li>\n",
698                         _("Leave all messages marked as unread, go to next room with unread messages"),
699                         _("Skip this room")
700                 );
701
702                 if (navbar_style == navbar_default) wprintf(
703                         "<li class=\"markngo\">"
704                         "<a href=\"gotonext\" "
705                         "title=\"%s\">"
706                         "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
707                         "<span class=\"navbar_link\">%s</span></a>"
708                         "</li>\n",
709                         _("Mark all messages as read, go to next room with unread messages"),
710                         _("Goto next room")
711                 );
712
713                 wprintf("</ul></div>\n");
714         }
715
716 }
717
718
719 /**
720  * \brief back end routine to take the session to a new room
721  * \param gname room to go to
722  *
723  */
724 int gotoroom(char *gname)
725 {
726         char buf[SIZ];
727         static long ls = (-1L);
728         int err = 0;
729
730         /** store ungoto information */
731         strcpy(WC->ugname, WC->wc_roomname);
732         WC->uglsn = ls;
733
734         /** move to the new room */
735         serv_printf("GOTO %s", gname);
736         serv_getln(buf, sizeof buf);
737         if (buf[0] != '2') {
738                 buf[3] = 0;
739                 err = atoi(buf);
740                 serv_puts("GOTO _BASEROOM_");
741                 serv_getln(buf, sizeof buf);
742         }
743         if (buf[0] != '2') {
744                 buf[3] = 0;
745                 err = atoi(buf);
746                 return err;
747         }
748         extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
749         WC->room_flags = extract_int(&buf[4], 4);
750         /* highest_msg_read = extract_int(&buf[4],6);
751            maxmsgnum = extract_int(&buf[4],5);
752          */
753         WC->is_mailbox = extract_int(&buf[4],7);
754         ls = extract_long(&buf[4], 6);
755         WC->wc_floor = extract_int(&buf[4], 10);
756         WC->wc_view = extract_int(&buf[4], 11);
757         WC->wc_default_view = extract_int(&buf[4], 12);
758         WC->wc_is_trash = extract_int(&buf[4], 13);
759         WC->room_flags2 = extract_int(&buf[4], 14);
760
761         if (WC->is_aide)
762                 WC->is_room_aide = WC->is_aide;
763         else
764                 WC->is_room_aide = (char) extract_int(&buf[4], 8);
765
766         remove_march(WC->wc_roomname);
767         if (!strcasecmp(gname, "_BASEROOM_"))
768                 remove_march(gname);
769
770         return err;
771 }
772
773
774 /**
775  * \brief Locate the room on the march list which we most want to go to.  
776  * Each room
777  * is measured given a "weight" of preference based on various factors.
778  * \param desired_floor the room number on the citadel server
779  * \return the roomname
780  */
781 char *pop_march(int desired_floor)
782 {
783         static char TheRoom[128];
784         int TheFloor = 0;
785         int TheOrder = 32767;
786         int TheWeight = 0;
787         int weight;
788         struct march *mptr = NULL;
789
790         strcpy(TheRoom, "_BASEROOM_");
791         if (WC->march == NULL)
792                 return (TheRoom);
793
794         for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
795                 weight = 0;
796                 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
797                         weight = weight + 10000;
798                 if (mptr->march_floor == desired_floor)
799                         weight = weight + 5000;
800
801                 weight = weight + ((128 - (mptr->march_floor)) * 128);
802                 weight = weight + (128 - (mptr->march_order));
803
804                 if (weight > TheWeight) {
805                         TheWeight = weight;
806                         strcpy(TheRoom, mptr->march_name);
807                         TheFloor = mptr->march_floor;
808                         TheOrder = mptr->march_order;
809                 }
810         }
811         return (TheRoom);
812 }
813
814
815
816 /**
817  *\brief Goto next room having unread messages.
818  * We want to skip over rooms that the user has already been to, and take the
819  * user back to the lobby when done.  The room we end up in is placed in
820  * newroom - which is set to 0 (the lobby) initially.
821  * We start the search in the current room rather than the beginning to prevent
822  * two or more concurrent users from dragging each other back to the same room.
823  */
824 void gotonext(void)
825 {
826         char buf[256];
827         struct march *mptr, *mptr2;
828         char room_name[128];
829         char next_room[128];
830
831         /**
832          * First check to see if the march-mode list is already allocated.
833          * If it is, pop the first room off the list and go there.
834          */
835
836         if (WC->march == NULL) {
837                 serv_puts("LKRN");
838                 serv_getln(buf, sizeof buf);
839                 if (buf[0] == '1')
840                         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
841                                 extract_token(room_name, buf, 0, '|', sizeof room_name);
842                                 if (strcasecmp(room_name, WC->wc_roomname)) {
843                                         mptr = (struct march *) malloc(sizeof(struct march));
844                                         mptr->next = NULL;
845                                         safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
846                                         mptr->march_floor = extract_int(buf, 2);
847                                         mptr->march_order = extract_int(buf, 3);
848                                         if (WC->march == NULL) {
849                                                 WC->march = mptr;
850                                         } else {
851                                                 mptr2 = WC->march;
852                                                 while (mptr2->next != NULL)
853                                                         mptr2 = mptr2->next;
854                                                 mptr2->next = mptr;
855                                         }
856                                 }
857                         }
858                 /**
859                  * add _BASEROOM_ to the end of the march list, so the user will end up
860                  * in the system base room (usually the Lobby>) at the end of the loop
861                  */
862                 mptr = (struct march *) malloc(sizeof(struct march));
863                 mptr->next = NULL;
864                 strcpy(mptr->march_name, "_BASEROOM_");
865                 if (WC->march == NULL) {
866                         WC->march = mptr;
867                 } else {
868                         mptr2 = WC->march;
869                         while (mptr2->next != NULL)
870                                 mptr2 = mptr2->next;
871                         mptr2->next = mptr;
872                 }
873                 /**
874                  * ...and remove the room we're currently in, so a <G>oto doesn't make us
875                  * walk around in circles
876                  */
877                 remove_march(WC->wc_roomname);
878         }
879         if (WC->march != NULL) {
880                 strcpy(next_room, pop_march(-1));
881         } else {
882                 strcpy(next_room, "_BASEROOM_");
883         }
884
885
886         smart_goto(next_room);
887 }
888
889
890 /**
891  * \brief goto next room
892  * \param next_room next room to go to
893  */
894 void smart_goto(char *next_room) {
895         gotoroom(next_room);
896         readloop("readnew");
897 }
898
899
900
901 /**
902  * \brief mark all messages in current room as having been read
903  */
904 void slrp_highest(void)
905 {
906         char buf[256];
907
908         serv_puts("SLRP HIGHEST");
909         serv_getln(buf, sizeof buf);
910 }
911
912
913 /**
914  * \brief un-goto the previous room
915  */
916 void ungoto(void)
917 {
918         char buf[SIZ];
919
920         if (!strcmp(WC->ugname, "")) {
921                 smart_goto(WC->wc_roomname);
922                 return;
923         }
924         serv_printf("GOTO %s", WC->ugname);
925         serv_getln(buf, sizeof buf);
926         if (buf[0] != '2') {
927                 smart_goto(WC->wc_roomname);
928                 return;
929         }
930         if (WC->uglsn >= 0L) {
931                 serv_printf("SLRP %ld", WC->uglsn);
932                 serv_getln(buf, sizeof buf);
933         }
934         strcpy(buf, WC->ugname);
935         strcpy(WC->ugname, "");
936         smart_goto(buf);
937 }
938
939
940
941
942
943 /**
944  * \brief Set/clear/read the "self-service list subscribe" flag for a room
945  * 
946  * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
947  * \return return the new value.
948  */
949
950 int self_service(int newval) {
951         int current_value = 0;
952         char buf[SIZ];
953         
954         char name[SIZ];
955         char password[SIZ];
956         char dirname[SIZ];
957         int flags, floor, order, view, flags2;
958
959         serv_puts("GETR");
960         serv_getln(buf, sizeof buf);
961         if (buf[0] != '2') return(0);
962
963         extract_token(name, &buf[4], 0, '|', sizeof name);
964         extract_token(password, &buf[4], 1, '|', sizeof password);
965         extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
966         flags = extract_int(&buf[4], 3);
967         floor = extract_int(&buf[4], 4);
968         order = extract_int(&buf[4], 5);
969         view = extract_int(&buf[4], 6);
970         flags2 = extract_int(&buf[4], 7);
971
972         if (flags2 & QR2_SELFLIST) {
973                 current_value = 1;
974         }
975         else {
976                 current_value = 0;
977         }
978
979         if (newval == 1) {
980                 flags2 = flags2 | QR2_SELFLIST;
981         }
982         else if (newval == 0) {
983                 flags2 = flags2 & ~QR2_SELFLIST;
984         }
985         else {
986                 return(current_value);
987         }
988
989         if (newval != current_value) {
990                 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
991                         name, password, dirname, flags,
992                         floor, order, view, flags2);
993                 serv_getln(buf, sizeof buf);
994         }
995
996         return(newval);
997
998 }
999
1000
1001
1002
1003
1004
1005 /**
1006  * \brief display the form for editing a room
1007  */
1008 void display_editroom(void)
1009 {
1010         char buf[SIZ];
1011         char cmd[1024];
1012         char node[256];
1013         char remote_room[128];
1014         char recp[1024];
1015         char er_name[128];
1016         char er_password[10];
1017         char er_dirname[15];
1018         char er_roomaide[26];
1019         unsigned er_flags;
1020         unsigned er_flags2;
1021         int er_floor;
1022         int i, j;
1023         char *tab;
1024         char *shared_with;
1025         char *not_shared_with;
1026         int roompolicy = 0;
1027         int roomvalue = 0;
1028         int floorpolicy = 0;
1029         int floorvalue = 0;
1030
1031         tab = bstr("tab");
1032         if (strlen(tab) == 0) tab = "admin";
1033
1034         load_floorlist();
1035         serv_puts("GETR");
1036         serv_getln(buf, sizeof buf);
1037
1038         if (buf[0] != '2') {
1039                 strcpy(WC->ImportantMessage, &buf[4]);
1040                 display_main_menu();
1041                 return;
1042         }
1043         extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1044         extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1045         extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1046         er_flags = extract_int(&buf[4], 3);
1047         er_floor = extract_int(&buf[4], 4);
1048         er_flags2 = extract_int(&buf[4], 7);
1049
1050         output_headers(1, 1, 1, 0, 0, 0);
1051
1052         /** print the tabbed dialog */
1053         wprintf("<br />"
1054                 "<div class=\"fix_scrollbar_bug\">"
1055                 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
1056                 "<TR ALIGN=CENTER>"
1057                 "<TD>&nbsp;</TD>\n");
1058
1059         if (!strcmp(tab, "admin")) {
1060                 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1061         }
1062         else {
1063                 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1064         }
1065         wprintf(_("Administration"));
1066         if (!strcmp(tab, "admin")) {
1067                 wprintf("</SPAN></TD>\n");
1068         }
1069         else {
1070                 wprintf("</A></TD>\n");
1071         }
1072
1073         wprintf("<TD>&nbsp;</TD>\n");
1074
1075         if (!strcmp(tab, "config")) {
1076                 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1077         }
1078         else {
1079                 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=config\">");
1080         }
1081         wprintf(_("Configuration"));
1082         if (!strcmp(tab, "config")) {
1083                 wprintf("</SPAN></TD>\n");
1084         }
1085         else {
1086                 wprintf("</A></TD>\n");
1087         }
1088
1089         wprintf("<TD>&nbsp;</TD>\n");
1090
1091         if (!strcmp(tab, "expire")) {
1092                 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1093         }
1094         else {
1095                 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1096         }
1097         wprintf(_("Message expire policy"));
1098         if (!strcmp(tab, "expire")) {
1099                 wprintf("</SPAN></TD>\n");
1100         }
1101         else {
1102                 wprintf("</A></TD>\n");
1103         }
1104
1105         wprintf("<TD>&nbsp;</TD>\n");
1106
1107         if (!strcmp(tab, "access")) {
1108                 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1109         }
1110         else {
1111                 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=access\">");
1112         }
1113         wprintf(_("Access controls"));
1114         if (!strcmp(tab, "access")) {
1115                 wprintf("</SPAN></TD>\n");
1116         }
1117         else {
1118                 wprintf("</A></TD>\n");
1119         }
1120
1121         wprintf("<TD>&nbsp;</TD>\n");
1122
1123         if (!strcmp(tab, "sharing")) {
1124                 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1125         }
1126         else {
1127                 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1128         }
1129         wprintf(_("Sharing"));
1130         if (!strcmp(tab, "sharing")) {
1131                 wprintf("</SPAN></TD>\n");
1132         }
1133         else {
1134                 wprintf("</A></TD>\n");
1135         }
1136
1137         wprintf("<TD>&nbsp;</TD>\n");
1138
1139         if (!strcmp(tab, "listserv")) {
1140                 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1141         }
1142         else {
1143                 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1144         }
1145         wprintf(_("Mailing list service"));
1146         if (!strcmp(tab, "listserv")) {
1147                 wprintf("</SPAN></TD>\n");
1148         }
1149         else {
1150                 wprintf("</A></TD>\n");
1151         }
1152
1153         wprintf("<TD>&nbsp;</TD>\n");
1154
1155         wprintf("</TR></TABLE></div>\n");
1156         /** end tabbed dialog */        
1157
1158         /** begin content of whatever tab is open now */
1159         wprintf("<div class=\"fix_scrollbar_bug\">"
1160                 "<TABLE class=\"roomops_background\">\n"
1161                 "<TR><TD>\n");
1162
1163         if (!strcmp(tab, "admin")) {
1164                 wprintf("<UL>"
1165                         "<LI><a href=\"delete_room\" "
1166                         "onClick=\"return confirm('");
1167                 wprintf(_("Are you sure you want to delete this room?"));
1168                 wprintf("');\">\n");
1169                 wprintf(_("Delete this room"));
1170                 wprintf("</A>\n"
1171                         "<LI><a href=\"display_editroompic\">\n");
1172                 wprintf(_("Set or change the icon for this room's banner"));
1173                 wprintf("</A>\n"
1174                         "<LI><a href=\"display_editinfo\">\n");
1175                 wprintf(_("Edit this room's Info file"));
1176                 wprintf("</A>\n"
1177                         "</UL>");
1178         }
1179
1180         if (!strcmp(tab, "config")) {
1181                 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1182                 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1183         
1184                 wprintf("<UL><LI>");
1185                 wprintf(_("Name of room: "));
1186                 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1187                         er_name,
1188                         (sizeof(er_name)-1)
1189                 );
1190         
1191                 wprintf("<LI>");
1192                 wprintf(_("Resides on floor: "));
1193                 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1194                 for (i = 0; i < 128; ++i)
1195                         if (strlen(floorlist[i]) > 0) {
1196                                 wprintf("<OPTION ");
1197                                 if (i == er_floor)
1198                                         wprintf("SELECTED ");
1199                                 wprintf("VALUE=\"%d\">", i);
1200                                 escputs(floorlist[i]);
1201                                 wprintf("</OPTION>\n");
1202                         }
1203                 wprintf("</SELECT>\n");
1204         
1205                 wprintf("<LI>");
1206                 wprintf(_("Type of room:"));
1207                 wprintf("<UL>\n");
1208
1209                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1210                 if ((er_flags & QR_PRIVATE) == 0)
1211                 wprintf("CHECKED ");
1212                 wprintf("> ");
1213                 wprintf(_("Public (automatically appears to everyone)"));
1214                 wprintf("\n");
1215
1216                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1217                 if ((er_flags & QR_PRIVATE) &&
1218                     (er_flags & QR_GUESSNAME))
1219                         wprintf("CHECKED ");
1220                 wprintf("> ");
1221                 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1222         
1223                 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1224                 if ((er_flags & QR_PRIVATE) &&
1225                     (er_flags & QR_PASSWORDED))
1226                         wprintf("CHECKED ");
1227                 wprintf("> ");
1228                 wprintf(_("Private - require password: "));
1229                 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1230                         er_password);
1231         
1232                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1233                 if ((er_flags & QR_PRIVATE)
1234                     && ((er_flags & QR_GUESSNAME) == 0)
1235                     && ((er_flags & QR_PASSWORDED) == 0))
1236                         wprintf("CHECKED ");
1237                 wprintf("> ");
1238                 wprintf(_("Private - invitation only"));
1239         
1240                 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1241                 wprintf("> ");
1242                 wprintf(_("If private, cause current users to forget room"));
1243         
1244                 wprintf("\n</UL>\n");
1245         
1246                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1247                 if (er_flags & QR_PREFONLY)
1248                         wprintf("CHECKED ");
1249                 wprintf("> ");
1250                 wprintf(_("Preferred users only"));
1251         
1252                 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1253                 if (er_flags & QR_READONLY)
1254                         wprintf("CHECKED ");
1255                 wprintf("> ");
1256                 wprintf(_("Read-only room"));
1257         
1258                 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1259                 if (er_flags2 & QR2_COLLABDEL)
1260                         wprintf("CHECKED ");
1261                 wprintf("> ");
1262                 wprintf(_("All users allowed to post may also delete messages"));
1263         
1264                 /** directory stuff */
1265                 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1266                 if (er_flags & QR_DIRECTORY)
1267                         wprintf("CHECKED ");
1268                 wprintf("> ");
1269                 wprintf(_("File directory room"));
1270
1271                 wprintf("\n<UL><LI>");
1272                 wprintf(_("Directory name: "));
1273                 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1274                         er_dirname);
1275
1276                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1277                 if (er_flags & QR_UPLOAD)
1278                         wprintf("CHECKED ");
1279                 wprintf("> ");
1280                 wprintf(_("Uploading allowed"));
1281         
1282                 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1283                 if (er_flags & QR_DOWNLOAD)
1284                         wprintf("CHECKED ");
1285                 wprintf("> ");
1286                 wprintf(_("Downloading allowed"));
1287         
1288                 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1289                 if (er_flags & QR_VISDIR)
1290                         wprintf("CHECKED ");
1291                 wprintf("> ");
1292                 wprintf(_("Visible directory"));
1293                 wprintf("</UL>\n");
1294         
1295                 /** end of directory stuff */
1296         
1297                 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1298                 if (er_flags & QR_NETWORK)
1299                         wprintf("CHECKED ");
1300                 wprintf("> ");
1301                 wprintf(_("Network shared room"));
1302
1303                 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1304                 if (er_flags & QR_PERMANENT)
1305                         wprintf("CHECKED ");
1306                 wprintf("> ");
1307                 wprintf(_("Permanent (does not auto-purge)"));
1308
1309                 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1310                 if (er_flags2 & QR2_SUBJECTREQ)
1311                         wprintf("CHECKED ");
1312                 wprintf("> ");
1313                 wprintf(_("Subject Required (Force users to specify a message subject)"));
1314
1315                 /** start of anon options */
1316         
1317                 wprintf("\n<LI>");
1318                 wprintf(_("Anonymous messages"));
1319                 wprintf("<UL>\n");
1320         
1321                 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1322                 if (((er_flags & QR_ANONONLY) == 0)
1323                     && ((er_flags & QR_ANONOPT) == 0))
1324                         wprintf("CHECKED ");
1325                 wprintf("> ");
1326                 wprintf(_("No anonymous messages"));
1327         
1328                 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1329                 if (er_flags & QR_ANONONLY)
1330                         wprintf("CHECKED ");
1331                 wprintf("> ");
1332                 wprintf(_("All messages are anonymous"));
1333         
1334                 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1335                 if (er_flags & QR_ANONOPT)
1336                         wprintf("CHECKED ");
1337                 wprintf("> ");
1338                 wprintf(_("Prompt user when entering messages"));
1339                 wprintf("</UL>\n");
1340         
1341         /* end of anon options */
1342         
1343                 wprintf("<LI>");
1344                 wprintf(_("Room aide: "));
1345                 serv_puts("GETA");
1346                 serv_getln(buf, sizeof buf);
1347                 if (buf[0] != '2') {
1348                         wprintf("<em>%s</em>\n", &buf[4]);
1349                 } else {
1350                         extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1351                         wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1352                 }
1353         
1354                 wprintf("</UL><CENTER>\n");
1355                 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1356                         "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1357                         "&nbsp;"
1358                         "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1359                         "</CENTER>\n",
1360                         _("Save changes"),
1361                         _("Cancel")
1362                 );
1363         }
1364
1365
1366         /** Sharing the room with other Citadel nodes... */
1367         if (!strcmp(tab, "sharing")) {
1368
1369                 shared_with = strdup("");
1370                 not_shared_with = strdup("");
1371
1372                 /** Learn the current configuration */
1373                 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1374                 serv_getln(buf, sizeof buf);
1375                 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1376                         extract_token(node, buf, 0, '|', sizeof node);
1377                         not_shared_with = realloc(not_shared_with,
1378                                         strlen(not_shared_with) + 32);
1379                         strcat(not_shared_with, node);
1380                         strcat(not_shared_with, "\n");
1381                 }
1382
1383                 serv_puts("GNET");
1384                 serv_getln(buf, sizeof buf);
1385                 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1386                         extract_token(cmd, buf, 0, '|', sizeof cmd);
1387                         extract_token(node, buf, 1, '|', sizeof node);
1388                         extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1389                         if (!strcasecmp(cmd, "ignet_push_share")) {
1390                                 shared_with = realloc(shared_with,
1391                                                 strlen(shared_with) + 32);
1392                                 strcat(shared_with, node);
1393                                 if (strlen(remote_room) > 0) {
1394                                         strcat(shared_with, "|");
1395                                         strcat(shared_with, remote_room);
1396                                 }
1397                                 strcat(shared_with, "\n");
1398                         }
1399                 }
1400
1401                 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1402                         extract_token(buf, shared_with, i, '\n', sizeof buf);
1403                         extract_token(node, buf, 0, '|', sizeof node);
1404                         for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1405                                 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1406                                 if (!strcasecmp(node, cmd)) {
1407                                         remove_token(not_shared_with, j, '\n');
1408                                 }
1409                         }
1410                 }
1411
1412                 /** Display the stuff */
1413                 wprintf("<CENTER><br />"
1414                         "<TABLE border=1 cellpadding=5><TR>"
1415                         "<TD><B><I>");
1416                 wprintf(_("Shared with"));
1417                 wprintf("</I></B></TD>"
1418                         "<TD><B><I>");
1419                 wprintf(_("Not shared with"));
1420                 wprintf("</I></B></TD></TR>\n"
1421                         "<TR><TD VALIGN=TOP>\n");
1422
1423                 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1424                 wprintf(_("Remote node name"));
1425                 wprintf("</TD><TD>");
1426                 wprintf(_("Remote room name"));
1427                 wprintf("</TD><TD>");
1428                 wprintf(_("Actions"));
1429                 wprintf("</TD></TR>\n");
1430
1431                 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1432                         extract_token(buf, shared_with, i, '\n', sizeof buf);
1433                         extract_token(node, buf, 0, '|', sizeof node);
1434                         extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1435                         if (strlen(node) > 0) {
1436                                 wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
1437                                 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1438                                 wprintf("<TR><TD>%s</TD>\n", node);
1439
1440                                 wprintf("<TD>");
1441                                 if (strlen(remote_room) > 0) {
1442                                         escputs(remote_room);
1443                                 }
1444                                 wprintf("</TD>");
1445
1446                                 wprintf("<TD>");
1447                 
1448                                 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1449                                         "VALUE=\"ignet_push_share|");
1450                                 urlescputs(node);
1451                                 if (strlen(remote_room) > 0) {
1452                                         wprintf("|");
1453                                         urlescputs(remote_room);
1454                                 }
1455                                 wprintf("\">");
1456                                 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1457                                         "VALUE=\"sharing\">\n");
1458                                 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1459                                         "VALUE=\"remove\">\n");
1460                                 wprintf("<INPUT TYPE=\"submit\" "
1461                                         "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1462                                 wprintf("</TD></TR></FORM>\n");
1463                         }
1464                 }
1465
1466                 wprintf("</TABLE>\n");
1467                 wprintf("</TD><TD VALIGN=TOP>\n");
1468                 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1469                 wprintf(_("Remote node name"));
1470                 wprintf("</TD><TD>");
1471                 wprintf(_("Remote room name"));
1472                 wprintf("</TD><TD>");
1473                 wprintf(_("Actions"));
1474                 wprintf("</TD></TR>\n");
1475
1476                 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1477                         extract_token(node, not_shared_with, i, '\n', sizeof node);
1478                         if (strlen(node) > 0) {
1479                                 wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
1480                                 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1481                                 wprintf("<TR><TD>");
1482                                 escputs(node);
1483                                 wprintf("</TD><TD>"
1484                                         "<INPUT TYPE=\"INPUT\" "
1485                                         "NAME=\"suffix\" "
1486                                         "MAXLENGTH=128>"
1487                                         "</TD><TD>");
1488                                 wprintf("<INPUT TYPE=\"hidden\" "
1489                                         "NAME=\"line\" "
1490                                         "VALUE=\"ignet_push_share|");
1491                                 urlescputs(node);
1492                                 wprintf("|\">");
1493                                 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1494                                         "VALUE=\"sharing\">\n");
1495                                 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1496                                         "VALUE=\"add\">\n");
1497                                 wprintf("<INPUT TYPE=\"submit\" "
1498                                         "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1499                                 wprintf("</TD></TR></FORM>\n");
1500                         }
1501                 }
1502
1503                 wprintf("</TABLE>\n");
1504                 wprintf("</TD></TR>"
1505                         "</TABLE></CENTER><br />\n"
1506                         "<I><B>%s</B><UL><LI>", _("Notes:"));
1507                 wprintf(_("When sharing a room, "
1508                         "it must be shared from both ends.  Adding a node to "
1509                         "the 'shared' list sends messages out, but in order to"
1510                         " receive messages, the other nodes must be configured"
1511                         " to send messages out to your system as well. "
1512                         "<LI>If the remote room name is blank, it is assumed "
1513                         "that the room name is identical on the remote node."
1514                         "<LI>If the remote room name is different, the remote "
1515                         "node must also configure the name of the room here."
1516                         "</UL></I><br />\n"
1517                 ));
1518
1519         }
1520
1521         /** Mailing list management */
1522         if (!strcmp(tab, "listserv")) {
1523
1524                 wprintf("<br /><center>"
1525                         "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1526                         "<TR><TD VALIGN=TOP>");
1527
1528                 wprintf(_("<i>The contents of this room are being "
1529                         "mailed <b>as individual messages</b> "
1530                         "to the following list recipients:"
1531                         "</i><br /><br />\n"));
1532
1533                 serv_puts("GNET");
1534                 serv_getln(buf, sizeof buf);
1535                 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1536                         extract_token(cmd, buf, 0, '|', sizeof cmd);
1537                         if (!strcasecmp(cmd, "listrecp")) {
1538                                 extract_token(recp, buf, 1, '|', sizeof recp);
1539                         
1540                                 escputs(recp);
1541                                 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1542                                 urlescputs(recp);
1543                                 wprintf("\">");
1544                                 wprintf(_("(remove)"));
1545                                 wprintf("</A><br />");
1546                         }
1547                 }
1548                 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1549                         "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1550                         "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1551                 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1552                 wprintf("<INPUT TYPE=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1553                 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1554                 wprintf("</FORM>\n");
1555
1556                 wprintf("</TD><TD VALIGN=TOP>\n");
1557                 
1558                 wprintf(_("<i>The contents of this room are being "
1559                         "mailed <b>in digest form</b> "
1560                         "to the following list recipients:"
1561                         "</i><br /><br />\n"));
1562
1563                 serv_puts("GNET");
1564                 serv_getln(buf, sizeof buf);
1565                 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1566                         extract_token(cmd, buf, 0, '|', sizeof cmd);
1567                         if (!strcasecmp(cmd, "digestrecp")) {
1568                                 extract_token(recp, buf, 1, '|', sizeof recp);
1569                         
1570                                 escputs(recp);
1571                                 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1572                                         "digestrecp|");
1573                                 urlescputs(recp);
1574                                 wprintf("\">");
1575                                 wprintf(_("(remove)"));
1576                                 wprintf("</A><br />");
1577                         }
1578                 }
1579                 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1580                         "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1581                         "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1582                 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1583                 wprintf("<INPUT TYPE=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1584                 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1585                 wprintf("</FORM>\n");
1586                 
1587                 wprintf("</TD></TR></TABLE>\n");
1588
1589                 /** Pop open an address book -- begin **/
1590                 wprintf("<div align=right>"
1591                         "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1592                         "title=\"%s\">"
1593                         "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1594                         "&nbsp;%s</a>"
1595                         "</div>",
1596                         _("List"),
1597                         _("Digest"),
1598                         _("Add recipients from Contacts or other address books"),
1599                         _("Add recipients from Contacts or other address books")
1600                 );
1601                 /** Pop open an address book -- end **/
1602
1603                 wprintf("<hr />");
1604                 if (self_service(999) == 1) {
1605                         wprintf(_("This room is configured to allow "
1606                                 "self-service subscribe/unsubscribe requests."));
1607                         wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1608                         wprintf(_("Click to disable."));
1609                         wprintf("</A><br />\n");
1610                         wprintf(_("The URL for subscribe/unsubscribe is: "));
1611                         wprintf("<TT>%s://%s/listsub</TT><br />\n",
1612                                 (is_https ? "https" : "http"),
1613                                 WC->http_host);
1614                 }
1615                 else {
1616                         wprintf(_("This room is <i>not</i> configured to allow "
1617                                 "self-service subscribe/unsubscribe requests."));
1618                         wprintf(" <a href=\"toggle_self_service?newval=1&"
1619                                 "tab=listserv\">");
1620                         wprintf(_("Click to enable."));
1621                         wprintf("</A><br />\n");
1622                 }
1623
1624
1625                 wprintf("</CENTER>\n");
1626         }
1627
1628
1629         /** Mailing list management */
1630         if (!strcmp(tab, "expire")) {
1631
1632                 serv_puts("GPEX room");
1633                 serv_getln(buf, sizeof buf);
1634                 if (buf[0] == '2') {
1635                         roompolicy = extract_int(&buf[4], 0);
1636                         roomvalue = extract_int(&buf[4], 1);
1637                 }
1638                 
1639                 serv_puts("GPEX floor");
1640                 serv_getln(buf, sizeof buf);
1641                 if (buf[0] == '2') {
1642                         floorpolicy = extract_int(&buf[4], 0);
1643                         floorvalue = extract_int(&buf[4], 1);
1644                 }
1645                 
1646                 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1647                 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1648                 wprintf("<TABLE border=0 cellspacing=5>\n");
1649                 wprintf("<TR><TD>");
1650                 wprintf(_("Message expire policy for this room"));
1651                 wprintf("<br />(");
1652                 escputs(WC->wc_roomname);
1653                 wprintf(")</TD><TD>");
1654                 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1655                         ((roompolicy == 0) ? "CHECKED" : "") );
1656                 wprintf(_("Use the default policy for this floor"));
1657                 wprintf("<br />\n");
1658                 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1659                         ((roompolicy == 1) ? "CHECKED" : "") );
1660                 wprintf(_("Never automatically expire messages"));
1661                 wprintf("<br />\n");
1662                 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1663                         ((roompolicy == 2) ? "CHECKED" : "") );
1664                 wprintf(_("Expire by message count"));
1665                 wprintf("<br />\n");
1666                 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1667                         ((roompolicy == 3) ? "CHECKED" : "") );
1668                 wprintf(_("Expire by message age"));
1669                 wprintf("<br />");
1670                 wprintf(_("Number of messages or days: "));
1671                 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1672                 wprintf("</TD></TR>\n");
1673
1674                 if (WC->axlevel >= 6) {
1675                         wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1676                         wprintf("<TR><TD>");
1677                         wprintf(_("Message expire policy for this floor"));
1678                         wprintf("<br />(");
1679                         escputs(floorlist[WC->wc_floor]);
1680                         wprintf(")</TD><TD>");
1681                         wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1682                                 ((floorpolicy == 0) ? "CHECKED" : "") );
1683                         wprintf(_("Use the system default"));
1684                         wprintf("<br />\n");
1685                         wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1686                                 ((floorpolicy == 1) ? "CHECKED" : "") );
1687                         wprintf(_("Never automatically expire messages"));
1688                         wprintf("<br />\n");
1689                         wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1690                                 ((floorpolicy == 2) ? "CHECKED" : "") );
1691                         wprintf(_("Expire by message count"));
1692                         wprintf("<br />\n");
1693                         wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1694                                 ((floorpolicy == 3) ? "CHECKED" : "") );
1695                         wprintf(_("Expire by message age"));
1696                         wprintf("<br />");
1697                         wprintf(_("Number of messages or days: "));
1698                         wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1699                                 floorvalue);
1700                 }
1701
1702                 wprintf("<CENTER>\n");
1703                 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1704                 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1705                 wprintf("&nbsp;");
1706                 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1707                 wprintf("</CENTER></TD><TR>\n");
1708
1709                 wprintf("</TABLE>\n"
1710                         "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1711                         "</FORM>\n"
1712                 );
1713
1714         }
1715
1716         /** Mailing list management */
1717         if (!strcmp(tab, "access")) {
1718                 display_whok();
1719         }
1720
1721         /** end content of whatever tab is open now */
1722         wprintf("</TD></TR></TABLE></div>\n");
1723
1724         address_book_popup();
1725         wDumpContent(1);
1726 }
1727
1728
1729 /** 
1730  * \brief Toggle self-service list subscription
1731  */
1732 void toggle_self_service(void) {
1733         int newval = 0;
1734
1735         newval = atoi(bstr("newval"));
1736         self_service(newval);
1737         display_editroom();
1738 }
1739
1740
1741
1742 /**
1743  * \brief save new parameters for a room
1744  */
1745 void editroom(void)
1746 {
1747         char buf[SIZ];
1748         char er_name[128];
1749         char er_password[10];
1750         char er_dirname[15];
1751         char er_roomaide[26];
1752         int er_floor;
1753         unsigned er_flags;
1754         int er_listingorder;
1755         int er_defaultview;
1756         unsigned er_flags2;
1757         int bump;
1758
1759
1760         if (strlen(bstr("ok_button")) == 0) {
1761                 strcpy(WC->ImportantMessage,
1762                         _("Cancelled.  Changes were not saved."));
1763                 display_editroom();
1764                 return;
1765         }
1766         serv_puts("GETR");
1767         serv_getln(buf, sizeof buf);
1768
1769         if (buf[0] != '2') {
1770                 strcpy(WC->ImportantMessage, &buf[4]);
1771                 display_editroom();
1772                 return;
1773         }
1774         extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1775         extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1776         extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1777         er_flags = extract_int(&buf[4], 3);
1778         er_listingorder = extract_int(&buf[4], 5);
1779         er_defaultview = extract_int(&buf[4], 6);
1780         er_flags2 = extract_int(&buf[4], 7);
1781
1782         strcpy(er_roomaide, bstr("er_roomaide"));
1783         if (strlen(er_roomaide) == 0) {
1784                 serv_puts("GETA");
1785                 serv_getln(buf, sizeof buf);
1786                 if (buf[0] != '2') {
1787                         strcpy(er_roomaide, "");
1788                 } else {
1789                         extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1790                 }
1791         }
1792         strcpy(buf, bstr("er_name"));
1793         buf[128] = 0;
1794         if (strlen(buf) > 0) {
1795                 strcpy(er_name, buf);
1796         }
1797
1798         strcpy(buf, bstr("er_password"));
1799         buf[10] = 0;
1800         if (strlen(buf) > 0)
1801                 strcpy(er_password, buf);
1802
1803         strcpy(buf, bstr("er_dirname"));
1804         buf[15] = 0;
1805         if (strlen(buf) > 0)
1806                 strcpy(er_dirname, buf);
1807
1808         strcpy(buf, bstr("type"));
1809         er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1810
1811         if (!strcmp(buf, "invonly")) {
1812                 er_flags |= (QR_PRIVATE);
1813         }
1814         if (!strcmp(buf, "hidden")) {
1815                 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1816         }
1817         if (!strcmp(buf, "passworded")) {
1818                 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1819         }
1820         if (!strcmp(bstr("prefonly"), "yes")) {
1821                 er_flags |= QR_PREFONLY;
1822         } else {
1823                 er_flags &= ~QR_PREFONLY;
1824         }
1825
1826         if (!strcmp(bstr("readonly"), "yes")) {
1827                 er_flags |= QR_READONLY;
1828         } else {
1829                 er_flags &= ~QR_READONLY;
1830         }
1831
1832         if (!strcmp(bstr("collabdel"), "yes")) {
1833                 er_flags2 |= QR2_COLLABDEL;
1834         } else {
1835                 er_flags2 &= ~QR2_COLLABDEL;
1836         }
1837
1838         if (!strcmp(bstr("permanent"), "yes")) {
1839                 er_flags |= QR_PERMANENT;
1840         } else {
1841                 er_flags &= ~QR_PERMANENT;
1842         }
1843
1844         if (!strcmp(bstr("subjectreq"), "yes")) {
1845                 er_flags2 |= QR2_SUBJECTREQ;
1846         } else {
1847                 er_flags2 &= ~QR2_SUBJECTREQ;
1848         }
1849
1850         if (!strcmp(bstr("network"), "yes")) {
1851                 er_flags |= QR_NETWORK;
1852         } else {
1853                 er_flags &= ~QR_NETWORK;
1854         }
1855
1856         if (!strcmp(bstr("directory"), "yes")) {
1857                 er_flags |= QR_DIRECTORY;
1858         } else {
1859                 er_flags &= ~QR_DIRECTORY;
1860         }
1861
1862         if (!strcmp(bstr("ulallowed"), "yes")) {
1863                 er_flags |= QR_UPLOAD;
1864         } else {
1865                 er_flags &= ~QR_UPLOAD;
1866         }
1867
1868         if (!strcmp(bstr("dlallowed"), "yes")) {
1869                 er_flags |= QR_DOWNLOAD;
1870         } else {
1871                 er_flags &= ~QR_DOWNLOAD;
1872         }
1873
1874         if (!strcmp(bstr("visdir"), "yes")) {
1875                 er_flags |= QR_VISDIR;
1876         } else {
1877                 er_flags &= ~QR_VISDIR;
1878         }
1879
1880         strcpy(buf, bstr("anon"));
1881
1882         er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1883         if (!strcmp(buf, "anononly"))
1884                 er_flags |= QR_ANONONLY;
1885         if (!strcmp(buf, "anon2"))
1886                 er_flags |= QR_ANONOPT;
1887
1888         bump = 0;
1889         if (!strcmp(bstr("bump"), "yes"))
1890                 bump = 1;
1891
1892         er_floor = atoi(bstr("er_floor"));
1893
1894         sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
1895                 er_name, er_password, er_dirname, er_flags, bump, er_floor,
1896                 er_listingorder, er_defaultview, er_flags2);
1897         serv_puts(buf);
1898         serv_getln(buf, sizeof buf);
1899         if (buf[0] != '2') {
1900                 strcpy(WC->ImportantMessage, &buf[4]);
1901                 display_editroom();
1902                 return;
1903         }
1904         gotoroom(er_name);
1905
1906         if (strlen(er_roomaide) > 0) {
1907                 sprintf(buf, "SETA %s", er_roomaide);
1908                 serv_puts(buf);
1909                 serv_getln(buf, sizeof buf);
1910                 if (buf[0] != '2') {
1911                         strcpy(WC->ImportantMessage, &buf[4]);
1912                         display_main_menu();
1913                         return;
1914                 }
1915         }
1916         gotoroom(er_name);
1917         strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1918         display_editroom();
1919         return;
1920 }
1921
1922
1923 /**
1924  * \brief Display form for Invite, Kick, and show Who Knows a room
1925  */
1926 void do_invt_kick(void) {
1927         char buf[SIZ], room[SIZ], username[SIZ];
1928
1929         serv_puts("GETR");
1930         serv_getln(buf, sizeof buf);
1931
1932         if (buf[0] != '2') {
1933                 escputs(&buf[4]);
1934                 return;
1935         }
1936         extract_token(room, &buf[4], 0, '|', sizeof room);
1937
1938         strcpy(username, bstr("username"));
1939
1940         if (strlen(bstr("kick_button")) > 0) {
1941                 sprintf(buf, "KICK %s", username);
1942                 serv_puts(buf);
1943                 serv_getln(buf, sizeof buf);
1944
1945                 if (buf[0] != '2') {
1946                         strcpy(WC->ImportantMessage, &buf[4]);
1947                 } else {
1948                         sprintf(WC->ImportantMessage,
1949                                 _("<B><I>User %s kicked out of room %s.</I></B>\n"), 
1950                                 username, room);
1951                 }
1952         }
1953
1954         if (strlen(bstr("invite_button")) > 0) {
1955                 sprintf(buf, "INVT %s", username);
1956                 serv_puts(buf);
1957                 serv_getln(buf, sizeof buf);
1958
1959                 if (buf[0] != '2') {
1960                         strcpy(WC->ImportantMessage, &buf[4]);
1961                 } else {
1962                         sprintf(WC->ImportantMessage,
1963                                 _("<B><I>User %s invited to room %s.</I></B>\n"), 
1964                                 username, room);
1965                 }
1966         }
1967
1968         display_editroom();
1969 }
1970
1971
1972
1973 /**
1974  * \brief Display form for Invite, Kick, and show Who Knows a room
1975  */
1976 void display_whok(void)
1977 {
1978         char buf[SIZ], room[SIZ], username[SIZ];
1979
1980         serv_puts("GETR");
1981         serv_getln(buf, sizeof buf);
1982
1983         if (buf[0] != '2') {
1984                 escputs(&buf[4]);
1985                 return;
1986         }
1987         extract_token(room, &buf[4], 0, '|', sizeof room);
1988
1989         
1990         wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1991         wprintf(_("The users listed below have access to this room.  "
1992                 "To remove a user from the access list, select the user "
1993                 "name from the list and click 'Kick'."));
1994         wprintf("<br /><br />");
1995         
1996         wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1997         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1998         wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1999         wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2000         serv_puts("WHOK");
2001         serv_getln(buf, sizeof buf);
2002         if (buf[0] == '1') {
2003                 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2004                         extract_token(username, buf, 0, '|', sizeof username);
2005                         wprintf("<OPTION>");
2006                         escputs(username);
2007                         wprintf("\n");
2008                 }
2009         }
2010         wprintf("</SELECT><br />\n");
2011
2012         wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2013         wprintf("</FORM></CENTER>\n");
2014
2015         wprintf("</TD><TD>");
2016         wprintf(_("To grant another user access to this room, enter the "
2017                 "user name in the box below and click 'Invite'."));
2018         wprintf("<br /><br />");
2019
2020         wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
2021         wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2022         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2023         wprintf(_("Invite:"));
2024         wprintf(" ");
2025         wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
2026                 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2027                 "<input type=\"submit\" value=\"%s\">"
2028                 "</FORM></CENTER>\n", _("Invite"));
2029
2030         wprintf("</TD></TR></TABLE>\n");
2031         wDumpContent(1);
2032 }
2033
2034
2035
2036 /**
2037  * \brief display the form for entering a new room
2038  */
2039 void display_entroom(void)
2040 {
2041         int i;
2042         char buf[SIZ];
2043
2044         serv_puts("CRE8 0");
2045         serv_getln(buf, sizeof buf);
2046
2047         if (buf[0] != '2') {
2048                 strcpy(WC->ImportantMessage, &buf[4]);
2049                 display_main_menu();
2050                 return;
2051         }
2052
2053         output_headers(1, 1, 2, 0, 0, 0);
2054         wprintf("<div id=\"banner\">\n"
2055                 "<TABLE class=\"roomops_banner\"><TR><TD>"
2056                 "<SPAN CLASS=\"titlebar\">");
2057         wprintf(_("Create a new room"));
2058         wprintf("</SPAN>"
2059                 "</TD></TR></TABLE>\n"
2060                 "</div>\n<div id=\"content\">\n"
2061         );
2062
2063         wprintf("<div class=\"fix_scrollbar_bug\">"
2064                 "<table class=\"roomops_background\"><tr><td>\n");
2065
2066         wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2067         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2068
2069         wprintf("<UL><LI>");
2070         wprintf(_("Name of room: "));
2071         wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2072
2073         wprintf("<LI>");
2074         wprintf(_("Resides on floor: "));
2075         load_floorlist(); 
2076         wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
2077         for (i = 0; i < 128; ++i)
2078                 if (strlen(floorlist[i]) > 0) {
2079                         wprintf("<OPTION ");
2080                         wprintf("VALUE=\"%d\">", i);
2081                         escputs(floorlist[i]);
2082                         wprintf("</OPTION>\n");
2083                 }
2084         wprintf("</SELECT>\n");
2085
2086                 /**
2087                  * Our clever little snippet of JavaScript automatically selects
2088                  * a public room if the view is set to Bulletin Board or wiki, and
2089                  * it selects a mailbox room otherwise.  The user can override this,
2090                  * of course.  We also disable the floor selector for mailboxes.
2091                  */
2092                 wprintf("<LI>");
2093                 wprintf(_("Default view for room: "));
2094         wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
2095                 "       if ( (this.form.er_view.value == 0)             "
2096                 "          || (this.form.er_view.value == 6) ) {        "
2097                 "               this.form.type[0].checked=true;         "
2098                 "               this.form.er_floor.disabled = false;    "
2099                 "       }                                               "
2100                 "       else {                                          "
2101                 "               this.form.type[4].checked=true;         "
2102                 "               this.form.er_floor.disabled = true;     "
2103                 "       }                                               "
2104                 "\">\n");
2105         for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2106                 if (is_view_allowed_as_default(i)) {
2107                         wprintf("<OPTION %s VALUE=\"%d\">",
2108                                 ((i == 0) ? "SELECTED" : ""), i );
2109                         escputs(viewdefs[i]);
2110                         wprintf("</OPTION>\n");
2111                 }
2112         }
2113         wprintf("</SELECT>\n");
2114
2115         wprintf("<LI>");
2116         wprintf(_("Type of room:"));
2117         wprintf("<UL>\n");
2118
2119         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2120         wprintf("CHECKED OnChange=\""
2121                 "       if (this.form.type[0].checked == true) {        "
2122                 "               this.form.er_floor.disabled = false;    "
2123                 "       }                                               "
2124                 "\"> ");
2125         wprintf(_("Public (automatically appears to everyone)"));
2126
2127         wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2128                 "       if (this.form.type[1].checked == true) {        "
2129                 "               this.form.er_floor.disabled = false;    "
2130                 "       }                                               "
2131                 "\"> ");
2132         wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2133
2134         wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2135                 "       if (this.form.type[2].checked == true) {        "
2136                 "               this.form.er_floor.disabled = false;    "
2137                 "       }                                               "
2138                 "\"> ");
2139         wprintf(_("Private - require password: "));
2140         wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2141
2142         wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2143                 "       if (this.form.type[3].checked == true) {        "
2144                 "               this.form.er_floor.disabled = false;    "
2145                 "       }                                               "
2146                 "\"> ");
2147         wprintf(_("Private - invitation only"));
2148
2149         wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2150                 "OnChange=\""
2151                 "       if (this.form.type[4].checked == true) {        "
2152                 "               this.form.er_floor.disabled = true;     "
2153                 "       }                                               "
2154                 "\"> ");
2155         wprintf(_("Personal (mailbox for you only)"));
2156
2157         wprintf("\n</UL>\n");
2158
2159         wprintf("<CENTER>\n");
2160         wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2161         wprintf("&nbsp;");
2162         wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2163         wprintf("</CENTER>\n");
2164         wprintf("</FORM>\n<hr />");
2165         serv_printf("MESG roomaccess");
2166         serv_getln(buf, sizeof buf);
2167         if (buf[0] == '1') {
2168                 fmout("CENTER");
2169         }
2170         wprintf("</td></tr></table></div>\n");
2171         wDumpContent(1);
2172 }
2173
2174
2175
2176
2177 /**
2178  * \brief support function for entroom() -- sets the default view 
2179  */
2180 void er_set_default_view(int newview) {
2181
2182         char buf[SIZ];
2183
2184         char rm_name[SIZ];
2185         char rm_pass[SIZ];
2186         char rm_dir[SIZ];
2187         int rm_bits1;
2188         int rm_floor;
2189         int rm_listorder;
2190         int rm_bits2;
2191
2192         serv_puts("GETR");
2193         serv_getln(buf, sizeof buf);
2194         if (buf[0] != '2') return;
2195
2196         extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2197         extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2198         extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2199         rm_bits1 = extract_int(&buf[4], 3);
2200         rm_floor = extract_int(&buf[4], 4);
2201         rm_listorder = extract_int(&buf[4], 5);
2202         rm_bits2 = extract_int(&buf[4], 7);
2203
2204         serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2205                 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2206                 rm_listorder, newview, rm_bits2
2207         );
2208         serv_getln(buf, sizeof buf);
2209 }
2210
2211
2212
2213 /**
2214  * \brief enter a new room
2215  */
2216 void entroom(void)
2217 {
2218         char buf[SIZ];
2219         char er_name[SIZ];
2220         char er_type[SIZ];
2221         char er_password[SIZ];
2222         int er_floor;
2223         int er_num_type;
2224         int er_view;
2225
2226         if (strlen(bstr("ok_button")) == 0) {
2227                 strcpy(WC->ImportantMessage,
2228                         _("Cancelled.  No new room was created."));
2229                 display_main_menu();
2230                 return;
2231         }
2232         strcpy(er_name, bstr("er_name"));
2233         strcpy(er_type, bstr("type"));
2234         strcpy(er_password, bstr("er_password"));
2235         er_floor = atoi(bstr("er_floor"));
2236         er_view = atoi(bstr("er_view"));
2237
2238         er_num_type = 0;
2239         if (!strcmp(er_type, "hidden"))
2240                 er_num_type = 1;
2241         if (!strcmp(er_type, "passworded"))
2242                 er_num_type = 2;
2243         if (!strcmp(er_type, "invonly"))
2244                 er_num_type = 3;
2245         if (!strcmp(er_type, "personal"))
2246                 er_num_type = 4;
2247
2248         sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d", 
2249                 er_name, er_num_type, er_password, er_floor, 0, er_view);
2250         serv_puts(buf);
2251         serv_getln(buf, sizeof buf);
2252         if (buf[0] != '2') {
2253                 strcpy(WC->ImportantMessage, &buf[4]);
2254                 display_main_menu();
2255                 return;
2256         }
2257         gotoroom(er_name);
2258         do_change_view(er_view);                /* Now go there */
2259 }
2260
2261
2262 /**
2263  * \brief display the screen to enter a private room
2264  */
2265 void display_private(char *rname, int req_pass)
2266 {
2267         output_headers(1, 1, 2, 0, 0, 0);
2268         wprintf("<div id=\"banner\">\n"
2269                 "<TABLE class=\"roomops_banner\"><TR><TD>"
2270                 "<SPAN CLASS=\"titlebar\">");
2271         wprintf(_("Go to a hidden room"));
2272         wprintf("</SPAN>"
2273                 "</TD></TR></TABLE>\n"
2274                 "</div>\n<div id=\"content\">\n"
2275         );
2276
2277         wprintf("<div class=\"fix_scrollbar_bug\">"
2278                 "<table class=\"roomops_background\"><tr><td>\n");
2279
2280         wprintf("<CENTER>\n");
2281         wprintf("<br />");
2282         wprintf(_("If you know the name of a hidden (guess-name) or "
2283                 "passworded room, you can enter that room by typing "
2284                 "its name below.  Once you gain access to a private "
2285                 "room, it will appear in your regular room listings "
2286                 "so you don't have to keep returning here."));
2287         wprintf("\n<br /><br />");
2288
2289         wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2290         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2291
2292         wprintf("<table border=\"0\" cellspacing=\"5\" "
2293                 "cellpadding=\"5\" class=\"roomops_background_alt\">\n"
2294                 "<TR><TD>");
2295         wprintf(_("Enter room name:"));
2296         wprintf("</TD><TD>"
2297                 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2298                 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2299
2300         if (req_pass) {
2301                 wprintf("</TD></TR><TR><TD>");
2302                 wprintf(_("Enter room password:"));
2303                 wprintf("</TD><TD>");
2304                 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2305         }
2306         wprintf("</TD></TR></TABLE><br />\n");
2307
2308         wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2309                 "&nbsp;"
2310                 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2311                 _("Go there"),
2312                 _("Cancel")
2313         );
2314         wprintf("</FORM>\n");
2315         wprintf("</td></tr></table></div>\n");
2316         wDumpContent(1);
2317 }
2318
2319 /**
2320  * \brief goto a private room
2321  */
2322 void goto_private(void)
2323 {
2324         char hold_rm[SIZ];
2325         char buf[SIZ];
2326
2327         if (strlen(bstr("ok_button")) == 0) {
2328                 display_main_menu();
2329                 return;
2330         }
2331         strcpy(hold_rm, WC->wc_roomname);
2332         strcpy(buf, "GOTO ");
2333         strcat(buf, bstr("gr_name"));
2334         strcat(buf, "|");
2335         strcat(buf, bstr("gr_pass"));
2336         serv_puts(buf);
2337         serv_getln(buf, sizeof buf);
2338
2339         if (buf[0] == '2') {
2340                 smart_goto(bstr("gr_name"));
2341                 return;
2342         }
2343         if (!strncmp(buf, "540", 3)) {
2344                 display_private(bstr("gr_name"), 1);
2345                 return;
2346         }
2347         output_headers(1, 1, 1, 0, 0, 0);
2348         wprintf("%s\n", &buf[4]);
2349         wDumpContent(1);
2350         return;
2351 }
2352
2353
2354 /**
2355  * \brief display the screen to zap a room
2356  */
2357 void display_zap(void)
2358 {
2359         output_headers(1, 1, 2, 0, 0, 0);
2360
2361         wprintf("<div id=\"banner\">\n");
2362         wprintf("<TABLE class=\"roomops_zap\"><TR><TD>");
2363         wprintf("<SPAN CLASS=\"titlebar\">");
2364         wprintf(_("Zap (forget/unsubscribe) the current room"));
2365         wprintf("</SPAN>\n");
2366         wprintf("</TD></TR></TABLE>\n");
2367         wprintf("</div>\n<div id=\"content\">\n");
2368
2369         wprintf(_("If you select this option, <em>%s</em> will "
2370                 "disappear from your room list.  Is this what you wish "
2371                 "to do?<br />\n"), WC->wc_roomname);
2372
2373         wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2374         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2375         wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2376         wprintf("&nbsp;");
2377         wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2378         wprintf("</FORM>\n");
2379         wDumpContent(1);
2380 }
2381
2382
2383 /**
2384  * \brief zap a room
2385  */
2386 void zap(void)
2387 {
2388         char buf[SIZ];
2389         char final_destination[SIZ];
2390
2391         /**
2392          * If the forget-room routine fails for any reason, we fall back
2393          * to the current room; otherwise, we go to the Lobby
2394          */
2395         strcpy(final_destination, WC->wc_roomname);
2396
2397         if (strlen(bstr("ok_button")) > 0) {
2398                 serv_printf("GOTO %s", WC->wc_roomname);
2399                 serv_getln(buf, sizeof buf);
2400                 if (buf[0] == '2') {
2401                         serv_puts("FORG");
2402                         serv_getln(buf, sizeof buf);
2403                         if (buf[0] == '2') {
2404                                 strcpy(final_destination, "_BASEROOM_");
2405                         }
2406                 }
2407         }
2408         smart_goto(final_destination);
2409 }
2410
2411
2412
2413 /**
2414  * \brief Delete the current room
2415  */
2416 void delete_room(void)
2417 {
2418         char buf[SIZ];
2419
2420         serv_puts("KILL 1");
2421         serv_getln(buf, sizeof buf);
2422         if (buf[0] != '2') {
2423                 strcpy(WC->ImportantMessage, &buf[4]);
2424                 display_main_menu();
2425                 return;
2426         } else {
2427                 smart_goto("_BASEROOM_");
2428         }
2429 }
2430
2431
2432
2433 /**
2434  * \brief Perform changes to a room's network configuration
2435  */
2436 void netedit(void) {
2437         FILE *fp;
2438         char buf[SIZ];
2439         char line[SIZ];
2440         char cmpa0[SIZ];
2441         char cmpa1[SIZ];
2442         char cmpb0[SIZ];
2443         char cmpb1[SIZ];
2444         int i, num_addrs;
2445
2446         if (strlen(bstr("line"))==0) {
2447                 display_editroom();
2448                 return;
2449         }
2450
2451         strcpy(line, bstr("prefix"));
2452         strcat(line, bstr("line"));
2453         strcat(line, bstr("suffix"));
2454
2455         fp = tmpfile();
2456         if (fp == NULL) {
2457                 display_editroom();
2458                 return;
2459         }
2460
2461         serv_puts("GNET");
2462         serv_getln(buf, sizeof buf);
2463         if (buf[0] != '1') {
2464                 fclose(fp);
2465                 display_editroom();
2466                 return;
2467         }
2468
2469         /** This loop works for add *or* remove.  Spiffy, eh? */
2470         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2471                 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2472                 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2473                 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2474                 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2475                 if ( (strcasecmp(cmpa0, cmpb0)) 
2476                    || (strcasecmp(cmpa1, cmpb1)) ) {
2477                         fprintf(fp, "%s\n", buf);
2478                 }
2479         }
2480
2481         rewind(fp);
2482         serv_puts("SNET");
2483         serv_getln(buf, sizeof buf);
2484         if (buf[0] != '4') {
2485                 fclose(fp);
2486                 display_editroom();
2487                 return;
2488         }
2489
2490         while (fgets(buf, sizeof buf, fp) != NULL) {
2491                 buf[strlen(buf)-1] = 0;
2492                 serv_puts(buf);
2493         }
2494
2495         if (strlen(bstr("add_button")) > 0) {
2496                 num_addrs = num_tokens(bstr("line"), ',');
2497                 if (num_addrs < 2) {
2498                         /* just adding one node or address */
2499                         serv_puts(line);
2500                 }
2501                 else {
2502                         /* adding multiple addresses separated by commas */
2503                         for (i=0; i<num_addrs; ++i) {
2504                                 strcpy(line, bstr("prefix"));
2505                                 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2506                                 striplt(buf);
2507                                 strcat(line, buf);
2508                                 strcat(line, bstr("suffix"));
2509                                 serv_puts(line);
2510                         }
2511                 }
2512         }
2513
2514         serv_puts("000");
2515         fclose(fp);
2516         display_editroom();
2517 }
2518
2519
2520
2521 /**
2522  * \brief Convert a room name to a folder-ish-looking name.
2523  * \param folder the folderish name
2524  * \param room the room name
2525  * \param floor the floor name
2526  * \param is_mailbox is it a mailbox?
2527  */
2528 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2529 {
2530         int i;
2531
2532         /**
2533          * For mailboxes, just do it straight...
2534          */
2535         if (is_mailbox) {
2536                 sprintf(folder, "My folders|%s", room);
2537         }
2538
2539         /**
2540          * Otherwise, prefix the floor name as a "public folders" moniker
2541          */
2542         else {
2543                 sprintf(folder, "%s|%s", floorlist[floor], room);
2544         }
2545
2546         /**
2547          * Replace "\" characters with "|" for pseudo-folder-delimiting
2548          */
2549         for (i=0; i<strlen(folder); ++i) {
2550                 if (folder[i] == '\\') folder[i] = '|';
2551         }
2552 }
2553
2554
2555
2556
2557 /**
2558  * \brief Back end for change_view()
2559  * \param newview set newview???
2560  */
2561 void do_change_view(int newview) {
2562         char buf[SIZ];
2563
2564         serv_printf("VIEW %d", newview);
2565         serv_getln(buf, sizeof buf);
2566         WC->wc_view = newview;
2567         smart_goto(WC->wc_roomname);
2568 }
2569
2570
2571
2572 /**
2573  * \brief Change the view for this room
2574  */
2575 void change_view(void) {
2576         int view;
2577
2578         view = atol(bstr("view"));
2579         do_change_view(view);
2580 }
2581
2582
2583 /**
2584  * \brief One big expanded tree list view --- like a folder list
2585  * \param fold the folder to view
2586  * \param max_folders how many folders???
2587  * \param num_floors hom many floors???
2588  */
2589 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2590         char buf[SIZ];
2591         int levels;
2592         int i;
2593         int has_subfolders = 0;
2594         int *parents;
2595
2596         parents = malloc(max_folders * sizeof(int));
2597
2598         /** BEGIN TREE MENU */
2599         wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2600
2601         /** include NanoTree */
2602         wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2603
2604         /** initialize NanoTree */
2605         wprintf("<script type=\"text/javascript\">                      \n"
2606                 "       showRootNode = false;                           \n"
2607                 "       sortNodes = false;                              \n"
2608                 "       dragable = false;                               \n"
2609                 "                                                       \n"
2610                 "       function standardClick(treeNode) {              \n"
2611                 "       }                                               \n"
2612                 "                                                       \n"
2613                 "       var closedGif = 'static/folder_closed.gif';     \n"
2614                 "       var openGif = 'static/folder_open.gif';         \n"
2615                 "                                                       \n"
2616                 "       rootNode = new TreeNode(1, 'root node - hide'); \n"
2617         );
2618
2619         levels = 0;
2620         for (i=0; i<max_folders; ++i) {
2621
2622                 has_subfolders = 0;
2623                 if ((i+1) < max_folders) {
2624                         if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2625                            && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2626                                 has_subfolders = 1;
2627                         }
2628                 }
2629
2630                 levels = num_tokens(fold[i].name, '|');
2631                 parents[levels] = i;
2632
2633                 wprintf("var node%d = new TreeNode(%d, '", i, i);
2634
2635                 if (fold[i].selectable) {
2636                         wprintf("<a href=\"dotgoto?room=");
2637                         urlescputs(fold[i].room);
2638                         wprintf("\">");
2639                 }
2640
2641                 if (levels == 1) {
2642                         wprintf("<SPAN CLASS=\"roomlist_floor\">");
2643                 }
2644                 else if (fold[i].hasnewmsgs) {
2645                         wprintf("<SPAN CLASS=\"roomlist_new\">");
2646                 }
2647                 else {
2648                         wprintf("<SPAN CLASS=\"roomlist_old\">");
2649                 }
2650                 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2651                 escputs(buf);
2652                 wprintf("</SPAN>");
2653
2654                 wprintf("</a>', ");
2655                 if (has_subfolders) {
2656                         wprintf("new Array(closedGif, openGif)");
2657                 }
2658                 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2659                         wprintf("'static/viewcontacts_16x.gif'");
2660                 }
2661                 else if (fold[i].view == VIEW_CALENDAR) {
2662                         wprintf("'static/calarea_16x.gif'");
2663                 }
2664                 else if (fold[i].view == VIEW_CALBRIEF) {
2665                         wprintf("'static/calarea_16x.gif'");
2666                 }
2667                 else if (fold[i].view == VIEW_TASKS) {
2668                         wprintf("'static/taskmanag_16x.gif'");
2669                 }
2670                 else if (fold[i].view == VIEW_NOTES) {
2671                         wprintf("'static/storenotes_16x.gif'");
2672                 }
2673                 else if (fold[i].view == VIEW_MAILBOX) {
2674                         wprintf("'static/privatemess_16x.gif'");
2675                 }
2676                 else {
2677                         wprintf("'static/chatrooms_16x.gif'");
2678                 }
2679                 wprintf(", '");
2680                 urlescputs(fold[i].name);
2681                 wprintf("');\n");
2682
2683                 if (levels < 2) {
2684                         wprintf("rootNode.addChild(node%d);\n", i);
2685                 }
2686                 else {
2687                         wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2688                 }
2689         }
2690
2691         wprintf("container = document.getElementById('roomlist_div');   \n"
2692                 "showTree('');  \n"
2693                 "</script>\n"
2694         );
2695
2696         free(parents);
2697         /** END TREE MENU */
2698 }
2699
2700 /**
2701  * \brief Boxes and rooms and lists ... oh my!
2702  * \param fold the folder to view
2703  * \param max_folders how many folders???
2704  * \param num_floors hom many floors???
2705  */
2706 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2707         char buf[256];
2708         char floor_name[256];
2709         char old_floor_name[256];
2710         char boxtitle[256];
2711         int levels, oldlevels;
2712         int i, t;
2713         int num_boxes = 0;
2714         static int columns = 3;
2715         int boxes_per_column = 0;
2716         int current_column = 0;
2717         int nf;
2718
2719         strcpy(floor_name, "");
2720         strcpy(old_floor_name, "");
2721
2722         nf = num_floors;
2723         while (nf % columns != 0) ++nf;
2724         boxes_per_column = (nf / columns);
2725         if (boxes_per_column < 1) boxes_per_column = 1;
2726
2727         /** Outer table (for columnization) */
2728         wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2729                 "<tr><td valign=top>");
2730
2731         levels = 0;
2732         oldlevels = 0;
2733         for (i=0; i<max_folders; ++i) {
2734
2735                 levels = num_tokens(fold[i].name, '|');
2736                 extract_token(floor_name, fold[i].name, 0,
2737                         '|', sizeof floor_name);
2738
2739                 if ( (strcasecmp(floor_name, old_floor_name))
2740                    && (strlen(old_floor_name) > 0) ) {
2741                         /* End inner box */
2742                         do_template("endbox");
2743
2744                         ++num_boxes;
2745                         if ((num_boxes % boxes_per_column) == 0) {
2746                                 ++current_column;
2747                                 if (current_column < columns) {
2748                                         wprintf("</td><td valign=top>\n");
2749                                 }
2750                         }
2751                 }
2752                 strcpy(old_floor_name, floor_name);
2753
2754                 if (levels == 1) {
2755                         /** Begin inner box */
2756                         stresc(boxtitle, floor_name, 1, 0);
2757                         svprintf("BOXTITLE", WCS_STRING, boxtitle);
2758                         do_template("beginbox");
2759                 }
2760
2761                 oldlevels = levels;
2762
2763                 if (levels > 1) {
2764                         wprintf("&nbsp;");
2765                         if (levels>2) for (t=0; t<(levels-2); ++t) wprintf("&nbsp;&nbsp;&nbsp;");
2766                         if (fold[i].selectable) {
2767                                 wprintf("<a href=\"dotgoto?room=");
2768                                 urlescputs(fold[i].room);
2769                                 wprintf("\">");
2770                         }
2771                         else {
2772                                 wprintf("<i>");
2773                         }
2774                         if (fold[i].hasnewmsgs) {
2775                                 wprintf("<SPAN CLASS=\"roomlist_new\">");
2776                         }
2777                         else {
2778                                 wprintf("<SPAN CLASS=\"roomlist_old\">");
2779                         }
2780                         extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2781                         escputs(buf);
2782                         wprintf("</SPAN>");
2783                         if (fold[i].selectable) {
2784                                 wprintf("</A>");
2785                         }
2786                         else {
2787                                 wprintf("</i>");
2788                         }
2789                         if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2790                                 wprintf(" (INBOX)");
2791                         }
2792                         wprintf("<br />\n");
2793                 }
2794         }
2795         /** End the final inner box */
2796         do_template("endbox");
2797
2798         wprintf("</TD></TR></TABLE>\n");
2799 }
2800
2801 /**
2802  * \brief print a floor div???
2803  * \param which_floordiv name of the floordiv???
2804  */
2805 void set_floordiv_expanded(char *which_floordiv) {
2806         begin_ajax_response();
2807         safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2808         end_ajax_response();
2809 }
2810
2811 /**
2812  * \brief view the iconbar
2813  * \param fold the folder to view
2814  * \param max_folders how many folders???
2815  * \param num_floors hom many floors???
2816  */
2817 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2818         char buf[256];
2819         char floor_name[256];
2820         char old_floor_name[256];
2821         char floordivtitle[256];
2822         char floordiv_id[32];
2823         int levels, oldlevels;
2824         int i, t;
2825         int num_drop_targets = 0;
2826         char *icon = NULL;
2827
2828         strcpy(floor_name, "");
2829         strcpy(old_floor_name, "");
2830
2831         levels = 0;
2832         oldlevels = 0;
2833         for (i=0; i<max_folders; ++i) {
2834
2835                 levels = num_tokens(fold[i].name, '|');
2836                 extract_token(floor_name, fold[i].name, 0,
2837                         '|', sizeof floor_name);
2838
2839                 if ( (strcasecmp(floor_name, old_floor_name))
2840                    && (strlen(old_floor_name) > 0) ) {
2841                         /** End inner box */
2842                         wprintf("<br>\n");
2843                         wprintf("</div>\n");    /** floordiv */
2844                 }
2845                 strcpy(old_floor_name, floor_name);
2846
2847                 if (levels == 1) {
2848                         /** Begin floor */
2849                         stresc(floordivtitle, floor_name, 0, 0);
2850                         sprintf(floordiv_id, "floordiv%d", i);
2851                         wprintf("<span class=\"ib_roomlist_floor\" "
2852                                 "onClick=\"expand_floor('%s')\">"
2853                                 "%s</span><br>\n", floordiv_id, floordivtitle);
2854                         wprintf("<div id=\"%s\" style=\"display:%s\">",
2855                                 floordiv_id,
2856                                 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2857                         );
2858                 }
2859
2860                 oldlevels = levels;
2861
2862                 if (levels > 1) {
2863                         wprintf("<div id=\"roomdiv%d\">", i);
2864                         wprintf("&nbsp;");
2865                         if (levels>2) for (t=0; t<(levels-2); ++t) wprintf("&nbsp;");
2866
2867                         /** choose the icon */
2868                         if (fold[i].view == VIEW_ADDRESSBOOK) {
2869                                 icon = "viewcontacts_16x.gif" ;
2870                         }
2871                         else if (fold[i].view == VIEW_CALENDAR) {
2872                                 icon = "calarea_16x.gif" ;
2873                         }
2874                         else if (fold[i].view == VIEW_CALBRIEF) {
2875                                 icon = "calarea_16x.gif" ;
2876                         }
2877                         else if (fold[i].view == VIEW_TASKS) {
2878                                 icon = "taskmanag_16x.gif" ;
2879                         }
2880                         else if (fold[i].view == VIEW_NOTES) {
2881                                 icon = "storenotes_16x.gif" ;
2882                         }
2883                         else if (fold[i].view == VIEW_MAILBOX) {
2884                                 icon = "privatemess_16x.gif" ;
2885                         }
2886                         else {
2887                                 icon = "chatrooms_16x.gif" ;
2888                         }
2889
2890                         if (fold[i].selectable) {
2891                                 wprintf("<a href=\"dotgoto?room=");
2892                                 urlescputs(fold[i].room);
2893                                 wprintf("\">");
2894                                 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2895                         }
2896                         else {
2897                                 wprintf("<i>");
2898                         }
2899                         if (fold[i].hasnewmsgs) {
2900                                 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2901                         }
2902                         else {
2903                                 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2904                         }
2905                         extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2906                         escputs(buf);
2907                         if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2908                                 wprintf(" (INBOX)");
2909                         }
2910                         wprintf("</SPAN>");
2911                         if (fold[i].selectable) {
2912                                 wprintf("</A>");
2913                         }
2914                         else {
2915                                 wprintf("</i>");
2916                         }
2917                         wprintf("<br />");
2918                         wprintf("</div>\n");    /** roomdiv */
2919                 }
2920         }
2921         wprintf("</div>\n");    /** floordiv */
2922
2923
2924         /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2925         wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2926
2927         num_drop_targets = 0;
2928
2929         for (i=0; i<max_folders; ++i) {
2930                 levels = num_tokens(fold[i].name, '|');
2931                 if (levels > 1) {
2932                         wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2933                         wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2934                         jsescputs(fold[i].room);
2935                         wprintf("';\n");
2936                         ++num_drop_targets;
2937                 }
2938         }
2939
2940         wprintf("num_drop_targets = %d;\n", num_drop_targets);
2941         if (strlen(WC->floordiv_expanded) > 1) {
2942                 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2943         }
2944
2945         wprintf("\">\n");
2946         /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2947 }
2948
2949
2950
2951 /**
2952  * \brief Show the room list.  
2953  * (only should get called by
2954  * knrooms() because that's where output_headers() is called from)
2955  * \param viewpref the view preferences???
2956  */
2957
2958 void list_all_rooms_by_floor(char *viewpref) {
2959         char buf[SIZ];
2960         int swap = 0;
2961         struct folder *fold = NULL;
2962         struct folder ftmp;
2963         int max_folders = 0;
2964         int alloc_folders = 0;
2965         int i, j;
2966         int ra_flags = 0;
2967         int flags = 0;
2968         int num_floors = 1;     /** add an extra one for private folders */
2969
2970         /** If our cached folder list is very old, burn it. */
2971         if (WC->cache_fold != NULL) {
2972                 if ((time(NULL) - WC->cache_timestamp) > 300) {
2973                         free(WC->cache_fold);
2974                         WC->cache_fold = NULL;
2975                 }
2976         }
2977
2978         /** Can we do the iconbar roomlist from cache? */
2979         if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2980                 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2981                 return;
2982         }
2983
2984         /** Grab the floor table so we know how to build the list... */
2985         load_floorlist();
2986
2987         /** Start with the mailboxes */
2988         max_folders = 1;
2989         alloc_folders = 1;
2990         fold = malloc(sizeof(struct folder));
2991         memset(fold, 0, sizeof(struct folder));
2992         strcpy(fold[0].name, "My folders");
2993         fold[0].is_mailbox = 1;
2994
2995         /** Then add floors */
2996         serv_puts("LFLR");
2997         serv_getln(buf, sizeof buf);
2998         if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2999                 if (max_folders >= alloc_folders) {
3000                         alloc_folders = max_folders + 100;
3001                         fold = realloc(fold,
3002                                 alloc_folders * sizeof(struct folder));
3003                 }
3004                 memset(&fold[max_folders], 0, sizeof(struct folder));
3005                 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3006                 ++max_folders;
3007                 ++num_floors;
3008         }
3009
3010         /** refresh the messages index for this room */
3011 //      serv_puts("GOTO ");
3012 //      while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3013         /** Now add rooms */
3014         serv_puts("LKRA");
3015         serv_getln(buf, sizeof buf);
3016         if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3017                 if (max_folders >= alloc_folders) {
3018                         alloc_folders = max_folders + 100;
3019                         fold = realloc(fold,
3020                                 alloc_folders * sizeof(struct folder));
3021                 }
3022                 memset(&fold[max_folders], 0, sizeof(struct folder));
3023                 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3024                 ra_flags = extract_int(buf, 5);
3025                 flags = extract_int(buf, 1);
3026                 fold[max_folders].floor = extract_int(buf, 2);
3027                 fold[max_folders].hasnewmsgs =
3028                         ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3029                 if (flags & QR_MAILBOX) {
3030                         fold[max_folders].is_mailbox = 1;
3031                 }
3032                 fold[max_folders].view = extract_int(buf, 6);
3033                 room_to_folder(fold[max_folders].name,
3034                                 fold[max_folders].room,
3035                                 fold[max_folders].floor,
3036                                 fold[max_folders].is_mailbox);
3037                 fold[max_folders].selectable = 1;
3038                 ++max_folders;
3039         }
3040
3041         /** Bubble-sort the folder list */
3042         for (i=0; i<max_folders; ++i) {
3043                 for (j=0; j<(max_folders-1)-i; ++j) {
3044                         if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3045                                 swap = strcasecmp(fold[j].name, fold[j+1].name);
3046                         }
3047                         else {
3048                                 if ( (fold[j+1].is_mailbox)
3049                                    && (!fold[j].is_mailbox)) {
3050                                         swap = 1;
3051                                 }
3052                                 else {
3053                                         swap = 0;
3054                                 }
3055                         }
3056                         if (swap > 0) {
3057                                 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3058                                 memcpy(&fold[j], &fold[j+1],
3059                                                         sizeof(struct folder));
3060                                 memcpy(&fold[j+1], &ftmp,
3061                                                         sizeof(struct folder));
3062                         }
3063                 }
3064         }
3065
3066
3067         if (!strcasecmp(viewpref, "folders")) {
3068                 do_folder_view(fold, max_folders, num_floors);
3069         }
3070         else if (!strcasecmp(viewpref, "hackish_view")) {
3071                 for (i=0; i<max_folders; ++i) {
3072                         escputs(fold[i].name);
3073                         wprintf("<br />\n");
3074                 }
3075         }
3076         else if (!strcasecmp(viewpref, "iconbar")) {
3077                 do_iconbar_view(fold, max_folders, num_floors);
3078         }
3079         else {
3080                 do_rooms_view(fold, max_folders, num_floors);
3081         }
3082
3083         /* Don't free the folder list ... cache it for future use! */
3084         if (WC->cache_fold != NULL) {
3085                 free(WC->cache_fold);
3086         }
3087         WC->cache_fold = fold;
3088         WC->cache_max_folders = max_folders;
3089         WC->cache_num_floors = num_floors;
3090         WC->cache_timestamp = time(NULL);
3091 }
3092
3093
3094 /**
3095  * \brief Do either a known rooms list or a folders list, depending on the
3096  * user's preference
3097  */
3098 void knrooms(void)
3099 {
3100         char listviewpref[SIZ];
3101
3102         output_headers(1, 1, 2, 0, 0, 0);
3103
3104         /** Determine whether the user is trying to change views */
3105         if (bstr("view") != NULL) {
3106                 if (strlen(bstr("view")) > 0) {
3107                         set_preference("roomlistview", bstr("view"), 1);
3108                 }
3109         }
3110
3111         get_preference("roomlistview", listviewpref, sizeof listviewpref);
3112
3113         if ( (strcasecmp(listviewpref, "folders"))
3114            && (strcasecmp(listviewpref, "table")) ) {
3115                 strcpy(listviewpref, "rooms");
3116         }
3117
3118         /** title bar */
3119         wprintf("<div id=\"banner\">\n"
3120                 "<TABLE class=\"roomops_banner\"><TR><TD>"
3121                 "<SPAN CLASS=\"titlebar\">"
3122         );
3123         if (!strcasecmp(listviewpref, "rooms")) {
3124                 wprintf(_("Room list"));
3125         }
3126         if (!strcasecmp(listviewpref, "folders")) {
3127                 wprintf(_("Folder list"));
3128         }
3129         if (!strcasecmp(listviewpref, "table")) {
3130                 wprintf(_("Room list"));
3131         }
3132         wprintf("</SPAN></TD>\n");
3133
3134         /** offer the ability to switch views */
3135         wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
3136                 "<SELECT NAME=\"newview\" SIZE=\"1\" "
3137                 "OnChange=\"location.href=roomlistomatic.newview.options"
3138                 "[selectedIndex].value\">\n");
3139
3140         wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3141                 "View as room list"
3142                 "</OPTION>\n",
3143                 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3144         );
3145
3146         wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3147                 "View as folder list"
3148                 "</OPTION>\n",
3149                 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3150         );
3151
3152         wprintf("</SELECT><br />");
3153         offer_start_page();
3154         wprintf("</FORM></TD></TR></TABLE>\n");
3155         wprintf("</div>\n"
3156                 "</div>\n"
3157                 "<div id=\"content\">\n");
3158
3159         /** Display the room list in the user's preferred format */
3160         list_all_rooms_by_floor(listviewpref);
3161         wDumpContent(1);
3162 }
3163
3164
3165
3166 /**
3167  * \brief Set the message expire policy for this room and/or floor
3168  */
3169 void set_room_policy(void) {
3170         char buf[SIZ];
3171
3172         if (strlen(bstr("ok_button")) == 0) {
3173                 strcpy(WC->ImportantMessage,
3174                         _("Cancelled.  Changes were not saved."));
3175                 display_editroom();
3176                 return;
3177         }
3178
3179         serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3180         serv_getln(buf, sizeof buf);
3181         strcpy(WC->ImportantMessage, &buf[4]);
3182
3183         if (WC->axlevel >= 6) {
3184                 strcat(WC->ImportantMessage, "<br />\n");
3185                 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3186                 serv_getln(buf, sizeof buf);
3187                 strcat(WC->ImportantMessage, &buf[4]);
3188         }
3189
3190         display_editroom();
3191 }
3192
3193 /*@}*/