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