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);
190 /* store ungoto information */
191 if (StrLength(gname) > 0)
192 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
196 /* move to the new room */
197 if (StrLength(gname) > 0)
198 serv_printf("GOTO %s", ChrPtr(gname));
199 else /* or just refresh the current state... */
200 serv_printf("GOTO 00000000000000000000");
201 StrBuf_ServGetln(Buf);
202 if (GetServerStatus(Buf, &err) != 2) {
203 serv_puts("GOTO _BASEROOM_");
204 StrBuf_ServGetln(Buf);
206 * well, we know that this is the fallback case,
207 * but we're interested that the first command
208 * didn't work out in first place.
210 if (GetServerStatus(Buf, NULL) != 2) {
215 FlushFolder(&WCC->CurRoom);
216 ParseGoto(&WCC->CurRoom, Buf);
218 if (StrLength(gname) > 0)
220 remove_march(WCC->CurRoom.name);
221 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
231 void ParseGoto(folder *room, StrBuf *Line)
239 if (StrLength(Line) < 4) {
243 /* ignore the commandstate... */
244 Pos = ChrPtr(Line) + 4;
246 if (room->RoomNameParts != NULL)
249 for (i=0; i < room->nRoomNameParts; i++)
250 FreeStrBuf(&room->RoomNameParts[i]);
251 free(room->RoomNameParts);
252 room->RoomNameParts = NULL;
257 pBuf = NewStrBufPlain(NULL, StrLength(Line));
260 memset(room, 0, sizeof(folder));
263 StrBufExtract_NextToken(room->name, Line, &Pos, '|');
265 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
266 if (room->nNewMessages > 0)
267 room->RAFlags |= UA_HASNEWMSGS;
269 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
271 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
273 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|');
275 DBG_QR(room->QRFlags);
277 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
278 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
280 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|');
282 flag = StrBufExtractNext_long(Line, &Pos, '|');
283 if (WCC->is_aide || flag) {
284 room->RAFlags |= UA_ADMINALLOWED;
287 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
289 room->floorid = StrBufExtractNext_int(Line, &Pos, '|');
291 room->view = StrBufExtractNext_long(Line, &Pos, '|');
293 room->defview = StrBufExtractNext_long(Line, &Pos, '|');
295 flag = StrBufExtractNext_long(Line, &Pos, '|');
297 room->RAFlags |= UA_ISTRASH;
299 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|');
300 DBG_QR2(room->QRFlags2);
302 /* find out, whether we are in a sub-room */
303 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
304 if (room->nRoomNameParts > 1)
309 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
310 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
311 for (i=0; i < room->nRoomNameParts; i++)
313 room->RoomNameParts[i] = NewStrBuf();
314 StrBufExtract_NextToken(room->RoomNameParts[i],
315 room->name, &Pos, '\\');
319 /* Private mailboxes on the main floor get remapped to the personal folder */
320 if ((room->QRFlags & QR_MAILBOX) &&
321 (room->floorid == 0))
323 room->floorid = VIRTUAL_MY_FLOOR;
324 if ((room->nRoomNameParts == 1) &&
325 (StrLength(room->name) == 4) &&
326 (strcmp(ChrPtr(room->name), "Mail") == 0))
332 /* get a pointer to the floor we're on: */
333 if (WCC->Floors == NULL)
334 GetFloorListHash(NULL, NULL);
336 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
337 room->Floor = (const Floor*) vFloor;
341 * Delete the current room
343 void delete_room(void)
349 serv_getln(buf, sizeof buf);
352 strcpy(WC->ImportantMessage, &buf[4]);
359 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
371 StrBuf *final_destination;
374 * If the forget-room routine fails for any reason, we fall back
375 * to the current room; otherwise, we go to the Lobby
377 final_destination = NewStrBufDup(WC->CurRoom.name);
379 if (havebstr("ok_button")) {
380 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
381 serv_getln(buf, sizeof buf);
384 serv_getln(buf, sizeof buf);
386 FlushStrBuf(final_destination);
387 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
392 smart_goto(final_destination);
393 FreeStrBuf(&final_destination);
398 * mark all messages in current room as having been read
400 void slrp_highest(void)
404 serv_puts("SLRP HIGHEST");
405 serv_getln(buf, sizeof buf);
421 /*******************************************************************************
422 ***************************** Modify Rooms ************************************
423 ******************************************************************************/
429 void LoadRoomAide(void)
434 if (WCC->CurRoom.RoomAideLoaded)
437 WCC->CurRoom.RoomAideLoaded = 1;
440 StrBuf_ServGetln(Buf);
441 if (GetServerStatus(Buf, NULL) != 2) {
442 FlushStrBuf(WCC->CurRoom.RoomAide);
443 AppendImportantMessage (ChrPtr(Buf) + 4,
448 Pos = ChrPtr(Buf) + 4;
450 FreeStrBuf(&WCC->CurRoom.RoomAide);
451 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
453 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
458 int SaveRoomAide(folder *Room)
462 serv_printf("SETA %s", ChrPtr(Room->RoomAide));
463 StrBuf_ServGetln(Buf);
464 if (GetServerStatus(Buf, NULL) != 2) {
465 StrBufCutLeft(Buf, 4);
466 AppendImportantMessage (SKEY(Buf));
475 int GetCurrentRoomFlags(folder *Room)
481 StrBuf_ServGetln(Buf);
482 if (GetServerStatus(Buf, NULL) != 2) {
483 FlushStrBuf(Room->XAPass);
484 FlushStrBuf(Room->Directory);
485 StrBufCutLeft(Buf, 4);
486 AppendImportantMessage (SKEY(Buf));
492 Pos = ChrPtr(Buf) + 4;
494 FreeStrBuf(&Room->XAPass);
495 FreeStrBuf(&Room->Directory);
497 Room->XAPass = NewStrBufPlain (NULL, StrLength (Buf));
498 Room->Directory = NewStrBufPlain (NULL, StrLength (Buf));
500 FreeStrBuf(&Room->name);
501 Room->name = NewStrBufPlain(NULL, StrLength(Buf));
502 StrBufExtract_NextToken(Room->name, Buf, &Pos, '|');
504 StrBufExtract_NextToken(Room->XAPass, Buf, &Pos, '|');
505 StrBufExtract_NextToken(Room->Directory, Buf, &Pos, '|');
507 Room->QRFlags = StrBufExtractNext_long(Buf, &Pos, '|');
508 Room->floorid = StrBufExtractNext_long(Buf, &Pos, '|');
509 Room->Order = StrBufExtractNext_long(Buf, &Pos, '|');
510 Room->defview = StrBufExtractNext_long(Buf, &Pos, '|');
511 Room->QRFlags2 = StrBufExtractNext_long(Buf, &Pos, '|');
519 int SetCurrentRoomFlags(folder *Room)
524 DBG_QR(Room->QRFlags);
525 DBG_QR2(Room->QRFlags2);
527 serv_printf("SETR %s|%s|%s|%ld|%d|%d|%ld|%ld|%ld",
529 ChrPtr(Room->XAPass),
530 ChrPtr(Room->Directory),
538 StrBuf_ServGetln(Buf);
539 if (GetServerStatus(Buf, NULL) != 2) {
540 StrBufCutLeft(Buf, 4);
541 AppendImportantMessage (SKEY(Buf));
550 void LoadRoomXA (void)
554 if (WCC->CurRoom.XALoaded)
557 GetCurrentRoomFlags(&WCC->CurRoom);
561 void LoadXRoomPic(void)
566 if (WCC->CurRoom.XHaveRoomPicLoaded)
569 WCC->CurRoom.XHaveRoomPicLoaded = 1;
571 serv_puts("OIMG _roompic_");
572 StrBuf_ServGetln(Buf);
573 if (GetServerStatus(Buf, NULL) != 2) {
574 WCC->CurRoom.XHaveRoomPic = 0;
576 WCC->CurRoom.XHaveRoomPic = 1;
579 StrBuf_ServGetln(Buf);
580 GetServerStatus(Buf, NULL);
585 void LoadXRoomInfoText(void)
591 if (WCC->CurRoom.XHaveInfoTextLoaded) {
595 WCC->CurRoom.XHaveInfoTextLoaded = 1;
600 StrBuf_ServGetln(Buf);
601 if (GetServerStatus(Buf, NULL) == 1) {
602 WCC->CurRoom.XInfoText = NewStrBuf ();
604 while (!Done && StrBuf_ServGetln(Buf)>=0) {
605 if ( (StrLength(Buf)==3) &&
606 !strcmp(ChrPtr(Buf), "000"))
609 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
617 void LoadXRoomXCountFiles(void)
623 if (WCC->CurRoom.XHaveDownloadCount)
626 WCC->CurRoom.XHaveDownloadCount = 1;
630 StrBuf_ServGetln(Buf);
631 if (GetServerStatus(Buf, NULL) == 1) {
633 while (!Done && StrBuf_ServGetln(Buf)>=0) {
634 if ( (StrLength(Buf)==3) &&
635 !strcmp(ChrPtr(Buf), "000"))
638 WCC->CurRoom.XDownloadCount++;
647 * Toggle self-service list subscription
649 void toggle_self_service(void) {
652 if (GetCurrentRoomFlags (&WCC->CurRoom) == 0)
655 if (yesbstr("QR2_SelfList"))
656 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SELFLIST;
658 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SELFLIST;
660 if (yesbstr("QR2_SMTP_PUBLIC"))
661 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
663 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
665 if (yesbstr("QR2_Moderated"))
666 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_MODERATED;
668 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_MODERATED;
669 if (yesbstr("QR2_SubsOnly"))
670 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
672 WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
674 SetCurrentRoomFlags (&WCC->CurRoom);
676 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
682 * save new parameters for a room
688 const StrBuf *er_name;
689 const StrBuf *er_password;
690 const StrBuf *er_dirname;
691 const StrBuf *er_roomaide;
696 if (!havebstr("ok_button")) {
697 strcpy(WC->ImportantMessage,
698 _("Cancelled. Changes were not saved."));
699 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
702 if (GetCurrentRoomFlags (&WCC->CurRoom) == 0)
707 er_flags = WCC->CurRoom.QRFlags;
708 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
710 er_flags2 = WCC->CurRoom.QRFlags2;
713 if (!strcmp(ChrPtr(Ptr), "invonly")) {
714 er_flags |= (QR_PRIVATE);
716 if (!strcmp(ChrPtr(Ptr), "hidden")) {
717 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
719 if (!strcmp(ChrPtr(Ptr), "passworded")) {
720 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
722 if (!strcmp(ChrPtr(Ptr), "personal")) {
723 er_flags |= QR_MAILBOX;
725 er_flags &= ~QR_MAILBOX;
730 if (yesbstr("prefonly")) {
731 er_flags |= QR_PREFONLY;
733 er_flags &= ~QR_PREFONLY;
736 if (yesbstr("readonly")) {
737 er_flags |= QR_READONLY;
739 er_flags &= ~QR_READONLY;
743 if (yesbstr("collabdel")) {
744 er_flags2 |= QR2_COLLABDEL;
746 er_flags2 &= ~QR2_COLLABDEL;
749 if (yesbstr("permanent")) {
750 er_flags |= QR_PERMANENT;
752 er_flags &= ~QR_PERMANENT;
755 if (yesbstr("subjectreq")) {
756 er_flags2 |= QR2_SUBJECTREQ;
758 er_flags2 &= ~QR2_SUBJECTREQ;
761 if (yesbstr("network")) {
762 er_flags |= QR_NETWORK;
764 er_flags &= ~QR_NETWORK;
767 if (yesbstr("directory")) {
768 er_flags |= QR_DIRECTORY;
770 er_flags &= ~QR_DIRECTORY;
773 if (yesbstr("ulallowed")) {
774 er_flags |= QR_UPLOAD;
776 er_flags &= ~QR_UPLOAD;
779 if (yesbstr("dlallowed")) {
780 er_flags |= QR_DOWNLOAD;
782 er_flags &= ~QR_DOWNLOAD;
785 if (yesbstr("visdir")) {
786 er_flags |= QR_VISDIR;
788 er_flags &= ~QR_VISDIR;
794 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
795 if (!strcmp(ChrPtr(Ptr), "anononly"))
796 er_flags |= QR_ANONONLY;
797 if (!strcmp(ChrPtr(Ptr), "anon2"))
798 er_flags |= QR_ANONOPT;
800 er_name = sbstr("er_name");
801 er_dirname = sbstr("er_dirname");
802 er_roomaide = sbstr("er_roomaide");
803 er_password = sbstr("er_password");
805 FlushStrBuf(WCC->CurRoom.name);
806 StrBufAppendBuf(WCC->CurRoom.name, er_name, 0);
808 FlushStrBuf(WCC->CurRoom.Directory);
809 StrBufAppendBuf(WCC->CurRoom.Directory, er_dirname, 0);
811 FlushStrBuf(WCC->CurRoom.RoomAide);
812 StrBufAppendBuf(WCC->CurRoom.RoomAide, er_roomaide, 0);
814 FlushStrBuf(WCC->CurRoom.XAPass);
815 StrBufAppendBuf(WCC->CurRoom.XAPass, er_password, 0);
817 WCC->CurRoom.BumpUsers = yesbstr("bump");
819 WCC->CurRoom.floorid = ibstr("er_floor");
821 succ1 = SetCurrentRoomFlags(&WCC->CurRoom);
823 succ2 = SaveRoomAide (&WCC->CurRoom);
825 if (succ1 + succ2 == 0)
826 AppendImportantMessage (_("Your changes have been saved."), -1);
827 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
834 * Display form for Invite, Kick, and show Who Knows a room
836 void do_invt_kick(void)
839 const StrBuf *UserNames;
844 if (GetCurrentRoomFlags(&WCC->CurRoom) == 1)
847 UserNames = sbstr("username");
848 Kick = havebstr("kick_button");
849 Invite = havebstr("invite_button");
851 User = NewStrBufPlain(NULL, StrLength(UserNames));
854 Pos = ChrPtr(UserNames);
855 while (Pos != StrBufNOTNULL)
857 StrBufExtract_NextToken(User, UserNames, &Pos, ',');
859 if ((StrLength(User) > 0) && (Kick))
861 serv_printf("KICK %s", ChrPtr(User));
862 if (StrBuf_ServGetln(Buf) < 0)
864 if (GetServerStatus(Buf, NULL) != 2) {
865 StrBufCutLeft(Buf, 4);
866 AppendImportantMessage(SKEY(Buf));
869 _("User '%s' kicked out of room '%s'."),
871 ChrPtr(WCC->CurRoom.name)
873 AppendImportantMessage(SKEY(Buf));
876 else if ((StrLength(User) > 0) && (Invite))
878 serv_printf("INVT %s", ChrPtr(User));
879 if (StrBuf_ServGetln(Buf) < 0)
881 if (GetServerStatus(Buf, NULL) != 2) {
882 StrBufCutLeft(Buf, 4);
883 AppendImportantMessage(SKEY(Buf));
886 _("User '%s' invited to room '%s'."),
888 ChrPtr(WCC->CurRoom.name)
890 AppendImportantMessage(SKEY(Buf));
896 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
906 const StrBuf *er_name;
907 const StrBuf *er_type;
908 const StrBuf *er_password;
914 if (!havebstr("ok_button")) {
915 strcpy(WC->ImportantMessage,
916 _("Cancelled. No new room was created."));
920 er_name = sbstr("er_name");
921 er_type = sbstr("type");
922 er_password = sbstr("er_password");
923 er_floor = ibstr("er_floor");
924 er_view = ibstr("er_view");
927 if (!strcmp(ChrPtr(er_type), "hidden"))
929 else if (!strcmp(ChrPtr(er_type), "passworded"))
931 else if (!strcmp(ChrPtr(er_type), "invonly"))
933 else if (!strcmp(ChrPtr(er_type), "personal"))
936 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
944 serv_getln(buf, sizeof buf);
946 strcpy(WCC->ImportantMessage, &buf[4]);
950 /** TODO: Room created, now update the left hand icon bar for this user */
953 serv_printf("VIEW %d", er_view);
954 serv_getln(buf, sizeof buf);
955 WCC->CurRoom.view = er_view;
957 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
958 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
960 smart_goto(WCC->CurRoom.name);
970 * Change the view for this room
972 void change_view(void) {
976 newview = lbstr("view");
977 serv_printf("VIEW %d", newview);
978 serv_getln(buf, sizeof buf);
979 WC->CurRoom.view = newview;
980 smart_goto(WC->CurRoom.name);
986 * Set the message expire policy for this room and/or floor
988 void set_room_policy(void) {
991 if (!havebstr("ok_button")) {
992 strcpy(WC->ImportantMessage,
993 _("Cancelled. Changes were not saved."));
994 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
998 serv_printf("SPEX roompolicy|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
999 serv_getln(buf, sizeof buf);
1000 strcpy(WC->ImportantMessage, &buf[4]);
1002 if (WC->axlevel >= 6) {
1003 strcat(WC->ImportantMessage, "<br>\n");
1004 serv_printf("SPEX floorpolicy|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
1005 serv_getln(buf, sizeof buf);
1006 strcat(WC->ImportantMessage, &buf[4]);
1008 ReloadCurrentRoom();
1009 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1015 * Perform changes to a room's network configuration
1017 void netedit(void) {
1029 /*/ TODO: do line dynamic! */
1030 if (havebstr("line_pop3host")) {
1031 strcpy(line, bstr("prefix"));
1032 strcat(line, bstr("line_pop3host"));
1034 strcat(line, bstr("line_pop3user"));
1036 strcat(line, bstr("line_pop3pass"));
1038 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
1040 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
1041 strcat(line, bstr("suffix"));
1043 else if (havebstr("line")) {
1044 strcpy(line, bstr("prefix"));
1045 strcat(line, bstr("line"));
1046 strcat(line, bstr("suffix"));
1049 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1056 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1062 StrBuf_ServGetln(Line);
1063 if (GetServerStatus(Line, NULL) != 1) {
1065 AppendImportantMessage(SRV_STATUS_MSG(Line));
1067 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1071 /** This loop works for add *or* remove. Spiffy, eh? */
1073 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
1074 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
1075 while (!Done && StrBuf_ServGetln(Line)>=0) {
1076 if ( (StrLength(Line)==3) &&
1077 !strcmp(ChrPtr(Line), "000"))
1083 extract_token(cmpa0, ChrPtr(Line), 0, '|', sizeof cmpa0);
1084 extract_token(cmpa1, ChrPtr(Line), 1, '|', sizeof cmpa1);
1085 if ( (strcasecmp(cmpa0, cmpb0))
1086 || (strcasecmp(cmpa1, cmpb1)) ) {
1087 StrBufAppendBufPlain(Line, HKEY("\n"), 0);
1088 fwrite(SKEY(Line), 1, fp);
1095 StrBuf_ServGetln(Line);
1096 if (GetServerStatus(Line, NULL) != 4) {
1098 AppendImportantMessage(SRV_STATUS_MSG(Line));
1099 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1104 while (fgets(buf, sizeof buf, fp) != NULL) {
1105 buf[strlen(buf)-1] = 0;
1109 if (havebstr("add_button")) {
1110 num_addrs = num_tokens(bstr("line"), ',');
1111 if (num_addrs < 2) {
1112 /* just adding one node or address */
1116 /* adding multiple addresses separated by commas */
1117 for (i=0; i<num_addrs; ++i) {
1118 strcpy(line, bstr("prefix"));
1119 extract_token(buf, bstr("line"), i, ',', sizeof buf);
1122 strcat(line, bstr("suffix"));
1130 FlushIgnetCfgs(&WC->CurRoom);
1133 http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
1137 * Known rooms list (box style)
1141 DeleteHash(&WC->Rooms);
1142 output_headers(1, 1, 1, 0, 0, 0);
1143 do_template("knrooms");
1164 /*******************************************************************************
1165 ********************** FLOOR Coomands *****************************************
1166 ******************************************************************************/
1171 * delete the actual floor
1173 void delete_floor(void) {
1178 floornum = ibstr("floornum");
1180 serv_printf("KFLR %d|1", floornum);
1182 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1184 if (GetServerStatus(Buf, NULL) == 2) {
1185 StrBufPlain(Buf, _("Floor has been deleted."),-1);
1188 StrBufCutLeft(Buf, 4);
1190 AppendImportantMessage (SKEY(Buf));
1193 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1198 * start creating a new floor
1200 void create_floor(void) {
1205 serv_printf("CFLR %s|1", bstr("floorname"));
1206 StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
1208 if (GetServerStatus(Buf, NULL) == 2) {
1209 StrBufPlain(Buf, _("New floor has been created."),-1);
1212 StrBufCutLeft(Buf, 4);
1214 AppendImportantMessage (SKEY(Buf));
1216 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1224 void rename_floor(void) {
1230 serv_printf("EFLR %d|%s", ibstr("floornum"), bstr("floorname"));
1231 StrBuf_ServGetln(Buf);
1233 StrBufCutLeft(Buf, 4);
1234 AppendImportantMessage (SKEY(Buf));
1236 http_transmit_thing(ChrPtr(do_template("floors")), 0);
1242 void jsonRoomFlr(void)
1244 /* Send as our own (application/json) content type */
1245 hprintf("HTTP/1.1 200 OK\r\n");
1246 hprintf("Content-type: application/json; charset=utf-8\r\n");
1247 hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
1248 hprintf("Connection: close\r\n");
1249 hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
1251 DoTemplate(HKEY("json_roomflr"),NULL,&NoCtx);
1255 void _FlushRoomList(wcsession *WCC)
1257 free_march_list(WCC);
1258 DeleteHash(&WCC->Floors);
1259 DeleteHash(&WCC->Rooms);
1260 DeleteHash(&WCC->FloorsByName);
1261 FlushFolder(&WCC->CurRoom);
1264 void ReloadCurrentRoom(void)
1266 wcsession *WCC = WC;
1269 CurRoom = WCC->CurRoom.name;
1270 WCC->CurRoom.name = NULL;
1271 _FlushRoomList(WCC);
1273 FreeStrBuf(&CurRoom);
1276 void FlushRoomlist(void)
1278 wcsession *WCC = WC;
1279 _FlushRoomList(WCC);
1287 RegisterPreference("roomlistview",
1288 _("Room list view"),
1291 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
1294 WebcitAddUrlHandler(HKEY("json_roomflr"), "", 0, jsonRoomFlr, 0);
1296 WebcitAddUrlHandler(HKEY("delete_floor"), "", 0, delete_floor, 0);
1297 WebcitAddUrlHandler(HKEY("rename_floor"), "", 0, rename_floor, 0);
1298 WebcitAddUrlHandler(HKEY("create_floor"), "", 0, create_floor, 0);
1300 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, ANONYMOUS);
1301 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
1302 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
1304 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
1305 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
1306 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
1307 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
1309 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
1310 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
1311 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
1312 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
1313 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
1314 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
1317 REGISTERTokenParamDefine(QR_PERMANENT);
1318 REGISTERTokenParamDefine(QR_INUSE);
1319 REGISTERTokenParamDefine(QR_PRIVATE);
1320 REGISTERTokenParamDefine(QR_PASSWORDED);
1321 REGISTERTokenParamDefine(QR_GUESSNAME);
1322 REGISTERTokenParamDefine(QR_DIRECTORY);
1323 REGISTERTokenParamDefine(QR_UPLOAD);
1324 REGISTERTokenParamDefine(QR_DOWNLOAD);
1325 REGISTERTokenParamDefine(QR_VISDIR);
1326 REGISTERTokenParamDefine(QR_ANONONLY);
1327 REGISTERTokenParamDefine(QR_ANONOPT);
1328 REGISTERTokenParamDefine(QR_NETWORK);
1329 REGISTERTokenParamDefine(QR_PREFONLY);
1330 REGISTERTokenParamDefine(QR_READONLY);
1331 REGISTERTokenParamDefine(QR_MAILBOX);
1332 REGISTERTokenParamDefine(QR2_SYSTEM);
1333 REGISTERTokenParamDefine(QR2_SELFLIST);
1334 REGISTERTokenParamDefine(QR2_COLLABDEL);
1335 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
1336 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
1337 REGISTERTokenParamDefine(QR2_MODERATED);
1339 REGISTERTokenParamDefine(UA_KNOWN);
1340 REGISTERTokenParamDefine(UA_GOTOALLOWED);
1341 REGISTERTokenParamDefine(UA_HASNEWMSGS);
1342 REGISTERTokenParamDefine(UA_ZAPPED);
1343 REGISTERTokenParamDefine(UA_POSTALLOWED);
1344 REGISTERTokenParamDefine(UA_ADMINALLOWED);
1345 REGISTERTokenParamDefine(UA_DELETEALLOWED);
1346 REGISTERTokenParamDefine(UA_ISTRASH);
1348 REGISTERTokenParamDefine(US_NEEDVALID);
1349 REGISTERTokenParamDefine(US_PERM);
1350 REGISTERTokenParamDefine(US_LASTOLD);
1351 REGISTERTokenParamDefine(US_EXPERT);
1352 REGISTERTokenParamDefine(US_UNLISTED);
1353 REGISTERTokenParamDefine(US_NOPROMPT);
1354 REGISTERTokenParamDefine(US_PROMPTCTL);
1355 REGISTERTokenParamDefine(US_DISAPPEAR);
1356 REGISTERTokenParamDefine(US_REGIS);
1357 REGISTERTokenParamDefine(US_PAGINATOR);
1358 REGISTERTokenParamDefine(US_INTERNET);
1359 REGISTERTokenParamDefine(US_FLOORS);
1360 REGISTERTokenParamDefine(US_COLOR);
1361 REGISTERTokenParamDefine(US_USER_SET);
1363 REGISTERTokenParamDefine(VIEW_BBS);
1364 REGISTERTokenParamDefine(VIEW_MAILBOX);
1365 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
1366 REGISTERTokenParamDefine(VIEW_CALENDAR);
1367 REGISTERTokenParamDefine(VIEW_TASKS);
1368 REGISTERTokenParamDefine(VIEW_NOTES);
1369 REGISTERTokenParamDefine(VIEW_WIKI);
1370 REGISTERTokenParamDefine(VIEW_CALBRIEF);
1371 REGISTERTokenParamDefine(VIEW_JOURNAL);
1372 REGISTERTokenParamDefine(VIEW_BLOG);
1375 /* server internal, we need to know but ignore them. */
1376 REGISTERTokenParamDefine(subpending);
1377 REGISTERTokenParamDefine(unsubpending);
1378 REGISTERTokenParamDefine(lastsent);
1380 REGISTERTokenParamDefine(ignet_push_share);
1381 { /* these are the parts of an IGNET push config */
1382 REGISTERTokenParamDefine(GNET_IGNET_NODE);
1383 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
1385 REGISTERTokenParamDefine(listrecp);
1386 REGISTERTokenParamDefine(digestrecp);
1387 REGISTERTokenParamDefine(pop3client);
1388 { /* These are the parts of a pop3 client line... */
1389 REGISTERTokenParamDefine(GNET_POP3_HOST);
1390 REGISTERTokenParamDefine(GNET_POP3_USER);
1391 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
1392 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
1394 REGISTERTokenParamDefine(rssclient);
1395 REGISTERTokenParamDefine(participate);
1403 SessionDestroyModule_ROOMOPS
1406 _FlushRoomList (sess);