]> code.citadel.org Git - citadel.git/blobdiff - webcit/dav_options.c
Offer the 'calendar-access' option when an OPTIONS command is performed on a calendar...
[citadel.git] / webcit / dav_options.c
index 96dffd300e62d9e87c007b79d69d335921462868..11b7088d3f5756507b0d35c5f66520a462c886e8 100644 (file)
@@ -25,7 +25,7 @@
 /*
  * The pathname is always going to be /groupdav/room_name/msg_num
  */
-void groupdav_options(void)
+void dav_options(void)
 {
        wcsession *WCC = WC;
        StrBuf *dav_roomname;
@@ -43,11 +43,11 @@ void groupdav_options(void)
        StrBufExtract_token(dav_uid, WCC->Hdr->HR.ReqLine, 1, '/');
 
        /*
-        * If the room name is blank, the client is doing a top-level OPTIONS.
+        * If the room name is blank, the client is doing an OPTIONS on the root.
         */
        if (StrLength(dav_roomname) == 0) {
                hprintf("HTTP/1.1 200 OK\r\n");
-               groupdav_common_headers();
+               dav_common_headers();
                hprintf("Date: %s\r\n", datestring);
                hprintf("DAV: 1\r\n");
                hprintf("Allow: OPTIONS, PROPFIND\r\n");
@@ -66,7 +66,7 @@ void groupdav_options(void)
 
        if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
                hprintf("HTTP/1.1 404 not found\r\n");
-               groupdav_common_headers();
+               dav_common_headers();
                hprintf("Date: %s\r\n", datestring);
                hprintf(
                        "Content-Type: text/plain\r\n");
@@ -85,11 +85,10 @@ void groupdav_options(void)
         * a specific item in the room.
         */
        if (StrLength(dav_uid) != 0) {
-
                dav_msgnum = locate_message_by_uid(ChrPtr(dav_uid));
                if (dav_msgnum < 0) {
                        hprintf("HTTP/1.1 404 not found\r\n");
-                       groupdav_common_headers();
+                       dav_common_headers();
                        hprintf("Content-Type: text/plain\r\n");
                        begin_burst();
                        wc_printf(
@@ -103,7 +102,7 @@ void groupdav_options(void)
                }
 
                hprintf("HTTP/1.1 200 OK\r\n");
-               groupdav_common_headers();
+               dav_common_headers();
                hprintf("Date: %s\r\n", datestring);
                hprintf("DAV: 1\r\n");
                hprintf("Allow: OPTIONS, PROPFIND, GET, PUT, DELETE\r\n");
@@ -123,9 +122,19 @@ void groupdav_options(void)
         * an OPTIONS on the room itself.
         */
        hprintf("HTTP/1.1 200 OK\r\n");
-       groupdav_common_headers();
+       dav_common_headers();
        hprintf("Date: %s\r\n", datestring);
-       hprintf("DAV: 1\r\n");
+
+       /*
+        * Offer CalDAV (RFC 4791) if this is a calendar room
+        */
+       if ( (WC->CurRoom.view == VIEW_CALENDAR) || (WC->CurRoom.view == VIEW_CALBRIEF) ) {
+               hprintf("DAV: 1, calendar-access\r\n");
+       }
+       else {
+               hprintf("DAV: 1\r\n");
+       }
+
        hprintf("Allow: OPTIONS, PROPFIND, GET, PUT\r\n");
        begin_burst();
        wc_printf("\r\n");