Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
authorWilfried Goesgens <dothebart@citadel.org>
Thu, 5 Jan 2012 20:41:37 +0000 (21:41 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Thu, 5 Jan 2012 20:41:37 +0000 (21:41 +0100)
citadel/server_main.c
libcitadel/README.txt
webcit/COPYING
webcit/README.txt
webcit/dav_propfind.c
webcit/tcp_sockets.c
webcit/webcit.h
webcit/webserver.c

index d1b2a4cd3cb4c9edb8f5915adb2bc1d50e08f9c4..592ea7708bbc620f518e10eb21af59406b86642d 100644 (file)
@@ -1,21 +1,15 @@
 /*
  * citserver's main() function lives here.
  * 
- * Copyright (c) 1987-2011 by the citadel.org team
+ * Copyright (c) 1987-2012 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 as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "sysdep.h"
@@ -208,7 +202,7 @@ int main(int argc, char **argv)
        syslog(LOG_NOTICE,
                "*** Citadel server engine v%d.%02d (build %s) ***",
                (REV_LEVEL/100), (REV_LEVEL%100), svn_revision());
-       syslog(LOG_NOTICE, "Copyright (C) 1987-2011 by the Citadel development team.");
+       syslog(LOG_NOTICE, "Copyright (C) 1987-2012 by the Citadel development team.");
        syslog(LOG_NOTICE, "This program is distributed under the terms of the GNU "
                                        "General Public License.");
        syslog(LOG_NOTICE, " ");
index 167df4b762f3b8907bc2cf502e7348b66acee19d..b24cb9048388b48dacc3f4a65aa1d5ae4b3e281d 100644 (file)
@@ -4,7 +4,7 @@ WebCit.  It is not intended to be a general-purpose library for widespread
 use, although there are parts of it that may be useful for that purpose,
 such as the MIME parser and the vCard data type.
 
-Copyright (c) 1987-2011 by the citadel.org development team.
+Copyright (c) 1987-2012 by the citadel.org development team.
 This program is distributed under the terms of the GNU General Public
 License, version 3.
 
index cdfcbc804ddfc489c5efd9d7c21b4245faecb866..0c6e2104e1caecff1539313b28eba6ebd215f2e6 100644 (file)
@@ -1,4 +1,4 @@
-Webcit Core is Copyright by the Citadel Development Team 1998 - 2011
+Webcit Core is Copyright by the Citadel Development Team 1998 - 2012
 Webcit contains components under different Licenses, here their authors and list:
 
 Scriptaculous:Copyright (c) 2005-2007 
index 95653514d6a990c559076fe8e28b1aba4e356760..aa8f6061fddcc2af4e0a05eafd855431d6eb015d 100644 (file)
@@ -1,6 +1,6 @@
                         WEBCIT for the Citadel System
  
-   Copyright (C) 1996-2011 by the authors.  Portions written by:
+   Copyright (C) 1996-2012 by the authors.  Portions written by:
  
        Art Cancro
        Wilfried Goesgens
index ebf145291cce8104f6c6b9b4018d3e44a2632dbc..80efafca4b9c626858374c4ca15ef6240e269e08 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Handles GroupDAV PROPFIND requests.
+ * Handles GroupDAV and CalDAV PROPFIND requests.
  *
  * A few notes about our XML output:
  *
  *     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
+
+Sample query:
+
+PROPFIND /groupdav/calendar/ HTTP/1.1
+Content-type: text/xml; charset=utf-8
+Content-length: 166
+
+<?xml version="1.0" encoding="UTF-8"?>
+<D:propfind xmlns:D="DAV:">
+  <D:prop>
+    <D:getcontenttype/>
+    <D:resourcetype/>
+    <D:getetag/>
+  </D:prop>
+</D:propfind>
+
+ *
+ * Copyright (c) 2005-2012 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.
  * 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
@@ -428,11 +445,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 +517,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 +616,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 +636,36 @@ void dav_propfind(void)
        begin_burst();
 
        wc_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
-               "<multistatus "
-                       "xmlns=\"DAV:\" "
+               "<D:multistatus "
+                       "xmlns:D=\"DAV:\" "
                        "xmlns:G=\"http://groupdav.org/\" "
-                       "xmlns:CALDAV=\"urn:ietf:params:xml:ns:caldav\""
+                       "xmlns:C=\"urn:ietf:params:xml:ns:caldav\""
                ">"
        );
 
-       /* Transmit the collection resource (FIXME check depth and starting point) */
-       wc_printf("<response>");
+       /* Transmit the collection resource */
+       wc_printf("<D:response>");
 
-       wc_printf("<href>");
+       wc_printf("<D:href>");
        dav_identify_host();
        wc_printf("/groupdav/");
        urlescputs(ChrPtr(WCC->CurRoom.name));
-       wc_printf("</href>");
+       wc_printf("</D:href>");
 
-       wc_printf("<propstat>");
-       wc_printf("<status>HTTP/1.1 200 OK</status>");
-       wc_printf("<prop>");
-       wc_printf("<displayname>");
+       wc_printf("<D:propstat>");
+       wc_printf("<D:status>HTTP/1.1 200 OK</D:status>");
+       wc_printf("<D:prop>");
+       wc_printf("<D:displayname>");
        escputs(ChrPtr(WCC->CurRoom.name));
-       wc_printf("</displayname>");
+       wc_printf("</D:displayname>");
 
-       wc_printf("<owner/>");          /* empty owner ought to be legal; see rfc3744 section 5.1 */
+       wc_printf("<D:owner/>");                /* empty owner ought to be legal; see rfc3744 section 5.1 */
 
-       wc_printf("<resourcetype><collection/>");
+       wc_printf("<D:resourcetype><D:collection/>");
        switch(WCC->CurRoom.defview) {
                case VIEW_CALENDAR:
                        wc_printf("<G:vevent-collection />");
-                       wc_printf("<CALDAV:calendar />");
+                       wc_printf("<C:calendar />");
                        break;
                case VIEW_TASKS:
                        wc_printf("<G:vtodo-collection />");
@@ -650,90 +674,92 @@ void dav_propfind(void)
                        wc_printf("<G:vcard-collection />");
                        break;
        }
-       wc_printf("</resourcetype>");
+       wc_printf("</D:resourcetype>");
 
        /* FIXME get the mtime
-       wc_printf("<getlastmodified>");
+       wc_printf("<D:getlastmodified>");
                escputs(datestring);
-       wc_printf("</getlastmodified>");
+       wc_printf("</D:getlastmodified>");
        */
-       wc_printf("</prop>");
-       wc_printf("</propstat>");
-       wc_printf("</response>");
-
-       /* Transmit the collection listing (FIXME check depth and starting point) */
-
-       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"))  ))
-               {
-                       msgs = realloc(msgs, ++num_msgs * sizeof(long));
-                       msgs[num_msgs-1] = StrTol(MsgNum);
-               }
+       wc_printf("</D:prop>");
+       wc_printf("</D:propstat>");
+       wc_printf("</D:response>");
 
-       if (num_msgs > 0) for (i=0; i<num_msgs; ++i) {
+       /* If a depth greater than zero was specified, transmit the collection listing */
 
-               syslog(LOG_DEBUG, "PROPFIND enumerating message # %ld", msgs[i]);
-               strcpy(uid, "");
-               now = (-1);
-               serv_printf("MSG0 %ld|3", msgs[i]);
+       if (WCC->Hdr->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]);
-                               }
-                               else if (!strncasecmp(ChrPtr(MsgNum), "time=", 5)) {
-                                       now = atol(&ChrPtr(MsgNum)[5]);
+                               msgs = realloc(msgs, ++num_msgs * sizeof(long));
+                               msgs[num_msgs-1] = StrTol(MsgNum);
                        }
