X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fdav_propfind.c;h=b3a848a9ddf80cbb2e0cb1abd002eb14aadadd03;hb=e21b689461215d6012ff62d76c2da73d4ffeb33a;hp=ebf145291cce8104f6c6b9b4018d3e44a2632dbc;hpb=7b6191e9787496d0a3157637414210832e68117b;p=citadel.git
diff --git a/webcit/dav_propfind.c b/webcit/dav_propfind.c
index ebf145291..b3a848a9d 100644
--- a/webcit/dav_propfind.c
+++ b/webcit/dav_propfind.c
@@ -1,5 +1,5 @@
/*
- * Handles GroupDAV PROPFIND requests.
+ * Handles GroupDAV and CalDAV PROPFIND requests.
*
* A few notes about our XML output:
*
@@ -10,7 +10,12 @@
* This makes it difficult to read, but we have discovered clients which
* crash when you try to pretty it up.
*
- * Copyright (c) 2005-2011 by the citadel.org team
+ * References:
+ * http://www.ietf.org/rfc/rfc4791.txt
+ * http://blogs.nologin.es/rickyepoderi/index.php?/archives/14-Introducing-CalDAV-Part-I.html
+ * https://msdn.microsoft.com/en-us/library/aa142960(v=exchg.65).aspx
+ *
+ * Copyright (c) 2005-2017 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.
@@ -19,15 +24,12 @@
* 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"
#include "webserver.h"
#include "dav.h"
-extern int DisableGzip;
-
/*
* Given an encoded UID, translate that to an unencoded Citadel EUID and
* then search for it in the current room. Return a message number or -1
@@ -150,7 +152,7 @@ const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
{
DeleteHashPos(&itd);
- syslog(0, "5\n");
+ syslog(LOG_DEBUG, "5\n");
continue;
}
DeleteHashPos(&itd);
@@ -161,7 +163,7 @@ const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
{
DeleteHashPos(&itd);
- syslog(0, "5\n");
+ syslog(LOG_DEBUG, "5\n");
continue;
}
DeleteHashPos(&itfl);
@@ -366,7 +368,8 @@ void dav_collection_list(void)
(view == VIEW_ADDRESSBOOK) ||
(view == VIEW_NOTES) ||
(view == VIEW_JOURNAL) ||
- (view == VIEW_WIKI)
+ (view == VIEW_WIKI) ||
+ (view == VIEW_WIKIMD)
) {
is_groupware_collection = 1;
}
@@ -408,6 +411,7 @@ void dav_collection_list(void)
wc_printf("");
break;
case VIEW_WIKI:
+ case VIEW_WIKIMD:
wc_printf("");
break;
}
@@ -428,11 +432,11 @@ void dav_collection_list(void)
void propfind_xml_start(void *data, const char *supplied_el, const char **attr) {
- syslog(LOG_DEBUG, "<%s>", supplied_el);
+ // syslog(LOG_DEBUG, "<%s>", supplied_el);
}
void propfind_xml_end(void *data, const char *supplied_el) {
- syslog(LOG_DEBUG, "%s>", supplied_el);
+ // syslog(LOG_DEBUG, "%s>", supplied_el);
}
@@ -500,6 +504,10 @@ void dav_propfind(void)
StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
StrBufExtract_token(dav_uid, WCC->Hdr->HR.ReqLine, 1, '/');
+ syslog(LOG_DEBUG, "PROPFIND requested for '%s' at depth %d",
+ ChrPtr(dav_roomname), WCC->Hdr->HR.dav_depth
+ );
+
/*
* If the room name is blank, the client is requesting a folder list.
*/
@@ -595,13 +603,16 @@ void dav_propfind(void)
/*
- * We got to this point, which means that the client is requesting
- * a 'collection' (i.e. a list of all items in the room).
+ * If we get to this point the client is performing a PROPFIND on the room itself.
+ *
+ * We call it a room; DAV calls it a "collection." We have to give it some properties
+ * of the room itself and then offer a list of all items contained therein.
*
* Be rude. Completely ignore the XML request and simply send them
* everything we know about (which is going to simply be the ETag and
* nothing else). Let the client-side parser sort it out.
*/
+ //syslog(LOG_DEBUG, "BE RUDE AND IGNORE: \033[31m%s\033[0m", ChrPtr(WC->upload) );
hprintf("HTTP/1.0 207 Multi-Status\r\n");
dav_common_headers();
hprintf("Date: %s\r\n", datestring);
@@ -612,36 +623,36 @@ void dav_propfind(void)
begin_burst();
wc_printf(""
- ""
);
- /* Transmit the collection resource (FIXME check depth and starting point) */
- wc_printf("");
+ /* Transmit the collection resource */
+ wc_printf("");
- wc_printf("");
+ wc_printf("");
dav_identify_host();
wc_printf("/groupdav/");
urlescputs(ChrPtr(WCC->CurRoom.name));
- wc_printf("");
+ wc_printf("");
- wc_printf("");
- wc_printf("HTTP/1.1 200 OK");
- wc_printf("");
- wc_printf("");
+ wc_printf("");
+ wc_printf("HTTP/1.1 200 OK");
+ wc_printf("");
+ wc_printf("");
escputs(ChrPtr(WCC->CurRoom.name));
- wc_printf("");
+ wc_printf("");
- wc_printf(""); /* empty owner ought to be legal; see rfc3744 section 5.1 */
+ wc_printf(""); /* empty owner ought to be legal; see rfc3744 section 5.1 */
- wc_printf("");
+ wc_printf("");
switch(WCC->CurRoom.defview) {
case VIEW_CALENDAR:
wc_printf("");
- wc_printf("");
+ wc_printf("");
break;
case VIEW_TASKS:
wc_printf("");
@@ -650,90 +661,92 @@ void dav_propfind(void)
wc_printf("");
break;
}
- wc_printf("");
+ wc_printf("");
/* FIXME get the mtime
- wc_printf("");
+ wc_printf("");
escputs(datestring);
- wc_printf("");
+ wc_printf("");
*/
- wc_printf("");
- wc_printf("");
- wc_printf("");
-
- /* Transmit the collection listing (FIXME check depth and starting point) */
+ wc_printf("");
+ wc_printf("");
+ wc_printf("");
- MsgNum = NewStrBuf();
- serv_puts("MSGS ALL");
+ /* If a depth greater than zero was specified, transmit the collection listing */
- StrBuf_ServGetln(MsgNum);
- if (GetServerStatus(MsgNum, NULL) == 1)
- while (BufLen = StrBuf_ServGetln(MsgNum),
- ((BufLen >= 0) &&
- ((BufLen != 3) || strcmp(ChrPtr(MsgNum), "000")) ))
- {
- msgs = realloc(msgs, ++num_msgs * sizeof(long));
- msgs[num_msgs-1] = StrTol(MsgNum);
- }
-
- if (num_msgs > 0) for (i=0; iHdr->HR.dav_depth > 0) {
+ MsgNum = NewStrBuf();
+ serv_puts("MSGS ALL");
+
StrBuf_ServGetln(MsgNum);
if (GetServerStatus(MsgNum, NULL) == 1)
while (BufLen = StrBuf_ServGetln(MsgNum),
- ((BufLen >= 0) &&
- ((BufLen != 3) || strcmp(ChrPtr(MsgNum), "000")) ))
+ ((BufLen >= 0) &&
+ ((BufLen != 3) || strcmp(ChrPtr(MsgNum), "000")) ))
{
- if (!strncasecmp(ChrPtr(MsgNum), "exti=", 5)) {
- strcpy(uid, &ChrPtr(MsgNum)[5]);
+ msgs = realloc(msgs, ++num_msgs * sizeof(long));
+ msgs[num_msgs-1] = StrTol(MsgNum);
+ }
+
+ if (num_msgs > 0) for (i=0; i= 0) &&
+ ((BufLen != 3) || strcmp(ChrPtr(MsgNum), "000")) ))
+ {
+ if (!strncasecmp(ChrPtr(MsgNum), "exti=", 5)) {
+ strcpy(uid, &ChrPtr(MsgNum)[5]);
+ }
+ else if (!strncasecmp(ChrPtr(MsgNum), "time=", 5)) {
+ now = atol(&ChrPtr(MsgNum)[5]);
}
- else if (!strncasecmp(ChrPtr(MsgNum), "time=", 5)) {
- now = atol(&ChrPtr(MsgNum)[5]);
}
- }
-
- if (!IsEmptyStr(uid)) {
- wc_printf("");
- wc_printf("");
- dav_identify_host();
- wc_printf("/groupdav/");
- urlescputs(ChrPtr(WCC->CurRoom.name));
- euid_escapize(encoded_uid, uid);
- wc_printf("/%s", encoded_uid);
- wc_printf("");
+
+ if (!IsEmptyStr(uid)) {
+ wc_printf("");
+ wc_printf("");
+ dav_identify_host();
+ wc_printf("/groupdav/");
+ urlescputs(ChrPtr(WCC->CurRoom.name));
+ euid_escapize(encoded_uid, uid);
+ wc_printf("/%s", encoded_uid);
+ wc_printf("");
+ wc_printf("");
+ wc_printf("HTTP/1.1 200 OK");
+ wc_printf("");
+ wc_printf("\"%ld\"", msgs[i]);
switch(WCC->CurRoom.defview) {
- case VIEW_CALENDAR:
- wc_printf("text/x-ical");
- break;
- case VIEW_TASKS:
- wc_printf("text/x-ical");
- break;
- case VIEW_ADDRESSBOOK:
- wc_printf("text/x-vcard");
- break;
+ case VIEW_CALENDAR:
+ wc_printf("text/x-ical");
+ break;
+ case VIEW_TASKS:
+ wc_printf("text/x-ical");
+ break;
+ case VIEW_ADDRESSBOOK:
+ wc_printf("text/x-vcard");
+ break;
}
- wc_printf("");
- wc_printf("HTTP/1.1 200 OK");
- wc_printf("");
- wc_printf("\"%ld\"", msgs[i]);
- if (now > 0L) {
- http_datestring(datestring, sizeof datestring, now);
- wc_printf("");
- escputs(datestring);
- wc_printf("");
- }
- wc_printf("");
- wc_printf("");
- wc_printf("");
+ if (now > 0L) {
+ http_datestring(datestring, sizeof datestring, now);
+ wc_printf("");
+ escputs(datestring);
+ wc_printf("");
+ }
+ wc_printf("");
+ wc_printf("");
+ wc_printf("");
+ }
}
+ FreeStrBuf(&MsgNum);
}
- FreeStrBuf(&MsgNum);
- wc_printf("\n");
+ wc_printf("\n");
end_burst();
if (msgs != NULL) {
@@ -746,7 +759,8 @@ void dav_propfind(void)
int ParseMessageListHeaders_EUID(StrBuf *Line,
const char **pos,
message_summary *Msg,
- StrBuf *ConversionBuffer)
+ StrBuf *ConversionBuffer,
+ void **ViewSpecific)
{
Msg->euid = NewStrBuf();
StrBufExtract_NextToken(Msg->euid, Line, pos, '|');
@@ -756,10 +770,12 @@ int ParseMessageListHeaders_EUID(StrBuf *Line,
}
int DavUIDL_GetParamsGetServerCall(SharedMessageStatus *Stat,
- void **ViewSpecific,
- long oper,
- char *cmd,
- long len)
+ void **ViewSpecific,
+ long oper,
+ char *cmd,
+ long len,
+ char *filter,
+ long flen)
{
Stat->defaultsortorder = 0;
Stat->sortit = 0;
@@ -799,10 +815,12 @@ InitModule_PROPFIND
RegisterReadLoopHandlerset(
eReadEUIDS,
DavUIDL_GetParamsGetServerCall,
- NULL, /// TODO: is this right?
+ NULL,
+ NULL,
ParseMessageListHeaders_EUID,
- NULL, //// ""
+ NULL,
DavUIDL_RenderView_or_Tail,
- DavUIDL_Cleanup);
+ DavUIDL_Cleanup,
+ NULL);
}