From 8e2ce08c74beb3dffd54fe3e0935c04c471b8667 Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 7 Oct 2004 22:50:44 +0000 Subject: [PATCH] improved WebDAV support git-svn-id: http://svn.opengroupware.org/SOGo/trunk@369 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Mailer/ChangeLog | 4 +++ SOGo/SoObjects/Mailer/SOGoDraftsFolder.m | 6 +++++ SOGo/SoObjects/Mailer/SOGoMailAccount.m | 4 +++ SOGo/SoObjects/Mailer/SOGoMailAccounts.m | 6 +++++ SOGo/SoObjects/Mailer/SOGoMailFolder.m | 6 +++++ SOGo/SoObjects/Mailer/SOGoMailObject.m | 7 +++++ SOGo/SoObjects/Mailer/Version | 2 +- SOGo/SoObjects/SOGo/ChangeLog | 19 ++++++++++++++ SOGo/SoObjects/SOGo/SOGoContentObject.m | 21 +++++++++++++++ SOGo/SoObjects/SOGo/SOGoFolder.m | 33 ++++++++++++++++++++++++ SOGo/SoObjects/SOGo/SOGoObject.h | 2 +- SOGo/SoObjects/SOGo/SOGoObject.m | 16 +++++++++++- SOGo/SoObjects/SOGo/SOGoUserFolder.m | 18 +++++++++++++ SOGo/SoObjects/SOGo/Version | 2 +- SOGoLogic/ChangeLog | 5 ++++ SOGoLogic/SOGoAppointment.m | 8 +++--- SOGoLogic/Version | 2 +- 17 files changed, 152 insertions(+), 9 deletions(-) diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index d06d9153..440bfab5 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,7 @@ +2004-10-08 Helge Hess + + * marked collections as WebDAV collections (v0.9.28) + 2004-10-06 Helge Hess * started SOGoDraftsFolder (v0.9.27) diff --git a/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m b/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m index 3528bea4..bde6c49a 100644 --- a/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m @@ -25,4 +25,10 @@ @implementation SOGoDraftsFolder +/* WebDAV */ + +- (BOOL)davIsCollection { + return YES; +} + @end /* SOGoDraftsFolder */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.m b/SOGo/SoObjects/Mailer/SOGoMailAccount.m index 11f8a3c3..9b2a52d2 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.m @@ -101,6 +101,10 @@ /* WebDAV */ +- (BOOL)davIsCollection { + return YES; +} + - (NSString *)shortTitle { NSString *s, *login, *host; NSRange r; diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m index cf6e2b49..0682a40a 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m @@ -142,4 +142,10 @@ return [self treeNavigationBlockForActiveNode]; } +/* WebDAV */ + +- (BOOL)davIsCollection { + return YES; +} + @end /* SOGoMailAccounts */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailFolder.m b/SOGo/SoObjects/Mailer/SOGoMailFolder.m index b158dc5f..425389c8 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoMailFolder.m @@ -103,4 +103,10 @@ return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; } +/* WebDAV */ + +- (BOOL)davIsCollection { + return YES; +} + @end /* SOGoMailFolder */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.m b/SOGo/SoObjects/Mailer/SOGoMailObject.m index e22a5ca8..c3d17e0d 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.m @@ -165,4 +165,11 @@ static NSArray *coreInfoKeys = nil; return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; } +/* WebDAV */ + +- (BOOL)davIsCollection { + /* while a mail has child objects, it should appear as a file in WebDAV */ + return NO; +} + @end /* SOGoMailObject */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 9461bed0..42d0a3b8 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=27 +SUBMINOR_VERSION:=28 diff --git a/SOGo/SoObjects/SOGo/ChangeLog b/SOGo/SoObjects/SOGo/ChangeLog index b76017e8..7ea1785e 100644 --- a/SOGo/SoObjects/SOGo/ChangeLog +++ b/SOGo/SoObjects/SOGo/ChangeLog @@ -1,3 +1,22 @@ +2004-10-08 Helge Hess + + * v0.9.21 + + * SOGoContentObject.m: added PUTAction: + + * SOGoObject.m: implemented special WebDAV support in GETAction: + + * SOGoFolder.m: added -toOneRelationshipKeys method (enables listing of + contained objects in WebDAV), added container name to logging prefix, + explicitly mark as WebDAV collection + + * SOGoContentObject.m: mark as WebDAV non-collection + +2004-10-07 Helge Hess + + * SOGoUserFolder.m: added toManyRelationshipKeys, marked as WebDAV + collection (v0.9.20) + 2004-09-29 Helge Hess * SOGoObject.m: added -fetchSubfolders method to resolve all diff --git a/SOGo/SoObjects/SOGo/SOGoContentObject.m b/SOGo/SoObjects/SOGo/SOGoContentObject.m index f82d031d..1419b0a2 100644 --- a/SOGo/SoObjects/SOGo/SOGoContentObject.m +++ b/SOGo/SoObjects/SOGo/SOGoContentObject.m @@ -132,6 +132,27 @@ return nil; } +/* actions */ + +- (id)PUTAction:(WOContext *)_ctx { + WORequest *rq; + NSException *error; + + rq = [_ctx request]; + if ((error = [self saveContentString:[rq contentAsString]]) != nil) + return error; + + // TODO: this should be automatic if we return nil? + [[_ctx response] setStatus:201 /* Created */]; + return [_ctx response]; +} + +/* WebDAV */ + +- (BOOL)davIsCollection { + return [self isFolderish]; +} + /* description */ - (void)appendAttributesToDescription:(NSMutableString *)_ms { diff --git a/SOGo/SoObjects/SOGo/SOGoFolder.m b/SOGo/SoObjects/SOGo/SOGoFolder.m index c3fff2fa..ff770364 100644 --- a/SOGo/SoObjects/SOGo/SOGoFolder.m +++ b/SOGo/SoObjects/SOGo/SOGoFolder.m @@ -66,6 +66,33 @@ return self->ocsFolder; } +- (NSArray *)fetchContentObjectNames { + NSArray *fields, *records; + + fields = [NSArray arrayWithObject:@"c_name"]; + records = [[self ocsFolder] fetchFields:fields matchingQualifier:nil]; + if (![records isNotNull]) { + [self logWithFormat:@"ERROR(%s): fetch failed!", __PRETTY_FUNCTION__]; + return nil; + } + if ([records isKindOfClass:[NSException class]]) + return records; + return [records valueForKey:@"cName"]; +} + +/* reflection */ + +- (NSArray *)toOneRelationshipKeys { + /* toOneRelationshipKeys are the 'files' contained in a folder */ + return [self fetchContentObjectNames]; +} + +/* WebDAV */ + +- (BOOL)davIsCollection { + return [self isFolderish]; +} + /* description */ - (void)appendAttributesToDescription:(NSMutableString *)_ms { @@ -74,4 +101,10 @@ [_ms appendFormat:@" ocs=%@", [self ocsPath]]; } +- (NSString *)loggingPrefix { + return [NSString stringWithFormat:@"<0x%08X[%@]:%@>", + self, NSStringFromClass([self class]), + [self nameInContainer]]; +} + @end /* SOGoFolder */ diff --git a/SOGo/SoObjects/SOGo/SOGoObject.h b/SOGo/SoObjects/SOGo/SOGoObject.h index a79577a5..b072828f 100644 --- a/SOGo/SoObjects/SOGo/SOGoObject.h +++ b/SOGo/SoObjects/SOGo/SOGoObject.h @@ -55,7 +55,7 @@ /* hierarchy */ -- (NSArray *)fetchSubfolders; +- (NSArray *)fetchSubfolders; /* uses toManyRelationshipKeys */ /* operations */ diff --git a/SOGo/SoObjects/SOGo/SOGoObject.m b/SOGo/SoObjects/SOGo/SOGoObject.m index 2afabb99..b18c9e3b 100644 --- a/SOGo/SoObjects/SOGo/SOGoObject.m +++ b/SOGo/SoObjects/SOGo/SOGoObject.m @@ -24,6 +24,10 @@ #include "SOGoUserFolder.h" #include "common.h" +@interface SOGoObject(Content) +- (NSString *)contentAsString; +@end + @implementation SOGoObject - (BOOL)doesRetainContainer { @@ -137,10 +141,20 @@ - (id)GETAction:(WOContext *)_ctx { // TODO: I guess this should really be done by SOPE (redirect to // default method) + WORequest *rq; WOResponse *r; NSString *uri; - uri = [[_ctx request] uri]; + rq = [_ctx request]; + if ([rq isSoWebDAVRequest]) { + if ([self respondsToSelector:@selector(contentAsString)]) + return [self contentAsString]; + + return [NSException exceptionWithHTTPStatus:502 /* not implemented */ + reason:@"no WebDAV GET support?!"]; + } + + uri = [rq uri]; if (![uri hasSuffix:@"/"]) uri = [uri stringByAppendingString:@"/"]; uri = [uri stringByAppendingString:@"view"]; diff --git a/SOGo/SoObjects/SOGo/SOGoUserFolder.m b/SOGo/SoObjects/SOGo/SOGoUserFolder.m index 9bc1a24a..96752e34 100644 --- a/SOGo/SoObjects/SOGo/SOGoUserFolder.m +++ b/SOGo/SoObjects/SOGo/SOGoUserFolder.m @@ -35,6 +35,18 @@ return [self nameInContainer]; } +/* hierarchy */ + +- (NSArray *)toManyRelationshipKeys { + static NSArray *children = nil; + + if (children == nil) { + children = [[NSArray alloc] initWithObjects: + @"Calendar", @"Contacts", @"Mail", nil]; + } + return children; +} + /* ownership */ - (NSString *)ownerInContext:(id)_ctx { @@ -158,4 +170,10 @@ return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; } +/* WebDAV */ + +- (BOOL)davIsCollection { + return YES; +} + @end /* SOGoUserFolder */ diff --git a/SOGo/SoObjects/SOGo/Version b/SOGo/SoObjects/SOGo/Version index 590c3a2c..d5b1826c 100644 --- a/SOGo/SoObjects/SOGo/Version +++ b/SOGo/SoObjects/SOGo/Version @@ -1,3 +1,3 @@ # $Id: Version 170 2004-08-11 10:45:40Z helge $ -SUBMINOR_VERSION:=19 +SUBMINOR_VERSION:=21 diff --git a/SOGoLogic/ChangeLog b/SOGoLogic/ChangeLog index f753756f..271c7d2f 100644 --- a/SOGoLogic/ChangeLog +++ b/SOGoLogic/ChangeLog @@ -1,3 +1,8 @@ +2004-10-08 Helge Hess + + * SOGoAppointment.m: improved behaviour in some edge condition (the + value of the categories being an NSCalendarDate) (v0.9.14) + 2004-10-06 Marcus Mueller * v0.9.13 diff --git a/SOGoLogic/SOGoAppointment.m b/SOGoLogic/SOGoAppointment.m index 11410330..8a664f06 100644 --- a/SOGoLogic/SOGoAppointment.m +++ b/SOGoLogic/SOGoAppointment.m @@ -205,12 +205,12 @@ static SaxObjectDecoder *sax = nil; NSString *catString; NSArray *cats; NSRange r; - + catString = [self->event categories]; - if(!catString) { + if (![catString isNotNull]) return [NSArray array]; - } - r = [catString rangeOfString:@";"]; + + r = [[catString stringValue] rangeOfString:@";"]; if(r.length > 0) { catString = [catString substringToIndex:r.location]; } diff --git a/SOGoLogic/Version b/SOGoLogic/Version index 9637b5fa..dc9886a4 100644 --- a/SOGoLogic/Version +++ b/SOGoLogic/Version @@ -1,5 +1,5 @@ # $Id$ -SUBMINOR_VERSION:=13 +SUBMINOR_VERSION:=14 # v0.9.13 requires libFoundation v1.0.62 -- 2.39.5