indent -kr -i8 -brf -bbb -fnc -l132 -nce on all of webcit-classic
[citadel.git] / webcit / roomops.c
1
2 /*
3  * Lots of different room-related operations.
4  *
5  * Copyright (c) 1996-2016 by the citadel.org team
6  *
7  * This program is open source software.  You can redistribute it and/or
8  * modify it under the terms of the GNU General Public License, version 3.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  */
15
16 #include "webcit.h"
17 #include "webserver.h"
18
19 ConstStr QRFlagList[] = {
20         { HKEY(strof(QR_PERMANENT)) },
21         { HKEY(strof(QR_INUSE)) },
22         { HKEY(strof(QR_PRIVATE)) },
23         { HKEY(strof(QR_PASSWORDED)) },
24         { HKEY(strof(QR_GUESSNAME)) },
25         { HKEY(strof(QR_DIRECTORY)) },
26         { HKEY(strof(QR_UPLOAD)) },
27         { HKEY(strof(QR_DOWNLOAD)) },
28         { HKEY(strof(QR_VISDIR)) },
29         { HKEY(strof(QR_ANONONLY)) },
30         { HKEY(strof(QR_ANONOPT)) },
31         { HKEY(strof(QR_NETWORK)) },
32         { HKEY(strof(QR_PREFONLY)) },
33         { HKEY(strof(QR_READONLY)) },
34         { HKEY(strof(QR_MAILBOX)) }
35 };
36
37 ConstStr QR2FlagList[] = {
38         { HKEY(strof(QR2_SYSTEM)) },
39         { HKEY(strof(QR2_SELFLIST)) },
40         { HKEY(strof(QR2_COLLABDEL)) },
41         { HKEY(strof(QR2_SUBJECTREQ)) },
42         { HKEY(strof(QR2_SMTP_PUBLIC)) },
43         { HKEY(strof(QR2_MODERATED)) },
44         { HKEY(strof(QR2_NOUPLMSG)) },
45         { HKEY("") },
46         { HKEY("") },
47         { HKEY("") },
48         { HKEY("") },
49         { HKEY("") },
50         { HKEY("") },
51         { HKEY("") },
52         { HKEY("") }
53 };
54
55 void _DBG_QR(long QR) {
56         int i = 1;
57         int j = 0;
58         StrBuf *QRVec;
59
60         QRVec = NewStrBufPlain(NULL, 256);
61         while (i != 0) {
62                 if ((QR & i) != 0) {
63                         if (StrLength(QRVec) > 0)
64                                 StrBufAppendBufPlain(QRVec, HKEY(" | "), 0);
65                         StrBufAppendBufPlain(QRVec, CKEY(QRFlagList[j]), 0);
66                 }
67                 i = i << 1;
68                 j++;
69         }
70         syslog(LOG_DEBUG, "DBG: QR-Vec [%ld] [%s]\n", QR, ChrPtr(QRVec));
71         FreeStrBuf(&QRVec);
72 }
73
74
75
76 void _DBG_QR2(long QR2) {
77         int i = 1;
78         int j = 0;
79         StrBuf *QR2Vec;
80
81         QR2Vec = NewStrBufPlain(NULL, 256);
82         while (i != 0) {
83                 if ((QR2 & i) != 0) {
84                         if (StrLength(QR2Vec) > 0)
85                                 StrBufAppendBufPlain(QR2Vec, HKEY(" | "), 0);
86                         StrBufAppendBufPlain(QR2Vec, CKEY(QR2FlagList[j]), 0);
87                 }
88                 i = i << 1;
89                 j++;
90         }
91         syslog(LOG_DEBUG, "DBG: QR2-Vec [%ld] [%s]\n", QR2, ChrPtr(QR2Vec));
92         FreeStrBuf(&QR2Vec);
93 }
94
95
96
97
98
99
100
101
102
103
104
105 /*******************************************************************************
106  ***************************** Goto Commands ***********************************
107  ******************************************************************************/
108
109 void dotskip(void) {
110         smart_goto(sbstr("room"));
111 }
112
113 void dotgoto(void) {
114         if (!havebstr("room")) {
115                 readloop(readnew, eUseDefault);
116                 return;
117         }
118         if (WC->CurRoom.view != VIEW_MAILBOX) {
119                 /* dotgoto acts like dotskip when we're in a mailbox view */
120                 slrp_highest();
121         }
122         smart_goto(sbstr("room"));
123 }
124
125 /*
126  * goto next room
127  */
128 void smart_goto(const StrBuf * next_room) {
129         if (gotoroom(next_room) / 100 == 2)
130                 readloop(readnew, eUseDefault);
131         else
132                 do_404();
133 }
134
135 /*
136  * goto a private room
137  */
138 void goto_private(void) {
139         char hold_rm[SIZ];
140         StrBuf *Buf;
141         const StrBuf *gr_name;
142         long err;
143
144         if (!havebstr("ok_button")) {
145                 display_main_menu();
146                 return;
147         }
148         gr_name = sbstr("gr_name");
149         Buf = NewStrBuf();
150         strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
151         serv_printf("GOTO %s|%s", ChrPtr(gr_name), bstr("gr_pass"));
152         StrBuf_ServGetln(Buf);
153         if (GetServerStatus(Buf, &err) == 2) {
154                 FlushRoomlist();
155                 smart_goto(gr_name);
156                 FreeStrBuf(&Buf);
157                 return;
158         }
159         if (err == 540) {
160                 DoTemplate(HKEY("room_display_private"), NULL, &NoCtx);
161                 FreeStrBuf(&Buf);
162                 return;
163         }
164         StrBufCutLeft(Buf, 4);
165         AppendImportantMessage(SKEY(Buf));
166         Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
167         smart_goto(Buf);
168         FreeStrBuf(&Buf);
169         return;
170 }
171
172 /*
173  * back end routine to take the session to a new room
174  */
175 long gotoroom(const StrBuf * gname) {
176         wcsession *WCC = WC;
177         StrBuf *Buf;
178         static long ls = (-1L);
179         long err = 0;
180         int room_name_supplied = 0;
181         int is_baseroom = 0;
182         int failvisibly;
183
184         /* on fail, should we fallback to _BASEROOM_? */
185         failvisibly = ibstr("failvisibly");
186
187         /* store ungoto information */
188         if (StrLength(gname) > 0) {
189                 room_name_supplied = 1;
190         }
191         if (room_name_supplied) {
192                 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
193                 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_")) {
194                         is_baseroom = 1;
195                 }
196         }
197         WCC->uglsn = ls;
198         Buf = NewStrBuf();
199
200         /* move to the new room */
201         if (room_name_supplied) {
202                 serv_printf("GOTO %s", ChrPtr(gname));
203         }
204         else {
205                 /* or just refresh the current state... */
206                 serv_printf("GOTO 00000000000000000000");
207         }
208         StrBuf_ServGetln(Buf);
209         if (GetServerStatus(Buf, &err) != 2) {
210                 if (failvisibly) {
211                         FreeStrBuf(&Buf);
212                         return err;
213                 }
214                 serv_puts("GOTO _BASEROOM_");
215                 StrBuf_ServGetln(Buf);
216                 /* 
217                  * well, we know that this is the fallback case, 
218                  * but we're interested that the first command 
219                  * didn't work out in first place.
220                  */
221                 if (GetServerStatus(Buf, NULL) != 2) {
222                         FreeStrBuf(&Buf);
223                         return err;
224                 }
225         }
226         FlushFolder(&WCC->CurRoom);
227         ParseGoto(&WCC->CurRoom, Buf);
228
229         if (room_name_supplied) {
230                 remove_march(WCC->CurRoom.name);
231                 if (is_baseroom) {
232                         remove_march(gname);
233                 }
234         }
235         FreeStrBuf(&Buf);
236
237         return err;
238 }
239
240
241
242 void ParseGoto(folder * room, StrBuf * Line) {
243         wcsession *WCC = WC;
244         const char *Pos;
245         int flag;
246         void *vFloor = NULL;
247         StrBuf *pBuf;
248
249         if (StrLength(Line) < 4) {
250                 return;
251         }
252
253         /* ignore the commandstate... */
254         Pos = ChrPtr(Line) + 4;
255
256         if (room->RoomNameParts != NULL) {
257                 int i;
258                 for (i = 0; i < room->nRoomNameParts; i++)
259                         FreeStrBuf(&room->RoomNameParts[i]);
260                 free(room->RoomNameParts);
261                 room->RoomNameParts = NULL;
262         }
263
264         pBuf = room->name;
265         if (pBuf == NULL)
266                 pBuf = NewStrBufPlain(NULL, StrLength(Line));
267         else
268                 FlushStrBuf(pBuf);
269         memset(room, 0, sizeof(folder));
270         room->name = pBuf;
271
272         StrBufExtract_NextToken(room->name, Line, &Pos, '|');
273
274         room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
275         if (room->nNewMessages > 0)
276                 room->RAFlags |= UA_HASNEWMSGS;
277
278         room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
279
280         room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
281
282         room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|');
283
284         DBG_QR(room->QRFlags);
285
286         room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
287         room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
288
289         room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|');
290
291         flag = StrBufExtractNext_long(Line, &Pos, '|');
292         if (WCC->is_aide || flag) {
293                 room->RAFlags |= UA_ADMINALLOWED;
294         }
295
296         room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
297
298         room->floorid = StrBufExtractNext_int(Line, &Pos, '|');
299
300         room->view = StrBufExtractNext_long(Line, &Pos, '|');
301
302         room->defview = StrBufExtractNext_long(Line, &Pos, '|');
303
304         flag = StrBufExtractNext_long(Line, &Pos, '|');
305         if (flag)
306                 room->RAFlags |= UA_ISTRASH;
307
308         room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|');
309         DBG_QR2(room->QRFlags2);
310
311         /* find out, whether we are in a sub-room */
312         room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
313         if (room->nRoomNameParts > 1) {
314                 int i;
315
316                 Pos = NULL;
317                 room->RoomNameParts = malloc(sizeof(StrBuf *) * (room->nRoomNameParts + 1));
318                 memset(room->RoomNameParts, 0, sizeof(StrBuf *) * (room->nRoomNameParts + 1));
319                 for (i = 0; i < room->nRoomNameParts; i++) {
320                         room->RoomNameParts[i] = NewStrBuf();
321                         StrBufExtract_NextToken(room->RoomNameParts[i], room->name, &Pos, '\\');
322                 }
323         }
324
325         /* Private mailboxes on the main floor get remapped to the personal folder */
326         if ((room->QRFlags & QR_MAILBOX) && (room->floorid == 0)) {
327                 room->floorid = VIRTUAL_MY_FLOOR;
328                 if ((room->nRoomNameParts == 1) && (StrLength(room->name) == 4) && (strcmp(ChrPtr(room->name), "Mail") == 0)) {
329                         room->is_inbox = 1;
330                 }
331
332         }
333         /* get a pointer to the floor we're on: */
334         if (WCC->Floors == NULL)
335                 GetFloorListHash(NULL, NULL);
336
337         GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
338         room->Floor = (const Floor *) vFloor;
339 }
340
341 /*
342  * Delete the current room
343  */
344 void delete_room(void) {
345         StrBuf *Line = NewStrBuf();
346         const StrBuf *GoBstr;
347
348         GoBstr = sbstr("go");
349
350         if (GoBstr != NULL) {
351                 if (gotoroom(GoBstr) == 200) {
352                         serv_puts("KILL 1");
353                         StrBuf_ServGetln(Line);
354                         if (GetServerStatusMsg(Line, NULL, 1, 2) == 2) {
355                                 StrBuf *Buf;
356
357                                 FlushRoomlist();
358                                 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
359                                 smart_goto(Buf);
360                                 FreeStrBuf(&Buf);
361                                 FreeStrBuf(&Line);
362                                 return;
363                         }
364                 }
365         }
366         display_main_menu();
367         FreeStrBuf(&Line);
368 }
369
370 /*
371  * zap a room
372  */
373 void zap(void) {
374         char buf[SIZ];
375         StrBuf *final_destination;
376
377         /**
378          * If the forget-room routine fails for any reason, we fall back
379          * to the current room; otherwise, we go to the Lobby
380          */
381         final_destination = NewStrBufDup(WC->CurRoom.name);
382
383         if (havebstr("ok_button")) {
384                 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
385                 serv_getln(buf, sizeof buf);
386                 if (buf[0] == '2') {
387                         serv_puts("FORG");
388                         serv_getln(buf, sizeof buf);
389                         if (buf[0] == '2') {
390                                 FlushStrBuf(final_destination);
391                                 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
392                         }
393                 }
394                 FlushRoomlist();
395         }
396         smart_goto(final_destination);
397         FreeStrBuf(&final_destination);
398 }
399
400
401 /*
402  * mark all messages in current room as having been read
403  */
404 void slrp_highest(void) {
405         char buf[256];
406
407         serv_puts("SLRP HIGHEST");
408         serv_getln(buf, sizeof buf);
409 }
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424 /*******************************************************************************
425  ***************************** Modify Rooms ************************************
426  ******************************************************************************/
427
428
429
430
431
432 void LoadRoomAide(void) {
433         wcsession *WCC = WC;
434         StrBuf *Buf;
435
436         if (WCC->CurRoom.RoomAideLoaded)
437                 return;
438
439         WCC->CurRoom.RoomAideLoaded = 1;
440         Buf = NewStrBuf();
441         serv_puts("GETA");
442         StrBuf_ServGetln(Buf);
443         if (GetServerStatus(Buf, NULL) != 2) {
444                 FlushStrBuf(WCC->CurRoom.RoomAide);
445                 AppendImportantMessage(ChrPtr(Buf) + 4, StrLength(Buf) - 4);
446         }
447         else {
448                 const char *Pos;
449
450                 Pos = ChrPtr(Buf) + 4;
451
452                 FreeStrBuf(&WCC->CurRoom.RoomAide);
453                 WCC->CurRoom.RoomAide = NewStrBufPlain(NULL, StrLength(Buf));
454
455                 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
456         }
457         FreeStrBuf(&Buf);
458 }
459
460 int SaveRoomAide(folder * Room) {
461         StrBuf *Buf;
462         Buf = NewStrBuf();
463         serv_printf("SETA %s", ChrPtr(Room->RoomAide));
464         StrBuf_ServGetln(Buf);
465         if (GetServerStatus(Buf, NULL) != 2) {
466                 StrBufCutLeft(Buf, 4);
467                 AppendImportantMessage(SKEY(Buf));
468                 FreeStrBuf(&Buf);
469                 return 0;
470         }
471         FreeStrBuf(&Buf);
472         return 1;
473 }
474
475
476 int GetCurrentRoomFlags(folder * Room, int CareForStatusMessage) {
477         StrBuf *Buf;
478
479         Buf = NewStrBuf();
480         serv_puts("GETR");
481         StrBuf_ServGetln(Buf);
482         if (GetServerStatus(Buf, NULL) != 2) {
483                 FlushStrBuf(Room->XAPass);
484                 FlushStrBuf(Room->Directory);
485                 StrBufCutLeft(Buf, 4);
486                 if (CareForStatusMessage)
487                         AppendImportantMessage(SKEY(Buf));
488                 FreeStrBuf(&Buf);
489                 Room->XALoaded = 2;
490                 return 0;
491         }
492         else {
493                 const char *Pos;
494
495                 Pos = ChrPtr(Buf) + 4;
496
497                 FreeStrBuf(&Room->XAPass);
498                 FreeStrBuf(&Room->Directory);
499
500                 Room->XAPass = NewStrBufPlain(NULL, StrLength(Buf));
501                 Room->Directory = NewStrBufPlain(NULL, StrLength(Buf));
502
503                 FreeStrBuf(&Room->name);
504                 Room->name = NewStrBufPlain(NULL, StrLength(Buf));
505                 StrBufExtract_NextToken(Room->name, Buf, &Pos, '|');
506
507                 StrBufExtract_NextToken(Room->XAPass, Buf, &Pos, '|');
508                 StrBufExtract_NextToken(Room->Directory, Buf, &Pos, '|');
509
510                 Room->QRFlags = StrBufExtractNext_long(Buf, &Pos, '|');
511                 Room->floorid = StrBufExtractNext_long(Buf, &Pos, '|');
512                 Room->Order = StrBufExtractNext_long(Buf, &Pos, '|');
513                 Room->defview = StrBufExtractNext_long(Buf, &Pos, '|');
514                 Room->QRFlags2 = StrBufExtractNext_long(Buf, &Pos, '|');
515                 FreeStrBuf(&Buf);
516                 Room->XALoaded = 1;
517                 return 1;
518         }
519 }
520
521
522 int SetCurrentRoomFlags(folder * Room) {
523         StrBuf *Buf;
524
525         Buf = NewStrBuf();
526         DBG_QR(Room->QRFlags);
527         DBG_QR2(Room->QRFlags2);
528
529         serv_printf("SETR %s|%s|%s|%ld|%d|%d|%ld|%ld|%ld",
530                     ChrPtr(Room->name),
531                     ChrPtr(Room->XAPass),
532                     ChrPtr(Room->Directory),
533                     Room->QRFlags, Room->BumpUsers, Room->floorid, Room->Order, Room->defview, Room->QRFlags2);
534
535         StrBuf_ServGetln(Buf);
536         if (GetServerStatus(Buf, NULL) != 2) {
537                 StrBufCutLeft(Buf, 4);
538                 AppendImportantMessage(SKEY(Buf));
539                 FreeStrBuf(&Buf);
540                 return 0;
541         }
542         else {
543                 FreeStrBuf(&Buf);
544                 return 1;
545         }
546 }
547
548 void LoadRoomXA(void) {
549         wcsession *WCC = WC;
550
551         if (WCC->CurRoom.XALoaded > 0)
552                 return;
553
554         GetCurrentRoomFlags(&WCC->CurRoom, 0);
555 }
556
557
558 void LoadXRoomPic(void) {
559         wcsession *WCC = WC;
560         StrBuf *Buf;
561         off_t bytes;
562
563         if (WCC->CurRoom.XHaveRoomPicLoaded) {
564                 return;
565         }
566
567         WCC->CurRoom.XHaveRoomPicLoaded = 1;
568         Buf = NewStrBuf();
569         serv_puts("DLRI");
570         StrBuf_ServGetln(Buf);
571         if (GetServerStatus(Buf, NULL) == 6) {
572                 StrBufCutLeft(Buf, 4);
573                 bytes = StrBufExtract_long(Buf, 0, '|');
574                 WCC->CurRoom.XHaveRoomPic = 1;
575                 StrBuf_ServGetBLOBBuffered(Buf, bytes); // discard the data
576         }
577         else {
578                 WCC->CurRoom.XHaveRoomPic = 0;
579         }
580         FreeStrBuf(&Buf);
581 }
582
583
584 void LoadXRoomInfoText(void) {
585         wcsession *WCC = WC;
586         StrBuf *Buf;
587         int Done = 0;
588
589         if (WCC->CurRoom.XHaveInfoTextLoaded) {
590                 return;
591         }
592
593         WCC->CurRoom.XHaveInfoTextLoaded = 1;
594         Buf = NewStrBuf();
595
596         serv_puts("RINF");
597
598         StrBuf_ServGetln(Buf);
599         if (GetServerStatus(Buf, NULL) == 1) {
600                 WCC->CurRoom.XInfoText = NewStrBuf();
601
602                 while (!Done && StrBuf_ServGetln(Buf) >= 0) {
603                         if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000"))
604                                 Done = 1;
605                         else
606                                 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
607                 }
608         }
609
610         FreeStrBuf(&Buf);
611 }
612
613
614 void LoadXRoomXCountFiles(void) {
615         wcsession *WCC = WC;
616         StrBuf *Buf;
617         int Done = 0;
618
619         if (WCC->CurRoom.XHaveDownloadCount)
620                 return;
621
622         WCC->CurRoom.XHaveDownloadCount = 1;
623
624         Buf = NewStrBuf();
625         serv_puts("RDIR");
626         StrBuf_ServGetln(Buf);
627         if (GetServerStatus(Buf, NULL) == 1) {
628
629                 while (!Done && StrBuf_ServGetln(Buf) >= 0) {
630                         if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000"))
631                                 Done = 1;
632                         else
633                                 WCC->CurRoom.XDownloadCount++;
634                 }
635         }
636
637         FreeStrBuf(&Buf);
638 }
639
640
641 /* 
642  * Toggle self-service list subscription
643  */
644 void toggle_self_service(void) {
645         wcsession *WCC = WC;
646
647         if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 0)
648                 return;
649
650         if (yesbstr("QR2_SelfList"))
651                 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SELFLIST;
652         else
653                 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SELFLIST;
654
655         if (yesbstr("QR2_SMTP_PUBLIC"))
656                 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
657         else
658                 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
659
660         if (yesbstr("QR2_Moderated"))
661                 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_MODERATED;
662         else
663                 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_MODERATED;
664         if (yesbstr("QR2_SubsOnly"))
665                 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
666         else
667                 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
668
669         SetCurrentRoomFlags(&WCC->CurRoom);
670
671         output_headers(1, 1, 1, 0, 0, 0);
672         do_template("room_edit");
673         wDumpContent(1);
674 }
675
676
677
678 /*
679  * save new parameters for a room
680  */
681 void editroom(void) {
682         wcsession *WCC = WC;
683         const StrBuf *Ptr;
684         const StrBuf *er_name;
685         const StrBuf *er_password;
686         const StrBuf *er_dirname;
687         const StrBuf *er_roomaide;
688         const StrBuf *templ;
689         int succ1, succ2;
690
691         templ = sbstr("template");
692         if (!havebstr("ok_button")) {
693                 putlbstr("success", 0);
694                 AppendImportantMessage(_("Cancelled.  Changes were not saved."), -1);
695                 if (templ != NULL) {
696                         output_headers(1, 0, 0, 0, 0, 0);
697                         DoTemplate(SKEY(templ), NULL, &NoCtx);
698                         end_burst();
699                 }
700                 else {
701                         output_headers(1, 1, 1, 0, 0, 0);
702                         do_template("room_edit");
703                         wDumpContent(1);
704                 }
705                 return;
706         }
707
708         if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 0) {
709                 putlbstr("success", 0);
710                 if (templ != NULL) {
711                         output_headers(1, 0, 0, 0, 0, 0);
712                         DoTemplate(SKEY(templ), NULL, &NoCtx);
713                         end_burst();
714                 }
715                 else {
716                         output_headers(1, 1, 1, 0, 0, 0);
717                         do_template("room_edit");
718                         wDumpContent(1);
719                 }
720                 return;
721         }
722
723         LoadRoomAide();
724         WCC->CurRoom.QRFlags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
725
726         Ptr = sbstr("type");
727         if (!strcmp(ChrPtr(Ptr), "invonly")) {
728                 WCC->CurRoom.QRFlags |= (QR_PRIVATE);
729         }
730         if (!strcmp(ChrPtr(Ptr), "hidden")) {
731                 WCC->CurRoom.QRFlags |= (QR_PRIVATE | QR_GUESSNAME);
732         }
733         if (!strcmp(ChrPtr(Ptr), "passworded")) {
734                 WCC->CurRoom.QRFlags |= (QR_PRIVATE | QR_PASSWORDED);
735         }
736         if (!strcmp(ChrPtr(Ptr), "personal")) {
737                 WCC->CurRoom.QRFlags |= QR_MAILBOX;
738         }
739         else {
740                 WCC->CurRoom.QRFlags &= ~QR_MAILBOX;
741         }
742
743         if (yesbstr("prefonly")) {
744                 WCC->CurRoom.QRFlags |= QR_PREFONLY;
745         }
746         else {
747                 WCC->CurRoom.QRFlags &= ~QR_PREFONLY;
748         }
749
750         if (yesbstr("readonly")) {
751                 WCC->CurRoom.QRFlags |= QR_READONLY;
752         }
753         else {
754                 WCC->CurRoom.QRFlags &= ~QR_READONLY;
755         }
756
757         if (yesbstr("collabdel")) {
758                 WCC->CurRoom.QRFlags2 |= QR2_COLLABDEL;
759         }
760         else {
761                 WCC->CurRoom.QRFlags2 &= ~QR2_COLLABDEL;
762         }
763
764         if (yesbstr("permanent")) {
765                 WCC->CurRoom.QRFlags |= QR_PERMANENT;
766         }
767         else {
768                 WCC->CurRoom.QRFlags &= ~QR_PERMANENT;
769         }
770
771         if (yesbstr("subjectreq")) {
772                 WCC->CurRoom.QRFlags2 |= QR2_SUBJECTREQ;
773         }
774         else {
775                 WCC->CurRoom.QRFlags2 &= ~QR2_SUBJECTREQ;
776         }
777
778         if (yesbstr("network")) {
779                 WCC->CurRoom.QRFlags |= QR_NETWORK;
780         }
781         else {
782                 WCC->CurRoom.QRFlags &= ~QR_NETWORK;
783         }
784
785         if (yesbstr("directory")) {
786                 WCC->CurRoom.QRFlags |= QR_DIRECTORY;
787         }
788         else {
789                 WCC->CurRoom.QRFlags &= ~QR_DIRECTORY;
790         }
791
792         if (yesbstr("ulallowed")) {
793                 WCC->CurRoom.QRFlags |= QR_UPLOAD;
794         }
795         else {
796                 WCC->CurRoom.QRFlags &= ~QR_UPLOAD;
797         }
798
799         if (yesbstr("dlallowed")) {
800                 WCC->CurRoom.QRFlags |= QR_DOWNLOAD;
801         }
802         else {
803                 WCC->CurRoom.QRFlags &= ~QR_DOWNLOAD;
804         }
805
806         if (yesbstr("ulmsg")) {
807                 WCC->CurRoom.QRFlags2 |= QR2_NOUPLMSG;
808         }
809         else {
810                 WCC->CurRoom.QRFlags2 &= ~QR2_NOUPLMSG;
811         }
812
813         if (yesbstr("visdir")) {
814                 WCC->CurRoom.QRFlags |= QR_VISDIR;
815         }
816         else {
817                 WCC->CurRoom.QRFlags &= ~QR_VISDIR;
818         }
819
820         Ptr = sbstr("anon");
821
822         WCC->CurRoom.QRFlags &= ~(QR_ANONONLY | QR_ANONOPT);
823         if (!strcmp(ChrPtr(Ptr), "anononly"))
824                 WCC->CurRoom.QRFlags |= QR_ANONONLY;
825         if (!strcmp(ChrPtr(Ptr), "anon2"))
826                 WCC->CurRoom.QRFlags |= QR_ANONOPT;
827
828         er_name = sbstr("er_name");
829         er_dirname = sbstr("er_dirname");
830         er_roomaide = sbstr("er_roomaide");
831         er_password = sbstr("er_password");
832
833         FlushStrBuf(WCC->CurRoom.name);
834         StrBufAppendBuf(WCC->CurRoom.name, er_name, 0);
835
836         FlushStrBuf(WCC->CurRoom.Directory);
837         StrBufAppendBuf(WCC->CurRoom.Directory, er_dirname, 0);
838
839         FlushStrBuf(WCC->CurRoom.RoomAide);
840         StrBufAppendBuf(WCC->CurRoom.RoomAide, er_roomaide, 0);
841
842         FlushStrBuf(WCC->CurRoom.XAPass);
843         StrBufAppendBuf(WCC->CurRoom.XAPass, er_password, 0);
844
845         WCC->CurRoom.BumpUsers = yesbstr("bump");
846
847         WCC->CurRoom.floorid = ibstr("er_floor");
848
849         succ1 = SetCurrentRoomFlags(&WCC->CurRoom);
850
851         succ2 = SaveRoomAide(&WCC->CurRoom);
852
853         if (succ1 + succ2 == 0) {
854                 putlbstr("success", 1);
855                 AppendImportantMessage(_("Your changes have been saved."), -1);
856         }
857         else {
858                 putlbstr("success", 0);
859         }
860         if (templ != NULL) {
861                 output_headers(1, 0, 0, 0, 0, 0);
862                 DoTemplate(SKEY(templ), NULL, &NoCtx);
863                 end_burst();
864         }
865         else {
866                 output_headers(1, 1, 1, 0, 0, 0);
867                 do_template("room_edit");
868                 wDumpContent(1);
869         }
870         return;
871 }
872
873
874
875 /*
876  * Display form for Invite, Kick, and show Who Knows a room
877  */
878 void do_invt_kick(void) {
879         StrBuf *Buf, *User;
880         const StrBuf *UserNames;
881         int Kick, Invite;
882         wcsession *WCC = WC;
883
884
885         if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 1) {
886                 const char *Pos;
887                 UserNames = sbstr("username");
888                 Kick = havebstr("kick_button");
889                 Invite = havebstr("invite_button");
890
891                 User = NewStrBufPlain(NULL, StrLength(UserNames));
892                 Buf = NewStrBuf();
893
894                 Pos = ChrPtr(UserNames);
895                 while (Pos != StrBufNOTNULL) {
896                         StrBufExtract_NextToken(User, UserNames, &Pos, ',');
897                         StrBufTrim(User);
898                         if ((StrLength(User) > 0) && (Kick)) {
899                                 serv_printf("KICK %s", ChrPtr(User));
900                                 if (StrBuf_ServGetln(Buf) < 0)
901                                         break;
902                                 if (GetServerStatus(Buf, NULL) != 2) {
903                                         StrBufCutLeft(Buf, 4);
904                                         AppendImportantMessage(SKEY(Buf));
905                                 }
906                                 else {
907                                         StrBufPrintf(Buf,
908                                                      _("User '%s' kicked out of room '%s'."),
909                                                      ChrPtr(User), ChrPtr(WCC->CurRoom.name)
910                                             );
911                                         AppendImportantMessage(SKEY(Buf));
912                                 }
913                         }
914                         else if ((StrLength(User) > 0) && (Invite)) {
915                                 serv_printf("INVT %s", ChrPtr(User));
916                                 if (StrBuf_ServGetln(Buf) < 0)
917                                         break;
918                                 if (GetServerStatus(Buf, NULL) != 2) {
919                                         StrBufCutLeft(Buf, 4);
920                                         AppendImportantMessage(SKEY(Buf));
921                                 }
922                                 else {
923                                         StrBufPrintf(Buf,
924                                                      _("User '%s' invited to room '%s'."), ChrPtr(User), ChrPtr(WCC->CurRoom.name)
925                                             );
926                                         AppendImportantMessage(SKEY(Buf));
927                                 }
928                         }
929                 }
930         }
931
932         output_headers(1, 1, 1, 0, 0, 0);
933         do_template("room_edit");
934         wDumpContent(1);
935 }
936
937
938 /*
939  * Create a new room
940  */
941 void entroom(void) {
942         StrBuf *Line;
943         const StrBuf *er_name;
944         const StrBuf *er_type;
945         const StrBuf *er_password;
946         const StrBuf *template;
947         int er_floor;
948         int er_num_type;
949         int er_view;
950         wcsession *WCC = WC;
951
952         template = sbstr("template");
953         if ((WCC == NULL) || !havebstr("ok_button")) {
954                 putlbstr("success", 0);
955                 AppendImportantMessage(_("Cancelled.  No new room was created."), -1);
956                 if (template != NULL) {
957                         output_headers(1, 0, 0, 0, 0, 0);
958                         DoTemplate(SKEY(template), NULL, &NoCtx);
959                         end_burst();
960                 }
961                 else {
962                         display_main_menu();
963                 }
964                 return;
965         }
966         er_name = sbstr("er_name");
967         er_type = sbstr("type");
968         er_password = sbstr("er_password");
969         er_floor = ibstr("er_floor");
970         er_view = ibstr("er_view");
971
972         er_num_type = 0;
973         if (!strcmp(ChrPtr(er_type), "hidden"))
974                 er_num_type = 1;
975         else if (!strcmp(ChrPtr(er_type), "passworded"))
976                 er_num_type = 2;
977         else if (!strcmp(ChrPtr(er_type), "invonly"))
978                 er_num_type = 3;
979         else if (!strcmp(ChrPtr(er_type), "personal"))
980                 er_num_type = 4;
981
982         serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d", ChrPtr(er_name), er_num_type, ChrPtr(er_password), er_floor, 0, er_view);
983
984         Line = NewStrBuf();
985         StrBuf_ServGetln(Line);
986         if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
987                 putlbstr("success", 0);
988                 FreeStrBuf(&Line);
989                 if (template != NULL) {
990                         output_headers(1, 0, 0, 0, 0, 0);
991                         DoTemplate(SKEY(template), NULL, &NoCtx);
992                         end_burst();
993                 }
994                 else {
995                         display_main_menu();
996                 }
997                 return;
998         }
999
1000         /** TODO: Room created, now update the left hand icon bar for this user */
1001         gotoroom(er_name);
1002
1003         serv_printf("VIEW %d", er_view);
1004         StrBuf_ServGetln(Line);
1005         FreeStrBuf(&Line);      /* TODO: should we care about errors? */
1006         WCC->CurRoom.view = er_view;
1007
1008         putlbstr("success", 1);
1009         if (template != NULL) {
1010                 output_headers(1, 0, 0, 0, 0, 0);
1011                 DoTemplate(SKEY(template), NULL, &NoCtx);
1012                 end_burst();
1013         }
1014         else if ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) {
1015                 output_headers(1, 1, 1, 0, 0, 0);
1016                 do_template("room_edit");
1017                 wDumpContent(1);
1018         }
1019         else {
1020                 smart_goto(WCC->CurRoom.name);
1021         }
1022         FreeStrBuf(&Line);
1023 }
1024
1025
1026
1027
1028
1029 /*
1030  * Change the view for this room
1031  */
1032 void change_view(void) {
1033         int newview;
1034         char buf[SIZ];
1035
1036         newview = lbstr("view");
1037         serv_printf("VIEW %d", newview);
1038         serv_getln(buf, sizeof buf);
1039         WC->CurRoom.view = newview;
1040         smart_goto(WC->CurRoom.name);
1041 }
1042
1043
1044
1045 /*
1046  * Set the message expire policy for this room and/or floor
1047  */
1048 void set_room_policy(void) {
1049         StrBuf *Line;
1050
1051         if (!havebstr("ok_button")) {
1052                 AppendImportantMessage(_("Cancelled.  Changes were not saved."), -1);
1053                 output_headers(1, 1, 1, 0, 0, 0);
1054                 do_template("room_edit");
1055                 wDumpContent(1);
1056                 return;
1057         }
1058
1059         Line = NewStrBuf();
1060
1061         serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
1062         StrBuf_ServGetln(Line);
1063         GetServerStatusMsg(Line, NULL, 1, 0);
1064         if (WC->axlevel >= 6) {
1065                 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
1066                 StrBuf_ServGetln(Line);
1067                 GetServerStatusMsg(Line, NULL, 1, 0);
1068         }
1069         FreeStrBuf(&Line);
1070         ReloadCurrentRoom();
1071
1072         output_headers(1, 1, 1, 0, 0, 0);
1073         do_template("room_edit");
1074         wDumpContent(1);
1075 }
1076
1077
1078
1079 /*
1080  * Perform changes to a room's network configuration
1081  */
1082 void netedit(void) {
1083         char buf[SIZ];
1084         char line[SIZ];
1085         char cmpa0[SIZ];
1086         char cmpa1[SIZ];
1087         char cmpb0[SIZ];
1088         char cmpb1[SIZ];
1089         int i, num_addrs;
1090         StrBuf *Line;
1091         StrBuf *TmpBuf;
1092         int malias = 0;
1093         int malias_set_default = 0;
1094         char sepchar = '|';
1095         int Done;
1096
1097         line[0] = '\0';
1098         if (havebstr("force_room")) {
1099                 gotoroom(sbstr("force_room"));
1100         }
1101         /*/ TODO: do line dynamic! */
1102         if (havebstr("line_pop3host")) {
1103                 strcpy(line, bstr("prefix"));
1104                 strcat(line, bstr("line_pop3host"));
1105                 strcat(line, "|");
1106                 strcat(line, bstr("line_pop3user"));
1107                 strcat(line, "|");
1108                 strcat(line, bstr("line_pop3pass"));
1109                 strcat(line, "|");
1110                 strcat(line, ibstr("line_pop3keep") ? "1" : "0");
1111                 strcat(line, "|");
1112                 sprintf(&line[strlen(line)], "%ld", lbstr("line_pop3int"));
1113                 strcat(line, bstr("suffix"));
1114         }
1115         else if (havebstr("line")) {
1116                 strcpy(line, bstr("prefix"));
1117                 strcat(line, bstr("line"));
1118                 strcat(line, bstr("suffix"));
1119         }
1120         else if (havebstr("alias")) {
1121                 const char *domain;
1122                 domain = bstr("aliasdomain");
1123                 if ((domain == NULL) || IsEmptyStr(domain)) {
1124                         malias_set_default = 1;
1125                         strcpy(line, bstr("prefix"));
1126                         strcat(line, bstr("default_aliasdomain"));
1127                 }
1128                 else {
1129                         malias = 1;
1130                         sepchar = ',';
1131                         strcat(line, bstr("prefix"));
1132                         if (!IsEmptyStr(domain)) {
1133                                 strcat(line, "@");
1134                                 strcat(line, domain);
1135                         }
1136                         strcat(line, ",");
1137                         strcat(line, "room_");
1138                         strcat(line, ChrPtr(WC->CurRoom.name));
1139                 }
1140         }
1141         else {
1142                 output_headers(1, 1, 1, 0, 0, 0);
1143                 do_template("room_edit");
1144                 wDumpContent(1);
1145                 return;
1146         }
1147
1148         Line = NewStrBuf();
1149         TmpBuf = NewStrBuf();
1150         if (malias)
1151                 serv_puts("GNET " FILE_MAILALIAS);
1152         else
1153                 serv_puts("GNET");
1154         StrBuf_ServGetln(Line);
1155         if (GetServerStatus(Line, NULL) != 1) {
1156                 AppendImportantMessage(SRV_STATUS_MSG(Line));
1157                 FreeStrBuf(&Line);
1158                 output_headers(1, 1, 1, 0, 0, 0);
1159                 do_template("room_edit");
1160                 wDumpContent(1);
1161                 return;
1162         }
1163
1164         /** This loop works for add *or* remove.  Spiffy, eh? */
1165         Done = 0;
1166         extract_token(cmpb0, line, 0, sepchar, sizeof cmpb0);
1167         extract_token(cmpb1, line, 1, sepchar, sizeof cmpb1);
1168         while (!Done && StrBuf_ServGetln(Line) >= 0) {
1169                 if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
1170                         Done = 1;
1171                 }
1172                 else {
1173                         if (StrLength(Line) == 0)
1174                                 continue;
1175
1176                         if (malias_set_default) {
1177                                 if (strncasecmp(ChrPtr(Line), HKEY("roommailalias|")) != 0) {
1178                                         StrBufAppendBufPlain(Line, HKEY("\n"), 0);
1179                                         StrBufAppendBuf(TmpBuf, Line, 0);
1180                                 }
1181                         }
1182                         else {
1183                                 extract_token(cmpa0, ChrPtr(Line), 0, sepchar, sizeof cmpa0);
1184                                 extract_token(cmpa1, ChrPtr(Line), 1, sepchar, sizeof cmpa1);
1185                                 if ((strcasecmp(cmpa0, cmpb0)) || (strcasecmp(cmpa1, cmpb1))) {
1186                                         StrBufAppendBufPlain(Line, HKEY("\n"), 0);
1187                                         StrBufAppendBuf(TmpBuf, Line, 0);
1188                                 }
1189                         }
1190                 }
1191         }
1192
1193         if (malias)
1194                 serv_puts("SNET " FILE_MAILALIAS);
1195         else
1196                 serv_puts("SNET");
1197         StrBuf_ServGetln(Line);
1198         if (GetServerStatus(Line, NULL) != 4) {
1199
1200                 AppendImportantMessage(SRV_STATUS_MSG(Line));
1201                 output_headers(1, 1, 1, 0, 0, 0);
1202                 do_template("room_edit");
1203                 wDumpContent(1);
1204                 FreeStrBuf(&Line);
1205                 FreeStrBuf(&TmpBuf);
1206                 return;
1207         }
1208
1209         serv_putbuf(TmpBuf);
1210         FreeStrBuf(&TmpBuf);
1211
1212         if (havebstr("add_button")) {
1213                 num_addrs = num_tokens(bstr("line"), ',');
1214                 if (num_addrs < 2) {
1215                         /* just adding one node or address */
1216                         serv_puts(line);
1217                 }
1218                 else {
1219                         /* adding multiple addresses separated by commas */
1220                         for (i = 0; i < num_addrs; ++i) {
1221                                 strcpy(line, bstr("prefix"));
1222                                 extract_token(buf, bstr("line"), i, ',', sizeof buf);
1223                                 striplt(buf);
1224                                 strcat(line, buf);
1225                                 strcat(line, bstr("suffix"));
1226                                 serv_puts(line);
1227                         }
1228                 }
1229         }
1230
1231         serv_puts("000");
1232         serv_puts("NOOP");
1233         StrBuf_ServGetln(Line);
1234         if (GetServerStatus(Line, NULL) != 2) { /* WHOOOPS? ERROR? */
1235                 AppendImportantMessage(SRV_STATUS_MSG(Line));
1236                 StrBuf_ServGetln(Line); /* resync... */
1237         }
1238
1239
1240         FlushIgnetCfgs(&WC->CurRoom);
1241         FreeStrBuf(&Line);
1242
1243         output_headers(1, 1, 1, 0, 0, 0);
1244         do_template("room_edit");
1245         wDumpContent(1);
1246 }
1247
1248 /*
1249  * Known rooms list (box style)
1250  */
1251 void knrooms(void) {
1252         DeleteHash(&WC->Rooms);
1253         output_headers(1, 1, 1, 0, 0, 0);
1254         do_template("knrooms");
1255         wDumpContent(1);
1256 }
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275 /*******************************************************************************
1276  ********************** FLOOR Coomands *****************************************
1277  ******************************************************************************/
1278
1279
1280
1281 /*
1282  * delete the actual floor
1283  */
1284 void delete_floor(void) {
1285         int floornum;
1286         StrBuf *Buf;
1287         const char *Err;
1288
1289         floornum = ibstr("floornum");
1290         Buf = NewStrBuf();
1291         serv_printf("KFLR %d|1", floornum);
1292
1293         StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1294
1295         if (GetServerStatus(Buf, NULL) == 2) {
1296                 StrBufPlain(Buf, _("Floor has been deleted."), -1);
1297         }
1298         else {
1299                 StrBufCutLeft(Buf, 4);
1300         }
1301         AppendImportantMessage(SKEY(Buf));
1302
1303         FlushRoomlist();
1304         http_transmit_thing(ChrPtr(do_template("floors")), 0);
1305         FreeStrBuf(&Buf);
1306 }
1307
1308 /*
1309  * start creating a new floor
1310  */
1311 void create_floor(void) {
1312         StrBuf *Buf;
1313         const char *Err;
1314
1315         Buf = NewStrBuf();
1316         serv_printf("CFLR %s|1", bstr("floorname"));
1317         StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1318
1319         if (GetServerStatus(Buf, NULL) == 2) {
1320                 StrBufPlain(Buf, _("New floor has been created."), -1);
1321         }
1322         else {
1323                 StrBufCutLeft(Buf, 4);
1324         }
1325         AppendImportantMessage(SKEY(Buf));
1326         FlushRoomlist();
1327         http_transmit_thing(ChrPtr(do_template("floors")), 0);
1328         FreeStrBuf(&Buf);
1329 }
1330
1331
1332 /*
1333  * rename this floor
1334  */
1335 void rename_floor(void) {
1336         StrBuf *Buf;
1337
1338         Buf = NewStrBuf();
1339         FlushRoomlist();
1340
1341         serv_printf("EFLR %d|%s", ibstr("floornum"), bstr("floorname"));
1342         StrBuf_ServGetln(Buf);
1343
1344         StrBufCutLeft(Buf, 4);
1345         AppendImportantMessage(SKEY(Buf));
1346
1347         http_transmit_thing(ChrPtr(do_template("floors")), 0);
1348         FreeStrBuf(&Buf);
1349 }
1350
1351
1352
1353 void jsonRoomFlr(void) {
1354         /* Send as our own (application/json) content type */
1355         hprintf("HTTP/1.1 200 OK\r\n");
1356         hprintf("Content-type: application/json; charset=utf-8\r\n");
1357         hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
1358         hprintf("Connection: close\r\n");
1359         hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
1360         begin_burst();
1361         DoTemplate(HKEY("json_roomflr"), NULL, &NoCtx);
1362         end_burst();
1363 }
1364
1365 void _FlushRoomList(wcsession * WCC) {
1366         free_march_list(WCC);
1367         DeleteHash(&WCC->Floors);
1368         DeleteHash(&WCC->Rooms);
1369         DeleteHash(&WCC->FloorsByName);
1370         FlushFolder(&WCC->CurRoom);
1371 }
1372
1373 void ReloadCurrentRoom(void) {
1374         wcsession *WCC = WC;
1375         StrBuf *CurRoom;
1376
1377         CurRoom = WCC->CurRoom.name;
1378         WCC->CurRoom.name = NULL;
1379         _FlushRoomList(WCC);
1380         gotoroom(CurRoom);
1381         FreeStrBuf(&CurRoom);
1382 }
1383
1384 void FlushRoomlist(void) {
1385         wcsession *WCC = WC;
1386         _FlushRoomList(WCC);
1387 }
1388
1389
1390 void InitModule_ROOMOPS(void) {
1391         RegisterPreference("roomlistview", _("Room list view"), PRF_STRING, NULL);
1392         RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
1393
1394         WebcitAddUrlHandler(HKEY("json_roomflr"), "", 0, jsonRoomFlr, 0);
1395
1396         WebcitAddUrlHandler(HKEY("delete_floor"), "", 0, delete_floor, 0);
1397         WebcitAddUrlHandler(HKEY("rename_floor"), "", 0, rename_floor, 0);
1398         WebcitAddUrlHandler(HKEY("create_floor"), "", 0, create_floor, 0);
1399
1400         WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, ANONYMOUS);
1401         WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
1402         WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
1403
1404         WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
1405         WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
1406         WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
1407         WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
1408
1409         WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
1410         WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
1411         WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
1412         WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
1413         WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
1414         WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
1415
1416
1417         REGISTERTokenParamDefine(QR_PERMANENT);
1418         REGISTERTokenParamDefine(QR_INUSE);
1419         REGISTERTokenParamDefine(QR_PRIVATE);
1420         REGISTERTokenParamDefine(QR_PASSWORDED);
1421         REGISTERTokenParamDefine(QR_GUESSNAME);
1422         REGISTERTokenParamDefine(QR_DIRECTORY);
1423         REGISTERTokenParamDefine(QR_UPLOAD);
1424         REGISTERTokenParamDefine(QR_DOWNLOAD);
1425         REGISTERTokenParamDefine(QR_VISDIR);
1426         REGISTERTokenParamDefine(QR_ANONONLY);
1427         REGISTERTokenParamDefine(QR_ANONOPT);
1428         REGISTERTokenParamDefine(QR_NETWORK);
1429         REGISTERTokenParamDefine(QR_PREFONLY);
1430         REGISTERTokenParamDefine(QR_READONLY);
1431         REGISTERTokenParamDefine(QR_MAILBOX);
1432         REGISTERTokenParamDefine(QR2_SYSTEM);
1433         REGISTERTokenParamDefine(QR2_SELFLIST);
1434         REGISTERTokenParamDefine(QR2_COLLABDEL);
1435         REGISTERTokenParamDefine(QR2_SUBJECTREQ);
1436         REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
1437         REGISTERTokenParamDefine(QR2_MODERATED);
1438         REGISTERTokenParamDefine(QR2_NOUPLMSG);
1439
1440         REGISTERTokenParamDefine(UA_KNOWN);
1441         REGISTERTokenParamDefine(UA_GOTOALLOWED);
1442         REGISTERTokenParamDefine(UA_HASNEWMSGS);
1443         REGISTERTokenParamDefine(UA_ZAPPED);
1444         REGISTERTokenParamDefine(UA_POSTALLOWED);
1445         REGISTERTokenParamDefine(UA_ADMINALLOWED);
1446         REGISTERTokenParamDefine(UA_DELETEALLOWED);
1447         REGISTERTokenParamDefine(UA_REPLYALLOWED);
1448         REGISTERTokenParamDefine(UA_ISTRASH);
1449
1450         REGISTERTokenParamDefine(US_NEEDVALID);
1451         REGISTERTokenParamDefine(US_PERM);
1452         REGISTERTokenParamDefine(US_LASTOLD);
1453         REGISTERTokenParamDefine(US_EXPERT);
1454         REGISTERTokenParamDefine(US_UNLISTED);
1455         REGISTERTokenParamDefine(US_NOPROMPT);
1456         REGISTERTokenParamDefine(US_PROMPTCTL);
1457         REGISTERTokenParamDefine(US_DISAPPEAR);
1458         REGISTERTokenParamDefine(US_REGIS);
1459         REGISTERTokenParamDefine(US_PAGINATOR);
1460         REGISTERTokenParamDefine(US_INTERNET);
1461         REGISTERTokenParamDefine(US_FLOORS);
1462         REGISTERTokenParamDefine(US_COLOR);
1463         REGISTERTokenParamDefine(US_USER_SET);
1464
1465         REGISTERTokenParamDefine(VIEW_BBS);
1466         REGISTERTokenParamDefine(VIEW_MAILBOX);
1467         REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
1468         REGISTERTokenParamDefine(VIEW_CALENDAR);
1469         REGISTERTokenParamDefine(VIEW_TASKS);
1470         REGISTERTokenParamDefine(VIEW_NOTES);
1471         REGISTERTokenParamDefine(VIEW_WIKI);
1472         REGISTERTokenParamDefine(VIEW_CALBRIEF);
1473         REGISTERTokenParamDefine(VIEW_JOURNAL);
1474         REGISTERTokenParamDefine(VIEW_BLOG);
1475         REGISTERTokenParamDefine(VIEW_QUEUE);
1476
1477         /* GNET types: */
1478         /* server internal, we need to know but ignore them. */
1479         REGISTERTokenParamDefine(subpending);
1480         REGISTERTokenParamDefine(unsubpending);
1481         REGISTERTokenParamDefine(lastsent);
1482
1483         REGISTERTokenParamDefine(ignet_push_share);
1484         {                       /* these are the parts of an IGNET push config */
1485                 REGISTERTokenParamDefine(GNET_IGNET_NODE);
1486                 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
1487         }
1488         REGISTERTokenParamDefine(listrecp);
1489         REGISTERTokenParamDefine(digestrecp);
1490         REGISTERTokenParamDefine(pop3client);
1491         {                       /* These are the parts of a pop3 client line... */
1492                 REGISTERTokenParamDefine(GNET_POP3_HOST);
1493                 REGISTERTokenParamDefine(GNET_POP3_USER);
1494                 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
1495                 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
1496         }
1497         REGISTERTokenParamDefine(rssclient);
1498         REGISTERTokenParamDefine(participate);
1499         REGISTERTokenParamDefine(roommailalias);
1500
1501
1502
1503 }
1504
1505
1506 void SessionDestroyModule_ROOMOPS(wcsession * sess) {
1507         _FlushRoomList(sess);
1508 }