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