-/*
- * Room functions
- *
- * Copyright (c) 1996-2019 by the citadel.org team
- *
- * This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+//
+// Room functions
+//
+// Copyright (c) 1996-2021 by the citadel.org team
+//
+// This program is open source software. It runs great on the
+// Linux operating system (and probably elsewhere). You can use,
+// copy, and run it under the terms of the GNU General Public
+// License version 3.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
#include "webcit.h"
* Return a "zero-terminated" array of message numbers in the current room.
* Caller owns the memory and must free it. Returns NULL if any problems.
*/
-long *get_msglist(struct ctdlsession *c, char *which_msgs)
-{
+long *get_msglist(struct ctdlsession *c, char *which_msgs) {
char buf[1024];
long *msglist = NULL;
int num_msgs = 0;
* a message number (which we always use as the entity tag in Citadel), return nonzero if the
* message number matches any of the supplied tags in the string.
*/
-int match_etags(char *taglist, long msgnum)
-{
+int match_etags(char *taglist, long msgnum) {
int num_tags = num_tokens(taglist, ',');
int i = 0;
char tag[1024];
/*
* Client is requesting a message list
*/
-void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which)
-{
+void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which) {
int i = 0;
long *msglist = get_msglist(c, which);
JsonValue *j = NewJsonArray(HKEY("msgs"));
/*
* Client requested an object in a room.
*/
-void object_in_room(struct http_transaction *h, struct ctdlsession *c)
-{
+void object_in_room(struct http_transaction *h, struct ctdlsession *c) {
char buf[1024];
long msgnum = (-1);
char unescaped_euid[1024];
if (!strcasecmp(h->method, "DELETE")) {
dav_delete_message(h, c, msgnum);
- } else if (!strcasecmp(h->method, "GET")) {
+ }
+ else if (!strcasecmp(h->method, "GET")) {
dav_get_message(h, c, msgnum);
- } else if (!strcasecmp(h->method, "PUT")) {
+ }
+ else if (!strcasecmp(h->method, "PUT")) {
dav_put_message(h, c, unescaped_euid, msgnum);
- } else {
+ }
+ else {
do_404(h); // Got this far but the method made no sense? Bummer.
}
/*
* Called by the_room_itself() when the HTTP method is REPORT
*/
-void report_the_room_itself(struct http_transaction *h, struct ctdlsession *c)
-{
+void report_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
if (c->room_default_view == VIEW_CALENDAR) {
caldav_report(h, c); // CalDAV REPORTs ... fmgwac
return;
/*
* Called by the_room_itself() when the HTTP method is OPTIONS
*/
-void options_the_room_itself(struct http_transaction *h, struct ctdlsession *c)
-{
+void options_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
h->response_code = 200;
h->response_string = strdup("OK");
if (c->room_default_view == VIEW_CALENDAR) {
add_response_header(h, strdup("DAV"), strdup("1, calendar-access")); // offer CalDAV
- } else if (c->room_default_view == VIEW_ADDRESSBOOK) {
+ }
+ else if (c->room_default_view == VIEW_ADDRESSBOOK) {
add_response_header(h, strdup("DAV"), strdup("1, addressbook")); // offer CardDAV
- } else {
+ }
+ else {
add_response_header(h, strdup("DAV"), strdup("1")); // ordinary WebDAV for all other room types
}
add_response_header(h, strdup("Allow"), strdup("OPTIONS, PROPFIND, GET, PUT, REPORT, DELETE"));
/*
* Called by the_room_itself() when the HTTP method is PROPFIND
*/
-void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c)
-{
+void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
char *e;
long timestamp;
int dav_depth = (header_val(h, "Depth") ? atoi(header_val(h, "Depth")) : INT_MAX);
int enumerate_by_euid = 0; // nonzero if messages will be retrieved by euid instead of msgnum
switch (c->room_default_view) {
- case VIEW_CALENDAR: // RFC4791 section 5.2
- StrBufAppendPrintf(Buf,
- "<C:supported-calendar-component-set><C:comp name=\"VEVENT\"/></C:supported-calendar-component-set>");
+ case VIEW_CALENDAR: // RFC4791 section 5.2
+ StrBufAppendPrintf(Buf, "<C:supported-calendar-component-set><C:comp name=\"VEVENT\"/></C:supported-calendar-component-set>");
StrBufAppendPrintf(Buf, "<C:supported-calendar-data>");
StrBufAppendPrintf(Buf, "<C:calendar-data content-type=\"text/calendar\" version=\"2.0\"/>");
StrBufAppendPrintf(Buf, "</C:supported-calendar-data>");
enumerate_by_euid = 1;
break;
- case VIEW_TASKS: // RFC4791 section 5.2
- StrBufAppendPrintf(Buf,
- "<C:supported-calendar-component-set><C:comp name=\"VTODO\"/></C:supported-calendar-component-set>");
+ case VIEW_TASKS: // RFC4791 section 5.2
+ StrBufAppendPrintf(Buf, "<C:supported-calendar-component-set><C:comp name=\"VTODO\"/></C:supported-calendar-component-set>");
StrBufAppendPrintf(Buf, "<C:supported-calendar-data>");
StrBufAppendPrintf(Buf, "<C:calendar-data content-type=\"text/calendar\" version=\"2.0\"/>");
StrBufAppendPrintf(Buf, "</C:supported-calendar-data>");
enumerate_by_euid = 1;
break;
- case VIEW_ADDRESSBOOK: // FIXME put some sort of CardDAV crapola here when we implement it
+ case VIEW_ADDRESSBOOK: // FIXME put some sort of CardDAV crapola here when we implement it
enumerate_by_euid = 1;
break;
- case VIEW_WIKI: // FIXME invent "WikiDAV" ?
+ case VIEW_WIKI: // FIXME invent "WikiDAV" ?
enumerate_by_euid = 1;
break;
}
-
/* FIXME get the mtime
StrBufAppendPrintf(Buf, "<D:getlastmodified>");
escputs(datestring);
* Handle REST/DAV requests for the room itself (such as /ctdl/r/roomname
* or /ctdl/r/roomname/ but *not* specific objects within the room)
*/
-void the_room_itself(struct http_transaction *h, struct ctdlsession *c)
-{
- // OPTIONS method on the room itself usually is a DAV client assessing what's here.
+void the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
+ // OPTIONS method on the room itself usually is a DAV client assessing what's here.
if (!strcasecmp(h->method, "OPTIONS")) {
options_the_room_itself(h, c);
return;
}
- // PROPFIND method on the room itself could be looking for a directory
+ // PROPFIND method on the room itself could be looking for a directory
if (!strcasecmp(h->method, "PROPFIND")) {
propfind_the_room_itself(h, c);
return;
}
- // REPORT method on the room itself is probably the dreaded CalDAV tower-of-crapola
+ // REPORT method on the room itself is probably the dreaded CalDAV tower-of-crapola
if (!strcasecmp(h->method, "REPORT")) {
report_the_room_itself(h, c);
return;
}
- // GET method on the room itself is an API call, possibly from our JavaScript front end
+ // GET method on the room itself is an API call, possibly from our JavaScript front end
if (!strcasecmp(h->method, "get")) {
get_the_room_itself(h, c);
return;
}
+
// we probably want a "go to this room" for interactive access
do_404(h);
}
/*
* Dispatcher for "/ctdl/r" and "/ctdl/r/" for the room list
*/
-void room_list(struct http_transaction *h, struct ctdlsession *c)
-{
+void room_list(struct http_transaction *h, struct ctdlsession *c) {
char buf[1024];
char roomname[1024];
/*
* Dispatcher for paths starting with /ctdl/r/
*/
-void ctdl_r(struct http_transaction *h, struct ctdlsession *c)
-{
+void ctdl_r(struct http_transaction *h, struct ctdlsession *c) {
char requested_roomname[128];
char buf[1024];