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