2 * Lots of different room-related operations.
4 * Copyright (c) 1996-2011 by the citadel.org team
6 * This program is open source software. You can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "webserver.h"
24 ConstStr QRFlagList[] = {
25 {HKEY(strof(QR_PERMANENT))},
26 {HKEY(strof(QR_INUSE))},
27 {HKEY(strof(QR_PRIVATE))},
28 {HKEY(strof(QR_PASSWORDED))},
29 {HKEY(strof(QR_GUESSNAME))},
30 {HKEY(strof(QR_DIRECTORY))},
31 {HKEY(strof(QR_UPLOAD))},
32 {HKEY(strof(QR_DOWNLOAD))},
33 {HKEY(strof(QR_VISDIR))},
34 {HKEY(strof(QR_ANONONLY))},
35 {HKEY(strof(QR_ANONOPT))},
36 {HKEY(strof(QR_NETWORK))},
37 {HKEY(strof(QR_PREFONLY))},
38 {HKEY(strof(QR_READONLY))},
39 {HKEY(strof(QR_MAILBOX))}
41 ConstStr QR2FlagList[] = {
42 {HKEY(strof(QR2_SYSTEM))},
43 {HKEY(strof(QR2_SELFLIST))},
44 {HKEY(strof(QR2_COLLABDEL))},
45 {HKEY(strof(QR2_SUBJECTREQ))},
46 {HKEY(strof(QR2_SMTP_PUBLIC))},
47 {HKEY(strof(QR2_MODERATED))},
65 QRVec = NewStrBufPlain(NULL, 256);
69 if (StrLength(QRVec) > 0)
70 StrBufAppendBufPlain(QRVec, HKEY(" | "), 0);
71 StrBufAppendBufPlain(QRVec, CKEY(QRFlagList[j]), 0);
76 syslog(9, "DBG: QR-Vec [%ld] [%s]\n", QR, ChrPtr(QRVec));
82 void _DBG_QR2(long QR2)
88 QR2Vec = NewStrBufPlain(NULL, 256);
92 if (StrLength(QR2Vec) > 0)
93 StrBufAppendBufPlain(QR2Vec, HKEY(" | "), 0);
94 StrBufAppendBufPlain(QR2Vec, CKEY(QR2FlagList[j]), 0);
99 syslog(9, "DBG: QR2-Vec [%ld] [%s]\n", QR2, ChrPtr(QR2Vec));
113 /*******************************************************************************
114 ***************************** Goto Commands ***********************************
115 ******************************************************************************/
118 smart_goto(sbstr("room"));
122 if (!havebstr("room")) {
123 readloop(readnew, eUseDefault);
126 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
129 smart_goto(sbstr("room"));
135 void smart_goto(const StrBuf *next_room) {
137 readloop(readnew, eUseDefault);
141 * goto a private room
143 void goto_private(void)
147 const StrBuf *gr_name;
150 if (!havebstr("ok_button")) {
154 gr_name = sbstr("gr_name");
156 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
157 serv_printf("GOTO %s|%s",
160 StrBuf_ServGetln(Buf);
161 if (GetServerStatus(Buf, &err) == 2) {
168 DoTemplate(HKEY("room_display_private"), NULL, &NoCtx);
172 StrBufCutLeft(Buf, 4);
173 AppendImportantMessage (SKEY(Buf));
174 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
181 * back end routine to take the session to a new room
183 long gotoroom(const StrBuf *gname)
187 static long ls = (-1L);
189 int room_name_supplied = 0;
192 /* store ungoto information */
193 if (StrLength(gname) > 0) {
194 room_name_supplied = 1;
196 if (room_name_supplied) {
197 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
198 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_")) {
205 /* move to the new room */
206 if (room_name_supplied) {
207 serv_printf("GOTO %s", ChrPtr(gname));
210 /* or just refresh the current state... */
211 serv_printf("GOTO 00000000000000000000");
213 StrBuf_ServGetln(Buf);
214 if (GetServerStatus(Buf, &err) != 2) {
215 serv_puts("GOTO _BASEROOM_");
216 StrBuf_ServGetln(Buf);
218 * well, we know that this is the fallback case,
219 * but we're interested that the first command
220 * didn't work out in first place.
222 if (GetServerStatus(Buf, NULL) != 2) {
227 FlushFolder(&WCC->CurRoom);
228 ParseGoto(&WCC->CurRoom, Buf);
230 if (room_name_supplied) {
231 remove_march(WCC->CurRoom.name);
243 void ParseGoto(folder *room, StrBuf *Line)
251 if (StrLength(Line) < 4) {
255 /* ignore the commandstate... */
256 Pos = ChrPtr(Line) + 4;
258 if (room->RoomNameParts != NULL)
261 for (i=0; i < room->nRoomNameParts; i++)
262 FreeStrBuf(&room->RoomNameParts[i]);
263 free(room->RoomNameParts);
264 room->RoomNameParts = NULL;
269 pBuf = NewStrBufPlain(NULL, StrLength(Line));
272 memset(room, 0, sizeof(folder));
275 StrBufExtract_NextToken(room->name, Line, &Pos, '|');
277 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
278 if (room->nNewMessages > 0)
279 room->RAFlags |= UA_HASNEWMSGS;
281 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
283 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
285 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|');
287 DBG_QR(room->QRFlags);
289 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
290 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
292 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|');
294 flag = StrBufExtractNext_long(Line, &Pos, '|');
295 if (WCC->is_aide || flag) {
296 room->RAFlags |= UA_ADMINALLOWED;
299 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
301 room->floorid = StrBufExtractNext_int(Line, &Pos, '|');
303 room->view = StrBufExtractNext_long(Line, &Pos, '|');
305 room->defview = StrBufExtractNext_long(Line, &Pos, '|');
307 flag = StrBufExtractNext_long(Line, &Pos, '|');
309 room->RAFlags |= UA_ISTRASH;
311 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|');
312 DBG_QR2(room->QRFlags2);
314 /* find out, whether we are in a sub-room */
315 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
316 if (room->nRoomNameParts > 1)
321 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
322 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
323 for (i=0; i < room->nRoomNameParts; i++)
325 room->RoomNameParts[i] = NewStrBuf();
326 StrBufExtract_NextToken(room->RoomNameParts[i],
327 room->name, &Pos, '\\');
331 /* Private mailboxes on the main floor get remapped to the personal folder */
332 if ((room->QRFlags & QR_MAILBOX) &&
333 (room->floorid == 0))
335 room->floorid = VIRTUAL_MY_FLOOR;
336 if ((room->nRoomNameParts == 1) &&
337 (StrLength(room->name) == 4) &&
338 (strcmp(ChrPtr(room->name), "Mail") == 0))
344 /* get a pointer to the floor we're on: */
345 if (WCC->Floors == NULL)
346 GetFloorListHash(NULL, NULL);
348 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
349 room->Floor = (const Floor*) vFloor;
353 * Delete the current room
355 void delete_room(void)
360 StrBuf_ServGetln(Line);
361 if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
367 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
380 StrBuf *final_destination;
383 * If the forget-room routine fails for any reason, we fall back
384 * to the current room; otherwise, we go to the Lobby
386 final_destination = NewStrBufDup(WC->CurRoom.name);
388 if (havebstr("ok_button")) {
389 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
390 serv_getln(buf, sizeof buf);
393 serv_getln(buf, sizeof buf);
395 FlushStrBuf(final_destination);
396 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
401 smart_goto(final_destination);
402 FreeStrBuf(&final_destination);
407 * mark all messages in current room as having been read
409 void slrp_highest(void)
413 serv_puts("SLRP HIGHEST");
414 serv_getln(buf, sizeof buf);
430 /*******************************************************************************
431 ***************************** Modify Rooms ************************************
432 ******************************************************************************/
438 void LoadRoomAide(void)
443 if (WCC->CurRoom.RoomAideLoaded)
446 WCC->CurRoom.RoomAideLoaded = 1;
449 StrBuf_ServGetln(Buf);
450 if (GetServerStatus(Buf, NULL) != 2) {
451 FlushStrBuf(WCC->CurRoom.RoomAide);
452 AppendImportantMessage (ChrPtr(Buf) + 4,
457 Pos = ChrPtr(Buf) + 4;
459 FreeStrBuf(&WCC->CurRoom.RoomAide);
460 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
462 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
467 int SaveRoomAide(folder *Room)
471 serv_printf("SETA %s", ChrPtr(Room->RoomAide));
472 StrBuf_ServGetln(Buf);
473 if (GetServerStatus(Buf, NULL) != 2) {
474 StrBufCutLeft(Buf, 4);
475 AppendImportantMessage (SKEY(Buf));
484 int GetCurrentRoomFlags(folder *Room, int CareForStatusMessage)
490 StrBuf_ServGetln(Buf);
491 if (GetServerStatus(Buf, NULL) != 2) {
492 FlushStrBuf(Room->XAPass);
493 FlushStrBuf(Room->Directory);
494 StrBufCutLeft(Buf, 4);
495 if (CareForStatusMessage)
496 AppendImportantMessage (SKEY(Buf));
503 Pos = ChrPtr(Buf) + 4;
505 FreeStrBuf(&Room->XAPass);
506 FreeStrBuf(&Room->Directory);
508 Room->XAPass = NewStrBufPlain (NULL, StrLength (Buf));
509 Room->Directory = NewStrBufPlain (NULL, StrLength (Buf));
511 FreeStrBuf(&Room->name);
512 Room->name = NewStrBufPlain(NULL, StrLength(Buf));
513 StrBufExtract_NextToken(Room->name, Buf, &Pos, '|');
515 StrBufExtract_NextToken(Room->XAPass, Buf, &Pos, '|');
516 StrBufExtract_NextToken(Room->Directory, Buf, &Pos, '|');
518 Room->QRFlags = StrBufExtractNext_long(Buf, &Pos, '|');
519 Room->floorid = StrBufExtractNext_long(Buf, &Pos, '|');
520 Room->Order = StrBufExtractNext_long(Buf, &Pos, '|');
521 Room->defview = StrBufExtractNext_long(Buf, &Pos, '|');
522 Room->QRFlags2 = StrBufExtractNext_long(Buf, &Pos, '|');
530 int SetCurrentRoomFlags(folder *Room)
535 DBG_QR(Room->QRFlags);
536 DBG_QR2(Room->QRFlags2);
538 serv_printf("SETR %s|%s|%s|%ld|%d|%d|%ld|%ld|%ld",
540 ChrPtr(Room->XAPass),
541 ChrPtr(Room->Directory),
549 StrBuf_ServGetln(Buf);
550 if (GetServerStatus(Buf, NULL) != 2) {
551 StrBufCutLeft(Buf, 4);
552 AppendImportantMessage (SKEY(Buf));
561 void LoadRoomXA (void)
565 if (WCC->CurRoom.XALoaded > 0)
568 GetCurrentRoomFlags(&WCC->CurRoom, 0);
572 void LoadXRoomPic(void)
577 if (WCC->CurRoom.XHaveRoomPicLoaded)
580 WCC->CurRoom.XHaveRoomPicLoaded = 1;
582 serv_puts("OIMG _roompic_");
583 StrBuf_ServGetln(Buf);
584 if (GetServerStatus(Buf, NULL) != 2) {
585 WCC->CurRoom.XHaveRoomPic = 0;
587 WCC->CurRoom.XHaveRoomPic = 1;
590 StrBuf_ServGetln(Buf);
591 GetServerStatus(Buf, NULL);
596 void LoadXRoomInfoText(void)
602 if (WCC->CurRoom.XHaveInfoTextLoaded) {
606 WCC->CurRoom.XHaveInfoTextLoaded = 1;
611 StrBuf_ServGetln(Buf);
612 if (GetServerStatus(Buf, NULL) == 1) {
613 WCC->CurRoom.XInfoText = NewStrBuf ();
615 while (!Done && StrBuf_ServGetln(Buf)>=0) {
616 if ( (StrLength(Buf)==3) &&
617 !strcmp(ChrPtr(Buf), "000"))
620 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
628 void LoadXRoomXCountFiles(void)
634 if (WCC->CurRoom.XHaveDownloadCount)
637 WCC->CurRoom.XHaveDownloadCount = 1;
641 StrBuf_ServGetln(Buf);
642 if (GetServerStatus(Buf, NULL) == 1) {
644 while (!Done && StrBuf_ServGetln(Buf)>=0) {
645 if ( (StrLength(Buf)==3) &&
646 !strcmp(ChrPtr(Buf), "000"))
649 WCC->CurRoom.XDownloadCount++;
658 * Toggle self-service list subscription
660 void toggle_self_service(void) {
663 if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0)
666 if (yesbstr("QR2_SelfList"))
667 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SELFLIST;
669 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SELFLIST;
671 if (yesbstr("QR2_SMTP_PUBLIC"))
672 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
674 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
676 if (yesbstr("QR2_Moderated"))
677 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_MODERATED;
679 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_MODERATED;
680 if (yesbstr("QR2_SubsOnly"))
681 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
683 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
685 SetCurrentRoomFlags (&WCC->CurRoom);
687 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
693 * save new parameters for a room
699 const StrBuf *er_name;
700 const StrBuf *er_password;
701 const StrBuf *er_dirname;
702 const StrBuf *er_roomaide;
707 if (!havebstr("ok_button")) {
708 AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
709 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
712 if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0) {
713 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
719 er_flags = WCC->CurRoom.QRFlags;
720 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
722 er_flags2 = WCC->CurRoom.QRFlags2;
725 if (!strcmp(ChrPtr(Ptr), "invonly")) {
726 er_flags |= (QR_PRIVATE);
728 if (!strcmp(ChrPtr(Ptr), "hidden")) {
729 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
731 if (!strcmp(ChrPtr(Ptr), "passworded")) {
732 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
734 if (!strcmp(ChrPtr(Ptr), "personal")) {
735 er_flags |= QR_MAILBOX;
737 er_flags &= ~QR_MAILBOX;
742 if (yesbstr("prefonly")) {
743 er_flags |= QR_PREFONLY;
745 er_flags &= ~QR_PREFONLY;
748 if (yesbstr("readonly")) {
749 er_flags |= QR_READONLY;
751 er_flags &= ~QR_READONLY;
755 if (yesbstr("collabdel")) {
756 er_flags2 |= QR2_COLLABDEL;
758 er_flags2 &= ~QR2_COLLABDEL;
761 if (yesbstr("permanent")) {
762 er_flags |= QR_PERMANENT;
764 er_flags &= ~QR_PERMANENT;
767 if (yesbstr("subjectreq")) {
768 er_flags2 |= QR2_SUBJECTREQ;
770 er_flags2 &= ~QR2_SUBJECTREQ;
773 if (yesbstr("network")) {
774 er_flags |= QR_NETWORK;
776 er_flags &= ~QR_NETWORK;
779 if (yesbstr("directory")) {
780 er_flags |= QR_DIRECTORY;
782 er_flags &= ~QR_DIRECTORY;
785 if (yesbstr("ulallowed")) {
786 er_flags |= QR_UPLOAD;
788 er_flags &= ~QR_UPLOAD;
791 if (yesbstr("dlallowed")) {
792 er_flags |= QR_DOWNLOAD;
794 er_flags &= ~QR_DOWNLOAD;
797 if (yesbstr("visdir")) {
798 er_flags |= QR_VISDIR;
800 er_flags &= ~QR_VISDIR;
806 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
807 if (!strcmp(ChrPtr(Ptr), "anononly"))
808 er_flags |= QR_ANONONLY;
809 if (!strcmp(ChrPtr(Ptr), "anon2"))
810 er_flags |= QR_ANONOPT;
812 er_name = sbstr("er_name");
813 er_dirname = sbstr("er_dirname");
814 er_roomaide = sbstr("er_roomaide");
815 er_password = sbstr("er_password");
817 FlushStrBuf(WCC->CurRoom.name);
818 StrBufAppendBuf(WCC->CurRoom.name, er_name, 0);
820 FlushStrBuf(WCC->CurRoom.Directory);
821 StrBufAppendBuf(WCC->CurRoom.Directory, er_dirname, 0);
823 FlushStrBuf(WCC->CurRoom.RoomAide);
824 StrBufAppendBuf(WCC->CurRoom.RoomAide, er_roomaide, 0);
826 FlushStrBuf(WCC->CurRoom.XAPass);
827 StrBufAppendBuf(WCC->CurRoom.XAPass, er_password, 0);
829 WCC->CurRoom.BumpUsers = yesbstr("bump");
831 WCC->CurRoom.floorid = ibstr("er_floor");
833 succ1 = SetCurrentRoomFlags(&WCC->CurRoom);
835 succ2 = SaveRoomAide (&WCC->CurRoom);
837 if (succ1 + succ2 == 0)
838 AppendImportantMessage (_("Your changes have been saved."), -1);
839 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
846 * Display form for Invite, Kick, and show Who Knows a room
848 void do_invt_kick(void)
851 const StrBuf *UserNames;
856 if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 1)
859 UserNames = sbstr("username");
860 Kick = havebstr("kick_button");
861 Invite = havebstr("invite_button");
863 User = NewStrBufPlain(NULL, StrLength(UserNames));
866 Pos = ChrPtr(UserNames);
867 while (Pos != StrBufNOTNULL)
869 StrBufExtract_NextToken(User, UserNames, &Pos, ',');
871 if ((StrLength(User) > 0) && (Kick))
873 serv_printf("KICK %s", ChrPtr(User));
874 if (StrBuf_ServGetln(Buf) < 0)
876 if (GetServerStatus(Buf, NULL) != 2) {
877 StrBufCutLeft(Buf, 4);
878 AppendImportantMessage(SKEY(Buf));
881 _("User '%s' kicked out of room '%s'."),
883 ChrPtr(WCC->CurRoom.name)
885 AppendImportantMessage(SKEY(Buf));
888 else if ((StrLength(User) > 0) && (Invite))
890 serv_printf("INVT %s", ChrPtr(User));
891 if (StrBuf_ServGetln(Buf) < 0)
893 if (GetServerStatus(Buf, NULL) != 2) {
894 StrBufCutLeft(Buf, 4);
895 AppendImportantMessage(SKEY(Buf));
898 _("User '%s' invited to room '%s'."),
900 ChrPtr(WCC->CurRoom.name)
902 AppendImportantMessage(SKEY(Buf));
908 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
918 const StrBuf *er_name;
919 const StrBuf *er_type;
920 const StrBuf *er_password;
926 if (!havebstr("ok_button")) {
927 AppendImportantMessage(_("Cancelled. No new room was created."), -1);
931 er_name = sbstr("er_name");
932 er_type = sbstr("type");
933 er_password = sbstr("er_password");
934 er_floor = ibstr("er_floor");
935 er_view = ibstr("er_view");
938 if (!strcmp(ChrPtr(er_type), "hidden"))
940 else if (!strcmp(ChrPtr(er_type), "passworded"))
942 else if (!strcmp(ChrPtr(er_type), "invonly"))
944 else if (!strcmp(ChrPtr(er_type), "personal"))
947 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
956 StrBuf_ServGetln(Line);
957 if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
962 /** TODO: Room created, now update the left hand icon bar for this user */
965 serv_printf("VIEW %d", er_view);
966 StrBuf_ServGetln(Line);
967 FreeStrBuf(&Line); /* TODO: should we care about errors? */
968 WCC->CurRoom.view = er_view;
970 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
971 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
973 smart_goto(WCC->CurRoom.name);
983 * Change the view for this room
985 void change_view(void) {
989 newview = lbstr("view");
990 serv_printf("VIEW %d", newview);
991 serv_getln(buf, sizeof buf);
992 WC->CurRoom.view = newview;
993 smart_goto(WC->CurRoom.name);
999 * Set the message expire policy for this room and/or floor
1001 void set_room_policy(void) {
1004 if (!havebstr("ok_button")) {
1005 AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
1006 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1011 serv_printf("SPEX roompolicy|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
1012 StrBuf_ServGetln(Line);
1013 GetServerStatusMsg(Line, NULL, 1, 0);
1014 if (WC->axlevel >= 6) {
1015 serv_printf("SPEX floorpolicy|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
1016 StrBuf_ServGetln(Line);
1017 GetServerStatusMsg(Line, NULL, 1, 0);
1020 ReloadCurrentRoom();
1021 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1027 * Perform changes to a room's network configuration
1029 void netedit(void) {
1041 /*/ TODO: do line dynamic! */
1042 if (havebstr("line_pop3host")) {
1043 strcpy(line, bstr("prefix"));
1044 strcat(line, bstr("line_pop3host"));
1046 strcat(line, bstr("line_pop3user"));
1048 strcat(line, bstr("line_pop3pass"));
1050 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
1052 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
1053 strcat(line, bstr("suffix"));
1055 else if (havebstr("line")) {
1056 strcpy(line, bstr("prefix"));
1057 strcat(line, bstr("line"));
1058 strcat(line, bstr("suffix"));
1061 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1066 TmpBuf = NewStrBuf();
1068 StrBuf_ServGetln(Line);
1069 if (GetServerStatus(Line, NULL) != 1) {
1070 AppendImportantMessage(SRV_STATUS_MSG(Line));
1072 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1076 /** This loop works for add *or* remove. Spiffy, eh? */
1078 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
1079 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
1080 while (!Done && StrBuf_ServGetln(Line)>=0) {
1081 if ( (StrLength(Line)==3) &&
1082 !strcmp(ChrPtr(Line), "000"))
1088 extract_token(cmpa0, ChrPtr(Line), 0, '|', sizeof cmpa0);
1089 extract_token(cmpa1, ChrPtr(Line), 1, '|', sizeof cmpa1);
1090 if ( (strcasecmp(cmpa0, cmpb0))
1091 || (strcasecmp(cmpa1, cmpb1)) ) {
1092 StrBufAppendBufPlain(Line, HKEY("\n"), 0);
1093 StrBufAppendBuf(TmpBuf, Line, 0);
1099 StrBuf_ServGetln(Line);
1100 if (GetServerStatus(Line, NULL) != 4) {
1102 AppendImportantMessage(SRV_STATUS_MSG(Line));
1103 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1105 FreeStrBuf(&TmpBuf);
1109 serv_putbuf(TmpBuf);
1110 FreeStrBuf(&TmpBuf);
1112 if (havebstr("add_button")) {
1113 num_addrs = num_tokens(bstr("line"), ',');
1114 if (num_addrs < 2) {
1115 /* just adding one node or address */
1119 /* adding multiple addresses separated by commas */
1120 for (i=0; i<num_addrs; ++i) {
1121 strcpy(line, bstr("prefix"));
1122 extract_token(buf, bstr("line"), i, ',', sizeof buf);
1125 strcat(line, bstr("suffix"));
1132 FlushIgnetCfgs(&WC->CurRoom);
1135 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1139 * Known rooms list (box style)
1143 DeleteHash(&WC->Rooms);
1144 output_headers(1, 1, 1, 0, 0, 0);
1145 do_template("knrooms");
1166 /*******************************************************************************
1167 ********************** FLOOR Coomands *****************************************
1168 ******************************************************************************/
1173 * delete the actual floor
1175 void delete_floor(void) {
1180 floornum = ibstr("floornum");
1182 serv_printf("KFLR %d|1", floornum);
1184 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1186 if (GetServerStatus(Buf, NULL) == 2) {
1187 StrBufPlain(Buf, _("Floor has been deleted."),-1);
1190 StrBufCutLeft(Buf, 4);
1192 AppendImportantMessage (SKEY(Buf));
1195 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1200 * start creating a new floor
1202 void create_floor(void) {
1207 serv_printf("CFLR %s|1", bstr("floorname"));
1208 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1210 if (GetServerStatus(Buf, NULL) == 2) {
1211 StrBufPlain(Buf, _("New floor has been created."),-1);
1214 StrBufCutLeft(Buf, 4);
1216 AppendImportantMessage (SKEY(Buf));
1218 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1226 void rename_floor(void) {
1232 serv_printf("EFLR %d|%s", ibstr("floornum"), bstr("floorname"));
1233 StrBuf_ServGetln(Buf);
1235 StrBufCutLeft(Buf, 4);
1236 AppendImportantMessage (SKEY(Buf));
1238 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1244 void jsonRoomFlr(void)
1246 /* Send as our own (application/json) content type */
1247 hprintf("HTTP/1.1 200 OK\r\n");
1248 hprintf("Content-type: application/json; charset=utf-8\r\n");
1249 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
1250 hprintf("Connection: close\r\n");
1251 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
1253 DoTemplate(HKEY("json_roomflr"),NULL,&NoCtx);
1257 void _FlushRoomList(wcsession *WCC)
1259 free_march_list(WCC);
1260 DeleteHash(&WCC->Floors);
1261 DeleteHash(&WCC->Rooms);
1262 DeleteHash(&WCC->FloorsByName);
1263 FlushFolder(&WCC->CurRoom);
1266 void ReloadCurrentRoom(void)
1268 wcsession *WCC = WC;
1271 CurRoom = WCC->CurRoom.name;
1272 WCC->CurRoom.name = NULL;
1273 _FlushRoomList(WCC);
1275 FreeStrBuf(&CurRoom);
1278 void FlushRoomlist(void)
1280 wcsession *WCC = WC;
1281 _FlushRoomList(WCC);
1289 RegisterPreference("roomlistview",
1290 _("Room list view"),
1293 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
1296 WebcitAddUrlHandler(HKEY("json_roomflr"), "", 0, jsonRoomFlr, 0);
1298 WebcitAddUrlHandler(HKEY("delete_floor"), "", 0, delete_floor, 0);
1299 WebcitAddUrlHandler(HKEY("rename_floor"), "", 0, rename_floor, 0);
1300 WebcitAddUrlHandler(HKEY("create_floor"), "", 0, create_floor, 0);
1302 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, ANONYMOUS);
1303 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
1304 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
1306 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
1307 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
1308 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
1309 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
1311 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
1312 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
1313 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
1314 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
1315 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
1316 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
1319 REGISTERTokenParamDefine(QR_PERMANENT);
1320 REGISTERTokenParamDefine(QR_INUSE);
1321 REGISTERTokenParamDefine(QR_PRIVATE);
1322 REGISTERTokenParamDefine(QR_PASSWORDED);
1323 REGISTERTokenParamDefine(QR_GUESSNAME);
1324 REGISTERTokenParamDefine(QR_DIRECTORY);
1325 REGISTERTokenParamDefine(QR_UPLOAD);
1326 REGISTERTokenParamDefine(QR_DOWNLOAD);
1327 REGISTERTokenParamDefine(QR_VISDIR);
1328 REGISTERTokenParamDefine(QR_ANONONLY);
1329 REGISTERTokenParamDefine(QR_ANONOPT);
1330 REGISTERTokenParamDefine(QR_NETWORK);
1331 REGISTERTokenParamDefine(QR_PREFONLY);
1332 REGISTERTokenParamDefine(QR_READONLY);
1333 REGISTERTokenParamDefine(QR_MAILBOX);
1334 REGISTERTokenParamDefine(QR2_SYSTEM);
1335 REGISTERTokenParamDefine(QR2_SELFLIST);
1336 REGISTERTokenParamDefine(QR2_COLLABDEL);
1337 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
1338 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
1339 REGISTERTokenParamDefine(QR2_MODERATED);
1341 REGISTERTokenParamDefine(UA_KNOWN);
1342 REGISTERTokenParamDefine(UA_GOTOALLOWED);
1343 REGISTERTokenParamDefine(UA_HASNEWMSGS);
1344 REGISTERTokenParamDefine(UA_ZAPPED);
1345 REGISTERTokenParamDefine(UA_POSTALLOWED);
1346 REGISTERTokenParamDefine(UA_ADMINALLOWED);
1347 REGISTERTokenParamDefine(UA_DELETEALLOWED);
1348 REGISTERTokenParamDefine(UA_ISTRASH);
1350 REGISTERTokenParamDefine(US_NEEDVALID);
1351 REGISTERTokenParamDefine(US_PERM);
1352 REGISTERTokenParamDefine(US_LASTOLD);
1353 REGISTERTokenParamDefine(US_EXPERT);
1354 REGISTERTokenParamDefine(US_UNLISTED);
1355 REGISTERTokenParamDefine(US_NOPROMPT);
1356 REGISTERTokenParamDefine(US_PROMPTCTL);
1357 REGISTERTokenParamDefine(US_DISAPPEAR);
1358 REGISTERTokenParamDefine(US_REGIS);
1359 REGISTERTokenParamDefine(US_PAGINATOR);
1360 REGISTERTokenParamDefine(US_INTERNET);
1361 REGISTERTokenParamDefine(US_FLOORS);
1362 REGISTERTokenParamDefine(US_COLOR);
1363 REGISTERTokenParamDefine(US_USER_SET);
1365 REGISTERTokenParamDefine(VIEW_BBS);
1366 REGISTERTokenParamDefine(VIEW_MAILBOX);
1367 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
1368 REGISTERTokenParamDefine(VIEW_CALENDAR);
1369 REGISTERTokenParamDefine(VIEW_TASKS);
1370 REGISTERTokenParamDefine(VIEW_NOTES);
1371 REGISTERTokenParamDefine(VIEW_WIKI);
1372 REGISTERTokenParamDefine(VIEW_CALBRIEF);
1373 REGISTERTokenParamDefine(VIEW_JOURNAL);
1374 REGISTERTokenParamDefine(VIEW_BLOG);
1377 /* server internal, we need to know but ignore them. */
1378 REGISTERTokenParamDefine(subpending);
1379 REGISTERTokenParamDefine(unsubpending);
1380 REGISTERTokenParamDefine(lastsent);
1382 REGISTERTokenParamDefine(ignet_push_share);
1383 { /* these are the parts of an IGNET push config */
1384 REGISTERTokenParamDefine(GNET_IGNET_NODE);
1385 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
1387 REGISTERTokenParamDefine(listrecp);
1388 REGISTERTokenParamDefine(digestrecp);
1389 REGISTERTokenParamDefine(pop3client);
1390 { /* These are the parts of a pop3 client line... */
1391 REGISTERTokenParamDefine(GNET_POP3_HOST);
1392 REGISTERTokenParamDefine(GNET_POP3_USER);
1393 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
1394 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
1396 REGISTERTokenParamDefine(rssclient);
1397 REGISTERTokenParamDefine(participate);
1405 SessionDestroyModule_ROOMOPS
1408 _FlushRoomList (sess);