2004-10-04 Helge Hess <helge.hess@opengroupware.org>
+ * fixed fetching of mails with only text content (v0.9.17)
+
* added flat body fetches, used in text viewer (v0.9.16)
* added MIME content viewer infrastructure (v0.9.15)
NSString *s;
NSData *content;
- if ((content = [self flatContent]) == nil)
+ if ((content = [self flatContent]) == nil) {
+ [self logWithFormat:@"ERROR: got no text content: %@", [self partPath]];
return nil;
+ }
charset =
[[[self bodyInfo] objectForKey:@"parameterList"] objectForKey:@"charset"];
// TODO: properly decode charset, might need to handle encoding?
s = [[NSString alloc] initWithData:content encoding:NSUTF8StringEncoding];
+ if (s == nil)
+ [self logWithFormat:@"ERROR: could not convert content to text!"];
return [s autorelease];
}
xmlns:rsrc="OGo:url"
xmlns:label="OGo:label"
class="mailer_plaincontent"
->
- <var:string value="flatContentAsString" />
-</pre>
+><var:string value="flatContentAsString" /></pre>
return [self->flatContents isNotNull] ? self->flatContents : nil;
self->flatContents = [[self->viewer fetchFlatContents] retain];
+ [self debugWithFormat:@"CON: %@", self->flatContents];
return self->flatContents;
}
- (NSData *)flatContentForPartPath:(NSArray *)_partPath {
- return [[self flatContents] objectForKey:
- [_partPath componentsJoinedByString:@"."]];
+ NSString *pid;
+
+ pid = _partPath ? [_partPath componentsJoinedByString:@"."] : @"";
+ return [[self flatContents] objectForKey:pid];
}
/* viewer components */
mt = [[_info valueForKey:@"type"] lowercaseString];
st = [[_info valueForKey:@"subtype"] lowercaseString];
-
+
if ([mt isEqualToString:@"multipart"]) {
if ([st isEqualToString:@"mixed"])
return [self mixedViewer];
+ if ([st isEqualToString:@"signed"]) // TODO: temporary workaround
+ return [self mixedViewer];
}
else if ([mt isEqualToString:@"text"]) {
if ([st isEqualToString:@"plain"])
}
else if ([mt isEqualToString:@"image"])
return [self imageViewer];
+ else if ([mt isEqualToString:@"application"]) {
+ /*
+ octed-stream (generate download link?)
+ pgp-viewer
+ */
+ }
[self logWithFormat:@"ERROR: found no viewer for MIME type: %@/%@", mt, st];
return nil;
}
+/* debugging */
+
+- (BOOL)isDebuggingEnabled {
+ return NO;
+}
+
@end /* UIxMailRenderingContext */
if (fetchPart) {
NSString *k;
- k = [[@"body[" stringByAppendingString:_p] stringByAppendingString:@"]"];
+ if ([_p length] > 0) {
+ k = [[@"body[" stringByAppendingString:_p] stringByAppendingString:@"]"];
+ }
+ else {
+ /*
+ for some reason we need to add ".TEXT" for plain text stuff on root
+ entities?
+ TODO: check with HTML
+ */
+ k = @"body[text]";
+ }
[_keys addObject:k];
}
id result;
keys = [self contentFetchKeys];
+ [self debugWithFormat:@"fetch keys: %@", keys];
+
result = [[self clientObject] fetchParts:keys];
result = [result valueForKey:@"RawResponse"]; // hackish
result = [result objectForKey:@"fetch"]; // Note: -valueForKey: doesn't work!
key = [keys objectAtIndex:i];
data = [[result objectForKey:key] objectForKey:@"data"];
- if (![data isNotNull]) continue;
-
- if ([key hasPrefix:@"body["]) {
+ if (![data isNotNull]) {
+ [self debugWithFormat:@"got no data fork key: %@", key];
+ continue;
+ }
+
+ if ([key isEqualToString:@"body[text]"])
+ key = @""; // see key collector
+ else if ([key hasPrefix:@"body["]) {
NSRange r;
key = [key substringFromIndex:5];
# $Id$
-SUBMINOR_VERSION:=16
+SUBMINOR_VERSION:=17