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