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