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