From f5eaf23b3ef68375c89ac37d3c3cf060ef8d5238 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Mon, 19 Apr 2010 10:20:54 +0000 Subject: [PATCH] * add one more callback hook to the webcit DAV handler structure; this will be used to revalidate URLs, move or delete certain items referenced by URLs * 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 | 8 +++++- webcit/groupdav_main.c | 32 +++++++++++++++++++-- webcit/groupdav_propfind.c | 59 ++++++++++++++++++++------------------ webcit/webcit.h | 8 ++++++ 4 files changed, 76 insertions(+), 31 deletions(-) diff --git a/webcit/groupdav.h b/webcit/groupdav.h index 773444a90..fa7808be9 100644 --- a/webcit/groupdav.h +++ b/webcit/groupdav.h @@ -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); diff --git a/webcit/groupdav_main.c b/webcit/groupdav_main.c index b63a0da50..fb3f5203c 100644 --- a/webcit/groupdav_main.c +++ b/webcit/groupdav_main.c @@ -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); diff --git a/webcit/groupdav_propfind.c b/webcit/groupdav_propfind.c index 1a2ffc52d..f3a37294a 100644 --- a/webcit/groupdav_propfind.c +++ b/webcit/groupdav_propfind.c @@ -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 diff --git a/webcit/webcit.h b/webcit/webcit.h index 385f9f573..9fff7edea 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -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; -- 2.39.2