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