2 * Lots of different room-related operations.
4 * Copyright (c) 1996-2012 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, version 3.
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.
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)
357 StrBuf *Line = NewStrBuf();
358 const StrBuf *GoBstr;
360 GoBstr = sbstr("go");
364 if (gotoroom(GoBstr) == 200)
367 StrBuf_ServGetln(Line);
368 if (GetServerStatusMsg(Line, NULL, 1, 2) == 2) {
372 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
390 StrBuf *final_destination;
393 * If the forget-room routine fails for any reason, we fall back
394 * to the current room; otherwise, we go to the Lobby
396 final_destination = NewStrBufDup(WC->CurRoom.name);
398 if (havebstr("ok_button")) {
399 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
400 serv_getln(buf, sizeof buf);
403 serv_getln(buf, sizeof buf);
405 FlushStrBuf(final_destination);
406 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
411 smart_goto(final_destination);
412 FreeStrBuf(&final_destination);
417 * mark all messages in current room as having been read
419 void slrp_highest(void)
423 serv_puts("SLRP HIGHEST");
424 serv_getln(buf, sizeof buf);
440 /*******************************************************************************
441 ***************************** Modify Rooms ************************************
442 ******************************************************************************/
448 void LoadRoomAide(void)
453 if (WCC->CurRoom.RoomAideLoaded)
456 WCC->CurRoom.RoomAideLoaded = 1;
459 StrBuf_ServGetln(Buf);
460 if (GetServerStatus(Buf, NULL) != 2) {
461 FlushStrBuf(WCC->CurRoom.RoomAide);
462 AppendImportantMessage (ChrPtr(Buf) + 4,
467 Pos = ChrPtr(Buf) + 4;
469 FreeStrBuf(&WCC->CurRoom.RoomAide);
470 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
472 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
477 int SaveRoomAide(folder *Room)
481 serv_printf("SETA %s", ChrPtr(Room->RoomAide));
482 StrBuf_ServGetln(Buf);
483 if (GetServerStatus(Buf, NULL) != 2) {
484 StrBufCutLeft(Buf, 4);
485 AppendImportantMessage (SKEY(Buf));
494 int GetCurrentRoomFlags(folder *Room, int CareForStatusMessage)
500 StrBuf_ServGetln(Buf);
501 if (GetServerStatus(Buf, NULL) != 2) {
502 FlushStrBuf(Room->XAPass);
503 FlushStrBuf(Room->Directory);
504 StrBufCutLeft(Buf, 4);
505 if (CareForStatusMessage)
506 AppendImportantMessage (SKEY(Buf));
513 Pos = ChrPtr(Buf) + 4;
515 FreeStrBuf(&Room->XAPass);
516 FreeStrBuf(&Room->Directory);
518 Room->XAPass = NewStrBufPlain (NULL, StrLength (Buf));
519 Room->Directory = NewStrBufPlain (NULL, StrLength (Buf));
521 FreeStrBuf(&Room->name);
522 Room->name = NewStrBufPlain(NULL, StrLength(Buf));
523 StrBufExtract_NextToken(Room->name, Buf, &Pos, '|');
525 StrBufExtract_NextToken(Room->XAPass, Buf, &Pos, '|');
526 StrBufExtract_NextToken(Room->Directory, Buf, &Pos, '|');
528 Room->QRFlags = StrBufExtractNext_long(Buf, &Pos, '|');
529 Room->floorid = StrBufExtractNext_long(Buf, &Pos, '|');
530 Room->Order = StrBufExtractNext_long(Buf, &Pos, '|');
531 Room->defview = StrBufExtractNext_long(Buf, &Pos, '|');
532 Room->QRFlags2 = StrBufExtractNext_long(Buf, &Pos, '|');
540 int SetCurrentRoomFlags(folder *Room)
545 DBG_QR(Room->QRFlags);
546 DBG_QR2(Room->QRFlags2);
548 serv_printf("SETR %s|%s|%s|%ld|%d|%d|%ld|%ld|%ld",
550 ChrPtr(Room->XAPass),
551 ChrPtr(Room->Directory),
559 StrBuf_ServGetln(Buf);
560 if (GetServerStatus(Buf, NULL) != 2) {
561 StrBufCutLeft(Buf, 4);
562 AppendImportantMessage (SKEY(Buf));
571 void LoadRoomXA (void)
575 if (WCC->CurRoom.XALoaded > 0)
578 GetCurrentRoomFlags(&WCC->CurRoom, 0);
582 void LoadXRoomPic(void)
587 if (WCC->CurRoom.XHaveRoomPicLoaded)
590 WCC->CurRoom.XHaveRoomPicLoaded = 1;
592 serv_puts("OIMG _roompic_");
593 StrBuf_ServGetln(Buf);
594 if (GetServerStatus(Buf, NULL) != 2) {
595 WCC->CurRoom.XHaveRoomPic = 0;
597 WCC->CurRoom.XHaveRoomPic = 1;
600 StrBuf_ServGetln(Buf);
601 GetServerStatus(Buf, NULL);
606 void LoadXRoomInfoText(void)
612 if (WCC->CurRoom.XHaveInfoTextLoaded) {
616 WCC->CurRoom.XHaveInfoTextLoaded = 1;
621 StrBuf_ServGetln(Buf);
622 if (GetServerStatus(Buf, NULL) == 1) {
623 WCC->CurRoom.XInfoText = NewStrBuf ();
625 while (!Done && StrBuf_ServGetln(Buf)>=0) {
626 if ( (StrLength(Buf)==3) &&
627 !strcmp(ChrPtr(Buf), "000"))
630 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
638 void LoadXRoomXCountFiles(void)
644 if (WCC->CurRoom.XHaveDownloadCount)
647 WCC->CurRoom.XHaveDownloadCount = 1;
651 StrBuf_ServGetln(Buf);
652 if (GetServerStatus(Buf, NULL) == 1) {
654 while (!Done && StrBuf_ServGetln(Buf)>=0) {
655 if ( (StrLength(Buf)==3) &&
656 !strcmp(ChrPtr(Buf), "000"))
659 WCC->CurRoom.XDownloadCount++;
668 * Toggle self-service list subscription
670 void toggle_self_service(void) {
673 if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0)
676 if (yesbstr("QR2_SelfList"))
677 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SELFLIST;
679 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SELFLIST;
681 if (yesbstr("QR2_SMTP_PUBLIC"))
682 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
684 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
686 if (yesbstr("QR2_Moderated"))
687 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_MODERATED;
689 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_MODERATED;
690 if (yesbstr("QR2_SubsOnly"))
691 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
693 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
695 SetCurrentRoomFlags (&WCC->CurRoom);
697 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
703 * save new parameters for a room
709 const StrBuf *er_name;
710 const StrBuf *er_password;
711 const StrBuf *er_dirname;
712 const StrBuf *er_roomaide;
717 if (!havebstr("ok_button")) {
718 AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
719 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
722 if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0) {
723 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
729 er_flags = WCC->CurRoom.QRFlags;
730 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
732 er_flags2 = WCC->CurRoom.QRFlags2;
735 if (!strcmp(ChrPtr(Ptr), "invonly")) {
736 er_flags |= (QR_PRIVATE);
738 if (!strcmp(ChrPtr(Ptr), "hidden")) {
739 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
741 if (!strcmp(ChrPtr(Ptr), "passworded")) {
742 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
744 if (!strcmp(ChrPtr(Ptr), "personal")) {
745 er_flags |= QR_MAILBOX;
747 er_flags &= ~QR_MAILBOX;
752 if (yesbstr("prefonly")) {
753 er_flags |= QR_PREFONLY;
755 er_flags &= ~QR_PREFONLY;
758 if (yesbstr("readonly")) {
759 er_flags |= QR_READONLY;
761 er_flags &= ~QR_READONLY;
765 if (yesbstr("collabdel")) {
766 er_flags2 |= QR2_COLLABDEL;
768 er_flags2 &= ~QR2_COLLABDEL;
771 if (yesbstr("permanent")) {
772 er_flags |= QR_PERMANENT;
774 er_flags &= ~QR_PERMANENT;
777 if (yesbstr("subjectreq")) {
778 er_flags2 |= QR2_SUBJECTREQ;
780 er_flags2 &= ~QR2_SUBJECTREQ;
783 if (yesbstr("network")) {
784 er_flags |= QR_NETWORK;
786 er_flags &= ~QR_NETWORK;
789 if (yesbstr("directory")) {
790 er_flags |= QR_DIRECTORY;
792 er_flags &= ~QR_DIRECTORY;
795 if (yesbstr("ulallowed")) {
796 er_flags |= QR_UPLOAD;
798 er_flags &= ~QR_UPLOAD;
801 if (yesbstr("dlallowed")) {
802 er_flags |= QR_DOWNLOAD;
804 er_flags &= ~QR_DOWNLOAD;
807 if (yesbstr("visdir")) {
808 er_flags |= QR_VISDIR;
810 er_flags &= ~QR_VISDIR;
816 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
817 if (!strcmp(ChrPtr(Ptr), "anononly"))
818 er_flags |= QR_ANONONLY;
819 if (!strcmp(ChrPtr(Ptr), "anon2"))
820 er_flags |= QR_ANONOPT;
822 er_name = sbstr("er_name");
823 er_dirname = sbstr("er_dirname");
824 er_roomaide = sbstr("er_roomaide");
825 er_password = sbstr("er_password");
827 FlushStrBuf(WCC->CurRoom.name);
828 StrBufAppendBuf(WCC->CurRoom.name, er_name, 0);
830 FlushStrBuf(WCC->CurRoom.Directory);
831 StrBufAppendBuf(WCC->CurRoom.Directory, er_dirname, 0);
833 FlushStrBuf(WCC->CurRoom.RoomAide);
834 StrBufAppendBuf(WCC->CurRoom.RoomAide, er_roomaide, 0);
836 FlushStrBuf(WCC->CurRoom.XAPass);
837 StrBufAppendBuf(WCC->CurRoom.XAPass, er_password, 0);
839 WCC->CurRoom.BumpUsers = yesbstr("bump");
841 WCC->CurRoom.floorid = ibstr("er_floor");
843 succ1 = SetCurrentRoomFlags(&WCC->CurRoom);
845 succ2 = SaveRoomAide (&WCC->CurRoom);
847 if (succ1 + succ2 == 0)
848 AppendImportantMessage (_("Your changes have been saved."), -1);
849 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
856 * Display form for Invite, Kick, and show Who Knows a room
858 void do_invt_kick(void)
861 const StrBuf *UserNames;
866 if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 1)
869 UserNames = sbstr("username");
870 Kick = havebstr("kick_button");
871 Invite = havebstr("invite_button");
873 User = NewStrBufPlain(NULL, StrLength(UserNames));
876 Pos = ChrPtr(UserNames);
877 while (Pos != StrBufNOTNULL)
879 StrBufExtract_NextToken(User, UserNames, &Pos, ',');
881 if ((StrLength(User) > 0) && (Kick))
883 serv_printf("KICK %s", ChrPtr(User));
884 if (StrBuf_ServGetln(Buf) < 0)
886 if (GetServerStatus(Buf, NULL) != 2) {
887 StrBufCutLeft(Buf, 4);
888 AppendImportantMessage(SKEY(Buf));
891 _("User '%s' kicked out of room '%s'."),
893 ChrPtr(WCC->CurRoom.name)
895 AppendImportantMessage(SKEY(Buf));
898 else if ((StrLength(User) > 0) && (Invite))
900 serv_printf("INVT %s", ChrPtr(User));
901 if (StrBuf_ServGetln(Buf) < 0)
903 if (GetServerStatus(Buf, NULL) != 2) {
904 StrBufCutLeft(Buf, 4);
905 AppendImportantMessage(SKEY(Buf));
908 _("User '%s' invited to room '%s'."),
910 ChrPtr(WCC->CurRoom.name)
912 AppendImportantMessage(SKEY(Buf));
918 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
928 const StrBuf *er_name;
929 const StrBuf *er_type;
930 const StrBuf *er_password;
936 if (!havebstr("ok_button")) {
937 AppendImportantMessage(_("Cancelled. No new room was created."), -1);
941 er_name = sbstr("er_name");
942 er_type = sbstr("type");
943 er_password = sbstr("er_password");
944 er_floor = ibstr("er_floor");
945 er_view = ibstr("er_view");
948 if (!strcmp(ChrPtr(er_type), "hidden"))
950 else if (!strcmp(ChrPtr(er_type), "passworded"))
952 else if (!strcmp(ChrPtr(er_type), "invonly"))
954 else if (!strcmp(ChrPtr(er_type), "personal"))
957 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
966 StrBuf_ServGetln(Line);
967 if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
972 /** TODO: Room created, now update the left hand icon bar for this user */
975 serv_printf("VIEW %d", er_view);
976 StrBuf_ServGetln(Line);
977 FreeStrBuf(&Line); /* TODO: should we care about errors? */
978 WCC->CurRoom.view = er_view;
980 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
981 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
983 smart_goto(WCC->CurRoom.name);
993 * Change the view for this room
995 void change_view(void) {
999 newview = lbstr("view");
1000 serv_printf("VIEW %d", newview);
1001 serv_getln(buf, sizeof buf);
1002 WC->CurRoom.view = newview;
1003 smart_goto(WC->CurRoom.name);
1009 * Set the message expire policy for this room and/or floor
1011 void set_room_policy(void) {
1014 if (!havebstr("ok_button")) {
1015 AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
1016 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1021 serv_printf("SPEX roompolicy|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
1022 StrBuf_ServGetln(Line);
1023 GetServerStatusMsg(Line, NULL, 1, 0);
1024 if (WC->axlevel >= 6) {
1025 serv_printf("SPEX floorpolicy|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
1026 StrBuf_ServGetln(Line);
1027 GetServerStatusMsg(Line, NULL, 1, 0);
1030 ReloadCurrentRoom();
1031 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1037 * Perform changes to a room's network configuration
1039 void netedit(void) {
1051 if (havebstr("force_room")) {
1052 gotoroom(sbstr("force_room"));
1054 /*/ TODO: do line dynamic! */
1055 if (havebstr("line_pop3host")) {
1056 strcpy(line, bstr("prefix"));
1057 strcat(line, bstr("line_pop3host"));
1059 strcat(line, bstr("line_pop3user"));
1061 strcat(line, bstr("line_pop3pass"));
1063 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
1065 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
1066 strcat(line, bstr("suffix"));
1068 else if (havebstr("line")) {
1069 strcpy(line, bstr("prefix"));
1070 strcat(line, bstr("line"));
1071 strcat(line, bstr("suffix"));
1074 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1079 TmpBuf = NewStrBuf();
1081 StrBuf_ServGetln(Line);
1082 if (GetServerStatus(Line, NULL) != 1) {
1083 AppendImportantMessage(SRV_STATUS_MSG(Line));
1085 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1089 /** This loop works for add *or* remove. Spiffy, eh? */
1091 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
1092 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
1093 while (!Done && StrBuf_ServGetln(Line)>=0) {
1094 if ( (StrLength(Line)==3) &&
1095 !strcmp(ChrPtr(Line), "000"))
1101 extract_token(cmpa0, ChrPtr(Line), 0, '|', sizeof cmpa0);
1102 extract_token(cmpa1, ChrPtr(Line), 1, '|', sizeof cmpa1);
1103 if ( (strcasecmp(cmpa0, cmpb0))
1104 || (strcasecmp(cmpa1, cmpb1)) ) {
1105 StrBufAppendBufPlain(Line, HKEY("\n"), 0);
1106 StrBufAppendBuf(TmpBuf, Line, 0);
1112 StrBuf_ServGetln(Line);
1113 if (GetServerStatus(Line, NULL) != 4) {
1115 AppendImportantMessage(SRV_STATUS_MSG(Line));
1116 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1118 FreeStrBuf(&TmpBuf);
1122 serv_putbuf(TmpBuf);
1123 FreeStrBuf(&TmpBuf);
1125 if (havebstr("add_button")) {
1126 num_addrs = num_tokens(bstr("line"), ',');
1127 if (num_addrs < 2) {
1128 /* just adding one node or address */
1132 /* adding multiple addresses separated by commas */
1133 for (i=0; i<num_addrs; ++i) {
1134 strcpy(line, bstr("prefix"));
1135 extract_token(buf, bstr("line"), i, ',', sizeof buf);
1138 strcat(line, bstr("suffix"));
1145 FlushIgnetCfgs(&WC->CurRoom);
1148 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1152 * Known rooms list (box style)
1156 DeleteHash(&WC->Rooms);
1157 output_headers(1, 1, 1, 0, 0, 0);
1158 do_template("knrooms");
1179 /*******************************************************************************
1180 ********************** FLOOR Coomands *****************************************
1181 ******************************************************************************/
1186 * delete the actual floor
1188 void delete_floor(void) {
1193 floornum = ibstr("floornum");
1195 serv_printf("KFLR %d|1", floornum);
1197 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1199 if (GetServerStatus(Buf, NULL) == 2) {
1200 StrBufPlain(Buf, _("Floor has been deleted."),-1);
1203 StrBufCutLeft(Buf, 4);
1205 AppendImportantMessage (SKEY(Buf));
1208 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1213 * start creating a new floor
1215 void create_floor(void) {
1220 serv_printf("CFLR %s|1", bstr("floorname"));
1221 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1223 if (GetServerStatus(Buf, NULL) == 2) {
1224 StrBufPlain(Buf, _("New floor has been created."),-1);
1227 StrBufCutLeft(Buf, 4);
1229 AppendImportantMessage (SKEY(Buf));
1231 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1239 void rename_floor(void) {
1245 serv_printf("EFLR %d|%s", ibstr("floornum"), bstr("floorname"));
1246 StrBuf_ServGetln(Buf);
1248 StrBufCutLeft(Buf, 4);
1249 AppendImportantMessage (SKEY(Buf));
1251 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1257 void jsonRoomFlr(void)
1259 /* Send as our own (application/json) content type */
1260 hprintf("HTTP/1.1 200 OK\r\n");
1261 hprintf("Content-type: application/json; charset=utf-8\r\n");
1262 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
1263 hprintf("Connection: close\r\n");
1264 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
1266 DoTemplate(HKEY("json_roomflr"),NULL,&NoCtx);
1270 void _FlushRoomList(wcsession *WCC)
1272 free_march_list(WCC);
1273 DeleteHash(&WCC->Floors);
1274 DeleteHash(&WCC->Rooms);
1275 DeleteHash(&WCC->FloorsByName);
1276 FlushFolder(&WCC->CurRoom);
1279 void ReloadCurrentRoom(void)
1281 wcsession *WCC = WC;
1284 CurRoom = WCC->CurRoom.name;
1285 WCC->CurRoom.name = NULL;
1286 _FlushRoomList(WCC);
1288 FreeStrBuf(&CurRoom);
1291 void FlushRoomlist(void)
1293 wcsession *WCC = WC;
1294 _FlushRoomList(WCC);
1302 RegisterPreference("roomlistview",
1303 _("Room list view"),
1306 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
1309 WebcitAddUrlHandler(HKEY("json_roomflr"), "", 0, jsonRoomFlr, 0);
1311 WebcitAddUrlHandler(HKEY("delete_floor"), "", 0, delete_floor, 0);
1312 WebcitAddUrlHandler(HKEY("rename_floor"), "", 0, rename_floor, 0);
1313 WebcitAddUrlHandler(HKEY("create_floor"), "", 0, create_floor, 0);
1315 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, ANONYMOUS);
1316 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
1317 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
1319 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
1320 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
1321 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
1322 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
1324 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
1325 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
1326 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
1327 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
1328 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
1329 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
1332 REGISTERTokenParamDefine(QR_PERMANENT);
1333 REGISTERTokenParamDefine(QR_INUSE);
1334 REGISTERTokenParamDefine(QR_PRIVATE);
1335 REGISTERTokenParamDefine(QR_PASSWORDED);
1336 REGISTERTokenParamDefine(QR_GUESSNAME);
1337 REGISTERTokenParamDefine(QR_DIRECTORY);
1338 REGISTERTokenParamDefine(QR_UPLOAD);
1339 REGISTERTokenParamDefine(QR_DOWNLOAD);
1340 REGISTERTokenParamDefine(QR_VISDIR);
1341 REGISTERTokenParamDefine(QR_ANONONLY);
1342 REGISTERTokenParamDefine(QR_ANONOPT);
1343 REGISTERTokenParamDefine(QR_NETWORK);
1344 REGISTERTokenParamDefine(QR_PREFONLY);
1345 REGISTERTokenParamDefine(QR_READONLY);
1346 REGISTERTokenParamDefine(QR_MAILBOX);
1347 REGISTERTokenParamDefine(QR2_SYSTEM);
1348 REGISTERTokenParamDefine(QR2_SELFLIST);
1349 REGISTERTokenParamDefine(QR2_COLLABDEL);
1350 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
1351 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
1352 REGISTERTokenParamDefine(QR2_MODERATED);
1354 REGISTERTokenParamDefine(UA_KNOWN);
1355 REGISTERTokenParamDefine(UA_GOTOALLOWED);
1356 REGISTERTokenParamDefine(UA_HASNEWMSGS);
1357 REGISTERTokenParamDefine(UA_ZAPPED);
1358 REGISTERTokenParamDefine(UA_POSTALLOWED);
1359 REGISTERTokenParamDefine(UA_ADMINALLOWED);
1360 REGISTERTokenParamDefine(UA_DELETEALLOWED);
1361 REGISTERTokenParamDefine(UA_ISTRASH);
1363 REGISTERTokenParamDefine(US_NEEDVALID);
1364 REGISTERTokenParamDefine(US_PERM);
1365 REGISTERTokenParamDefine(US_LASTOLD);
1366 REGISTERTokenParamDefine(US_EXPERT);
1367 REGISTERTokenParamDefine(US_UNLISTED);
1368 REGISTERTokenParamDefine(US_NOPROMPT);
1369 REGISTERTokenParamDefine(US_PROMPTCTL);
1370 REGISTERTokenParamDefine(US_DISAPPEAR);
1371 REGISTERTokenParamDefine(US_REGIS);
1372 REGISTERTokenParamDefine(US_PAGINATOR);
1373 REGISTERTokenParamDefine(US_INTERNET);
1374 REGISTERTokenParamDefine(US_FLOORS);
1375 REGISTERTokenParamDefine(US_COLOR);
1376 REGISTERTokenParamDefine(US_USER_SET);
1378 REGISTERTokenParamDefine(VIEW_BBS);
1379 REGISTERTokenParamDefine(VIEW_MAILBOX);
1380 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
1381 REGISTERTokenParamDefine(VIEW_CALENDAR);
1382 REGISTERTokenParamDefine(VIEW_TASKS);
1383 REGISTERTokenParamDefine(VIEW_NOTES);
1384 REGISTERTokenParamDefine(VIEW_WIKI);
1385 REGISTERTokenParamDefine(VIEW_CALBRIEF);
1386 REGISTERTokenParamDefine(VIEW_JOURNAL);
1387 REGISTERTokenParamDefine(VIEW_BLOG);
1390 /* server internal, we need to know but ignore them. */
1391 REGISTERTokenParamDefine(subpending);
1392 REGISTERTokenParamDefine(unsubpending);
1393 REGISTERTokenParamDefine(lastsent);
1395 REGISTERTokenParamDefine(ignet_push_share);
1396 { /* these are the parts of an IGNET push config */
1397 REGISTERTokenParamDefine(GNET_IGNET_NODE);
1398 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
1400 REGISTERTokenParamDefine(listrecp);
1401 REGISTERTokenParamDefine(digestrecp);
1402 REGISTERTokenParamDefine(pop3client);
1403 { /* These are the parts of a pop3 client line... */
1404 REGISTERTokenParamDefine(GNET_POP3_HOST);
1405 REGISTERTokenParamDefine(GNET_POP3_USER);
1406 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
1407 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
1409 REGISTERTokenParamDefine(rssclient);
1410 REGISTERTokenParamDefine(participate);
1418 SessionDestroyModule_ROOMOPS
1421 _FlushRoomList (sess);