2005-01-30 Helge Hess <helge.hess@opengroupware.org>
+
+ * 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
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 {
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 {
return seenFlags;
}
- (unsigned)size {
+ // TODO: size, hard to support, we would need to generate MIME?
return 0;
}