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