-               }
-
-               if (!IsEmptyStr(uid)) {
-                       wc_printf("<response>");
-                               wc_printf("<href>");
-                                       dav_identify_host();
-                                       wc_printf("/groupdav/");
-                                       urlescputs(ChrPtr(WCC->CurRoom.name));
-                                       euid_escapize(encoded_uid, uid);
-                                       wc_printf("/%s", encoded_uid);
-                               wc_printf("</href>");
-                               switch(WCC->CurRoom.defview) {
-                               case VIEW_CALENDAR:
-                                       wc_printf("<getcontenttype>text/x-ical</getcontenttype>");
-                                       break;
-                               case VIEW_TASKS:
-                                       wc_printf("<getcontenttype>text/x-ical</getcontenttype>");
-                                       break;
-                               case VIEW_ADDRESSBOOK:
-                                       wc_printf("<getcontenttype>text/x-vcard</getcontenttype>");
-                                       break;
+       
+               if (num_msgs > 0) for (i=0; i<num_msgs; ++i) {
+       
+                       syslog(LOG_DEBUG, "PROPFIND enumerating message # %ld", msgs[i]);
+                       strcpy(uid, "");
+                       now = (-1);
+                       serv_printf("MSG0 %ld|3", msgs[i]);
+                       StrBuf_ServGetln(MsgNum);
+                       if (GetServerStatus(MsgNum, NULL) == 1)
+                               while (BufLen = StrBuf_ServGetln(MsgNum), 
+                               ((BufLen >= 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]);
                                }
-                               wc_printf("<propstat>");
-                                       wc_printf("<status>HTTP/1.1 200 OK</status>");
-                                       wc_printf("<prop>");
-                                               wc_printf("<getetag>\"%ld\"</getetag>", msgs[i]);
-                                       if (now > 0L) {
-                                               http_datestring(datestring, sizeof datestring, now);
-                                               wc_printf("<getlastmodified>");
-                                               escputs(datestring);
-                                               wc_printf("</getlastmodified>");
+                       }
+       
+                       if (!IsEmptyStr(uid)) {
+                               wc_printf("<D:response>");
+                                       wc_printf("<D:href>");
+                                               dav_identify_host();
+                                               wc_printf("/groupdav/");
+                                               urlescputs(ChrPtr(WCC->CurRoom.name));
+                                               euid_escapize(encoded_uid, uid);
+                                               wc_printf("/%s", encoded_uid);
+                                       wc_printf("</D:href>");
+                                       switch(WCC->CurRoom.defview) {
+                                       case VIEW_CALENDAR:
+                                               wc_printf("<D:getcontenttype>text/x-ical</D:getcontenttype>");
+                                               break;
+                                       case VIEW_TASKS:
+                                               wc_printf("<D:getcontenttype>text/x-ical</D:getcontenttype>");
+                                               break;
+                                       case VIEW_ADDRESSBOOK:
+                                               wc_printf("<D:getcontenttype>text/x-vcard</D:getcontenttype>");
+                                               break;
                                        }
-                                       wc_printf("</prop>");
-                               wc_printf("</propstat>");
-                       wc_printf("</response>");
+                                       wc_printf("<D:propstat>");
+                                               wc_printf("<D:status>HTTP/1.1 200 OK</D:status>");
+                                               wc_printf("<D:prop>");
+                                                       wc_printf("<D:getetag>\"%ld\"</D:getetag>", msgs[i]);
+                                               if (now > 0L) {
+                                                       http_datestring(datestring, sizeof datestring, now);
+                                                       wc_printf("<D:getlastmodified>");
+                                                       escputs(datestring);
+                                                       wc_printf("</D:getlastmodified>");
+                                               }
+                                               wc_printf("</D:prop>");
+                                       wc_printf("</D:propstat>");
+                               wc_printf("</D:response>");
+                       }
                }
+               FreeStrBuf(&MsgNum);
        }
-       FreeStrBuf(&MsgNum);
 
-       wc_printf("</multistatus>\n");
+       wc_printf("</D:multistatus>\n");
        end_burst();
 
        if (msgs != NULL) {
index 7db07943d4dd9210ba5b2fac3163f205e247d4f5..735899dbe4d48f1e082e8ea3d909fbb97907c328 100644 (file)
@@ -25,7 +25,6 @@
 #include "webcit.h"
 #include "webserver.h"
 
-extern int DisableGzip;
 long MaxRead = -1; /* should we do READ scattered or all at once? */
 
 /*
index e80489f22421531fcc802da4f31ffd50c5ee214e..5f6cd89b5e7e0cbf8412eca989e56fae5911d8eb 100644 (file)
@@ -799,6 +799,7 @@ void http_datestring(char *buf, size_t n, time_t xtime);
 #define WC_TIMEFORMAT_24 2
 
 extern int time_to_die;                        /* Nonzero if server is shutting down */
+extern int DisableGzip;
 
 /* 
  * Array type for a blog post.  The first message is the post; the rest are comments
index e8214883794ae063bbb8a9e8559a8a5f3286db07..803fe4c7217d57607e72f1a62e8d1f8324147a7c 100644 (file)
@@ -1,19 +1,13 @@
 /*
- * Copyright (c) 1996-2011 by the citadel.org team
+ * Copyright (c) 1996-2012 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 as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
+ * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "webcit.h"
@@ -236,7 +230,7 @@ int main(int argc, char **argv)
 
        /* Tell 'em who's in da house */
        syslog(1, "%s", PACKAGE_STRING);
-       syslog(1, "Copyright (C) 1996-2011 by the citadel.org team");
+       syslog(1, "Copyright (C) 1996-2012 by the citadel.org team");
        syslog(1, " ");
        syslog(1, "This program is open source software: you can redistribute it and/or");
        syslog(1, "modify it under the terms of the GNU General Public License as published");