982dfd8879c8e4864fd9c793946603bd92fefe34
[citadel.git] / webcit / roomops.c
1 /*
2  * $Id$
3  * Lots of different room-related operations.
4  */
5
6 #include "webcit.h"
7 #include "webserver.h"
8 #define MAX_FLOORS 128
9
10 char floorlist[MAX_FLOORS][SIZ];        /* list of our floor names */
11
12 char *viewdefs[9];                      /* the different kinds of available views */
13
14 /* See GetFloorListHash and GetRoomListHash for info on these.
15  * Basically we pull LFLR/LKRA etc. and set up a room HashList with these keys.
16  */
17
18 void display_whok(void);
19 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP);
20
21 /*
22  * Initialize the viewdefs with localized strings
23  */
24 void initialize_viewdefs(void) {
25         viewdefs[0] = _("Bulletin Board");
26         viewdefs[1] = _("Mail Folder");
27         viewdefs[2] = _("Address Book");
28         viewdefs[3] = _("Calendar");
29         viewdefs[4] = _("Task List");
30         viewdefs[5] = _("Notes List");
31         viewdefs[6] = _("Wiki");
32         viewdefs[7] = _("Calendar List");
33         viewdefs[8] = _("Journal");
34 }
35
36 /*
37  * Determine which views are allowed as the default for creating a new room.
38  */
39 int is_view_allowed_as_default(int which_view)
40 {
41         switch(which_view) {
42                 case VIEW_BBS:          return(1);
43                 case VIEW_MAILBOX:      return(1);
44                 case VIEW_ADDRESSBOOK:  return(1);
45                 case VIEW_CALENDAR:     return(1);
46                 case VIEW_TASKS:        return(1);
47                 case VIEW_NOTES:        return(1);
48                 case VIEW_WIKI:         return(1);
49                 case VIEW_CALBRIEF:     return(0);
50                 case VIEW_JOURNAL:      return(0);
51                 default:                return(0);      /* should never get here */
52         }
53 }
54
55
56 /*
57  * load the list of floors
58  */
59 void load_floorlist(StrBuf *Buf)
60 {
61         int a;
62         int Done = 0;
63
64         for (a = 0; a < MAX_FLOORS; ++a)
65                 floorlist[a][0] = 0;
66
67         serv_puts("LFLR");
68         StrBuf_ServGetln(Buf);
69         if (GetServerStatus(Buf, NULL) != 1) {
70                 strcpy(floorlist[0], "Main Floor");
71                 return;
72         }
73         while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
74                 if ( (StrLength(Buf)==3) && 
75                      !strcmp(ChrPtr(Buf), "000")) {
76                         Done = 1;
77                         break;
78                 }
79                 extract_token(floorlist[StrBufExtract_int(Buf, 0, '|')], ChrPtr(Buf), 1, '|', sizeof floorlist[0]);
80         }
81 }
82
83
84
85
86 /*
87  * display rooms in tree structure
88  */
89 void room_tree_list(struct roomlisting *rp)
90 {
91         char rmname[64];
92         int f;
93
94         if (rp == NULL) {
95                 return;
96         }
97
98         room_tree_list(rp->lnext);
99
100         strcpy(rmname, rp->rlname);
101         f = rp->rlflags;
102
103         wc_printf("<a href=\"dotgoto?room=");
104         urlescputs(rmname);
105         wc_printf("\"");
106         wc_printf(">");
107         escputs1(rmname, 1, 1);
108         if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
109                 wc_printf("}");
110         else if (f & QR_DIRECTORY)
111                 wc_printf("]");
112         else if (f & QR_NETWORK)
113                 wc_printf(")");
114         else
115                 wc_printf("&gt;");
116         wc_printf("</a><tt> </tt>\n");
117
118         room_tree_list(rp->rnext);
119         free(rp);
120 }
121
122
123 /* 
124  * Room ordering stuff (compare first by floor, then by order)
125  */
126 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
127 {
128         if ((r1 == NULL) && (r2 == NULL))
129                 return (0);
130         if (r1 == NULL)
131                 return (-1);
132         if (r2 == NULL)
133                 return (1);
134         if (r1->rlfloor < r2->rlfloor)
135                 return (-1);
136         if (r1->rlfloor > r2->rlfloor)
137                 return (1);
138         if (r1->rlorder < r2->rlorder)
139                 return (-1);
140         if (r1->rlorder > r2->rlorder)
141                 return (1);
142         return (0);
143 }
144
145
146 /*
147  * Common code for all room listings
148  */
149 void listrms(char *variety)
150 {
151         char buf[SIZ];
152         int num_rooms = 0;
153
154         struct roomlisting *rl = NULL;
155         struct roomlisting *rp;
156         struct roomlisting *rs;
157
158         /* Ask the server for a room list */
159         serv_puts(variety);
160         serv_getln(buf, sizeof buf);
161         if (buf[0] != '1') {
162                 wc_printf("&nbsp;");
163                 return;
164         }
165
166         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
167                 ++num_rooms;
168                 rp = malloc(sizeof(struct roomlisting));
169                 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
170                 rp->rlflags = extract_int(buf, 1);
171                 rp->rlfloor = extract_int(buf, 2);
172                 rp->rlorder = extract_int(buf, 3);
173                 rp->lnext = NULL;
174                 rp->rnext = NULL;
175
176                 rs = rl;
177                 if (rl == NULL) {
178                         rl = rp;
179                 } else
180                         while (rp != NULL) {
181                                 if (rordercmp(rp, rs) < 0) {
182                                         if (rs->lnext == NULL) {
183                                                 rs->lnext = rp;
184                                                 rp = NULL;
185                                         } else {
186                                                 rs = rs->lnext;
187                                         }
188                                 } else {
189                                         if (rs->rnext == NULL) {
190                                                 rs->rnext = rp;
191                                                 rp = NULL;
192                                         } else {
193                                                 rs = rs->rnext;
194                                         }
195                                 }
196                         }
197         }
198
199         room_tree_list(rl);
200
201         /*
202          * If no rooms were listed, print an nbsp to make the cell
203          * borders show up anyway.
204          */
205         if (num_rooms == 0) wc_printf("&nbsp;");
206 }
207
208
209 /*
210  * list all forgotten rooms
211  */
212 void zapped_list(void)
213 {
214         WCTemplputParams SubTP;
215         StrBuf *Buf;
216
217         output_headers(1, 1, 1, 0, 0, 0);
218         memset(&SubTP, 0, sizeof(WCTemplputParams));
219         Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
220         SubTP.Filter.ContextType = CTX_STRBUF;
221         SubTP.Context = Buf;
222         DoTemplate(HKEY("beginbox"), NULL, &SubTP);
223
224         FreeStrBuf(&Buf);
225
226         listrms("LZRM -1");
227
228         wc_printf("<br /><br />\n");
229         wc_printf(_("Click on any room to un-zap it and goto that room.\n"));
230         do_template("endbox", NULL);
231         wDumpContent(1);
232 }
233
234 /*
235  * Display the current view and offer an option to change it
236  */
237 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
238 {
239         int i;
240
241         wc_printf("<form name=\"viewomatic\" action=\"changeview\">\n");
242         wc_printf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
243         wc_printf("<label for=\"view_name\">");
244         wc_printf(_("View as:"));
245         wc_printf("</label> "
246                 "<select name=\"newview\" size=\"1\" "
247                 "id=\"view_name\" class=\"selectbox\" "
248                 "OnChange=\"location.href=viewomatic.newview.options"
249                 "[selectedIndex].value\">\n");
250
251         for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
252                 /*
253                  * Only offer the views that make sense, given the default
254                  * view for the room.  For example, don't offer a Calendar
255                  * view in a non-Calendar room.
256                  */
257                 if (
258                         (i == WC->CurRoom.view)
259                         ||      (i == WC->CurRoom.defview)                      /* default */
260                         ||      ( (i == 0) && (WC->CurRoom.defview == 1) )      /* mail or bulletin */
261                         ||      ( (i == 1) && (WC->CurRoom.defview == 0) )      /* mail or bulletin */
262                         /* ||   ( (i == 7) && (WC->CurRoom.defview == 3) )      (calendar list temporarily disabled) */
263                         ) {
264
265                         wc_printf("<option %s value=\"changeview?view=%d\">",
266                                 ((i == WC->CurRoom.view) ? "selected" : ""),
267                                 i );
268                         escputs(viewdefs[i]);
269                         wc_printf("</option>\n");
270                 }
271         }
272         wc_printf("</select></div></form>\n");
273 }
274
275
276
277 /*
278  * Embed the room banner
279  *
280  * got                  The information returned from a GOTO server command
281  * navbar_style         Determines which navigation buttons to display
282  *
283  */
284
285 void embed_room_banner(char *got, int navbar_style) {
286         wcsession *WCC = WC;
287         char buf[256];
288         char buf2[1024];
289         char with_files[256];
290         int file_count=0;
291         
292         /*
293          * We need to have the information returned by a GOTO server command.
294          * If it isn't supplied, we fake it by issuing our own GOTO.
295          */
296         if (got == NULL) {
297                 memset(buf, '0', 20);
298                 buf[20] = '\0';
299                 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
300                 serv_getln(buf, sizeof buf);
301                 got = buf;
302         }
303
304         /* The browser needs some information for its own use */
305         wc_printf("<script type=\"text/javascript\">    \n"
306                   "     room_is_trash = %d;             \n"
307                   "</script>\n",
308                   ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
309         );
310
311         /*
312          * If the user happens to select the "make this my start page" link,
313          * we want it to remember the URL as a "/dotskip" one instead of
314          * a "skip" or "gotonext" or something like that.
315          */
316         if (WCC->Hdr->this_page == NULL) {
317                 WCC->Hdr->this_page = NewStrBuf();
318         }
319         StrBufPrintf(WCC->Hdr->this_page, 
320                      "dotskip?room=%s",
321                      ChrPtr(WC->CurRoom.name)
322         );
323
324         /* Check for new mail. */
325         WC->new_mail = extract_int(&got[4], 9);
326         WC->CurRoom.view = extract_int(&got[4], 11);
327
328         /* Is this a directory room and does it contain files and how many? */
329         if ((WC->CurRoom.QRFlags & QR_DIRECTORY) && (WC->CurRoom.QRFlags & QR_VISDIR))
330         {
331                 serv_puts("RDIR");
332                 serv_getln(buf2, sizeof buf2);
333                 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
334                                             file_count++;
335                 snprintf (with_files, sizeof with_files, 
336                           "; <a href=\"do_template?template=files\"> %d %s </a>", 
337                           file_count, 
338                           ((file_count>1) || (file_count == 0)  ? _("files") : _("file")));
339         }
340         else
341                 strcpy (with_files, "");
342         
343         svprintf(HKEY("NUMMSGS"), WCS_STRING,
344                  _("%d new of %d messages%s"),
345                  extract_int(&got[4], 1),
346                  extract_int(&got[4], 2),
347                  with_files
348                 );
349         svcallback("VIEWOMATIC", embed_view_o_matic); 
350         svcallback("START", offer_start_page); 
351  
352         do_template("roombanner", NULL);
353         /* roombanner contains this for mobile */
354         if (navbar_style != navbar_none && (WC->is_mobile < 1)) { 
355
356                 wc_printf("<div id=\"navbar\"><ul>");
357
358                 if (navbar_style == navbar_default) wc_printf(
359                         "<li class=\"ungoto\">"
360                         "<a href=\"ungoto\">"
361                         "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
362                         "<span class=\"navbar_link\">%s</span></A>"
363                         "</li>\n", _("Ungoto")
364                         );
365
366                 if ( (navbar_style == navbar_default) && (WC->CurRoom.view == VIEW_BBS) ) {
367                         wc_printf(
368                                 "<li class=\"newmess\">"
369                                 "<a href=\"readnew\">"
370                                 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
371                                 "<span class=\"navbar_link\">%s</span></A>"
372                                 "</li>\n", _("Read new messages")
373                                 );
374                 }
375
376                 if (navbar_style == navbar_default) {
377                         switch(WC->CurRoom.view) {
378                         case VIEW_ADDRESSBOOK:
379                                 wc_printf(
380                                         "<li class=\"viewcontacts\">"
381                                         "<a href=\"readfwd\">"
382                                         "<img src=\"static/viewcontacts_24x.gif\" "
383                                         "alt=\"\" width=\"24\" height=\"24\">"
384                                         "<span class=\"navbar_link\">"
385                                         "%s"
386                                         "</span></a></li>\n", _("View contacts")
387                                         );
388                                 break;
389                         case VIEW_CALENDAR:
390                                 wc_printf(
391                                         "<li class=\"staskday\">"
392                                         "<a href=\"readfwd?calview=day\">"
393                                         "<img src=\"static/taskday2_24x.gif\" "
394                                         "alt=\"\" width=\"24\" height=\"24\">"
395                                         "<span class=\"navbar_link\">"
396                                         "%s"
397                                         "</span></a></li>\n", _("Day view")
398                                         );
399                                 wc_printf(
400                                         "<li class=\"monthview\">"
401                                         "<a href=\"readfwd?calview=month\">"
402                                         "<img src=\"static/monthview2_24x.gif\" "
403                                         "alt=\"\" width=\"24\" height=\"24\">"
404                                         "<span class=\"navbar_link\">"
405                                         "%s"
406                                         "</span></a></li>\n", _("Month view")
407                                         );
408                                 break;
409                         case VIEW_CALBRIEF:
410                                 wc_printf(
411                                         "<li class=\"monthview\">"
412                                         "<a href=\"readfwd?calview=month\">"
413                                         "<img src=\"static/monthview2_24x.gif\" "
414                                         "alt=\"\" width=\"24\" height=\"24\">"
415                                         "<span class=\"navbar_link\">"
416                                         "%s"
417                                         "</span></a></li>\n", _("Calendar list")
418                                         );
419                                 break;
420                         case VIEW_TASKS:
421                                 wc_printf(
422                                         "<li class=\"taskmanag\">"
423                                         "<a href=\"readfwd\">"
424                                         "<img src=\"static/taskmanag_24x.gif\" "
425                                         "alt=\"\" width=\"24\" height=\"24\">"
426                                         "<span class=\"navbar_link\">"
427                                         "%s"
428                                         "</span></a></li>\n", _("View tasks")
429                                         );
430                                 break;
431                         case VIEW_NOTES:
432                                 wc_printf(
433                                         "<li class=\"viewnotes\">"
434                                         "<a href=\"readfwd\">"
435                                         "<img src=\"static/viewnotes_24x.gif\" "
436                                         "alt=\"\" width=\"24\" height=\"24\">"
437                                         "<span class=\"navbar_link\">"
438                                         "%s"
439                                         "</span></a></li>\n", _("View notes")
440                                         );
441                                 break;
442                         case VIEW_MAILBOX:
443                                 wc_printf(
444                                         "<li class=\"readallmess\">"
445                                         "<a id=\"m_refresh\" href=\"readfwd\">"
446                                         "<img src=\"static/readallmess3_24x.gif\" "
447                                         "alt=\"\" width=\"24\" height=\"24\">"
448                                         "<span class=\"navbar_link\">"
449                                         "%s"
450                                         "</span></a></li>\n", _("Refresh message list")
451                                         );
452                                 break;
453                         case VIEW_WIKI:
454                                 wc_printf(
455                                         "<li class=\"readallmess\">"
456                                         "<a href=\"wiki?page=home\">"
457                                         "<img src=\"static/readallmess3_24x.gif\" "
458                                         "alt=\"\" width=\"24\" height=\"24\">"
459                                         "<span class=\"navbar_link\">"
460                                         "%s"
461                                         "</span></a></li>\n", _("Wiki home")
462                                         );
463                                 break;
464                         default:
465                                 wc_printf(
466                                         "<li class=\"readallmess\">"
467                                         "<a href=\"readfwd\">"
468                                         "<img src=\"static/readallmess3_24x.gif\" "
469                                         "alt=\"\" width=\"24\" height=\"24\">"
470                                         "<span class=\"navbar_link\">"
471                                         "%s"
472                                         "</span></a></li>\n", _("Read all messages")
473                                         );
474                                 break;
475                         }
476                 }
477
478                 if (navbar_style == navbar_default) {
479                         switch(WC->CurRoom.view) {
480                         case VIEW_ADDRESSBOOK:
481                                 wc_printf(
482                                         "<li class=\"addnewcontact\">"
483                                         "<a href=\"display_enter\">"
484                                         "<img src=\"static/addnewcontact_24x.gif\" "
485                                         "alt=\"\" width=\"24\" height=\"24\">"
486                                         "<span class=\"navbar_link\">"
487                                         "%s"
488                                         "</span></a></li>\n", _("Add new contact")
489                                         );
490                                 break;
491                         case VIEW_CALENDAR:
492                         case VIEW_CALBRIEF:
493                                 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
494                                 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
495                                 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
496                                 if (havebstr("day"  )) wc_printf("?day=%s", bstr("day"));
497                                 wc_printf("\">"
498                                         "<img  src=\"static/addevent_24x.gif\" "
499                                         "alt=\"\" width=\"24\" height=\"24\">"
500                                         "<span class=\"navbar_link\">"
501                                         "%s"
502                                         "</span></a></li>\n", _("Add new event")
503                                         );
504                                 break;
505                         case VIEW_TASKS:
506                                 wc_printf(
507                                         "<li class=\"newmess\">"
508                                         "<a href=\"display_enter\">"
509                                         "<img  src=\"static/newmess3_24x.gif\" "
510                                         "alt=\"\" width=\"24\" height=\"24\">"
511                                         "<span class=\"navbar_link\">"
512                                         "%s"
513                                         "</span></a></li>\n", _("Add new task")
514                                         );
515                                 break;
516                         case VIEW_NOTES:
517                                 wc_printf(
518                                         "<li class=\"enternewnote\">"
519                                         "<a href=\"add_new_note\">"
520                                         "<img  src=\"static/enternewnote_24x.gif\" "
521                                         "alt=\"\" width=\"24\" height=\"24\">"
522                                         "<span class=\"navbar_link\">"
523                                         "%s"
524                                         "</span></a></li>\n", _("Add new note")
525                                         );
526                                 break;
527                         case VIEW_WIKI:
528                                 safestrncpy(buf, bstr("page"), sizeof buf);
529                                 if (IsEmptyStr(buf)) {
530                                         safestrncpy(buf, "home", sizeof buf);
531                                 }
532                                 str_wiki_index(buf);
533                                 wc_printf(
534                                         "<li class=\"newmess\">"
535                                         "<a href=\"display_enter?page=%s\">"
536                                         "<img  src=\"static/newmess3_24x.gif\" "
537                                         "alt=\"\" width=\"24\" height=\"24\">"
538                                         "<span class=\"navbar_link\">"
539                                         "%s"
540                                         "</span></a></li>\n", buf, _("Edit this page")
541                                         );
542
543                                 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
544                                         /* already viewing history; display a link to the current page */
545                                         wc_printf(
546                                                 "<li class=\"newmess\">"
547                                                 "<a href=\"wiki?page=%s\">"
548                                                 "<img  src=\"static/newmess3_24x.gif\" "
549                                                 "alt=\"\" width=\"24\" height=\"24\">"
550                                                 "<span class=\"navbar_link\">"
551                                                 "%s"
552                                                 "</span></a></li>\n", buf, _("Current version")
553                                                 );
554                                 }
555                                 else {
556                                         /* display a link to the history */
557                                         wc_printf(
558                                                 "<li class=\"newmess\">"
559                                                 "<a href=\"wiki_history?page=%s\">"
560                                                 "<img  src=\"static/newmess3_24x.gif\" "
561                                                 "alt=\"\" width=\"24\" height=\"24\">"
562                                                 "<span class=\"navbar_link\">"
563                                                 "%s"
564                                                 "</span></a></li>\n", buf, _("History")
565                                                 );
566                                 }
567                                 break;
568                         case VIEW_MAILBOX:
569                                 wc_printf(
570                                         "<li class=\"newmess\">"
571                                         "<a href=\"display_enter\">"
572                                         "<img  src=\"static/newmess3_24x.gif\" "
573                                         "alt=\"\" width=\"24\" height=\"24\">"
574                                         "<span class=\"navbar_link\">"
575                                         "%s"
576                                         "</span></a></li>\n", _("Write mail")
577                                         );
578                                 wc_printf(
579                                         "<li class=\"newmess\">"
580                                         "<a href=\"javascript:deleteAllSelectedMessages();\">"
581                                         "<img  src=\"static/delete.gif\" "
582                                         "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
583                                         "%s"
584                                         "</span></a></li>\n", _("Delete")
585                                         );
586                                 break;
587                         default:
588                                 wc_printf(
589                                         "<li class=\"newmess\">"
590                                         "<a href=\"display_enter\">"
591                                         "<img  src=\"static/newmess3_24x.gif\" "
592                                         "alt=\"\" width=\"24\" height=\"24\">"
593                                         "<span class=\"navbar_link\">"
594                                         "%s"
595                                         "</span></a></li>\n", _("Enter a message")
596                                         );
597                                 break;
598                         }
599                 }
600
601                 if (navbar_style == navbar_default) wc_printf(
602                         "<li class=\"skipthisroom\">"
603                         "<a href=\"skip\" "
604                         "title=\"%s\">"
605                         "<img  src=\"static/skipthisroom_24x.gif\" alt=\"\" "
606                         "width=\"24\" height=\"24\">"
607                         "<span class=\"navbar_link\">%s</span></a>"
608                         "</li>\n",
609                         _("Leave all messages marked as unread, go to next room with unread messages"),
610                         _("Skip this room")
611                         );
612
613                 if (navbar_style == navbar_default) wc_printf(
614                         "<li class=\"markngo\">"
615                         "<a href=\"gotonext\" "
616                         "title=\"%s\">"
617                         "<img  src=\"static/markngo_24x.gif\" alt=\"\" "
618                         "width=\"24\" height=\"24\">"
619                         "<span class=\"navbar_link\">%s</span></a>"
620                         "</li>\n",
621                         _("Mark all messages as read, go to next room with unread messages"),
622                         _("Goto next room")
623                         );
624
625                 wc_printf("</ul></div>\n");
626         }
627
628 }
629
630
631 /*
632  * back end routine to take the session to a new room
633  */
634 long gotoroom(const StrBuf *gname)
635 {
636         wcsession *WCC = WC;
637         StrBuf *Buf;
638         static long ls = (-1L);
639         long err = 0;
640
641         /* store ungoto information */
642         strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
643         WCC->uglsn = ls;
644         Buf = NewStrBuf();
645
646         /* move to the new room */
647         serv_printf("GOTO %s", ChrPtr(gname));
648         StrBuf_ServGetln(Buf);
649         if  (GetServerStatus(Buf, &err) != 2) {
650                 serv_puts("GOTO _BASEROOM_");
651                 StrBuf_ServGetln(Buf);
652                 /* 
653                  * well, we know that this is the fallback case, 
654                  * but we're interested that the first command 
655                  * didn't work out in first place.
656                  */
657                 if (GetServerStatus(Buf, NULL) != 2) {
658                         FreeStrBuf(&Buf);
659                         return err;
660                 }
661         }
662         ParseGoto(&WCC->CurRoom, Buf);
663
664         remove_march(WCC->CurRoom.name);
665         if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
666                 remove_march(gname);
667         FreeStrBuf(&Buf);
668
669         return err;
670 }
671
672
673 void ParseGoto(folder *room, StrBuf *Line)
674 {
675         wcsession *WCC = WC;
676         const char *Pos;
677         int flag;
678         void *vFloor = NULL;
679         StrBuf *pBuf;
680
681         if (StrLength(Line) < 4) {
682                 return;
683         }
684         
685         /* ignore the commandstate... */
686         Pos = ChrPtr(Line) + 4;
687
688         if (room->RoomNameParts != NULL)
689         {
690                 int i;
691                 for (i=0; i < room->nRoomNameParts; i++)
692                         FreeStrBuf(&room->RoomNameParts[i]);
693                 free(room->RoomNameParts);
694                 room->RoomNameParts = NULL;
695         }
696
697         pBuf = room->name;  
698         if (pBuf == NULL)
699                 pBuf = NewStrBufPlain(NULL, StrLength(Line));
700         else
701                 FlushStrBuf(pBuf);
702         memset(room, 0, sizeof(folder));
703         room->name = pBuf;
704
705         StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
706
707         room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|'); 
708         if (room->nNewMessages > 0)
709                 room->RAFlags |= UA_HASNEWMSGS;
710
711         room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
712
713         room->ShowInfo =  StrBufExtractNext_long(Line, &Pos, '|');
714         
715         room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
716
717         room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
718         room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
719
720         room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
721
722         flag = StrBufExtractNext_long(Line, &Pos, '|');
723         if (WCC->is_aide || flag) {
724                 room->RAFlags |= UA_ADMINALLOWED;
725         }
726
727         room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
728
729         room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
730
731         room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
732
733         room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
734
735         flag = StrBufExtractNext_long(Line, &Pos, '|');
736         if (flag)
737                 room->RAFlags |= UA_ISTRASH; // wc_is_trash
738
739         room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
740
741         /* find out, whether we are in a sub-room */
742         room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
743         if (room->nRoomNameParts > 1)
744         {
745                 int i;
746                 
747                 Pos = NULL;
748                 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
749                 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
750                 for (i=0; i < room->nRoomNameParts; i++)
751                 {
752                         room->RoomNameParts[i] = NewStrBuf();
753                         StrBufExtract_NextToken(room->RoomNameParts[i],
754                                                 room->name, &Pos, '\\');
755                 }
756         }
757
758         /* Private mailboxes on the main floor get remapped to the personal folder */
759         if ((room->QRFlags & QR_MAILBOX) && 
760             (room->floorid == 0))
761         {
762                 room->floorid = VIRTUAL_MY_FLOOR;
763                 if ((room->nRoomNameParts == 1) && 
764                     (StrLength(room->name) == 4) && 
765                     (strcmp(ChrPtr(room->name), "Mail") == 0))
766                 {
767                         room->is_inbox = 1;
768                 }
769                 
770         }
771         /* get a pointer to the floor we're on: */
772         if (WCC->Floors == NULL)
773                 GetFloorListHash(NULL, NULL);
774
775         GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
776         room->Floor = (const Floor*) vFloor;
777 }
778
779 void LoadRoomAide(void)
780 {
781         wcsession *WCC = WC;
782         StrBuf *Buf;
783         
784         if (WCC->CurRoom.RoomAideLoaded)
785                 return;
786
787         WCC->CurRoom.RoomAideLoaded = 1;
788         Buf = NewStrBuf();
789         serv_puts("GETA");
790         StrBuf_ServGetln(Buf);
791         if (GetServerStatus(Buf, NULL) != 2) {
792                 FlushStrBuf(WCC->CurRoom.RoomAide);
793                 AppendImportantMessage (ChrPtr(Buf) + 4, 
794                                         StrLength(Buf) - 4);
795         } else {
796                 const char *Pos;
797
798                 Pos = ChrPtr(Buf) + 4;
799
800                 FreeStrBuf(&WCC->CurRoom.RoomAide);
801                 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
802
803                 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|'); 
804         }
805         FreeStrBuf (&Buf);
806 }
807 void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP) 
808 {
809         wcsession *WCC = WC;
810         folder *Folder = &WCC->CurRoom;
811         const Floor *pFloor = Folder->Floor;
812
813         if (pFloor == NULL)
814                 return;
815
816         StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
817 }
818
819 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP) 
820 {
821         wcsession *WCC = WC;
822
823         LoadRoomAide();
824
825         StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
826 }
827
828
829 void LoadRoomXA (void)
830 {
831         wcsession *WCC = WC;
832         StrBuf *Buf;
833         
834         if (WCC->CurRoom.XALoaded)
835                 return;
836
837         WCC->CurRoom.XALoaded = 1;
838         Buf = NewStrBuf();
839         serv_puts("GETA");
840         StrBuf_ServGetln(Buf);
841         if (GetServerStatus(Buf, NULL) != 2) {
842                 FlushStrBuf(WCC->CurRoom.XAPass);
843                 FlushStrBuf(WCC->CurRoom.Directory);
844
845                 AppendImportantMessage (ChrPtr(Buf) + 4, 
846                                         StrLength(Buf) - 4);
847         } else {
848                 const char *Pos;
849
850                 Pos = ChrPtr(Buf) + 4;
851
852                 FreeStrBuf(&WCC->CurRoom.XAPass);
853                 FreeStrBuf(&WCC->CurRoom.Directory);
854
855                 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
856                 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
857
858                 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
859                 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|'); 
860                 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|'); 
861                 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
862                 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
863                 WCC->CurRoom.DefView = StrBufExtractNext_long(Buf, &Pos, '|');
864                 /* QR2Flags, we already know them... */
865
866         }
867         FreeStrBuf (&Buf);
868 }
869
870
871 void LoadXRoomPic(void)
872 {
873         wcsession *WCC = WC;
874         StrBuf *Buf;
875         
876         if (WCC->CurRoom.XHaveRoomPicLoaded)
877                 return;
878
879         WCC->CurRoom.XHaveRoomPicLoaded = 1;
880         Buf = NewStrBuf();
881         serv_puts("OIMG _roompic_");
882         StrBuf_ServGetln(Buf);
883         if (GetServerStatus(Buf, NULL) != 2) {
884                 WCC->CurRoom.XHaveRoomPic = 0;
885         } else {
886                 WCC->CurRoom.XHaveRoomPic = 1;
887         }
888         serv_puts("CLOS");
889         StrBuf_ServGetln(Buf);
890         GetServerStatus(Buf, NULL);
891         FreeStrBuf (&Buf);
892 }
893
894 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
895 {
896         wcsession *WCC = WC;
897         
898         if (WCC == NULL)
899                 return 0;
900
901         LoadXRoomPic();
902         return WCC->CurRoom.XHaveRoomPic == 1;
903 }
904
905 void LoadXRoomInfoText(void)
906 {
907         wcsession *WCC = WC;
908         StrBuf *Buf;
909         int Done = 0;
910         
911         if (WCC->CurRoom.XHaveInfoTextLoaded)
912                 return;
913
914         WCC->CurRoom.XHaveInfoTextLoaded = 1;
915         Buf = NewStrBuf();
916
917         serv_puts("RINF");
918
919         StrBuf_ServGetln(Buf);
920         if (GetServerStatus(Buf, NULL) == 1) {
921                 WCC->CurRoom.XInfoText = NewStrBuf ();
922                 
923                 while (!Done && StrBuf_ServGetln(Buf)>=0) {
924                         if ( (StrLength(Buf)==3) && 
925                              !strcmp(ChrPtr(Buf), "000")) 
926                                 Done = 1;
927                         else 
928                                 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
929                 }
930         }
931
932         FreeStrBuf (&Buf);
933 }
934
935 int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
936 {
937         wcsession *WCC = WC;
938         
939         if (WCC == NULL)
940                 return 0;
941
942         LoadXRoomInfoText();
943         return (StrLength(WCC->CurRoom.XInfoText)>0);
944 }
945
946 void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP) 
947 {
948         wcsession *WCC = WC;
949
950         LoadXRoomInfoText();
951
952         StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1);
953 }
954
955 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP) 
956 {
957         wcsession *WCC = WC;
958
959         LoadRoomXA();
960
961         StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
962 }
963 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP) 
964 {
965         wcsession *WCC = WC;
966
967         LoadRoomXA();
968
969         StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
970 }
971 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP) 
972 {
973         wcsession *WCC = WC;
974
975         LoadRoomXA();
976
977         StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
978 }
979 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP) 
980 {
981         wcsession *WCC = WC;
982
983         LoadRoomXA();
984
985         StrBufAppendPrintf(Target, "%d", WCC->CurRoom.DefView);
986 }
987
988
989 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
990 {
991         wcsession *WCC = WC;
992         long CheckThis;
993
994         if (WCC == NULL)
995                 return 0;
996
997         LoadRoomXA();
998
999         CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1000         return CheckThis == WCC->CurRoom.Order;
1001 }
1002
1003 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1004 {
1005         wcsession *WCC = WC;
1006         long CheckThis;
1007
1008         if (WCC == NULL)
1009                 return 0;
1010
1011         LoadRoomXA();
1012
1013         CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1014         return CheckThis == WCC->CurRoom.DefView;
1015 }
1016
1017
1018
1019
1020
1021 /*
1022  * goto next room
1023  */
1024 void smart_goto(const StrBuf *next_room) {
1025         gotoroom(next_room);
1026         readloop(readnew, eUseDefault);
1027 }
1028
1029
1030
1031 /*
1032  * mark all messages in current room as having been read
1033  */
1034 void slrp_highest(void)
1035 {
1036         char buf[256];
1037
1038         serv_puts("SLRP HIGHEST");
1039         serv_getln(buf, sizeof buf);
1040 }
1041
1042
1043 typedef struct __room_states {
1044         char password[SIZ];
1045         char dirname[SIZ];
1046         char name[SIZ];
1047         int flags;
1048         int floor;
1049         int order;
1050         int view;
1051         int flags2;
1052 } room_states;
1053
1054
1055
1056
1057 /*
1058  * Set/clear/read the "self-service list subscribe" flag for a room
1059  * 
1060  * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1061  * returns the new value.
1062  */
1063
1064 int self_service(int newval) {
1065         int current_value = 0;
1066         char buf[SIZ];
1067         
1068         char name[SIZ];
1069         char password[SIZ];
1070         char dirname[SIZ];
1071         int flags, floor, order, view, flags2;
1072
1073         serv_puts("GETR");
1074         serv_getln(buf, sizeof buf);
1075         if (buf[0] != '2') return(0);
1076
1077         extract_token(name, &buf[4], 0, '|', sizeof name);
1078         extract_token(password, &buf[4], 1, '|', sizeof password);
1079         extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1080         flags = extract_int(&buf[4], 3);
1081         floor = extract_int(&buf[4], 4);
1082         order = extract_int(&buf[4], 5);
1083         view = extract_int(&buf[4], 6);
1084         flags2 = extract_int(&buf[4], 7);
1085
1086         if (flags2 & QR2_SELFLIST) {
1087                 current_value = 1;
1088         }
1089         else {
1090                 current_value = 0;
1091         }
1092
1093         if (newval == 1) {
1094                 flags2 = flags2 | QR2_SELFLIST;
1095         }
1096         else if (newval == 0) {
1097                 flags2 = flags2 & ~QR2_SELFLIST;
1098         }
1099         else {
1100                 return(current_value);
1101         }
1102
1103         if (newval != current_value) {
1104                 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1105                             name, password, dirname, flags,
1106                             floor, order, view, flags2);
1107                 serv_getln(buf, sizeof buf);
1108         }
1109
1110         return(newval);
1111
1112 }
1113
1114 int is_selflist(room_states *RoomFlags)
1115 {
1116         return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1117 }
1118
1119 int is_publiclist(room_states *RoomFlags)
1120 {
1121         return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1122 }
1123
1124 int is_moderatedlist(room_states *RoomFlags)
1125 {
1126         return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1127 }
1128
1129 /*
1130  * Set/clear/read the "self-service list subscribe" flag for a room
1131  * 
1132  * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1133  * returns the new value.
1134  */
1135
1136 int get_roomflags(room_states *RoomOps) 
1137 {
1138         char buf[SIZ];
1139         
1140         serv_puts("GETR");
1141         serv_getln(buf, sizeof buf);
1142         if (buf[0] != '2') return(0);
1143
1144         extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1145         extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1146         extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1147         RoomOps->flags = extract_int(&buf[4], 3);
1148         RoomOps->floor = extract_int(&buf[4], 4);
1149         RoomOps->order = extract_int(&buf[4], 5);
1150         RoomOps->view = extract_int(&buf[4], 6);
1151         RoomOps->flags2 = extract_int(&buf[4], 7);
1152         return (1);
1153 }
1154
1155 int set_roomflags(room_states *RoomOps)
1156 {
1157         char buf[SIZ];
1158
1159         serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1160                     RoomOps->name, 
1161                     RoomOps->password, 
1162                     RoomOps->dirname, 
1163                     RoomOps->flags,
1164                     RoomOps->floor, 
1165                     RoomOps->order, 
1166                     RoomOps->view, 
1167                     RoomOps->flags2);
1168         serv_getln(buf, sizeof buf);
1169         return (1);
1170 }
1171
1172
1173
1174
1175
1176
1177 /*
1178  * display the form for editing a room
1179  */
1180 void display_editroom(void)
1181 {
1182         StrBuf *Buf;
1183         char buf[SIZ];
1184         char cmd[1024];
1185         char node[256];
1186         char remote_room[128];
1187         char recp[1024];
1188         char er_name[128];
1189         char er_password[10];
1190         char er_dirname[15];
1191         char er_roomaide[26];
1192         unsigned er_flags;
1193         unsigned er_flags2;
1194         int er_floor;
1195         int i, j;
1196         char *tab;
1197         char *shared_with;
1198         char *not_shared_with = NULL;
1199         int roompolicy = 0;
1200         int roomvalue = 0;
1201         int floorpolicy = 0;
1202         int floorvalue = 0;
1203         char pop3_host[128];
1204         char pop3_user[32];
1205         int bg = 0;
1206
1207         tab = bstr("tab");
1208         if (IsEmptyStr(tab)) tab = "admin";
1209
1210         Buf = NewStrBuf();
1211         load_floorlist(Buf);
1212         FreeStrBuf(&Buf);
1213         output_headers(1, 1, 1, 0, 0, 0);
1214
1215         wc_printf("<div class=\"fix_scrollbar_bug\">");
1216
1217         wc_printf("<br />\n");
1218
1219         /* print the tabbed dialog */
1220         wc_printf("<div align=\"center\">");
1221         wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1222                 "<tr align=\"center\" style=\"cursor:pointer\"><td>&nbsp;</td>"
1223                 );
1224
1225         wc_printf("<td class=\"");
1226         if (!strcmp(tab, "admin")) {
1227                 wc_printf(" tab_cell_label\">");
1228                 wc_printf(_("Administration"));
1229         }
1230         else {
1231                 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1232                 wc_printf(_("Administration"));
1233                 wc_printf("</a>");
1234         }
1235         wc_printf("</td>\n");
1236         wc_printf("<td>&nbsp;</td>\n");
1237
1238         if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1239
1240                 wc_printf("<td class=\"");
1241                 if (!strcmp(tab, "config")) {
1242                         wc_printf(" tab_cell_label\">");
1243                         wc_printf(_("Configuration"));
1244                 }
1245                 else {
1246                         wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1247                         wc_printf(_("Configuration"));
1248                         wc_printf("</a>");
1249                 }
1250                 wc_printf("</td>\n");
1251                 wc_printf("<td>&nbsp;</td>\n");
1252
1253                 wc_printf("<td class=\"");
1254                 if (!strcmp(tab, "expire")) {
1255                         wc_printf(" tab_cell_label\">");
1256                         wc_printf(_("Message expire policy"));
1257                 }
1258                 else {
1259                         wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1260                         wc_printf(_("Message expire policy"));
1261                         wc_printf("</a>");
1262                 }
1263                 wc_printf("</td>\n");
1264                 wc_printf("<td>&nbsp;</td>\n");
1265         
1266                 wc_printf("<td class=\"");
1267                 if (!strcmp(tab, "access")) {
1268                         wc_printf(" tab_cell_label\">");
1269                         wc_printf(_("Access controls"));
1270                 }
1271                 else {
1272                         wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1273                         wc_printf(_("Access controls"));
1274                         wc_printf("</a>");
1275                 }
1276                 wc_printf("</td>\n");
1277                 wc_printf("<td>&nbsp;</td>\n");
1278
1279                 wc_printf("<td class=\"");
1280                 if (!strcmp(tab, "sharing")) {
1281                         wc_printf(" tab_cell_label\">");
1282                         wc_printf(_("Sharing"));
1283                 }
1284                 else {
1285                         wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1286                         wc_printf(_("Sharing"));
1287                         wc_printf("</a>");
1288                 }
1289                 wc_printf("</td>\n");
1290                 wc_printf("<td>&nbsp;</td>\n");
1291
1292                 wc_printf("<td class=\"");
1293                 if (!strcmp(tab, "listserv")) {
1294                         wc_printf(" tab_cell_label\">");
1295                         wc_printf(_("Mailing list service"));
1296                 }
1297                 else {
1298                         wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1299                         wc_printf(_("Mailing list service"));
1300                         wc_printf("</a>");
1301                 }
1302                 wc_printf("</td>\n");
1303                 wc_printf("<td>&nbsp;</td>\n");
1304
1305         }
1306
1307         wc_printf("<td class=\"");
1308         if (!strcmp(tab, "feeds")) {
1309                 wc_printf(" tab_cell_label\">");
1310                 wc_printf(_("Remote retrieval"));
1311         }
1312         else {
1313                 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1314                 wc_printf(_("Remote retrieval"));
1315                 wc_printf("</a>");
1316         }
1317         wc_printf("</td>\n");
1318         wc_printf("<td>&nbsp;</td>\n");
1319
1320         wc_printf("</tr></table>\n");
1321         wc_printf("</div>\n");
1322         /* end tabbed dialog */ 
1323
1324         wc_printf("<script type=\"text/javascript\">"
1325                 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1326                 "</script>"
1327                 );
1328
1329         /* begin content of whatever tab is open now */
1330
1331         if (!strcmp(tab, "admin")) {
1332                 wc_printf("<div class=\"tabcontent\">");
1333                 wc_printf("<ul>"
1334                         "<li><a href=\"delete_room\" "
1335                         "onClick=\"return confirm('");
1336                 wc_printf(_("Are you sure you want to delete this room?"));
1337                 wc_printf("');\">\n");
1338                 wc_printf(_("Delete this room"));
1339                 wc_printf("</a>\n"
1340                         "<li><a href=\"display_editroompic?which_room=");
1341                 urlescputs(ChrPtr(WC->CurRoom.name));
1342                 wc_printf("\">\n");
1343                 wc_printf(_("Set or change the icon for this room's banner"));
1344                 wc_printf("</a>\n"
1345                         "<li><a href=\"display_editinfo\">\n");
1346                 wc_printf(_("Edit this room's Info file"));
1347                 wc_printf("</a>\n"
1348                         "</ul>");
1349                 wc_printf("</div>");
1350         }
1351
1352         if (!strcmp(tab, "config")) {
1353                 wc_printf("<div class=\"tabcontent\">");
1354                 serv_puts("GETR");
1355                 serv_getln(buf, sizeof buf);
1356
1357                 if (!strncmp(buf, "550", 3)) {
1358                         wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1359                                 _("Higher access is required to access this function.")
1360                                 );
1361                 }
1362                 else if (buf[0] != '2') {
1363                         wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1364                 }
1365                 else {
1366                         extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1367                         extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1368                         extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1369                         er_flags = extract_int(&buf[4], 3);
1370                         er_floor = extract_int(&buf[4], 4);
1371                         er_flags2 = extract_int(&buf[4], 7);
1372         
1373                         wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1374                         wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1375                 
1376                         wc_printf("<ul><li>");
1377                         wc_printf(_("Name of room: "));
1378                         wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1379                                 er_name,
1380                                 (sizeof(er_name)-1)
1381                                 );
1382                 
1383                         wc_printf("<li>");
1384                         wc_printf(_("Resides on floor: "));
1385                         wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1386                         if (er_flags & QR_MAILBOX)
1387                                 wc_printf("disabled >\n");
1388                         for (i = 0; i < 128; ++i)
1389                                 if (!IsEmptyStr(floorlist[i])) {
1390                                         wc_printf("<OPTION ");
1391                                         if (i == er_floor )
1392                                                 wc_printf("SELECTED ");
1393                                         wc_printf("VALUE=\"%d\">", i);
1394                                         escputs(floorlist[i]);
1395                                         wc_printf("</OPTION>\n");
1396                                 }
1397                         wc_printf("</select>\n");
1398
1399                         wc_printf("<li>");
1400                         wc_printf(_("Type of room:"));
1401                         wc_printf("<ul>\n");
1402         
1403                         wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1404                         if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1405                                 wc_printf("CHECKED ");
1406                         wc_printf("OnChange=\""
1407                                 "       if (this.form.type[0].checked == true) {        "
1408                                 "               this.form.er_floor.disabled = false;    "
1409                                 "       }                                               "
1410                                 "\"> ");
1411                         wc_printf(_("Public (automatically appears to everyone)"));
1412                         wc_printf("\n");
1413         
1414                         wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1415                         if ((er_flags & QR_PRIVATE) &&
1416                             (er_flags & QR_GUESSNAME))
1417                                 wc_printf("CHECKED ");
1418                         wc_printf(" OnChange=\""
1419                                 "       if (this.form.type[1].checked == true) {        "
1420                                 "               this.form.er_floor.disabled = false;    "
1421                                 "       }                                               "
1422                                 "\"> ");
1423                         wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1424                 
1425                         wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1426                         if ((er_flags & QR_PRIVATE) &&
1427                             (er_flags & QR_PASSWORDED))
1428                                 wc_printf("CHECKED ");
1429                         wc_printf(" OnChange=\""
1430                                 "       if (this.form.type[2].checked == true) {        "
1431                                 "               this.form.er_floor.disabled = false;    "
1432                                 "       }                                               "
1433                                 "\"> ");
1434                         wc_printf(_("Private - require password: "));
1435                         wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1436                                 er_password);
1437                 
1438                         wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1439                         if ((er_flags & QR_PRIVATE)
1440                             && ((er_flags & QR_GUESSNAME) == 0)
1441                             && ((er_flags & QR_PASSWORDED) == 0))
1442                                 wc_printf("CHECKED ");
1443                         wc_printf(" OnChange=\""
1444                                 "       if (this.form.type[3].checked == true) {        "
1445                                 "               this.form.er_floor.disabled = false;    "
1446                                 "       }                                               "
1447                                 "\"> ");
1448                         wc_printf(_("Private - invitation only"));
1449                 
1450                         wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1451                         if (er_flags & QR_MAILBOX)
1452                                 wc_printf("CHECKED ");
1453                         wc_printf (" OnChange=\""
1454                                  "      if (this.form.type[4].checked == true) {        "
1455                                  "              this.form.er_floor.disabled = true;     "
1456                                  "      }                                               "
1457                                  "\"> ");
1458                         wc_printf(_("Personal (mailbox for you only)"));
1459                         
1460                         wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1461                         wc_printf("> ");
1462                         wc_printf(_("If private, cause current users to forget room"));
1463                 
1464                         wc_printf("\n</ul>\n");
1465                 
1466                         wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1467                         if (er_flags & QR_PREFONLY)
1468                                 wc_printf("CHECKED ");
1469                         wc_printf("> ");
1470                         wc_printf(_("Preferred users only"));
1471                 
1472                         wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1473                         if (er_flags & QR_READONLY)
1474                                 wc_printf("CHECKED ");
1475                         wc_printf("> ");
1476                         wc_printf(_("Read-only room"));
1477                 
1478                         wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1479                         if (er_flags2 & QR2_COLLABDEL)
1480                                 wc_printf("CHECKED ");
1481                         wc_printf("> ");
1482                         wc_printf(_("All users allowed to post may also delete messages"));
1483                 
1484                         /** directory stuff */
1485                         wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1486                         if (er_flags & QR_DIRECTORY)
1487                                 wc_printf("CHECKED ");
1488                         wc_printf("> ");
1489                         wc_printf(_("File directory room"));
1490         
1491                         wc_printf("\n<ul><li>");
1492                         wc_printf(_("Directory name: "));
1493                         wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1494                                 er_dirname);
1495         
1496                         wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1497                         if (er_flags & QR_UPLOAD)
1498                                 wc_printf("CHECKED ");
1499                         wc_printf("> ");
1500                         wc_printf(_("Uploading allowed"));
1501                 
1502                         wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1503                         if (er_flags & QR_DOWNLOAD)
1504                                 wc_printf("CHECKED ");
1505                         wc_printf("> ");
1506                         wc_printf(_("Downloading allowed"));
1507                 
1508                         wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1509                         if (er_flags & QR_VISDIR)
1510                                 wc_printf("CHECKED ");
1511                         wc_printf("> ");
1512                         wc_printf(_("Visible directory"));
1513                         wc_printf("</ul>\n");
1514                 
1515                         /** end of directory stuff */
1516         
1517                         wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1518                         if (er_flags & QR_NETWORK)
1519                                 wc_printf("CHECKED ");
1520                         wc_printf("> ");
1521                         wc_printf(_("Network shared room"));
1522         
1523                         wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1524                         if (er_flags & QR_PERMANENT)
1525                                 wc_printf("CHECKED ");
1526                         wc_printf("> ");
1527                         wc_printf(_("Permanent (does not auto-purge)"));
1528         
1529                         wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1530                         if (er_flags2 & QR2_SUBJECTREQ)
1531                                 wc_printf("CHECKED ");
1532                         wc_printf("> ");
1533                         wc_printf(_("Subject Required (Force users to specify a message subject)"));
1534         
1535                         /** start of anon options */
1536                 
1537                         wc_printf("\n<li>");
1538                         wc_printf(_("Anonymous messages"));
1539                         wc_printf("<ul>\n");
1540                 
1541                         wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1542                         if (((er_flags & QR_ANONONLY) == 0)
1543                             && ((er_flags & QR_ANONOPT) == 0))
1544                                 wc_printf("CHECKED ");
1545                         wc_printf("> ");
1546                         wc_printf(_("No anonymous messages"));
1547         
1548                         wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1549                         if (er_flags & QR_ANONONLY)
1550                                 wc_printf("CHECKED ");
1551                         wc_printf("> ");
1552                         wc_printf(_("All messages are anonymous"));
1553                 
1554                         wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1555                         if (er_flags & QR_ANONOPT)
1556                                 wc_printf("CHECKED ");
1557                         wc_printf("> ");
1558                         wc_printf(_("Prompt user when entering messages"));
1559                         wc_printf("</ul>\n");
1560                 
1561                         /* end of anon options */
1562                 
1563                         wc_printf("<li>");
1564                         wc_printf(_("Room aide: "));
1565                         serv_puts("GETA");
1566                         serv_getln(buf, sizeof buf);
1567                         if (buf[0] != '2') {
1568                                 wc_printf("<em>%s</em>\n", &buf[4]);
1569                         } else {
1570                                 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1571                                 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1572                         }
1573                 
1574                         wc_printf("</ul><CENTER>\n");
1575                         wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1576                                 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1577                                 "&nbsp;"
1578                                 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1579                                 "</CENTER>\n",
1580                                 _("Save changes"),
1581                                 _("Cancel")
1582                                 );
1583                 }
1584                 wc_printf("</div>");
1585         }
1586
1587
1588         /* Sharing the room with other Citadel nodes... */
1589         if (!strcmp(tab, "sharing")) {
1590                 wc_printf("<div class=\"tabcontent\">");
1591
1592                 shared_with = strdup("");
1593                 not_shared_with = strdup("");
1594
1595                 /** Learn the current configuration */
1596                 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1597                 serv_getln(buf, sizeof buf);
1598                 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1599                                 extract_token(node, buf, 0, '|', sizeof node);
1600                                 not_shared_with = realloc(not_shared_with,
1601                                                           strlen(not_shared_with) + 32);
1602                                 strcat(not_shared_with, node);
1603                                 strcat(not_shared_with, "\n");
1604                         }
1605
1606                 serv_puts("GNET");
1607                 serv_getln(buf, sizeof buf);
1608                 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1609                                 extract_token(cmd, buf, 0, '|', sizeof cmd);
1610                                 extract_token(node, buf, 1, '|', sizeof node);
1611                                 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1612                                 if (!strcasecmp(cmd, "ignet_push_share")) {
1613                                         shared_with = realloc(shared_with,
1614                                                               strlen(shared_with) + 32);
1615                                         strcat(shared_with, node);
1616                                         if (!IsEmptyStr(remote_room)) {
1617                                                 strcat(shared_with, "|");
1618                                                 strcat(shared_with, remote_room);
1619                                         }
1620                                         strcat(shared_with, "\n");
1621                                 }
1622                         }
1623
1624                 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1625                         extract_token(buf, shared_with, i, '\n', sizeof buf);
1626                         extract_token(node, buf, 0, '|', sizeof node);
1627                         for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1628                                 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1629                                 if (!strcasecmp(node, cmd)) {
1630                                         remove_token(not_shared_with, j, '\n');
1631                                 }
1632                         }
1633                 }
1634
1635                 /* Display the stuff */
1636                 wc_printf("<CENTER><br />"
1637                         "<table border=1 cellpadding=5><tr>"
1638                         "<td><B><I>");
1639                 wc_printf(_("Shared with"));
1640                 wc_printf("</I></B></td>"
1641                         "<td><B><I>");
1642                 wc_printf(_("Not shared with"));
1643                 wc_printf("</I></B></td></tr>\n"
1644                         "<tr><td VALIGN=TOP>\n");
1645
1646                 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1647                 wc_printf(_("Remote node name"));
1648                 wc_printf("</td><td>");
1649                 wc_printf(_("Remote room name"));
1650                 wc_printf("</td><td>");
1651                 wc_printf(_("Actions"));
1652                 wc_printf("</td></tr>\n");
1653
1654                 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1655                         extract_token(buf, shared_with, i, '\n', sizeof buf);
1656                         extract_token(node, buf, 0, '|', sizeof node);
1657                         extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1658                         if (!IsEmptyStr(node)) {
1659                                 wc_printf("<form method=\"POST\" action=\"netedit\">");
1660                                 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1661                                 wc_printf("<tr><td>%s</td>\n", node);
1662
1663                                 wc_printf("<td>");
1664                                 if (!IsEmptyStr(remote_room)) {
1665                                         escputs(remote_room);
1666                                 }
1667                                 wc_printf("</td>");
1668
1669                                 wc_printf("<td>");
1670                 
1671                                 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1672                                         "VALUE=\"ignet_push_share|");
1673                                 urlescputs(node);
1674                                 if (!IsEmptyStr(remote_room)) {
1675                                         wc_printf("|");
1676                                         urlescputs(remote_room);
1677                                 }
1678                                 wc_printf("\">");
1679                                 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1680                                 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1681                                 wc_printf("<input type=\"submit\" "
1682                                         "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1683                                 wc_printf("</td></tr></form>\n");
1684                         }
1685                 }
1686
1687                 wc_printf("</table>\n");
1688                 wc_printf("</td><td VALIGN=TOP>\n");
1689                 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1690                 wc_printf(_("Remote node name"));
1691                 wc_printf("</td><td>");
1692                 wc_printf(_("Remote room name"));
1693                 wc_printf("</td><td>");
1694                 wc_printf(_("Actions"));
1695                 wc_printf("</td></tr>\n");
1696
1697                 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1698                         extract_token(node, not_shared_with, i, '\n', sizeof node);
1699                         if (!IsEmptyStr(node)) {
1700                                 wc_printf("<form method=\"POST\" action=\"netedit\">");
1701                                 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1702                                 wc_printf("<tr><td>");
1703                                 escputs(node);
1704                                 wc_printf("</td><td>"
1705                                         "<input type=\"INPUT\" "
1706                                         "NAME=\"suffix\" "
1707                                         "MAXLENGTH=128>"
1708                                         "</td><td>");
1709                                 wc_printf("<input type=\"hidden\" "
1710                                         "NAME=\"line\" "
1711                                         "VALUE=\"ignet_push_share|");
1712                                 urlescputs(node);
1713                                 wc_printf("|\">");
1714                                 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1715                                         "VALUE=\"sharing\">\n");
1716                                 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1717                                         "VALUE=\"add\">\n");
1718                                 wc_printf("<input type=\"submit\" "
1719                                         "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1720                                 wc_printf("</td></tr></form>\n");
1721                         }
1722                 }
1723
1724                 wc_printf("</table>\n");
1725                 wc_printf("</td></tr>"
1726                         "</table></CENTER><br />\n"
1727                         "<I><B>%s</B><ul><li>", _("Notes:"));
1728                 wc_printf(_("When sharing a room, "
1729                           "it must be shared from both ends.  Adding a node to "
1730                           "the 'shared' list sends messages out, but in order to"
1731                           " receive messages, the other nodes must be configured"
1732                           " to send messages out to your system as well. "
1733                           "<li>If the remote room name is blank, it is assumed "
1734                           "that the room name is identical on the remote node."
1735                           "<li>If the remote room name is different, the remote "
1736                           "node must also configure the name of the room here."
1737                           "</ul></I><br />\n"
1738                                 ));
1739
1740                 wc_printf("</div>");
1741         }
1742
1743         if (not_shared_with != NULL)
1744                 free (not_shared_with);
1745
1746         /* Mailing list management */
1747         if (!strcmp(tab, "listserv")) {
1748                 room_states RoomFlags;
1749                 wc_printf("<div class=\"tabcontent\">");
1750
1751                 wc_printf("<br /><center>"
1752                         "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1753                         "<tr><td VALIGN=TOP>");
1754
1755                 wc_printf(_("<i>The contents of this room are being "
1756                           "mailed <b>as individual messages</b> "
1757                           "to the following list recipients:"
1758                           "</i><br /><br />\n"));
1759
1760                 serv_puts("GNET");
1761                 serv_getln(buf, sizeof buf);
1762                 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1763                                 extract_token(cmd, buf, 0, '|', sizeof cmd);
1764                                 if (!strcasecmp(cmd, "listrecp")) {
1765                                         extract_token(recp, buf, 1, '|', sizeof recp);
1766                         
1767                                         escputs(recp);
1768                                         wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1769                                         urlescputs(recp);
1770                                         wc_printf("\">");
1771                                         wc_printf(_("(remove)"));
1772                                         wc_printf("</A><br />");
1773                                 }
1774                         }
1775                 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1776                         "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1777                         "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1778                 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1779                 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1780                 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1781                 wc_printf("</form>\n");
1782
1783                 wc_printf("</td><td VALIGN=TOP>\n");
1784                 
1785                 wc_printf(_("<i>The contents of this room are being "
1786                           "mailed <b>in digest form</b> "
1787                           "to the following list recipients:"
1788                           "</i><br /><br />\n"));
1789
1790                 serv_puts("GNET");
1791                 serv_getln(buf, sizeof buf);
1792                 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1793                                 extract_token(cmd, buf, 0, '|', sizeof cmd);
1794                                 if (!strcasecmp(cmd, "digestrecp")) {
1795                                         extract_token(recp, buf, 1, '|', sizeof recp);
1796                         
1797                                         escputs(recp);
1798                                         wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1799                                                 "digestrecp|");
1800                                         urlescputs(recp);
1801                                         wc_printf("\">");
1802                                         wc_printf(_("(remove)"));
1803                                         wc_printf("</A><br />");
1804                                 }
1805                         }
1806                 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1807                         "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1808                         "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1809                 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1810                 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1811                 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1812                 wc_printf("</form>\n");
1813                 
1814                 wc_printf("</td></tr></table>\n");
1815
1816                 /** Pop open an address book -- begin **/
1817                 wc_printf("<div align=right>"
1818                         "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1819                         "title=\"%s\">"
1820                         "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1821                         "&nbsp;%s</a>"
1822                         "</div>",
1823                         _("List"),
1824                         _("Digest"),
1825                         _("Add recipients from Contacts or other address books"),
1826                         _("Add recipients from Contacts or other address books")
1827                         );
1828                 /* Pop open an address book -- end **/
1829
1830                 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1831
1832                 get_roomflags (&RoomFlags);
1833                 
1834                 /* Self Service subscription? */
1835                 wc_printf("<table><tr><td>\n");
1836                 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1837                 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1838                         " <tr><td colspan=\"2\">\n",
1839                         (is_selflist(&RoomFlags))?"checked":"");
1840                 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1841                 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1842                         (is_https ? "https" : "http"),
1843                         ChrPtr(WC->Hdr->HR.http_host));
1844                 /* Public posting? */
1845                 wc_printf("<tr><td>");
1846                 wc_printf(_("Allow non-subscribers to mail to this room."));
1847                 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1848                         (is_publiclist(&RoomFlags))?"checked":"");
1849                 
1850                 /* Moderated List? */
1851                 wc_printf("<tr><td>");
1852                 wc_printf(_("Room post publication needs Aide permission."));
1853                 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1854                         (is_moderatedlist(&RoomFlags))?"checked":"");
1855
1856
1857                 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1858                         "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1859                 wc_printf("</table></form>");
1860                         
1861
1862                 wc_printf("</CENTER>\n");
1863                 wc_printf("</div>");
1864         }
1865
1866
1867         /* Configuration of The Dreaded Auto-Purger */
1868         if (!strcmp(tab, "expire")) {
1869                 wc_printf("<div class=\"tabcontent\">");
1870
1871                 serv_puts("GPEX room");
1872                 serv_getln(buf, sizeof buf);
1873                 if (!strncmp(buf, "550", 3)) {
1874                         wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1875                                 _("Higher access is required to access this function.")
1876                                 );
1877                 }
1878                 else if (buf[0] != '2') {
1879                         wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1880                 }
1881                 else {
1882                         roompolicy = extract_int(&buf[4], 0);
1883                         roomvalue = extract_int(&buf[4], 1);
1884                 
1885                         serv_puts("GPEX floor");
1886                         serv_getln(buf, sizeof buf);
1887                         if (buf[0] == '2') {
1888                                 floorpolicy = extract_int(&buf[4], 0);
1889                                 floorvalue = extract_int(&buf[4], 1);
1890                         }
1891                         
1892                         wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1893                         wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1894                         wc_printf("<table border=0 cellspacing=5>\n");
1895                         wc_printf("<tr><td>");
1896                         wc_printf(_("Message expire policy for this room"));
1897                         wc_printf("<br />(");
1898                         escputs(ChrPtr(WC->CurRoom.name));
1899                         wc_printf(")</td><td>");
1900                         wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1901                                 ((roompolicy == 0) ? "CHECKED" : "") );
1902                         wc_printf(_("Use the default policy for this floor"));
1903                         wc_printf("<br />\n");
1904                         wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1905                                 ((roompolicy == 1) ? "CHECKED" : "") );
1906                         wc_printf(_("Never automatically expire messages"));
1907                         wc_printf("<br />\n");
1908                         wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1909                                 ((roompolicy == 2) ? "CHECKED" : "") );
1910                         wc_printf(_("Expire by message count"));
1911                         wc_printf("<br />\n");
1912                         wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1913                                 ((roompolicy == 3) ? "CHECKED" : "") );
1914                         wc_printf(_("Expire by message age"));
1915                         wc_printf("<br />");
1916                         wc_printf(_("Number of messages or days: "));
1917                         wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1918                         wc_printf("</td></tr>\n");
1919         
1920                         if (WC->axlevel >= 6) {
1921                                 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1922                                 wc_printf("<tr><td>");
1923                                 wc_printf(_("Message expire policy for this floor"));
1924                                 wc_printf("<br />(");
1925                                 escputs(floorlist[WC->CurRoom.floorid]);
1926                                 wc_printf(")</td><td>");
1927                                 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1928                                         ((floorpolicy == 0) ? "CHECKED" : "") );
1929                                 wc_printf(_("Use the system default"));
1930                                 wc_printf("<br />\n");
1931                                 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1932                                         ((floorpolicy == 1) ? "CHECKED" : "") );
1933                                 wc_printf(_("Never automatically expire messages"));
1934                                 wc_printf("<br />\n");
1935                                 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1936                                         ((floorpolicy == 2) ? "CHECKED" : "") );
1937                                 wc_printf(_("Expire by message count"));
1938                                 wc_printf("<br />\n");
1939                                 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1940                                         ((floorpolicy == 3) ? "CHECKED" : "") );
1941                                 wc_printf(_("Expire by message age"));
1942                                 wc_printf("<br />");
1943                                 wc_printf(_("Number of messages or days: "));
1944                                 wc_printf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1945                                         floorvalue);
1946                         }
1947         
1948                         wc_printf("<CENTER>\n");
1949                         wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1950                         wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1951                         wc_printf("&nbsp;");
1952                         wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1953                         wc_printf("</CENTER></td><tr>\n");
1954         
1955                         wc_printf("</table>\n"
1956                                 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1957                                 "</form>\n"
1958                                 );
1959                 }
1960
1961                 wc_printf("</div>");
1962         }
1963
1964         /* Access controls */
1965         if (!strcmp(tab, "access")) {
1966                 wc_printf("<div class=\"tabcontent\">");
1967                 display_whok();
1968                 wc_printf("</div>");
1969         }
1970
1971         /* Fetch messages from remote locations */
1972         if (!strcmp(tab, "feeds")) {
1973                 wc_printf("<div class=\"tabcontent\">");
1974
1975                 wc_printf("<i>");
1976                 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1977                 wc_printf("</i><br />\n");
1978
1979                 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
1980                         "<tr class=\"even\"><th>");
1981                 wc_printf(_("Remote host"));
1982                 wc_printf("</th><th>");
1983                 wc_printf(_("User name"));
1984                 wc_printf("</th><th>");
1985                 wc_printf(_("Password"));
1986                 wc_printf("</th><th>");
1987                 wc_printf(_("Keep messages on server?"));
1988                 wc_printf("</th><th>");
1989                 wc_printf(_("Interval"));
1990                 wc_printf("</th><th> </th></tr>");
1991
1992                 serv_puts("GNET");
1993                 serv_getln(buf, sizeof buf);
1994                 bg = 1;
1995                 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1996                                 extract_token(cmd, buf, 0, '|', sizeof cmd);
1997                                 if (!strcasecmp(cmd, "pop3client")) {
1998                                         safestrncpy(recp, &buf[11], sizeof recp);
1999
2000                                         bg = 1 - bg;
2001                                         wc_printf("<tr class=\"%s\">",
2002                                                 (bg ? "even" : "odd")
2003                                                 );
2004
2005                                         wc_printf("<td>");
2006                                         extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2007                                         escputs(pop3_host);
2008                                         wc_printf("</td>");
2009
2010                                         wc_printf("<td>");
2011                                         extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2012                                         escputs(pop3_user);
2013                                         wc_printf("</td>");
2014
2015                                         wc_printf("<td>*****</td>");            /* Don't show the password */
2016
2017                                         wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2018
2019                                         wc_printf("<td>%ld</td>", extract_long(buf, 5));        /* Fetching interval */
2020                         
2021                                         wc_printf("<td class=\"button_link\">");
2022                                         wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2023                                         urlescputs(recp);
2024                                         wc_printf("\">");
2025                                         wc_printf(_("(remove)"));
2026                                         wc_printf("</a></td>");
2027                         
2028                                         wc_printf("</tr>");
2029                                 }
2030                         }
2031
2032                 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2033                         "<tr>"
2034                         "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2035                         "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2036                 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2037                 wc_printf("<td>");
2038                 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2039                 wc_printf("</td>");
2040                 wc_printf("<td>");
2041                 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2042                 wc_printf("</td>");
2043                 wc_printf("<td>");
2044                 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2045                 wc_printf("</td>");
2046                 wc_printf("<td>");
2047                 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2048                 wc_printf("</td>");
2049                 wc_printf("<td>");
2050                 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2051                 wc_printf("</td>");
2052                 wc_printf("<td>");
2053                 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2054                 wc_printf("</td></tr>");
2055                 wc_printf("</form></table>\n");
2056
2057                 wc_printf("<hr>\n");
2058
2059                 wc_printf("<i>");
2060                 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2061                 wc_printf("</i><br />\n");
2062
2063                 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2064                         "<tr class=\"even\"><th>");
2065                 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2066                 wc_printf(_("Feed URL"));
2067                 wc_printf("</th><th>");
2068                 wc_printf("</th></tr>");
2069
2070                 serv_puts("GNET");
2071                 serv_getln(buf, sizeof buf);
2072                 bg = 1;
2073                 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2074                                 extract_token(cmd, buf, 0, '|', sizeof cmd);
2075                                 if (!strcasecmp(cmd, "rssclient")) {
2076                                         safestrncpy(recp, &buf[10], sizeof recp);
2077
2078                                         bg = 1 - bg;
2079                                         wc_printf("<tr class=\"%s\">",
2080                                                 (bg ? "even" : "odd")
2081                                                 );
2082
2083                                         wc_printf("<td>");
2084                                         extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2085                                         escputs(pop3_host);
2086                                         wc_printf("</td>");
2087
2088                                         wc_printf("<td class=\"button_link\">");
2089                                         wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2090                                         urlescputs(recp);
2091                                         wc_printf("\">");
2092                                         wc_printf(_("(remove)"));
2093                                         wc_printf("</a></td>");
2094                         
2095                                         wc_printf("</tr>");
2096                                 }
2097                         }
2098
2099                 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2100                         "<tr>"
2101                         "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2102                         "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2103                 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2104                 wc_printf("<td>");
2105                 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2106                         "maxlength=\"256\" name=\"line_pop3host\">\n");
2107                 wc_printf("</td>");
2108                 wc_printf("<td>");
2109                 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2110                 wc_printf("</td></tr>");
2111                 wc_printf("</form></table>\n");
2112
2113                 wc_printf("</div>");
2114         }
2115
2116
2117         /* end content of whatever tab is open now */
2118         wc_printf("</div>\n");
2119
2120         address_book_popup();
2121         wDumpContent(1);
2122 }
2123
2124
2125 /* 
2126  * Toggle self-service list subscription
2127  */
2128 void toggle_self_service(void) {
2129         room_states RoomFlags;
2130
2131         get_roomflags (&RoomFlags);
2132
2133         if (yesbstr("QR2_SelfList")) 
2134                 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2135         else 
2136                 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2137
2138         if (yesbstr("QR2_SMTP_PUBLIC")) 
2139                 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2140         else
2141                 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2142
2143         if (yesbstr("QR2_Moderated")) 
2144                 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2145         else
2146                 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2147         if (yesbstr("QR2_SubsOnly")) 
2148                 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2149         else
2150                 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2151
2152         set_roomflags (&RoomFlags);
2153         
2154         display_editroom();
2155 }
2156
2157
2158
2159 /*
2160  * save new parameters for a room
2161  */
2162 void editroom(void)
2163 {
2164         const StrBuf *Ptr;
2165         StrBuf *Buf;
2166         StrBuf *er_name;
2167         StrBuf *er_password;
2168         StrBuf *er_dirname;
2169         StrBuf *er_roomaide;
2170         int er_floor;
2171         unsigned er_flags;
2172         int er_listingorder;
2173         int er_defaultview;
2174         unsigned er_flags2;
2175         int bump;
2176
2177
2178         if (!havebstr("ok_button")) {
2179                 strcpy(WC->ImportantMessage,
2180                        _("Cancelled.  Changes were not saved."));
2181                 display_editroom();
2182                 return;
2183         }
2184         serv_puts("GETR");
2185         Buf = NewStrBuf();
2186         StrBuf_ServGetln(Buf);
2187         if (GetServerStatus(Buf, NULL) != 2) {
2188                 StrBufCutLeft(Buf, 4);
2189                 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2190                 display_editroom();
2191                 FreeStrBuf(&Buf);
2192                 return;
2193         }
2194
2195         er_name = NewStrBuf();
2196         er_password = NewStrBuf();
2197         er_dirname = NewStrBuf();
2198         er_roomaide = NewStrBuf();
2199
2200         StrBufCutLeft(Buf, 4);
2201         StrBufExtract_token(er_name, Buf, 0, '|');
2202         StrBufExtract_token(er_password, Buf, 1, '|');
2203         StrBufExtract_token(er_dirname, Buf, 2, '|');
2204         er_flags = StrBufExtract_int(Buf, 3, '|');
2205         er_listingorder = StrBufExtract_int(Buf, 5, '|');
2206         er_defaultview = StrBufExtract_int(Buf, 6, '|');
2207         er_flags2 = StrBufExtract_int(Buf, 7, '|');
2208
2209         er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2210         if (StrLength(er_roomaide) == 0) {
2211                 serv_puts("GETA");
2212                 StrBuf_ServGetln(Buf);
2213                 if (GetServerStatus(Buf, NULL) != 2) {
2214                         FlushStrBuf(er_roomaide);
2215                 } else {
2216                         StrBufCutLeft(Buf, 4);
2217                         StrBufExtract_token(er_roomaide, Buf, 0, '|');
2218                 }
2219         }
2220         Ptr = sbstr("er_name");
2221         if (StrLength(Ptr) > 0) {
2222                 FlushStrBuf(er_name);
2223                 StrBufAppendBuf(er_name, Ptr, 0);
2224         }
2225
2226         Ptr = sbstr("er_password");
2227         if (StrLength(Ptr) > 0) {
2228                 FlushStrBuf(er_password);
2229                 StrBufAppendBuf(er_password, Ptr, 0);
2230         }
2231                 
2232
2233         Ptr = sbstr("er_dirname");
2234         if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2235                 FlushStrBuf(er_dirname);
2236                 StrBufAppendBuf(er_dirname, Ptr, 0);
2237         }
2238
2239
2240         Ptr = sbstr("type");
2241         er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2242
2243         if (!strcmp(ChrPtr(Ptr), "invonly")) {
2244                 er_flags |= (QR_PRIVATE);
2245         }
2246         if (!strcmp(ChrPtr(Ptr), "hidden")) {
2247                 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2248         }
2249         if (!strcmp(ChrPtr(Ptr), "passworded")) {
2250                 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2251         }
2252         if (!strcmp(ChrPtr(Ptr), "personal")) {
2253                 er_flags |= QR_MAILBOX;
2254         } else {
2255                 er_flags &= ~QR_MAILBOX;
2256         }
2257         
2258         if (yesbstr("prefonly")) {
2259                 er_flags |= QR_PREFONLY;
2260         } else {
2261                 er_flags &= ~QR_PREFONLY;
2262         }
2263
2264         if (yesbstr("readonly")) {
2265                 er_flags |= QR_READONLY;
2266         } else {
2267                 er_flags &= ~QR_READONLY;
2268         }
2269
2270         
2271         if (yesbstr("collabdel")) {
2272                 er_flags2 |= QR2_COLLABDEL;
2273         } else {
2274                 er_flags2 &= ~QR2_COLLABDEL;
2275         }
2276
2277         if (yesbstr("permanent")) {
2278                 er_flags |= QR_PERMANENT;
2279         } else {
2280                 er_flags &= ~QR_PERMANENT;
2281         }
2282
2283         if (yesbstr("subjectreq")) {
2284                 er_flags2 |= QR2_SUBJECTREQ;
2285         } else {
2286                 er_flags2 &= ~QR2_SUBJECTREQ;
2287         }
2288
2289         if (yesbstr("network")) {
2290                 er_flags |= QR_NETWORK;
2291         } else {
2292                 er_flags &= ~QR_NETWORK;
2293         }
2294
2295         if (yesbstr("directory")) {
2296                 er_flags |= QR_DIRECTORY;
2297         } else {
2298                 er_flags &= ~QR_DIRECTORY;
2299         }
2300
2301         if (yesbstr("ulallowed")) {
2302                 er_flags |= QR_UPLOAD;
2303         } else {
2304                 er_flags &= ~QR_UPLOAD;
2305         }
2306
2307         if (yesbstr("dlallowed")) {
2308                 er_flags |= QR_DOWNLOAD;
2309         } else {
2310                 er_flags &= ~QR_DOWNLOAD;
2311         }
2312
2313         if (yesbstr("visdir")) {
2314                 er_flags |= QR_VISDIR;
2315         } else {
2316                 er_flags &= ~QR_VISDIR;
2317         }
2318
2319         Ptr = sbstr("anon");
2320
2321         er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2322         if (!strcmp(ChrPtr(Ptr), "anononly"))
2323                 er_flags |= QR_ANONONLY;
2324         if (!strcmp(ChrPtr(Ptr), "anon2"))
2325                 er_flags |= QR_ANONOPT;
2326
2327         bump = yesbstr("bump");
2328
2329         er_floor = ibstr("er_floor");
2330
2331         StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2332                      ChrPtr(er_name), 
2333                      ChrPtr(er_password), 
2334                      ChrPtr(er_dirname), 
2335                      er_flags, 
2336                      bump, 
2337                      er_floor,
2338                      er_listingorder, 
2339                      er_defaultview, 
2340                      er_flags2);
2341         serv_putbuf(Buf);
2342         StrBuf_ServGetln(Buf);
2343         if (GetServerStatus(Buf, NULL) != 2) {
2344                 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2345                 display_editroom();
2346                 FreeStrBuf(&Buf);
2347                 FreeStrBuf(&er_name);
2348                 FreeStrBuf(&er_password);
2349                 FreeStrBuf(&er_dirname);
2350                 FreeStrBuf(&er_roomaide);
2351                 return;
2352         }
2353         gotoroom(er_name);
2354
2355         if (StrLength(er_roomaide) > 0) {
2356                 serv_printf("SETA %s", ChrPtr(er_roomaide));
2357                 StrBuf_ServGetln(Buf);
2358                 if (GetServerStatus(Buf, NULL) != 2) {
2359                         strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2360                         display_main_menu();
2361                         FreeStrBuf(&Buf);
2362                         FreeStrBuf(&er_name);
2363                         FreeStrBuf(&er_password);
2364                         FreeStrBuf(&er_dirname);
2365                         FreeStrBuf(&er_roomaide);
2366                         return;
2367                 }
2368         }
2369         gotoroom(er_name);
2370         strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2371         display_editroom();
2372         FreeStrBuf(&Buf);
2373         FreeStrBuf(&er_name);
2374         FreeStrBuf(&er_password);
2375         FreeStrBuf(&er_dirname);
2376         FreeStrBuf(&er_roomaide);
2377         return;
2378 }
2379
2380
2381 /*
2382  * Display form for Invite, Kick, and show Who Knows a room
2383  */
2384 void do_invt_kick(void) {
2385         char buf[SIZ], room[SIZ], username[SIZ];
2386
2387         serv_puts("GETR");
2388         serv_getln(buf, sizeof buf);
2389
2390         if (buf[0] != '2') {
2391                 escputs(&buf[4]);
2392                 return;
2393         }
2394         extract_token(room, &buf[4], 0, '|', sizeof room);
2395
2396         strcpy(username, bstr("username"));
2397
2398         if (havebstr("kick_button")) {
2399                 sprintf(buf, "KICK %s", username);
2400                 serv_puts(buf);
2401                 serv_getln(buf, sizeof buf);
2402
2403                 if (buf[0] != '2') {
2404                         strcpy(WC->ImportantMessage, &buf[4]);
2405                 } else {
2406                         sprintf(WC->ImportantMessage,
2407                                 _("<B><I>User %s kicked out of room %s.</I></B>\n"), 
2408                                 username, room);
2409                 }
2410         }
2411
2412         if (havebstr("invite_button")) {
2413                 sprintf(buf, "INVT %s", username);
2414                 serv_puts(buf);
2415                 serv_getln(buf, sizeof buf);
2416
2417                 if (buf[0] != '2') {
2418                         strcpy(WC->ImportantMessage, &buf[4]);
2419                 } else {
2420                         sprintf(WC->ImportantMessage,
2421                                 _("<B><I>User %s invited to room %s.</I></B>\n"), 
2422                                 username, room);
2423                 }
2424         }
2425
2426         display_editroom();
2427 }
2428
2429
2430
2431 /*
2432  * Display form for Invite, Kick, and show Who Knows a room
2433  */
2434 void display_whok(void)
2435 {
2436         char buf[SIZ], room[SIZ], username[SIZ];
2437
2438         serv_puts("GETR");
2439         serv_getln(buf, sizeof buf);
2440
2441         if (buf[0] != '2') {
2442                 escputs(&buf[4]);
2443                 return;
2444         }
2445         extract_token(room, &buf[4], 0, '|', sizeof room);
2446
2447         
2448         wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2449         wc_printf(_("The users listed below have access to this room.  "
2450                   "To remove a user from the access list, select the user "
2451                   "name from the list and click 'Kick'."));
2452         wc_printf("<br /><br />");
2453         
2454         wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2455         wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2456         wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2457         wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2458         serv_puts("WHOK");
2459         serv_getln(buf, sizeof buf);
2460         if (buf[0] == '1') {
2461                 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2462                         extract_token(username, buf, 0, '|', sizeof username);
2463                         wc_printf("<OPTION>");
2464                         escputs(username);
2465                         wc_printf("\n");
2466                 }
2467         }
2468         wc_printf("</select><br />\n");
2469
2470         wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2471         wc_printf("</form></CENTER>\n");
2472
2473         wc_printf("</td><td>");
2474         wc_printf(_("To grant another user access to this room, enter the "
2475                   "user name in the box below and click 'Invite'."));
2476         wc_printf("<br /><br />");
2477
2478         wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2479         wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2480         wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2481         wc_printf(_("Invite:"));
2482         wc_printf(" ");
2483         wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2484                 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2485                 "<input type=\"submit\" value=\"%s\">"
2486                 "</form></CENTER>\n", _("Invite"));
2487         /* Pop open an address book -- begin **/
2488         wc_printf(
2489                 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2490                 "title=\"%s\">"
2491                 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2492                 "&nbsp;%s</a>",
2493                 _("User"), 
2494                 _("Users"), _("Users")
2495                 );
2496         /* Pop open an address book -- end **/
2497
2498         wc_printf("</td></tr></table>\n");
2499         address_book_popup();
2500         wDumpContent(1);
2501 }
2502
2503
2504
2505 /*
2506  * display the form for entering a new room
2507  */
2508 void display_entroom(void)
2509 {
2510         StrBuf *Buf;
2511         int i;
2512         char buf[SIZ];
2513
2514         Buf = NewStrBuf();
2515         serv_puts("CRE8 0");
2516         serv_getln(buf, sizeof buf);
2517
2518         if (buf[0] != '2') {
2519                 strcpy(WC->ImportantMessage, &buf[4]);
2520                 display_main_menu();
2521                 FreeStrBuf(&Buf);
2522                 return;
2523         }
2524
2525         output_headers(1, 1, 1, 0, 0, 0);
2526
2527         svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2528         do_template("beginbox", NULL);
2529
2530         wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2531         wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2532
2533         wc_printf("<table class=\"altern\"> ");
2534
2535         wc_printf("<tr class=\"even\"><td>");
2536         wc_printf(_("Name of room: "));
2537         wc_printf("</td><td>");
2538         wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2539         wc_printf("</td></tr>");
2540
2541         wc_printf("<tr class=\"odd\"><td>");
2542         wc_printf(_("Resides on floor: "));
2543         wc_printf("</td><td>");
2544         load_floorlist(Buf); 
2545         wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2546         for (i = 0; i < 128; ++i)
2547                 if (!IsEmptyStr(floorlist[i])) {
2548                         wc_printf("<option ");
2549                         wc_printf("value=\"%d\">", i);
2550                         escputs(floorlist[i]);
2551                         wc_printf("</option>\n");
2552                 }
2553         wc_printf("</select>\n");
2554         wc_printf("</td></tr>");
2555
2556         /*
2557          * Our clever little snippet of JavaScript automatically selects
2558          * a public room if the view is set to Bulletin Board or wiki, and
2559          * it selects a mailbox room otherwise.  The user can override this,
2560          * of course.  We also disable the floor selector for mailboxes.
2561          */
2562         wc_printf("<tr class=\"even\"><td>");
2563         wc_printf(_("Default view for room: "));
2564         wc_printf("</td><td>");
2565         wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2566                 "       if ( (this.form.er_view.value == 0)             "
2567                 "          || (this.form.er_view.value == 6) ) {        "
2568                 "               this.form.type[0].checked=true;         "
2569                 "               this.form.er_floor.disabled = false;    "
2570                 "       }                                               "
2571                 "       else {                                          "
2572                 "               this.form.type[4].checked=true;         "
2573                 "               this.form.er_floor.disabled = true;     "
2574                 "       }                                               "
2575                 "\">\n");
2576         for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2577                 if (is_view_allowed_as_default(i)) {
2578                         wc_printf("<option %s value=\"%d\">",
2579                                 ((i == 0) ? "selected" : ""), i );
2580                         escputs(viewdefs[i]);
2581                         wc_printf("</option>\n");
2582                 }
2583         }
2584         wc_printf("</select>\n");
2585         wc_printf("</td></tr>");
2586
2587         wc_printf("<tr class=\"even\"><td>");
2588         wc_printf(_("Type of room:"));
2589         wc_printf("</td><td>");
2590         wc_printf("<ul class=\"adminlist\">\n");
2591
2592         wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2593         wc_printf("CHECKED OnChange=\""
2594                 "       if (this.form.type[0].checked == true) {        "
2595                 "               this.form.er_floor.disabled = false;    "
2596                 "       }                                               "
2597                 "\"> ");
2598         wc_printf(_("Public (automatically appears to everyone)"));
2599         wc_printf("</li>");
2600
2601         wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2602                 "       if (this.form.type[1].checked == true) {        "
2603                 "               this.form.er_floor.disabled = false;    "
2604                 "       }                                               "
2605                 "\"> ");
2606         wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2607         wc_printf("</li>");
2608
2609         wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2610                 "       if (this.form.type[2].checked == true) {        "
2611                 "               this.form.er_floor.disabled = false;    "
2612                 "       }                                               "
2613                 "\"> ");
2614         wc_printf(_("Private - require password: "));
2615         wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2616         wc_printf("</li>");
2617
2618         wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2619                 "       if (this.form.type[3].checked == true) {        "
2620                 "               this.form.er_floor.disabled = false;    "
2621                 "       }                                               "
2622                 "\"> ");
2623         wc_printf(_("Private - invitation only"));
2624         wc_printf("</li>");
2625
2626         wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2627                 "OnChange=\""
2628                 "       if (this.form.type[4].checked == true) {        "
2629                 "               this.form.er_floor.disabled = true;     "
2630                 "       }                                               "
2631                 "\"> ");
2632         wc_printf(_("Personal (mailbox for you only)"));
2633         wc_printf("</li>");
2634
2635         wc_printf("\n</ul>\n");
2636         wc_printf("</td></tr></table>\n");
2637
2638         wc_printf("<div class=\"buttons\">\n");
2639         wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2640         wc_printf("&nbsp;");
2641         wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2642         wc_printf("</div>\n");
2643         wc_printf("</form>\n<hr />");
2644         serv_printf("MESG roomaccess");
2645         serv_getln(buf, sizeof buf);
2646         if (buf[0] == '1') {
2647                 fmout("LEFT");
2648         }
2649
2650         do_template("endbox", NULL);
2651
2652         wDumpContent(1);
2653         FreeStrBuf(&Buf);
2654 }
2655
2656
2657
2658
2659 /*
2660  * support function for entroom() -- sets the default view 
2661  */
2662 void er_set_default_view(int newview) {
2663
2664         char buf[SIZ];
2665
2666         char rm_name[SIZ];
2667         char rm_pass[SIZ];
2668         char rm_dir[SIZ];
2669         int rm_bits1;
2670         int rm_floor;
2671         int rm_listorder;
2672         int rm_bits2;
2673
2674         serv_puts("GETR");
2675         serv_getln(buf, sizeof buf);
2676         if (buf[0] != '2') return;
2677
2678         extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2679         extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2680         extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2681         rm_bits1 = extract_int(&buf[4], 3);
2682         rm_floor = extract_int(&buf[4], 4);
2683         rm_listorder = extract_int(&buf[4], 5);
2684         rm_bits2 = extract_int(&buf[4], 7);
2685
2686         serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2687                     rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2688                     rm_listorder, newview, rm_bits2
2689                 );
2690         serv_getln(buf, sizeof buf);
2691 }
2692
2693
2694
2695 /*
2696  * Create a new room
2697  */
2698 void entroom(void)
2699 {
2700         char buf[SIZ];
2701         const StrBuf *er_name;
2702         const StrBuf *er_type;
2703         const StrBuf *er_password;
2704         int er_floor;
2705         int er_num_type;
2706         int er_view;
2707         wcsession *WCC = WC;
2708
2709         if (!havebstr("ok_button")) {
2710                 strcpy(WC->ImportantMessage,
2711                        _("Cancelled.  No new room was created."));
2712                 display_main_menu();
2713                 return;
2714         }
2715         er_name = sbstr("er_name");
2716         er_type = sbstr("type");
2717         er_password = sbstr("er_password");
2718         er_floor = ibstr("er_floor");
2719         er_view = ibstr("er_view");
2720
2721         er_num_type = 0;
2722         if (!strcmp(ChrPtr(er_type), "hidden"))
2723                 er_num_type = 1;
2724         else if (!strcmp(ChrPtr(er_type), "passworded"))
2725                 er_num_type = 2;
2726         else if (!strcmp(ChrPtr(er_type), "invonly"))
2727                 er_num_type = 3;
2728         else if (!strcmp(ChrPtr(er_type), "personal"))
2729                 er_num_type = 4;
2730
2731         serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d", 
2732                     ChrPtr(er_name), 
2733                     er_num_type, 
2734                     ChrPtr(er_password), 
2735                     er_floor, 
2736                     0, 
2737                     er_view);
2738
2739         serv_getln(buf, sizeof buf);
2740         if (buf[0] != '2') {
2741                 strcpy(WCC->ImportantMessage, &buf[4]);
2742                 display_main_menu();
2743                 return;
2744         }
2745         /** TODO: Room created, now update the left hand icon bar for this user */
2746         burn_folder_cache(0);   /* burn the old folder cache */
2747         
2748         gotoroom(er_name);
2749
2750         serv_printf("VIEW %d", er_view);
2751         serv_getln(buf, sizeof buf);
2752         WCC->CurRoom.view = er_view;
2753
2754         if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) )  {
2755                 display_editroom ();
2756         } else {
2757                 do_change_view(er_view);                /* Now go there */
2758         }
2759
2760 }
2761
2762
2763 /**
2764  * \brief display the screen to enter a private room
2765  */
2766 void display_private(char *rname, int req_pass)
2767 {
2768         WCTemplputParams SubTP;
2769         StrBuf *Buf;
2770         output_headers(1, 1, 1, 0, 0, 0);
2771
2772         Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2773         memset(&SubTP, 0, sizeof(WCTemplputParams));
2774         SubTP.Filter.ContextType = CTX_STRBUF;
2775         SubTP.Context = Buf;
2776         DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2777
2778         FreeStrBuf(&Buf);
2779
2780         wc_printf("<p>");
2781         wc_printf(_("If you know the name of a hidden (guess-name) or "
2782                   "passworded room, you can enter that room by typing "
2783                   "its name below.  Once you gain access to a private "
2784                   "room, it will appear in your regular room listings "
2785                   "so you don't have to keep returning here."));
2786         wc_printf("</p>");
2787
2788         wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2789         wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2790
2791         wc_printf("<table class=\"altern\"> "
2792                 "<tr class=\"even\"><td>");
2793         wc_printf(_("Enter room name:"));
2794         wc_printf("</td><td>"
2795                 "<input type=\"text\" name=\"gr_name\" "
2796                 "value=\"%s\" maxlength=\"128\">\n", rname);
2797
2798         if (req_pass) {
2799                 wc_printf("</td></tr><tr class=\"odd\"><td>");
2800                 wc_printf(_("Enter room password:"));
2801                 wc_printf("</td><td>");
2802                 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2803         }
2804         wc_printf("</td></tr></table>\n");
2805
2806         wc_printf("<div class=\"buttons\">\n");
2807         wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2808                 "&nbsp;"
2809                 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2810                 _("Go there"),
2811                 _("Cancel")
2812                 );
2813         wc_printf("</div></form>\n");
2814
2815         do_template("endbox", NULL);
2816
2817         wDumpContent(1);
2818 }
2819
2820 /**
2821  * \brief goto a private room
2822  */
2823 void goto_private(void)
2824 {
2825         char hold_rm[SIZ];
2826         char buf[SIZ];
2827
2828         if (!havebstr("ok_button")) {
2829                 display_main_menu();
2830                 return;
2831         }
2832         strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2833         serv_printf("GOTO %s|%s",
2834                     bstr("gr_name"),
2835                     bstr("gr_pass"));
2836         serv_getln(buf, sizeof buf);
2837
2838         if (buf[0] == '2') {
2839                 smart_goto(sbstr("gr_name"));
2840                 return;
2841         }
2842         if (!strncmp(buf, "540", 3)) {
2843                 display_private(bstr("gr_name"), 1);
2844                 return;
2845         }
2846         output_headers(1, 1, 1, 0, 0, 0);
2847         wc_printf("%s\n", &buf[4]);
2848         wDumpContent(1);
2849         return;
2850 }
2851
2852
2853 /**
2854  * \brief display the screen to zap a room
2855  */
2856 void display_zap(void)
2857 {
2858         output_headers(1, 1, 2, 0, 0, 0);
2859
2860         wc_printf("<div id=\"banner\">\n");
2861         wc_printf("<h1>");
2862         wc_printf(_("Zap (forget/unsubscribe) the current room"));
2863         wc_printf("</h1>\n");
2864         wc_printf("</div>\n");
2865
2866         wc_printf("<div id=\"content\" class=\"service\">\n");
2867
2868         wc_printf(_("If you select this option, <em>%s</em> will "
2869                   "disappear from your room list.  Is this what you wish "
2870                   "to do?<br />\n"), ChrPtr(WC->CurRoom.name));
2871
2872         wc_printf("<form method=\"POST\" action=\"zap\">\n");
2873         wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2874         wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2875         wc_printf("&nbsp;");
2876         wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2877         wc_printf("</form>\n");
2878         wDumpContent(1);
2879 }
2880
2881
2882 /**
2883  * \brief zap a room
2884  */
2885 void zap(void)
2886 {
2887         char buf[SIZ];
2888         StrBuf *final_destination;
2889
2890         /**
2891          * If the forget-room routine fails for any reason, we fall back
2892          * to the current room; otherwise, we go to the Lobby
2893          */
2894         final_destination = NewStrBufDup(WC->CurRoom.name);
2895
2896         if (havebstr("ok_button")) {
2897                 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
2898                 serv_getln(buf, sizeof buf);
2899                 if (buf[0] == '2') {
2900                         serv_puts("FORG");
2901                         serv_getln(buf, sizeof buf);
2902                         if (buf[0] == '2') {
2903                                 FlushStrBuf(final_destination);
2904                                 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2905                         }
2906                 }
2907         }
2908         smart_goto(final_destination);
2909         FreeStrBuf(&final_destination);
2910 }
2911
2912
2913
2914 /**
2915  * \brief Delete the current room
2916  */
2917 void delete_room(void)
2918 {
2919         char buf[SIZ];
2920
2921         
2922         serv_puts("KILL 1");
2923         serv_getln(buf, sizeof buf);
2924         burn_folder_cache(0);   /* Burn the cahce of known rooms to update the icon bar */
2925         if (buf[0] != '2') {
2926                 strcpy(WC->ImportantMessage, &buf[4]);
2927                 display_main_menu();
2928                 return;
2929         } else {
2930                 StrBuf *Buf;
2931                 
2932                 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2933                 smart_goto(Buf);
2934                 FreeStrBuf(&Buf);
2935         }
2936 }
2937
2938
2939
2940 /**
2941  * \brief Perform changes to a room's network configuration
2942  */
2943 void netedit(void) {
2944         FILE *fp;
2945         char buf[SIZ];
2946         char line[SIZ];
2947         char cmpa0[SIZ];
2948         char cmpa1[SIZ];
2949         char cmpb0[SIZ];
2950         char cmpb1[SIZ];
2951         int i, num_addrs;
2952         /*/ TODO: do line dynamic! */
2953         if (havebstr("line_pop3host")) {
2954                 strcpy(line, bstr("prefix"));
2955                 strcat(line, bstr("line_pop3host"));
2956                 strcat(line, "|");
2957                 strcat(line, bstr("line_pop3user"));
2958                 strcat(line, "|");
2959                 strcat(line, bstr("line_pop3pass"));
2960                 strcat(line, "|");
2961                 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2962                 strcat(line, "|");
2963                 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2964                 strcat(line, bstr("suffix"));
2965         }
2966         else if (havebstr("line")) {
2967                 strcpy(line, bstr("prefix"));
2968                 strcat(line, bstr("line"));
2969                 strcat(line, bstr("suffix"));
2970         }
2971         else {
2972                 display_editroom();
2973                 return;
2974         }
2975
2976
2977         fp = tmpfile();
2978         if (fp == NULL) {
2979                 display_editroom();
2980                 return;
2981         }
2982
2983         serv_puts("GNET");
2984         serv_getln(buf, sizeof buf);
2985         if (buf[0] != '1') {
2986                 fclose(fp);
2987                 display_editroom();
2988                 return;
2989         }
2990
2991         /** This loop works for add *or* remove.  Spiffy, eh? */
2992         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2993                 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2994                 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2995                 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2996                 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2997                 if ( (strcasecmp(cmpa0, cmpb0)) 
2998                      || (strcasecmp(cmpa1, cmpb1)) ) {
2999                         fprintf(fp, "%s\n", buf);
3000                 }
3001         }
3002
3003         rewind(fp);
3004         serv_puts("SNET");
3005         serv_getln(buf, sizeof buf);
3006         if (buf[0] != '4') {
3007                 fclose(fp);
3008                 display_editroom();
3009                 return;
3010         }
3011
3012         while (fgets(buf, sizeof buf, fp) != NULL) {
3013                 buf[strlen(buf)-1] = 0;
3014                 serv_puts(buf);
3015         }
3016
3017         if (havebstr("add_button")) {
3018                 num_addrs = num_tokens(bstr("line"), ',');
3019                 if (num_addrs < 2) {
3020                         /* just adding one node or address */
3021                         serv_puts(line);
3022                 }
3023                 else {
3024                         /* adding multiple addresses separated by commas */
3025                         for (i=0; i<num_addrs; ++i) {
3026                                 strcpy(line, bstr("prefix"));
3027                                 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3028                                 striplt(buf);
3029                                 strcat(line, buf);
3030                                 strcat(line, bstr("suffix"));
3031                                 serv_puts(line);
3032                         }
3033                 }
3034         }
3035
3036         serv_puts("000");
3037         fclose(fp);
3038         display_editroom();
3039 }
3040
3041
3042
3043 /**
3044  * \brief Convert a room name to a folder-ish-looking name.
3045  * \param folder the folderish name
3046  * \param room the room name
3047  * \param floor the floor name
3048  * \param is_mailbox is it a mailbox?
3049  */
3050 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3051 {
3052         int i, len;
3053
3054         /**
3055          * For mailboxes, just do it straight...
3056          */
3057         if (is_mailbox) {
3058                 sprintf(folder, "My folders|%s", room);
3059         }
3060
3061         /**
3062          * Otherwise, prefix the floor name as a "public folders" moniker
3063          */
3064         else {
3065                 if (floor > MAX_FLOORS) {
3066                         wc_backtrace ();
3067                         sprintf(folder, "%%%%%%|%s", room);
3068                 }
3069                 else {
3070                         sprintf(folder, "%s|%s", floorlist[floor], room);
3071                 }
3072         }
3073
3074         /**
3075          * Replace "\" characters with "|" for pseudo-folder-delimiting
3076          */
3077         len = strlen (folder);
3078         for (i=0; i<len; ++i) {
3079                 if (folder[i] == '\\') folder[i] = '|';
3080         }
3081 }
3082
3083
3084
3085
3086 /**
3087  * \brief Back end for change_view()
3088  * \param newview set newview???
3089  */
3090 void do_change_view(int newview) {
3091         char buf[SIZ];
3092
3093         serv_printf("VIEW %d", newview);
3094         serv_getln(buf, sizeof buf);
3095         WC->CurRoom.view = newview;
3096         smart_goto(WC->CurRoom.name);
3097 }
3098
3099
3100
3101 /**
3102  * \brief Change the view for this room
3103  */
3104 void change_view(void) {
3105         int view;
3106
3107         view = lbstr("view");
3108         do_change_view(view);
3109 }
3110
3111 /**
3112  * \brief Burn the cached folder list.  
3113  * \param age How old the cahce needs to be before we burn it.
3114  */
3115
3116 void burn_folder_cache(time_t age)
3117 {
3118         /** If our cached folder list is very old, burn it. */
3119         if (WC->cache_fold != NULL) {
3120                 if ((time(NULL) - WC->cache_timestamp) > age) {
3121                         free(WC->cache_fold);
3122                         WC->cache_fold = NULL;
3123                 }
3124         }
3125 }
3126
3127
3128
3129 /**
3130  * \brief Do either a known rooms list or a folders list, depending on the
3131  * user's preference
3132  */
3133 void knrooms(void)
3134 {
3135         StrBuf *ListView = NULL;
3136
3137         /** Determine whether the user is trying to change views */
3138         if (havebstr("view")) {
3139                 ListView = NewStrBufDup(SBSTR("view"));
3140                 set_preference("roomlistview", ListView, 1);
3141         }
3142         /** Sanitize the input so its safe */
3143         if((get_preference("roomlistview", &ListView) != 0)||
3144            ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3145             (strcasecmp(ChrPtr(ListView), "table") != 0))) 
3146         {
3147                 if (ListView == NULL) {
3148                         ListView = NewStrBufPlain(HKEY("rooms"));
3149                         set_preference("roomlistview", ListView, 0);
3150                         ListView = NULL;
3151                 }
3152                 else {
3153                         ListView = NewStrBufPlain(HKEY("rooms"));
3154                         set_preference("roomlistview", ListView, 0);
3155                         ListView = NULL;
3156                 }
3157         }
3158         FreeStrBuf(&ListView);
3159         url_do_template();
3160 }
3161
3162
3163
3164 /**
3165  * \brief Set the message expire policy for this room and/or floor
3166  */
3167 void set_room_policy(void) {
3168         char buf[SIZ];
3169
3170         if (!havebstr("ok_button")) {
3171                 strcpy(WC->ImportantMessage,
3172                        _("Cancelled.  Changes were not saved."));
3173                 display_editroom();
3174                 return;
3175         }
3176
3177         serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3178         serv_getln(buf, sizeof buf);
3179         strcpy(WC->ImportantMessage, &buf[4]);
3180
3181         if (WC->axlevel >= 6) {
3182                 strcat(WC->ImportantMessage, "<br />\n");
3183                 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3184                 serv_getln(buf, sizeof buf);
3185                 strcat(WC->ImportantMessage, &buf[4]);
3186         }
3187
3188         display_editroom();
3189 }
3190
3191 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3192 {
3193         StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3194 }
3195
3196
3197 void _display_private(void) {
3198         display_private("", 0);
3199 }
3200
3201 void dotgoto(void) {
3202         if (!havebstr("room")) {
3203                 readloop(readnew, eUseDefault);
3204                 return;
3205         }
3206         if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3207                 slrp_highest();
3208         }
3209         smart_goto(sbstr("room"));
3210 }
3211
3212
3213
3214 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3215 {
3216         wcsession *WCC = WC;
3217
3218         if (WCC != NULL)
3219                 StrBufAppendTemplate(Target, TP, 
3220                                      WCC->CurRoom.name, 
3221                                      0); 
3222 }
3223
3224 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3225 {
3226         wc_printf("<div id=\"banner\">\n");
3227         embed_room_banner(NULL, navbar_default);
3228         wc_printf("</div>\n");
3229 }
3230
3231
3232 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3233 {
3234         wcsession *WCC = WC;
3235
3236         if ((WCC!=NULL) && 
3237             (!IsEmptyStr(WCC->ugname)))
3238                 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3239 }
3240
3241 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3242 {
3243         wcsession *WCC = WC;
3244         return (WCC != NULL)? 
3245                 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3246 }
3247
3248 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3249 {
3250         wcsession *WCC = WC;
3251         return (WCC == NULL)? 0 : 
3252                 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3253                    (WCC->CurRoom.is_inbox) || 
3254                    (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3255 }
3256
3257 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3258 {
3259         wcsession *WCC = WC;
3260         
3261         return ((WCC!=NULL) && 
3262                 (!IsEmptyStr(WCC->ugname)) && 
3263                 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3264 }
3265
3266
3267 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
3268 {
3269         folder *Folder = (folder *)(TP->Context);
3270         long UA_CheckFlag;
3271                 
3272         UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3273         if (UA_CheckFlag == 0)
3274                 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3275                                  "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
3276
3277         return ((Folder->RAFlags & UA_CheckFlag) != 0);
3278 }
3279
3280
3281
3282 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3283 {
3284         long QR_CheckFlag;
3285         wcsession *WCC = WC;
3286         
3287         QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3288         if (QR_CheckFlag == 0)
3289                 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3290                                  "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3291
3292         return ((WCC!=NULL) &&
3293                 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3294 }
3295
3296 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3297 {
3298         long QR_CheckFlag;
3299         folder *Folder = (folder *)(TP->Context);
3300
3301         QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3302         if (QR_CheckFlag == 0)
3303                 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3304                                  "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3305         return ((Folder->QRFlags & QR_CheckFlag) != 0);
3306 }
3307
3308
3309 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3310 {
3311         long QR2_CheckFlag;
3312         wcsession *WCC = WC;
3313         
3314         QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3315         if (QR2_CheckFlag == 0)
3316                 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3317                                  "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3318
3319         return ((WCC!=NULL) &&
3320                 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3321 }
3322
3323 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3324 {
3325         long QR2_CheckFlag;
3326         folder *Folder = (folder *)(TP->Context);
3327
3328         QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3329         if (QR2_CheckFlag == 0)
3330                 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3331                                  "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3332         return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3333 }
3334
3335
3336 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3337 {
3338         wcsession *WCC = WC;
3339
3340         return ( (WCC!= NULL) && 
3341                  ((WCC->axlevel >= 6) || 
3342                   ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3343                   (WCC->CurRoom.is_inbox) ));
3344 }
3345
3346 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3347 {
3348         wcsession *WCC = WC;
3349
3350         if ((WCC == NULL) ||
3351             (TP->Tokens->nParameters < 3))
3352         {
3353                 return ((WCC->CurRoom.view < VIEW_BBS) || 
3354                         (WCC->CurRoom.view > VIEW_MAX));
3355         }
3356
3357         return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3358 }
3359
3360
3361 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
3362 {
3363         wcsession *WCC = WC;
3364         StrBuf *Line;
3365         StrBuf *Token;
3366         long State;
3367         HashList *Whok = NULL;
3368         int Done = 0;
3369         int n;
3370
3371         serv_puts("WHOK");
3372         Line = NewStrBuf();
3373         Token = NewStrBuf();
3374         StrBuf_ServGetln(Line);
3375         if (GetServerStatus(Line, &State) == 1) 
3376         {
3377                 Whok = NewHash(1, Flathash);
3378                 while(!Done && StrBuf_ServGetln(Line))
3379                         if ( (StrLength(Line)==3) && 
3380                              !strcmp(ChrPtr(Line), "000")) 
3381                         {
3382                                 Done = 1;
3383                         }
3384                         else
3385                         {
3386                         
3387                                 const char *Pos = NULL;
3388                                 Token = NewStrBufPlain (NULL, StrLength(Line));
3389                                 StrBufExtract_NextToken(Token, Line, &Pos, '|');
3390
3391                                 Put(Whok, 
3392                                     IKEY(n),
3393                                     Token, 
3394                                     HFreeStrBuf);
3395                         }
3396         }
3397         else if (State == 550)
3398                 StrBufAppendBufPlain(WCC->ImportantMsg,
3399                                      _("Higher access is required to access this function."), -1, 0);
3400
3401
3402         return Whok;
3403 }
3404
3405 void 
3406 InitModule_ROOMOPS
3407 (void)
3408 {
3409         initialize_viewdefs();
3410         RegisterPreference("roomlistview",
3411                            _("Room list view"),
3412                            PRF_STRING,
3413                            NULL);
3414         RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3415
3416         RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3417
3418
3419         WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3420         WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3421         WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3422         WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3423         WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3424         WebcitAddUrlHandler(HKEY("zapped_list"), "", 0, zapped_list, 0);
3425         WebcitAddUrlHandler(HKEY("display_zap"), "", 0, display_zap, 0);
3426         WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3427         WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3428         WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3429         WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3430         WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3431         WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3432         WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3433         WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3434         WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3435         WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3436         WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3437         WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3438         RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3439
3440         RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3441         RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3442         RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3443
3444         RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3445         RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3446         RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
3447
3448         RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
3449         RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
3450         RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3451         RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3452         RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3453         RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3454         RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3455         RegisterNamespace("THISROOM:INFOTEXT", 1, 2, tmplput_CurrentRoomInfoText, NULL, CTX_NONE);
3456         RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3457         RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3458         RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
3459         RegisterConditional(HKEY("COND:THISROOM:HAVE_INFOTEXT"), 0, ConditionalThisRoomXHaveInfoText, CTX_NONE);
3460
3461
3462         REGISTERTokenParamDefine(QR_PERMANENT);
3463         REGISTERTokenParamDefine(QR_INUSE);
3464         REGISTERTokenParamDefine(QR_PRIVATE);
3465         REGISTERTokenParamDefine(QR_PASSWORDED);
3466         REGISTERTokenParamDefine(QR_GUESSNAME);
3467         REGISTERTokenParamDefine(QR_DIRECTORY);
3468         REGISTERTokenParamDefine(QR_UPLOAD);
3469         REGISTERTokenParamDefine(QR_DOWNLOAD);
3470         REGISTERTokenParamDefine(QR_VISDIR);
3471         REGISTERTokenParamDefine(QR_ANONONLY);
3472         REGISTERTokenParamDefine(QR_ANONOPT);
3473         REGISTERTokenParamDefine(QR_NETWORK);
3474         REGISTERTokenParamDefine(QR_PREFONLY);
3475         REGISTERTokenParamDefine(QR_READONLY);
3476         REGISTERTokenParamDefine(QR_MAILBOX);
3477         REGISTERTokenParamDefine(QR2_SYSTEM);
3478         REGISTERTokenParamDefine(QR2_SELFLIST);
3479         REGISTERTokenParamDefine(QR2_COLLABDEL);
3480         REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3481         REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3482         REGISTERTokenParamDefine(QR2_MODERATED);
3483
3484         REGISTERTokenParamDefine(UA_KNOWN);
3485         REGISTERTokenParamDefine(UA_GOTOALLOWED);
3486         REGISTERTokenParamDefine(UA_HASNEWMSGS);
3487         REGISTERTokenParamDefine(UA_ZAPPED);
3488         REGISTERTokenParamDefine(UA_POSTALLOWED);
3489         REGISTERTokenParamDefine(UA_ADMINALLOWED);
3490         REGISTERTokenParamDefine(UA_DELETEALLOWED);
3491         REGISTERTokenParamDefine(UA_ISTRASH);
3492
3493         REGISTERTokenParamDefine(US_NEEDVALID);
3494         REGISTERTokenParamDefine(US_PERM);
3495         REGISTERTokenParamDefine(US_LASTOLD);
3496         REGISTERTokenParamDefine(US_EXPERT);
3497         REGISTERTokenParamDefine(US_UNLISTED);
3498         REGISTERTokenParamDefine(US_NOPROMPT);
3499         REGISTERTokenParamDefine(US_PROMPTCTL);
3500         REGISTERTokenParamDefine(US_DISAPPEAR);
3501         REGISTERTokenParamDefine(US_REGIS);
3502         REGISTERTokenParamDefine(US_PAGINATOR);
3503         REGISTERTokenParamDefine(US_INTERNET);
3504         REGISTERTokenParamDefine(US_FLOORS);
3505         REGISTERTokenParamDefine(US_COLOR);
3506         REGISTERTokenParamDefine(US_USER_SET);
3507
3508         REGISTERTokenParamDefine(VIEW_BBS);
3509         REGISTERTokenParamDefine(VIEW_MAILBOX); 
3510         REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3511         REGISTERTokenParamDefine(VIEW_CALENDAR);        
3512         REGISTERTokenParamDefine(VIEW_TASKS);   
3513         REGISTERTokenParamDefine(VIEW_NOTES);           
3514         REGISTERTokenParamDefine(VIEW_WIKI);            
3515         REGISTERTokenParamDefine(VIEW_CALBRIEF);
3516         REGISTERTokenParamDefine(VIEW_JOURNAL);
3517         REGISTERTokenParamDefine(VIEW_BLOG);
3518
3519         /* GNET types: */
3520         REGISTERTokenParamDefine(ignet_push_share);
3521         { /* these are the parts of an IGNET push config */
3522                 REGISTERTokenParamDefine(GNET_IGNET_NODE);
3523                 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
3524         }
3525         REGISTERTokenParamDefine(listrecp);
3526         REGISTERTokenParamDefine(digestrecp);
3527         REGISTERTokenParamDefine(pop3client);
3528         { /* These are the parts of a pop3 client line... */
3529                 REGISTERTokenParamDefine(GNET_POP3_HOST);
3530                 REGISTERTokenParamDefine(GNET_POP3_USER);
3531                 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
3532                 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
3533         }
3534         REGISTERTokenParamDefine(rssclient);
3535         REGISTERTokenParamDefine(participate);
3536
3537         RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3538         RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3539
3540         RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3541         RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3542
3543         RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3544         RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3545         RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3546
3547
3548 }
3549
3550
3551 void 
3552 SessionDestroyModule_ROOMOPS
3553 (wcsession *sess)
3554 {
3555         FlushFolder(&sess->CurRoom);
3556         if (sess->cache_fold != NULL) {
3557                 free(sess->cache_fold);
3558         }
3559         
3560         free_march_list(sess);
3561         DeleteHash(&sess->Floors);
3562         DeleteHash(&sess->Rooms);
3563         DeleteHash(&sess->FloorsByName);
3564 }
3565
3566
3567 /*@}*/