* add one more callback hook to the webcit DAV handler structure; this will be used...
authorWilfried Göesgens <willi@citadel.org>
Mon, 19 Apr 2010 10:20:54 +0000 (10:20 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 19 Apr 2010 10:20:54 +0000 (10:20 +0000)
* add handler vor EUID based namespaces; so far we just have the exists logic; this will be filled with the other required operations soon.
* finish REST URL parsing with 'best-guess'-room logic

webcit/groupdav.h
webcit/groupdav_main.c
webcit/groupdav_propfind.c
webcit/webcit.h

index 773444a9067e556f4c2aa2ecf590a0fc3f26b39a..fa7808be946cba9f77aa12910821724cc24ffa3f 100644 (file)
@@ -28,4 +28,10 @@ void euid_unescapize(char *, const char *);
 void groupdav_identify_host(void);
 void groupdav_identify_hosthdr(void);
 
-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);
index b63a0da500ad70d3d8bcffb1a8e342935cb77720..fb3f5203c56cb0fc083542b6a06ad77f1dcc29d4 100644 (file)
@@ -236,7 +236,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 +250,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 +291,25 @@ void tmplput_DAV_NAMESPACE(StrBuf *Target, WCTemplputParams *TP)
        }
 }
 
+int GroupdavDispatchREST(RESTDispatchID WhichAction, int IgnoreFloor)
+{
+
+       switch(WhichAction){
+       case ExistsID:
+               //WCC->Directory
+//nRoomNameParts
+//             return locate_message_by_uid() != -1;
+               /* TODO: remember euid */
+       case PutID:
+       case DeleteID:
+               break;
+
+
+       }
+       return 0;
+}
+
+
 void
 ServerStartModule_DAV
 (void)
@@ -308,7 +334,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);
 
index 1a2ffc52dcba7207ca125aaa047390465f4ed6b5..f3a37294a2b0e60799da5ddce71b6f758ffedfb1 100644 (file)
@@ -42,6 +42,11 @@ long locate_message_by_uid(const char *uid) {
        return(retval);
 }
 
+
+/*
+ * IgnoreFloor: set to 0 or 1 _nothing else_
+ * Subfolders: direct child floors will be put here.
+ */
 const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
 {
        wcsession  *WCC = WC;
@@ -77,13 +82,13 @@ const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
                if (ThisFolder->nRoomNameParts > 1) 
                {
                        /*TODO: is that number all right? */
-                       if (urlp - ThisFolder->nRoomNameParts != 2) {
+//                     if (urlp - ThisFolder->nRoomNameParts != 2) {
 //                             if (BestGuess != NULL)
-                                       continue;
+//                                     continue;
 //ThisFolder->name
 //                             itd  = GetNewHashPos(WCC->Directory, 0);
 //                             GetNextHashPos(WCC->Directory, itd, &len, &Key, &vDir); //TODO: how many to fast forward?
-                       }
+//                     }
                        itd  = GetNewHashPos(WCC->Directory, 0);
                        GetNextHashPos(WCC->Directory, itd, &len, &Key, &vDir); //TODO: how many to fast forward?
        
@@ -154,9 +159,11 @@ const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
                                BestGuess = ThisFolder;
                        }
                        else 
-                               FoundFolder = ThisFolder;;
+                               FoundFolder = ThisFolder;
                }
        }
+
+/* TODO: Subfolders: remove patterns not matching the best guess or thisfolder */
        DeleteHashPos(&itfl);
        if (FoundFolder != NULL)
                return FoundFolder;
@@ -169,6 +176,7 @@ const folder *GetRESTFolder(int IgnoreFloor, HashList *Subfolders)
 
 long GotoRestRoom()
 {
+       int IgnoreFloor = 0; /* deprecated... */
        wcsession *WCC = WC;
        long Count;
        long State;
@@ -187,44 +195,39 @@ long GotoRestRoom()
        if (Count >= 1) State |=REST_IN_FLOOR;
        if (Count == 1) return State;
        
-       if (Count >= 3) {
-               State |= REST_IN_FLOOR;
-               SubRooms = NewHash(1, Flathash);
-               ThisFolder = GetRESTFolder(0, SubRooms);
-               WCC->ThisRoom = ThisFolder;
-               if (ThisFolder != NULL)
-               {
-                       gotoroom(ThisFolder->name);
-                       State |= REST_IN_ROOM;
-                       return State;
-               }
-               
-       }
-
-
        /* 
         * More than 3 params and no floor found? 
         * -> fall back to old non-floored notation
         */
-
        if ((Count >= 3) && (WCC->CurrentFloor == NULL))
+               IgnoreFloor = 1;
+       if (Count >= 3)
        {
+               IgnoreFloor = 0;
+               State |= REST_IN_FLOOR;
                SubRooms = NewHash(1, Flathash);
-               ThisFolder = GetRESTFolder(1, SubRooms);
-               WCC->ThisRoom = ThisFolder;
+               ThisFolder = GetRESTFolder(IgnoreFloor, SubRooms);
                if (ThisFolder != NULL)
                {
-                       gotoroom(ThisFolder->name);
+                       if (WCC->ThisRoom != NULL)
+                               if (CompareRooms(WCC->ThisRoom, ThisFolder))
+                                       gotoroom(ThisFolder->name);
                        State |= REST_IN_ROOM;
-                       return State;
                }
-
-
        }
+       if ((WCC->ThisRoom != NULL) && 
+           (Count + IgnoreFloor > 3))
+       {
+               if (WCC->Hdr->HR.Handler.RID(ExistsID, IgnoreFloor))
+               {
+                       State |= REST_GOT_EUID;
+               }/////TODO
+               else {
+                       /// WHOOPS, not there???
+               }
 
 
-       if (Count == 3) return State;
-
+       }
        /// TODO: ID detection
        /// TODO: File detection
 
index 385f9f57354d9ad3615bb5ed931c7927380c2570..9fff7edea0b3a44cd2e3f8c4863215d2a137e8ff 100644 (file)
@@ -348,9 +348,17 @@ typedef struct _addrbookent {
 #define PARSE_REST_URL (1<<9)
 #define PROHIBIT_STARTPAGE (1<<10)
 
+typedef enum _RESTDispatchID {
+       ExistsID,
+       PutID,
+       DeleteID
+} RESTDispatchID;
+
+typedef int (*WebcitRESTDispatchID)(RESTDispatchID WhichAction, int IgnoreFloor);
 typedef void (*WebcitHandlerFunc)(void);
 typedef struct  _WebcitHandler{
        WebcitHandlerFunc F;
+       WebcitRESTDispatchID RID;
        long Flags;
        StrBuf *Name;
        StrBuf *DisplayName;