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