X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fdav_options.c;h=f7687cf4ef347269c42029f79c50eb181e69c90f;hb=HEAD;hp=96dffd300e62d9e87c007b79d69d335921462868;hpb=977a00909d0de9ab3f96e6f5bdac18d91e30d79f;p=citadel.git diff --git a/webcit/dav_options.c b/webcit/dav_options.c index 96dffd300..cbb8f4421 100644 --- a/webcit/dav_options.c +++ b/webcit/dav_options.c @@ -1,31 +1,25 @@ /* * Handles DAV OPTIONS requests (experimental -- not required by GroupDAV) * - * Copyright (c) 2005-2010 by the citadel.org team + * 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 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 "webcit.h" -#include "webserver.h" + #include "dav.h" /* * 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; @@ -42,12 +36,14 @@ void groupdav_options(void) StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/'); StrBufExtract_token(dav_uid, WCC->Hdr->HR.ReqLine, 1, '/'); + syslog(LOG_DEBUG, "\033[35m%s (logged_in=%d)\033[0m", ChrPtr(WCC->Hdr->HR.ReqLine), WC->logged_in); /* - * 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) { + syslog(LOG_DEBUG, "\033[36mOPTIONS requested for root\033[0m"); 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"); @@ -65,8 +61,9 @@ void groupdav_options(void) } if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) { + syslog(LOG_DEBUG, "\033[36mOPTIONS requested for invalid item\033[0m"); 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 +82,11 @@ void groupdav_options(void) * a specific item in the room. */ if (StrLength(dav_uid) != 0) { - + syslog(LOG_DEBUG, "\033[36mOPTIONS requested for specific item\033[0m"); 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 +100,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"); @@ -122,12 +119,27 @@ void groupdav_options(void) * We got to this point, which means that the client is requesting * an OPTIONS on the room itself. */ + syslog(LOG_DEBUG, "\033[36mOPTIONS requested for room '%s' (%slogged in)\033[0m", + ChrPtr(WC->CurRoom.name), + ((WC->logged_in) ? "" : "not ") + ); 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\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"); + syslog(LOG_DEBUG, "\033[36mDAV: 1, calendar-access\033[0m"); + } + else { + hprintf("DAV: 1\r\n"); + syslog(LOG_DEBUG, "\033[36mDAV: 1\033[0m"); + } + + hprintf("Allow: OPTIONS, PROPFIND, GET, PUT, REPORT\r\n"); begin_burst(); - wc_printf("\r\n"); end_burst(); }