]> code.citadel.org Git - citadel.git/blobdiff - webcit/groupdav_main.c
New global variable 'site_prefix' which replaces the often-repeated code which constr...
[citadel.git] / webcit / groupdav_main.c
index b63a0da500ad70d3d8bcffb1a8e342935cb77720..3fc38fb306d1b585f4ef26d8ba873eb97655ffd1 100644 (file)
@@ -1,8 +1,21 @@
 /*
- * $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"
@@ -177,39 +190,20 @@ void groupdav_main(void)
  * 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));
 }
 
 
@@ -236,7 +230,13 @@ int Conditional_DAV_DEPTH(StrBuf *Target, WCTemplputParams *TP)
 }
 
 
-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;
 
@@ -244,6 +244,7 @@ void RegisterDAVNamespace(const char * UrlString, long UrlSLen, const char *Disp
        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);
 }
@@ -284,6 +285,26 @@ void tmplput_DAV_NAMESPACE(StrBuf *Target, WCTemplputParams *TP)
        }
 }
 
+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)
@@ -308,7 +329,9 @@ InitModule_GROUPDAV
 (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);