* 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
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);
}
-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)
+{
+
+ 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)
(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);
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;
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?
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;
long GotoRestRoom()
{
+ int IgnoreFloor = 0; /* deprecated... */
wcsession *WCC = WC;
long Count;
long State;
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
#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;