From: helge Date: Sun, 30 Jan 2005 17:52:01 +0000 (+0000) Subject: improved WebDAV support in Drafts folder X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1aa499ac492cc2fb1851a8392c6c0e186ccb1aa;p=scalable-opengroupware.org improved WebDAV support in Drafts folder git-svn-id: http://svn.opengroupware.org/SOGo/trunk@507 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 80443409..3b728916 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,4 +1,13 @@ 2005-01-30 Helge Hess + + * v0.9.60 + + * SOGoDraftObject.m: added -content and -contentAsString methods (Note: + those are expensive operations!), added GETAction: to retrieve the + MIME representation of a draft + + * SOGoDraftsFolder.m: added -toOneRelationshipKeys to support SOPE + WebDAV access * v0.9.59 diff --git a/SOGo/SoObjects/Mailer/SOGoDraftObject.m b/SOGo/SoObjects/Mailer/SOGoDraftObject.m index 5add8897..7f478265 100644 --- a/SOGo/SoObjects/Mailer/SOGoDraftObject.m +++ b/SOGo/SoObjects/Mailer/SOGoDraftObject.m @@ -727,6 +727,38 @@ static BOOL debugOn = NO; return nil; } +- (NSData *)content { + /* Note: does not cache, expensive operation */ + NSData *data; + NSString *p; + + if ((p = [self saveMimeMessageToTemporaryFile]) == nil) + return nil; + + data = [NSData dataWithContentsOfMappedFile:p]; + + /* delete temporary file */ + [self deleteTemporaryMessageFile:p]; + + return data; +} +- (NSString *)contentAsString { + NSString *str; + NSData *data; + + if ((data = [self content]) == nil) + return nil; + + str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; + if (str == nil) { + [self errorWithFormat:@"could not load draft as ASCII (data size=%d)", + [data length]]; + return nil; + } + + return [str autorelease]; +} + /* actions */ - (id)DELETEAction:(id)_ctx { @@ -738,6 +770,31 @@ static BOOL debugOn = NO; return [NSNumber numberWithBool:YES]; /* delete worked out ... */ } +- (id)GETAction:(WOContext *)_ctx { + /* + Override, because SOGoObject's GETAction uses the less efficient + -contentAsString method. + */ + WORequest *rq; + + rq = [_ctx request]; + if ([rq isSoWebDAVRequest]) { + WOResponse *r; + NSData *content; + + if ((content = [self content]) == nil) { + return [NSException exceptionWithHTTPStatus:500 + reason:@"Could not generate MIME content!"]; + } + r = [_ctx response]; + [r setHeader:@"message/rfc822" forKey:@"content-type"]; + [r setContent:content]; + return r; + } + + return [super GETAction:_ctx]; +} + /* fake being a SOGoMailObject */ - (id)fetchParts:(NSArray *)_parts { @@ -753,6 +810,7 @@ static BOOL debugOn = NO; return seenFlags; } - (unsigned)size { + // TODO: size, hard to support, we would need to generate MIME? return 0; } diff --git a/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m b/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m index 62f10ab5..f6b7f0ef 100644 --- a/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m @@ -173,4 +173,8 @@ static NSString *spoolFolder = nil; return YES; } +- (NSArray *)toOneRelationshipKeys { + return [self fetchMailNames]; +} + @end /* SOGoDraftsFolder */