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 ******************************************************************************/
117 if (!havebstr("room")) {
118 readloop(readnew, eUseDefault);
121 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
124 smart_goto(sbstr("room"));
130 void smart_goto(const StrBuf *next_room) {
132 readloop(readnew, eUseDefault);
136 * goto a private room
138 void goto_private(void)
142 const StrBuf *gr_name;
145 if (!havebstr("ok_button")) {
149 gr_name = sbstr("gr_name");
151 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
152 serv_printf("GOTO %s|%s",
155 StrBuf_ServGetln(Buf);
156 if (GetServerStatus(Buf, &err) == 2) {
163 DoTemplate(HKEY("room_display_private"), NULL, &NoCtx);
167 StrBufCutLeft(Buf, 4);
168 AppendImportantMessage (SKEY(Buf));
169 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
176 * back end routine to take the session to a new room
178 long gotoroom(const StrBuf *gname)
182 static long ls = (-1L);
185 /* store ungoto information */
186 if (StrLength(gname) > 0)
187 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
191 /* move to the new room */
192 if (StrLength(gname) > 0)
193 serv_printf("GOTO %s", ChrPtr(gname));
194 else /* or just refresh the current state... */
195 serv_printf("GOTO 00000000000000000000");
196 StrBuf_ServGetln(Buf);
197 if (GetServerStatus(Buf, &err) != 2) {
198 serv_puts("GOTO _BASEROOM_");
199 StrBuf_ServGetln(Buf);
201 * well, we know that this is the fallback case,
202 * but we're interested that the first command
203 * didn't work out in first place.
205 if (GetServerStatus(Buf, NULL) != 2) {
210 FlushFolder(&WCC->CurRoom);
211 ParseGoto(&WCC->CurRoom, Buf);
213 if (StrLength(gname) > 0)
215 remove_march(WCC->CurRoom.name);
216 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
226 void ParseGoto(folder *room, StrBuf *Line)
234 if (StrLength(Line) < 4) {
238 /* ignore the commandstate... */
239 Pos = ChrPtr(Line) + 4;
241 if (room->RoomNameParts != NULL)
244 for (i=0; i < room->nRoomNameParts; i++)
245 FreeStrBuf(&room->RoomNameParts[i]);
246 free(room->RoomNameParts);
247 room->RoomNameParts = NULL;
252 pBuf = NewStrBufPlain(NULL, StrLength(Line));
255 memset(room, 0, sizeof(folder));
258 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
260 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
261 if (room->nNewMessages > 0)
262 room->RAFlags |= UA_HASNEWMSGS;
264 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
266 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
268 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
270 DBG_QR(room->QRFlags);
272 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
273 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
275 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
277 flag = StrBufExtractNext_long(Line, &Pos, '|');
278 if (WCC->is_aide || flag) {
279 room->RAFlags |= UA_ADMINALLOWED;
282 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
284 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
286 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
288 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
290 flag = StrBufExtractNext_long(Line, &Pos, '|');
292 room->RAFlags |= UA_ISTRASH; // wc_is_trash
294 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
295 DBG_QR2(room->QRFlags2);
297 /* find out, whether we are in a sub-room */
298 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
299 if (room->nRoomNameParts > 1)
304 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
305 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
306 for (i=0; i < room->nRoomNameParts; i++)
308 room->RoomNameParts[i] = NewStrBuf();
309 StrBufExtract_NextToken(room->RoomNameParts[i],
310 room->name, &Pos, '\\');
314 /* Private mailboxes on the main floor get remapped to the personal folder */
315 if ((room->QRFlags & QR_MAILBOX) &&
316 (room->floorid == 0))
318 room->floorid = VIRTUAL_MY_FLOOR;
319 if ((room->nRoomNameParts == 1) &&
320 (StrLength(room->name) == 4) &&
321 (strcmp(ChrPtr(room->name), "Mail") == 0))
327 /* get a pointer to the floor we're on: */
328 if (WCC->Floors == NULL)
329 GetFloorListHash(NULL, NULL);
331 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
332 room->Floor = (const Floor*) vFloor;
336 * \brief Delete the current room
338 void delete_room(void)
344 serv_getln(buf, sizeof buf);
347 strcpy(WC->ImportantMessage, &buf[4]);
354 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
366 StrBuf *final_destination;
369 * If the forget-room routine fails for any reason, we fall back
370 * to the current room; otherwise, we go to the Lobby
372 final_destination = NewStrBufDup(WC->CurRoom.name);
374 if (havebstr("ok_button")) {
375 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
376 serv_getln(buf, sizeof buf);
379 serv_getln(buf, sizeof buf);
381 FlushStrBuf(final_destination);
382 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
387 smart_goto(final_destination);
388 FreeStrBuf(&final_destination);
393 * mark all messages in current room as having been read
395 void slrp_highest(void)
399 serv_puts("SLRP HIGHEST");
400 serv_getln(buf, sizeof buf);
416 /*******************************************************************************
417 ***************************** Modify Rooms ************************************
418 ******************************************************************************/
424 void LoadRoomAide(void)
429 if (WCC->CurRoom.RoomAideLoaded)
432 WCC->CurRoom.RoomAideLoaded = 1;
435 StrBuf_ServGetln(Buf);
436 if (GetServerStatus(Buf, NULL) != 2) {
437 FlushStrBuf(WCC->CurRoom.RoomAide);
438 AppendImportantMessage (ChrPtr(Buf) + 4,
443 Pos = ChrPtr(Buf) + 4;
445 FreeStrBuf(&WCC->CurRoom.RoomAide);
446 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
448 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
453 int SaveRoomAide(folder *Room)
457 serv_printf("SETA %s", ChrPtr(Room->RoomAide));
458 StrBuf_ServGetln(Buf);
459 if (GetServerStatus(Buf, NULL) != 2) {
460 StrBufCutLeft(Buf, 4);
461 AppendImportantMessage (SKEY(Buf));
470 int GetCurrentRoomFlags(folder *Room)
476 StrBuf_ServGetln(Buf);
477 if (GetServerStatus(Buf, NULL) != 2) {
478 FlushStrBuf(Room->XAPass);
479 FlushStrBuf(Room->Directory);
480 StrBufCutLeft(Buf, 4);
481 AppendImportantMessage (SKEY(Buf));
487 Pos = ChrPtr(Buf) + 4;
489 FreeStrBuf(&Room->XAPass);
490 FreeStrBuf(&Room->Directory);
492 Room->XAPass = NewStrBufPlain (NULL, StrLength (Buf));
493 Room->Directory = NewStrBufPlain (NULL, StrLength (Buf));
495 FreeStrBuf(&Room->name);
496 Room->name = NewStrBufPlain(NULL, StrLength(Buf));
497 StrBufExtract_NextToken(Room->name, Buf, &Pos, '|');
499 StrBufExtract_NextToken(Room->XAPass, Buf, &Pos, '|');
500 StrBufExtract_NextToken(Room->Directory, Buf, &Pos, '|');
502 Room->QRFlags = StrBufExtractNext_long(Buf, &Pos, '|');
503 Room->floorid = StrBufExtractNext_long(Buf, &Pos, '|');
504 Room->Order = StrBufExtractNext_long(Buf, &Pos, '|');
505 Room->defview = StrBufExtractNext_long(Buf, &Pos, '|');
506 Room->QRFlags2 = StrBufExtractNext_long(Buf, &Pos, '|');
514 int SetCurrentRoomFlags(folder *Room)
519 DBG_QR(Room->QRFlags);
520 DBG_QR2(Room->QRFlags2);
522 serv_printf("SETR %s|%s|%s|%ld|%d|%d|%ld|%ld|%ld",
524 ChrPtr(Room->XAPass),
525 ChrPtr(Room->Directory),
533 StrBuf_ServGetln(Buf);
534 if (GetServerStatus(Buf, NULL) != 2) {
535 StrBufCutLeft(Buf, 4);
536 AppendImportantMessage (SKEY(Buf));
545 void LoadRoomXA (void)
549 if (WCC->CurRoom.XALoaded)
552 GetCurrentRoomFlags(&WCC->CurRoom);
556 void LoadXRoomPic(void)
561 if (WCC->CurRoom.XHaveRoomPicLoaded)
564 WCC->CurRoom.XHaveRoomPicLoaded = 1;
566 serv_puts("OIMG _roompic_");
567 StrBuf_ServGetln(Buf);
568 if (GetServerStatus(Buf, NULL) != 2) {
569 WCC->CurRoom.XHaveRoomPic = 0;
571 WCC->CurRoom.XHaveRoomPic = 1;
574 StrBuf_ServGetln(Buf);
575 GetServerStatus(Buf, NULL);
580 void LoadXRoomInfoText(void)
586 if (WCC->CurRoom.XHaveInfoTextLoaded) {
590 WCC->CurRoom.XHaveInfoTextLoaded = 1;
595 StrBuf_ServGetln(Buf);
596 if (GetServerStatus(Buf, NULL) == 1) {
597 WCC->CurRoom.XInfoText = NewStrBuf ();
599 while (!Done && StrBuf_ServGetln(Buf)>=0) {
600 if ( (StrLength(Buf)==3) &&
601 !strcmp(ChrPtr(Buf), "000"))
604 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
612 void LoadXRoomXCountFiles(void)
618 if (WCC->CurRoom.XHaveDownloadCount)
621 WCC->CurRoom.XHaveDownloadCount = 1;
625 StrBuf_ServGetln(Buf);
626 if (GetServerStatus(Buf, NULL) == 1) {
628 while (!Done && StrBuf_ServGetln(Buf)>=0) {
629 if ( (StrLength(Buf)==3) &&
630 !strcmp(ChrPtr(Buf), "000"))
633 WCC->CurRoom.XDownloadCount++;
642 * Toggle self-service list subscription
644 void toggle_self_service(void) {
647 if (GetCurrentRoomFlags (&WCC->CurRoom) == 0)
650 if (yesbstr("QR2_SelfList"))
651 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SELFLIST;
653 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SELFLIST;
655 if (yesbstr("QR2_SMTP_PUBLIC"))
656 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
658 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
660 if (yesbstr("QR2_Moderated"))
661 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_MODERATED;
663 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_MODERATED;
664 if (yesbstr("QR2_SubsOnly"))
665 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
667 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
669 SetCurrentRoomFlags (&WCC->CurRoom);
671 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
677 * save new parameters for a room
683 const StrBuf *er_name;
684 const StrBuf *er_password;
685 const StrBuf *er_dirname;
686 const StrBuf *er_roomaide;
691 if (!havebstr("ok_button")) {
692 strcpy(WC->ImportantMessage,
693 _("Cancelled. Changes were not saved."));
694 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
697 if (GetCurrentRoomFlags (&WCC->CurRoom) == 0)
702 er_flags = WCC->CurRoom.QRFlags;
703 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
705 er_flags2 = WCC->CurRoom.QRFlags2;
708 if (!strcmp(ChrPtr(Ptr), "invonly")) {
709 er_flags |= (QR_PRIVATE);
711 if (!strcmp(ChrPtr(Ptr), "hidden")) {
712 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
714 if (!strcmp(ChrPtr(Ptr), "passworded")) {
715 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
717 if (!strcmp(ChrPtr(Ptr), "personal")) {
718 er_flags |= QR_MAILBOX;
720 er_flags &= ~QR_MAILBOX;
725 if (yesbstr("prefonly")) {
726 er_flags |= QR_PREFONLY;
728 er_flags &= ~QR_PREFONLY;
731 if (yesbstr("readonly")) {
732 er_flags |= QR_READONLY;
734 er_flags &= ~QR_READONLY;
738 if (yesbstr("collabdel")) {
739 er_flags2 |= QR2_COLLABDEL;
741 er_flags2 &= ~QR2_COLLABDEL;
744 if (yesbstr("permanent")) {
745 er_flags |= QR_PERMANENT;
747 er_flags &= ~QR_PERMANENT;
750 if (yesbstr("subjectreq")) {
751 er_flags2 |= QR2_SUBJECTREQ;
753 er_flags2 &= ~QR2_SUBJECTREQ;
756 if (yesbstr("network")) {
757 er_flags |= QR_NETWORK;
759 er_flags &= ~QR_NETWORK;
762 if (yesbstr("directory")) {
763 er_flags |= QR_DIRECTORY;
765 er_flags &= ~QR_DIRECTORY;
768 if (yesbstr("ulallowed")) {
769 er_flags |= QR_UPLOAD;
771 er_flags &= ~QR_UPLOAD;
774 if (yesbstr("dlallowed")) {
775 er_flags |= QR_DOWNLOAD;
777 er_flags &= ~QR_DOWNLOAD;
780 if (yesbstr("visdir")) {
781 er_flags |= QR_VISDIR;
783 er_flags &= ~QR_VISDIR;
789 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
790 if (!strcmp(ChrPtr(Ptr), "anononly"))
791 er_flags |= QR_ANONONLY;
792 if (!strcmp(ChrPtr(Ptr), "anon2"))
793 er_flags |= QR_ANONOPT;
795 er_name = sbstr("er_name");
796 er_dirname = sbstr("er_dirname");
797 er_roomaide = sbstr("er_roomaide");
798 er_password = sbstr("er_password");
800 FlushStrBuf(WCC->CurRoom.name);
801 StrBufAppendBuf(WCC->CurRoom.name, er_name, 0);
803 FlushStrBuf(WCC->CurRoom.Directory);
804 StrBufAppendBuf(WCC->CurRoom.Directory, er_dirname, 0);
806 FlushStrBuf(WCC->CurRoom.RoomAide);
807 StrBufAppendBuf(WCC->CurRoom.RoomAide, er_roomaide, 0);
809 FlushStrBuf(WCC->CurRoom.XAPass);
810 StrBufAppendBuf(WCC->CurRoom.XAPass, er_password, 0);
812 WCC->CurRoom.BumpUsers = yesbstr("bump");
814 WCC->CurRoom.floorid = ibstr("er_floor");
816 succ1 = SetCurrentRoomFlags(&WCC->CurRoom);
818 succ2 = SaveRoomAide (&WCC->CurRoom);
820 if (succ1 + succ2 == 0)
821 AppendImportantMessage (_("Your changes have been saved."), -1);
822 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
829 * Display form for Invite, Kick, and show Who Knows a room
831 void do_invt_kick(void)
834 const StrBuf *UserNames;
839 if (GetCurrentRoomFlags(&WCC->CurRoom) == 1)
842 UserNames = sbstr("username");
843 Kick = havebstr("kick_button");
844 Invite = havebstr("invite_button");
846 User = NewStrBufPlain(NULL, StrLength(UserNames));
849 Pos = ChrPtr(UserNames);
850 while (Pos != StrBufNOTNULL)
852 StrBufExtract_NextToken(User, UserNames, &Pos, ',');
854 if ((StrLength(User) > 0) && (Kick))
856 serv_printf("KICK %s", ChrPtr(User));
857 StrBuf_ServGetln(Buf);
858 if (GetServerStatus(Buf, NULL) != 2) {
859 StrBufCutLeft(Buf, 4);
860 AppendImportantMessage(SKEY(Buf));
863 _("User '%s' kicked out of room '%s'."),
865 ChrPtr(WCC->CurRoom.name)
867 AppendImportantMessage(SKEY(Buf));
870 else if ((StrLength(User) > 0) && (Invite))
872 serv_printf("INVT %s", ChrPtr(User));
873 StrBuf_ServGetln(Buf);
874 if (GetServerStatus(Buf, NULL) != 2) {
875 StrBufCutLeft(Buf, 4);
876 AppendImportantMessage(SKEY(Buf));
879 _("User '%s' invited to room '%s'."),
881 ChrPtr(WCC->CurRoom.name)
883 AppendImportantMessage(SKEY(Buf));
889 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
899 const StrBuf *er_name;
900 const StrBuf *er_type;
901 const StrBuf *er_password;
907 if (!havebstr("ok_button")) {
908 strcpy(WC->ImportantMessage,
909 _("Cancelled. No new room was created."));
913 er_name = sbstr("er_name");
914 er_type = sbstr("type");
915 er_password = sbstr("er_password");
916 er_floor = ibstr("er_floor");
917 er_view = ibstr("er_view");
920 if (!strcmp(ChrPtr(er_type), "hidden"))
922 else if (!strcmp(ChrPtr(er_type), "passworded"))
924 else if (!strcmp(ChrPtr(er_type), "invonly"))
926 else if (!strcmp(ChrPtr(er_type), "personal"))
929 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
937 serv_getln(buf, sizeof buf);
939 strcpy(WCC->ImportantMessage, &buf[4]);
943 /** TODO: Room created, now update the left hand icon bar for this user */
946 serv_printf("VIEW %d", er_view);
947 serv_getln(buf, sizeof buf);
948 WCC->CurRoom.view = er_view;
950 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
951 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
953 smart_goto(WCC->CurRoom.name);
963 * Change the view for this room
965 void change_view(void) {
969 newview = lbstr("view");
970 serv_printf("VIEW %d", newview);
971 serv_getln(buf, sizeof buf);
972 WC->CurRoom.view = newview;
973 smart_goto(WC->CurRoom.name);
979 * \brief Set the message expire policy for this room and/or floor
981 void set_room_policy(void) {
984 if (!havebstr("ok_button")) {
985 strcpy(WC->ImportantMessage,
986 _("Cancelled. Changes were not saved."));
987 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
991 serv_printf("SPEX roompolicy|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
992 serv_getln(buf, sizeof buf);
993 strcpy(WC->ImportantMessage, &buf[4]);
995 if (WC->axlevel >= 6) {
996 strcat(WC->ImportantMessage, "<br>\n");
997 serv_printf("SPEX floorpolicy|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
998 serv_getln(buf, sizeof buf);
999 strcat(WC->ImportantMessage, &buf[4]);
1001 ReloadCurrentRoom();
1002 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
1008 * \brief Perform changes to a room's network configuration
1010 void netedit(void) {
1022 /*/ TODO: do line dynamic! */
1023 if (havebstr("line_pop3host")) {
1024 strcpy(line, bstr("prefix"));
1025 strcat(line, bstr("line_pop3host"));
1027 strcat(line, bstr("line_pop3user"));
1029 strcat(line, bstr("line_pop3pass"));
1031 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
1033 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
1034 strcat(line, bstr("suffix"));
1036 else if (havebstr("line")) {
1037 strcpy(line, bstr("prefix"));
1038 strcat(line, bstr("line"));
1039 strcat(line, bstr("suffix"));
1042 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
1049 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
1055 StrBuf_ServGetln(Line);
1056 if (GetServerStatus(Line, NULL) != 1) {
1058 AppendImportantMessage(SRV_STATUS_MSG(Line));
1060 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
1064 /** This loop works for add *or* remove. Spiffy, eh? */
1066 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
1067 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
1068 while (!Done && StrBuf_ServGetln(Line)>=0) {
1069 if ( (StrLength(Line)==3) &&
1070 !strcmp(ChrPtr(Line), "000"))
1076 extract_token(cmpa0, ChrPtr(Line), 0, '|', sizeof cmpa0);
1077 extract_token(cmpa1, ChrPtr(Line), 1, '|', sizeof cmpa1);
1078 if ( (strcasecmp(cmpa0, cmpb0))
1079 || (strcasecmp(cmpa1, cmpb1)) ) {
1080 StrBufAppendBufPlain(Line, HKEY("\n"), 0);
1081 fwrite(SKEY(Line), 1, fp);
1088 StrBuf_ServGetln(Line);
1089 if (GetServerStatus(Line, NULL) != 4) {
1091 AppendImportantMessage(SRV_STATUS_MSG(Line));
1092 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
1097 while (fgets(buf, sizeof buf, fp) != NULL) {
1098 buf[strlen(buf)-1] = 0;
1102 if (havebstr("add_button")) {
1103 num_addrs = num_tokens(bstr("line"), ',');
1104 if (num_addrs < 2) {
1105 /* just adding one node or address */
1109 /* adding multiple addresses separated by commas */
1110 for (i=0; i<num_addrs; ++i) {
1111 strcpy(line, bstr("prefix"));
1112 extract_token(buf, bstr("line"), i, ',', sizeof buf);
1115 strcat(line, bstr("suffix"));
1123 FlushIgnetCfgs(&WC->CurRoom);
1126 http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0);
1130 * Known rooms list (box style)
1134 DeleteHash(&WC->Rooms);
1135 output_headers(1, 1, 1, 0, 0, 0);
1136 do_template("knrooms", NULL);
1157 /*******************************************************************************
1158 ********************** FLOOR Coomands *****************************************
1159 ******************************************************************************/
1164 * delete the actual floor
1166 void delete_floor(void) {
1171 floornum = ibstr("floornum");
1173 serv_printf("KFLR %d|1", floornum);
1175 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1177 if (GetServerStatus(Buf, NULL) == 2) {
1178 StrBufPlain(Buf, _("Floor has been deleted."),-1);
1181 StrBufCutLeft(Buf, 4);
1183 AppendImportantMessage (SKEY(Buf));
1186 http_transmit_thing(ChrPtr(do_template("floors", NULL)), 0);
1191 * start creating a new floor
1193 void create_floor(void) {
1198 serv_printf("CFLR %s|1", bstr("floorname"));
1199 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1201 if (GetServerStatus(Buf, NULL) == 2) {
1202 StrBufPlain(Buf, _("New floor has been created."),-1);
1205 StrBufCutLeft(Buf, 4);
1207 AppendImportantMessage (SKEY(Buf));
1209 http_transmit_thing(ChrPtr(do_template("floors", NULL)), 0);
1217 void rename_floor(void) {
1223 serv_printf("EFLR %d|%s", ibstr("floornum"), bstr("floorname"));
1224 StrBuf_ServGetln(Buf);
1226 StrBufCutLeft(Buf, 4);
1227 AppendImportantMessage (SKEY(Buf));
1229 http_transmit_thing(ChrPtr(do_template("floors", NULL)), 0);
1235 void jsonRoomFlr(void)
1237 /* Send as our own (application/json) content type */
1238 hprintf("HTTP/1.1 200 OK\r\n");
1239 hprintf("Content-type: application/json; charset=utf-8\r\n");
1240 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
1241 hprintf("Connection: close\r\n");
1242 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
1244 DoTemplate(HKEY("json_roomflr"),NULL,&NoCtx);
1248 void _FlushRoomList(wcsession *WCC)
1250 free_march_list(WCC);
1251 DeleteHash(&WCC->Floors);
1252 DeleteHash(&WCC->Rooms);
1253 DeleteHash(&WCC->FloorsByName);
1254 FlushFolder(&WCC->CurRoom);
1257 void ReloadCurrentRoom(void)
1259 wcsession *WCC = WC;
1262 CurRoom = WCC->CurRoom.name;
1263 WCC->CurRoom.name = NULL;
1264 _FlushRoomList(WCC);
1266 FreeStrBuf(&CurRoom);
1269 void FlushRoomlist(void)
1271 wcsession *WCC = WC;
1272 _FlushRoomList(WCC);
1280 RegisterPreference("roomlistview",
1281 _("Room list view"),
1284 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
1287 WebcitAddUrlHandler(HKEY("json_roomflr"), "", 0, jsonRoomFlr, 0);
1289 WebcitAddUrlHandler(HKEY("delete_floor"), "", 0, delete_floor, 0);
1290 WebcitAddUrlHandler(HKEY("rename_floor"), "", 0, rename_floor, 0);
1291 WebcitAddUrlHandler(HKEY("create_floor"), "", 0, create_floor, 0);
1293 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, ANONYMOUS);
1294 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
1295 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
1297 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
1298 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
1299 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
1300 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
1302 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
1303 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
1304 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
1305 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
1306 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
1307 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
1310 REGISTERTokenParamDefine(QR_PERMANENT);
1311 REGISTERTokenParamDefine(QR_INUSE);
1312 REGISTERTokenParamDefine(QR_PRIVATE);
1313 REGISTERTokenParamDefine(QR_PASSWORDED);
1314 REGISTERTokenParamDefine(QR_GUESSNAME);
1315 REGISTERTokenParamDefine(QR_DIRECTORY);
1316 REGISTERTokenParamDefine(QR_UPLOAD);
1317 REGISTERTokenParamDefine(QR_DOWNLOAD);
1318 REGISTERTokenParamDefine(QR_VISDIR);
1319 REGISTERTokenParamDefine(QR_ANONONLY);
1320 REGISTERTokenParamDefine(QR_ANONOPT);
1321 REGISTERTokenParamDefine(QR_NETWORK);
1322 REGISTERTokenParamDefine(QR_PREFONLY);
1323 REGISTERTokenParamDefine(QR_READONLY);
1324 REGISTERTokenParamDefine(QR_MAILBOX);
1325 REGISTERTokenParamDefine(QR2_SYSTEM);
1326 REGISTERTokenParamDefine(QR2_SELFLIST);
1327 REGISTERTokenParamDefine(QR2_COLLABDEL);
1328 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
1329 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
1330 REGISTERTokenParamDefine(QR2_MODERATED);
1332 REGISTERTokenParamDefine(UA_KNOWN);
1333 REGISTERTokenParamDefine(UA_GOTOALLOWED);
1334 REGISTERTokenParamDefine(UA_HASNEWMSGS);
1335 REGISTERTokenParamDefine(UA_ZAPPED);
1336 REGISTERTokenParamDefine(UA_POSTALLOWED);
1337 REGISTERTokenParamDefine(UA_ADMINALLOWED);
1338 REGISTERTokenParamDefine(UA_DELETEALLOWED);
1339 REGISTERTokenParamDefine(UA_ISTRASH);
1341 REGISTERTokenParamDefine(US_NEEDVALID);
1342 REGISTERTokenParamDefine(US_PERM);
1343 REGISTERTokenParamDefine(US_LASTOLD);
1344 REGISTERTokenParamDefine(US_EXPERT);
1345 REGISTERTokenParamDefine(US_UNLISTED);
1346 REGISTERTokenParamDefine(US_NOPROMPT);
1347 REGISTERTokenParamDefine(US_PROMPTCTL);
1348 REGISTERTokenParamDefine(US_DISAPPEAR);
1349 REGISTERTokenParamDefine(US_REGIS);
1350 REGISTERTokenParamDefine(US_PAGINATOR);
1351 REGISTERTokenParamDefine(US_INTERNET);
1352 REGISTERTokenParamDefine(US_FLOORS);
1353 REGISTERTokenParamDefine(US_COLOR);
1354 REGISTERTokenParamDefine(US_USER_SET);
1356 REGISTERTokenParamDefine(VIEW_BBS);
1357 REGISTERTokenParamDefine(VIEW_MAILBOX);
1358 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
1359 REGISTERTokenParamDefine(VIEW_CALENDAR);
1360 REGISTERTokenParamDefine(VIEW_TASKS);
1361 REGISTERTokenParamDefine(VIEW_NOTES);
1362 REGISTERTokenParamDefine(VIEW_WIKI);
1363 REGISTERTokenParamDefine(VIEW_CALBRIEF);
1364 REGISTERTokenParamDefine(VIEW_JOURNAL);
1365 REGISTERTokenParamDefine(VIEW_BLOG);
1368 /* server internal, we need to know but ignore them. */
1369 REGISTERTokenParamDefine(subpending);
1370 REGISTERTokenParamDefine(unsubpending);
1371 REGISTERTokenParamDefine(lastsent);
1373 REGISTERTokenParamDefine(ignet_push_share);
1374 { /* these are the parts of an IGNET push config */
1375 REGISTERTokenParamDefine(GNET_IGNET_NODE);
1376 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
1378 REGISTERTokenParamDefine(listrecp);
1379 REGISTERTokenParamDefine(digestrecp);
1380 REGISTERTokenParamDefine(pop3client);
1381 { /* These are the parts of a pop3 client line... */
1382 REGISTERTokenParamDefine(GNET_POP3_HOST);
1383 REGISTERTokenParamDefine(GNET_POP3_USER);
1384 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
1385 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
1387 REGISTERTokenParamDefine(rssclient);
1388 REGISTERTokenParamDefine(participate);
1396 SessionDestroyModule_ROOMOPS
1399 _FlushRoomList (sess);