/*
- * $Id$
- *
* Entry point for GroupDAV functions
*
+ * Copyright (c) 2005-2010 by the citadel.org team
+ *
+ * This program is free 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.
+ *
+ * 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"
* Output our host prefix for globally absolute URL's.
*/
void groupdav_identify_host(void) {
- wcsession *WCC = WC;
-
- if (StrLength(WCC->Hdr->HR.http_host)!=0) {
- wc_printf("%s://%s",
- (is_https ? "https" : "http"),
- ChrPtr(WCC->Hdr->HR.http_host));
- }
+ wc_printf("%s", ChrPtr(site_prefix));
}
void tmplput_GROUPDAV_HOSTNAME(StrBuf *Target, WCTemplputParams *TP)
{
- wcsession *WCC = WC;
-
- if (StrLength(WCC->Hdr->HR.http_host)!=0) {
- StrBufAppendPrintf(Target,
- "%s://%s",
- (is_https ? "https" : "http"),
- ChrPtr(WCC->Hdr->HR.http_host));
- }
+ StrBufAppendPrintf(Target, "%s", ChrPtr(site_prefix));
}
/*
* Output our host prefix for globally absolute URL's.
*/
void groupdav_identify_hosthdr(void) {
- wcsession *WCC = WC;
-
- if (StrLength(WCC->Hdr->HR.http_host)!=0) {
- hprintf("%s://%s",
- (is_https ? "https" : "http"),
- ChrPtr(WCC->Hdr->HR.http_host));
- }
+ hprintf("%s", ChrPtr(site_prefix));
}
}
-void RegisterDAVNamespace(const char * UrlString, long UrlSLen, const char *DisplayName, long dslen, WebcitHandlerFunc F, long Flags)
+void RegisterDAVNamespace(const char * UrlString,
+ long UrlSLen,
+ const char *DisplayName,
+ long dslen,
+ WebcitHandlerFunc F,
+ WebcitRESTDispatchID RID,
+ long Flags)
{
void *vHandler;
WebcitAddUrlHandler(UrlString, UrlSLen, DisplayName, dslen, F, Flags|PARSE_REST_URL);
/* get it out again... */
GetHash(HandlerHash, UrlString, UrlSLen, &vHandler);
+ ((WebcitHandler*)vHandler)->RID = RID;
/* and keep a copy of it, so we can compare it later */
Put(DavNamespaces, UrlString, UrlSLen, vHandler, reference_free_handler);
}
}
}
+int GroupdavDispatchREST(RESTDispatchID WhichAction, int IgnoreFloor)
+{
+ wcsession *WCC = WC;
+ void *vDir;
+
+ switch(WhichAction){
+ case ExistsID:
+ GetHash(WCC->Directory, IKEY(WCC->ThisRoom->nRoomNameParts + 1), &vDir);
+ return locate_message_by_uid(ChrPtr((StrBuf*)vDir)) != -1;
+ /* TODO: remember euid */
+ case PutID:
+ case DeleteID:
+ break;
+
+
+ }
+ return 0;
+}
+
+
void
ServerStartModule_DAV
(void)
(void)
{
// WebcitAddUrlHandler(HKEY("groupdav"), "", 0, groupdav_main, XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
- RegisterDAVNamespace(HKEY("groupdav"), HKEY("GroupDAV"), groupdav_main, XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
+ RegisterDAVNamespace(HKEY("groupdav"), HKEY("GroupDAV"),
+ groupdav_main, GroupdavDispatchREST,
+ XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
RegisterNamespace("DAV:HOSTNAME", 0, 0, tmplput_GROUPDAV_HOSTNAME, NULL, CTX_NONE);