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