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)
490 StrBuf_ServGetln(Buf);
491 if (GetServerStatus(Buf, NULL) != 2) {
492 FlushStrBuf(Room->XAPass);
493 FlushStrBuf(Room->Directory);
494 StrBufCutLeft(Buf, 4);
495 AppendImportantMessage (SKEY(Buf));
501 Pos = ChrPtr(Buf) + 4;
503 FreeStrBuf(&Room->XAPass);
504 FreeStrBuf(&Room->Directory);
506 Room->XAPass = NewStrBufPlain (NULL, StrLength (Buf));
507 Room->Directory = NewStrBufPlain (NULL, StrLength (Buf));
509 FreeStrBuf(&Room->name);
510 Room->name = NewStrBufPlain(NULL, StrLength(Buf));
511 StrBufExtract_NextToken(Room->name, Buf, &Pos, '|');
513 StrBufExtract_NextToken(Room->XAPass, Buf, &Pos, '|');
514 StrBufExtract_NextToken(Room->Directory, Buf, &Pos, '|');
516 Room->QRFlags = StrBufExtractNext_long(Buf, &Pos, '|');
517 Room->floorid = StrBufExtractNext_long(Buf, &Pos, '|');
518 Room->Order = StrBufExtractNext_long(Buf, &Pos, '|');
519 Room->defview = StrBufExtractNext_long(Buf, &Pos, '|');
520 Room->QRFlags2 = StrBufExtractNext_long(Buf, &Pos, '|');
528 int SetCurrentRoomFlags(folder *Room)
533 DBG_QR(Room->QRFlags);
534 DBG_QR2(Room->QRFlags2);
536 serv_printf("SETR %s|%s|%s|%ld|%d|%d|%ld|%ld|%ld",
538 ChrPtr(Room->XAPass),
539 ChrPtr(Room->Directory),
547 StrBuf_ServGetln(Buf);
548 if (GetServerStatus(Buf, NULL) != 2) {
549 StrBufCutLeft(Buf, 4);
550 AppendImportantMessage (SKEY(Buf));
559 void LoadRoomXA (void)
563 if (WCC->CurRoom.XALoaded)
566 GetCurrentRoomFlags(&WCC->CurRoom);
570 void LoadXRoomPic(void)
575 if (WCC->CurRoom.XHaveRoomPicLoaded)
578 WCC->CurRoom.XHaveRoomPicLoaded = 1;
580 serv_puts("OIMG _roompic_");
581 StrBuf_ServGetln(Buf);
582 if (GetServerStatus(Buf, NULL) != 2) {
583 WCC->CurRoom.XHaveRoomPic = 0;
585 WCC->CurRoom.XHaveRoomPic = 1;
588 StrBuf_ServGetln(Buf);
589 GetServerStatus(Buf, NULL);
594 void LoadXRoomInfoText(void)
600 if (WCC->CurRoom.XHaveInfoTextLoaded) {
604 WCC->CurRoom.XHaveInfoTextLoaded = 1;
609 StrBuf_ServGetln(Buf);
610 if (GetServerStatus(Buf, NULL) == 1) {
611 WCC->CurRoom.XInfoText = NewStrBuf ();
613 while (!Done && StrBuf_ServGetln(Buf)>=0) {
614 if ( (StrLength(Buf)==3) &&
615 !strcmp(ChrPtr(Buf), "000"))
618 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
626 void LoadXRoomXCountFiles(void)
632 if (WCC->CurRoom.XHaveDownloadCount)
635 WCC->CurRoom.XHaveDownloadCount = 1;
639 StrBuf_ServGetln(Buf);
640 if (GetServerStatus(Buf, NULL) == 1) {
642 while (!Done && StrBuf_ServGetln(Buf)>=0) {
643 if ( (StrLength(Buf)==3) &&
644 !strcmp(ChrPtr(Buf), "000"))
647 WCC->CurRoom.XDownloadCount++;
656 * Toggle self-service list subscription
658 void toggle_self_service(void) {
661 if (GetCurrentRoomFlags (&WCC->CurRoom) == 0)
664 if (yesbstr("QR2_SelfList"))
665 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SELFLIST;
667 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SELFLIST;
669 if (yesbstr("QR2_SMTP_PUBLIC"))
670 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
672 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
674 if (yesbstr("QR2_Moderated"))
675 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_MODERATED;
677 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_MODERATED;
678 if (yesbstr("QR2_SubsOnly"))
679 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
681 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
683 SetCurrentRoomFlags (&WCC->CurRoom);
685 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
691 * save new parameters for a room
697 const StrBuf *er_name;
698 const StrBuf *er_password;
699 const StrBuf *er_dirname;
700 const StrBuf *er_roomaide;
705 if (!havebstr("ok_button")) {
706 AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
707 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
710 if (GetCurrentRoomFlags (&WCC->CurRoom) == 0)
715 er_flags = WCC->CurRoom.QRFlags;
716 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
718 er_flags2 = WCC->CurRoom.QRFlags2;
721 if (!strcmp(ChrPtr(Ptr), "invonly")) {
722 er_flags |= (QR_PRIVATE);
724 if (!strcmp(ChrPtr(Ptr), "hidden")) {
725 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
727 if (!strcmp(ChrPtr(Ptr), "passworded")) {
728 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
730 if (!strcmp(ChrPtr(Ptr), "personal")) {
731 er_flags |= QR_MAILBOX;
733 er_flags &= ~QR_MAILBOX;
738 if (yesbstr("prefonly")) {
739 er_flags |= QR_PREFONLY;
741 er_flags &= ~QR_PREFONLY;
744 if (yesbstr("readonly")) {
745 er_flags |= QR_READONLY;
747 er_flags &= ~QR_READONLY;
751 if (yesbstr("collabdel")) {
752 er_flags2 |= QR2_COLLABDEL;
754 er_flags2 &= ~QR2_COLLABDEL;
757 if (yesbstr("permanent")) {
758 er_flags |= QR_PERMANENT;
760 er_flags &= ~QR_PERMANENT;
763 if (yesbstr("subjectreq")) {
764 er_flags2 |= QR2_SUBJECTREQ;
766 er_flags2 &= ~QR2_SUBJECTREQ;
769 if (yesbstr("network")) {
770 er_flags |= QR_NETWORK;
772 er_flags &= ~QR_NETWORK;
775 if (yesbstr("directory")) {
776 er_flags |= QR_DIRECTORY;
778 er_flags &= ~QR_DIRECTORY;
781 if (yesbstr("ulallowed")) {
782 er_flags |= QR_UPLOAD;
784 er_flags &= ~QR_UPLOAD;
787 if (yesbstr("dlallowed")) {
788 er_flags |= QR_DOWNLOAD;
790 er_flags &= ~QR_DOWNLOAD;
793 if (yesbstr("visdir")) {
794 er_flags |= QR_VISDIR;
796 er_flags &= ~QR_VISDIR;
802 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
803 if (!strcmp(ChrPtr(Ptr), "anononly"))
804 er_flags |= QR_ANONONLY;
805 if (!strcmp(ChrPtr(Ptr), "anon2"))
806 er_flags |= QR_ANONOPT;
808 er_name = sbstr("er_name");
809 er_dirname = sbstr("er_dirname");
810 er_roomaide = sbstr("er_roomaide");
811 er_password = sbstr("er_password");
813 FlushStrBuf(WCC->CurRoom.name);
814 StrBufAppendBuf(WCC->CurRoom.name, er_name, 0);
816 FlushStrBuf(WCC->CurRoom.Directory);
817 StrBufAppendBuf(WCC->CurRoom.Directory, er_dirname, 0);
819 FlushStrBuf(WCC->CurRoom.RoomAide);
820 StrBufAppendBuf(WCC->CurRoom.RoomAide, er_roomaide, 0);
822 FlushStrBuf(WCC->CurRoom.XAPass);
823 StrBufAppendBuf(WCC->CurRoom.XAPass, er_password, 0);
825 WCC->CurRoom.BumpUsers = yesbstr("bump");
827 WCC->CurRoom.floorid = ibstr("er_floor");
829 succ1 = SetCurrentRoomFlags(&WCC->CurRoom);
831 succ2 = SaveRoomAide (&WCC->CurRoom);
833 if (succ1 + succ2 == 0)
834 AppendImportantMessage (_("Your changes have been saved."), -1);
835 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
842 * Display form for Invite, Kick, and show Who Knows a room
844 void do_invt_kick(void)
847 const StrBuf *UserNames;
852 if (GetCurrentRoomFlags(&WCC->CurRoom) == 1)
855 UserNames = sbstr("username");
856 Kick = havebstr("kick_button");
857 Invite = havebstr("invite_button");
859 User = NewStrBufPlain(NULL, StrLength(UserNames));
862 Pos = ChrPtr(UserNames);
863 while (Pos != StrBufNOTNULL)
865 StrBufExtract_NextToken(User, UserNames, &Pos, ',');
867 if ((StrLength(User) > 0) && (Kick))
869 serv_printf("KICK %s", ChrPtr(User));
870 if (StrBuf_ServGetln(Buf) < 0)
872 if (GetServerStatus(Buf, NULL) != 2) {
873 StrBufCutLeft(Buf, 4);
874 AppendImportantMessage(SKEY(Buf));
877 _("User '%s' kicked out of room '%s'."),
879 ChrPtr(WCC->CurRoom.name)
881 AppendImportantMessage(SKEY(Buf));
884 else if ((StrLength(User) > 0) && (Invite))
886 serv_printf("INVT %s", ChrPtr(User));
887 if (StrBuf_ServGetln(Buf) < 0)
889 if (GetServerStatus(Buf, NULL) != 2) {
890 StrBufCutLeft(Buf, 4);
891 AppendImportantMessage(SKEY(Buf));
894 _("User '%s' invited to room '%s'."),
896 ChrPtr(WCC->CurRoom.name)
898 AppendImportantMessage(SKEY(Buf));
904 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
914 const StrBuf *er_name;
915 const StrBuf *er_type;
916 const StrBuf *er_password;
922 if (!havebstr("ok_button")) {
923 AppendImportantMessage(_("Cancelled. No new room was created."), -1);
927 er_name = sbstr("er_name");
928 er_type = sbstr("type");
929 er_password = sbstr("er_password");
930 er_floor = ibstr("er_floor");
931 er_view = ibstr("er_view");
934 if (!strcmp(ChrPtr(er_type), "hidden"))
936 else if (!strcmp(ChrPtr(er_type), "passworded"))
938 else if (!strcmp(ChrPtr(er_type), "invonly"))
940 else if (!strcmp(ChrPtr(er_type), "personal"))
943 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
952 StrBuf_ServGetln(Line);
953 if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
958 /** TODO: Room created, now update the left hand icon bar for this user */
961 serv_printf("VIEW %d", er_view);
962 StrBuf_ServGetln(Line);
963 FreeStrBuf(&Line); /* TODO: should we care about errors? */
964 WCC->CurRoom.view = er_view;
966 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
967 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
969 smart_goto(WCC->CurRoom.name);
979 * Change the view for this room
981 void change_view(void) {
985 newview = lbstr("view");
986 serv_printf("VIEW %d", newview);
987 serv_getln(buf, sizeof buf);
988 WC->CurRoom.view = newview;
989 smart_goto(WC->CurRoom.name);
995 * Set the message expire policy for this room and/or floor
997 void set_room_policy(void) {
1000 if (!havebstr("ok_button")) {
1001 AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
1002 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1007 serv_printf("SPEX roompolicy|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
1008 StrBuf_ServGetln(Line);
1009 GetServerStatusMsg(Line, NULL, 1, 0);
1010 if (WC->axlevel >= 6) {
1011 serv_printf("SPEX floorpolicy|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
1012 StrBuf_ServGetln(Line);
1013 GetServerStatusMsg(Line, NULL, 1, 0);
1016 ReloadCurrentRoom();
1017 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1023 * Perform changes to a room's network configuration
1025 void netedit(void) {
1037 /*/ TODO: do line dynamic! */
1038 if (havebstr("line_pop3host")) {
1039 strcpy(line, bstr("prefix"));
1040 strcat(line, bstr("line_pop3host"));
1042 strcat(line, bstr("line_pop3user"));
1044 strcat(line, bstr("line_pop3pass"));
1046 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
1048 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
1049 strcat(line, bstr("suffix"));
1051 else if (havebstr("line")) {
1052 strcpy(line, bstr("prefix"));
1053 strcat(line, bstr("line"));
1054 strcat(line, bstr("suffix"));
1057 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1064 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1070 StrBuf_ServGetln(Line);
1071 if (GetServerStatus(Line, NULL) != 1) {
1073 AppendImportantMessage(SRV_STATUS_MSG(Line));
1075 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1079 /** This loop works for add *or* remove. Spiffy, eh? */
1081 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
1082 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
1083 while (!Done && StrBuf_ServGetln(Line)>=0) {
1084 if ( (StrLength(Line)==3) &&
1085 !strcmp(ChrPtr(Line), "000"))
1091 extract_token(cmpa0, ChrPtr(Line), 0, '|', sizeof cmpa0);
1092 extract_token(cmpa1, ChrPtr(Line), 1, '|', sizeof cmpa1);
1093 if ( (strcasecmp(cmpa0, cmpb0))
1094 || (strcasecmp(cmpa1, cmpb1)) ) {
1095 StrBufAppendBufPlain(Line, HKEY("\n"), 0);
1096 fwrite(SKEY(Line), 1, fp);
1103 StrBuf_ServGetln(Line);
1104 if (GetServerStatus(Line, NULL) != 4) {
1106 AppendImportantMessage(SRV_STATUS_MSG(Line));
1107 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1112 while (fgets(buf, sizeof buf, fp) != NULL) {
1113 buf[strlen(buf)-1] = 0;
1117 if (havebstr("add_button")) {
1118 num_addrs = num_tokens(bstr("line"), ',');
1119 if (num_addrs < 2) {
1120 /* just adding one node or address */
1124 /* adding multiple addresses separated by commas */
1125 for (i=0; i<num_addrs; ++i) {
1126 strcpy(line, bstr("prefix"));
1127 extract_token(buf, bstr("line"), i, ',', sizeof buf);
1130 strcat(line, bstr("suffix"));
1138 FlushIgnetCfgs(&WC->CurRoom);
1141 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1145 * Known rooms list (box style)
1149 DeleteHash(&WC->Rooms);
1150 output_headers(1, 1, 1, 0, 0, 0);
1151 do_template("knrooms");
1172 /*******************************************************************************
1173 ********************** FLOOR Coomands *****************************************
1174 ******************************************************************************/
1179 * delete the actual floor
1181 void delete_floor(void) {
1186 floornum = ibstr("floornum");
1188 serv_printf("KFLR %d|1", floornum);
1190 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1192 if (GetServerStatus(Buf, NULL) == 2) {
1193 StrBufPlain(Buf, _("Floor has been deleted."),-1);
1196 StrBufCutLeft(Buf, 4);
1198 AppendImportantMessage (SKEY(Buf));
1201 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1206 * start creating a new floor
1208 void create_floor(void) {
1213 serv_printf("CFLR %s|1", bstr("floorname"));
1214 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1216 if (GetServerStatus(Buf, NULL) == 2) {
1217 StrBufPlain(Buf, _("New floor has been created."),-1);
1220 StrBufCutLeft(Buf, 4);
1222 AppendImportantMessage (SKEY(Buf));
1224 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1232 void rename_floor(void) {
1238 serv_printf("EFLR %d|%s", ibstr("floornum"), bstr("floorname"));
1239 StrBuf_ServGetln(Buf);
1241 StrBufCutLeft(Buf, 4);
1242 AppendImportantMessage (SKEY(Buf));
1244 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1250 void jsonRoomFlr(void)
1252 /* Send as our own (application/json) content type */
1253 hprintf("HTTP/1.1 200 OK\r\n");
1254 hprintf("Content-type: application/json; charset=utf-8\r\n");
1255 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
1256 hprintf("Connection: close\r\n");
1257 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
1259 DoTemplate(HKEY("json_roomflr"),NULL,&NoCtx);
1263 void _FlushRoomList(wcsession *WCC)
1265 free_march_list(WCC);
1266 DeleteHash(&WCC->Floors);
1267 DeleteHash(&WCC->Rooms);
1268 DeleteHash(&WCC->FloorsByName);
1269 FlushFolder(&WCC->CurRoom);
1272 void ReloadCurrentRoom(void)
1274 wcsession *WCC = WC;
1277 CurRoom = WCC->CurRoom.name;
1278 WCC->CurRoom.name = NULL;
1279 _FlushRoomList(WCC);
1281 FreeStrBuf(&CurRoom);
1284 void FlushRoomlist(void)
1286 wcsession *WCC = WC;
1287 _FlushRoomList(WCC);
1295 RegisterPreference("roomlistview",
1296 _("Room list view"),
1299 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
1302 WebcitAddUrlHandler(HKEY("json_roomflr"), "", 0, jsonRoomFlr, 0);
1304 WebcitAddUrlHandler(HKEY("delete_floor"), "", 0, delete_floor, 0);
1305 WebcitAddUrlHandler(HKEY("rename_floor"), "", 0, rename_floor, 0);
1306 WebcitAddUrlHandler(HKEY("create_floor"), "", 0, create_floor, 0);
1308 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, ANONYMOUS);
1309 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
1310 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
1312 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
1313 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
1314 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
1315 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
1317 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
1318 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
1319 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
1320 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
1321 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
1322 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
1325 REGISTERTokenParamDefine(QR_PERMANENT);
1326 REGISTERTokenParamDefine(QR_INUSE);
1327 REGISTERTokenParamDefine(QR_PRIVATE);
1328 REGISTERTokenParamDefine(QR_PASSWORDED);
1329 REGISTERTokenParamDefine(QR_GUESSNAME);
1330 REGISTERTokenParamDefine(QR_DIRECTORY);
1331 REGISTERTokenParamDefine(QR_UPLOAD);
1332 REGISTERTokenParamDefine(QR_DOWNLOAD);
1333 REGISTERTokenParamDefine(QR_VISDIR);
1334 REGISTERTokenParamDefine(QR_ANONONLY);
1335 REGISTERTokenParamDefine(QR_ANONOPT);
1336 REGISTERTokenParamDefine(QR_NETWORK);
1337 REGISTERTokenParamDefine(QR_PREFONLY);
1338 REGISTERTokenParamDefine(QR_READONLY);
1339 REGISTERTokenParamDefine(QR_MAILBOX);
1340 REGISTERTokenParamDefine(QR2_SYSTEM);
1341 REGISTERTokenParamDefine(QR2_SELFLIST);
1342 REGISTERTokenParamDefine(QR2_COLLABDEL);
1343 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
1344 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
1345 REGISTERTokenParamDefine(QR2_MODERATED);
1347 REGISTERTokenParamDefine(UA_KNOWN);
1348 REGISTERTokenParamDefine(UA_GOTOALLOWED);
1349 REGISTERTokenParamDefine(UA_HASNEWMSGS);
1350 REGISTERTokenParamDefine(UA_ZAPPED);
1351 REGISTERTokenParamDefine(UA_POSTALLOWED);
1352 REGISTERTokenParamDefine(UA_ADMINALLOWED);
1353 REGISTERTokenParamDefine(UA_DELETEALLOWED);
1354 REGISTERTokenParamDefine(UA_ISTRASH);
1356 REGISTERTokenParamDefine(US_NEEDVALID);
1357 REGISTERTokenParamDefine(US_PERM);
1358 REGISTERTokenParamDefine(US_LASTOLD);
1359 REGISTERTokenParamDefine(US_EXPERT);
1360 REGISTERTokenParamDefine(US_UNLISTED);
1361 REGISTERTokenParamDefine(US_NOPROMPT);
1362 REGISTERTokenParamDefine(US_PROMPTCTL);
1363 REGISTERTokenParamDefine(US_DISAPPEAR);
1364 REGISTERTokenParamDefine(US_REGIS);
1365 REGISTERTokenParamDefine(US_PAGINATOR);
1366 REGISTERTokenParamDefine(US_INTERNET);
1367 REGISTERTokenParamDefine(US_FLOORS);
1368 REGISTERTokenParamDefine(US_COLOR);
1369 REGISTERTokenParamDefine(US_USER_SET);
1371 REGISTERTokenParamDefine(VIEW_BBS);
1372 REGISTERTokenParamDefine(VIEW_MAILBOX);
1373 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
1374 REGISTERTokenParamDefine(VIEW_CALENDAR);
1375 REGISTERTokenParamDefine(VIEW_TASKS);
1376 REGISTERTokenParamDefine(VIEW_NOTES);
1377 REGISTERTokenParamDefine(VIEW_WIKI);
1378 REGISTERTokenParamDefine(VIEW_CALBRIEF);
1379 REGISTERTokenParamDefine(VIEW_JOURNAL);
1380 REGISTERTokenParamDefine(VIEW_BLOG);
1383 /* server internal, we need to know but ignore them. */
1384 REGISTERTokenParamDefine(subpending);
1385 REGISTERTokenParamDefine(unsubpending);
1386 REGISTERTokenParamDefine(lastsent);
1388 REGISTERTokenParamDefine(ignet_push_share);
1389 { /* these are the parts of an IGNET push config */
1390 REGISTERTokenParamDefine(GNET_IGNET_NODE);
1391 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
1393 REGISTERTokenParamDefine(listrecp);
1394 REGISTERTokenParamDefine(digestrecp);
1395 REGISTERTokenParamDefine(pop3client);
1396 { /* These are the parts of a pop3 client line... */
1397 REGISTERTokenParamDefine(GNET_POP3_HOST);
1398 REGISTERTokenParamDefine(GNET_POP3_USER);
1399 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
1400 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
1402 REGISTERTokenParamDefine(rssclient);
1403 REGISTERTokenParamDefine(participate);
1411 SessionDestroyModule_ROOMOPS
1414 _FlushRoomList (sess);