From: helge Date: Mon, 4 Oct 2004 02:57:44 +0000 (+0000) Subject: fixed fetching of mails with only text content X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1fb83476564cbc5dc644480c9996b0097c463fe;p=scalable-opengroupware.org fixed fetching of mails with only text content git-svn-id: http://svn.opengroupware.org/SOGo/trunk@355 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index ed269b20..c7f2f4a3 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,5 +1,7 @@ 2004-10-04 Helge Hess + * 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) diff --git a/SOGo/UI/Mailer/UIxMailPartTextViewer.m b/SOGo/UI/Mailer/UIxMailPartTextViewer.m index 78da7133..d0c28c2a 100644 --- a/SOGo/UI/Mailer/UIxMailPartTextViewer.m +++ b/SOGo/UI/Mailer/UIxMailPartTextViewer.m @@ -43,8 +43,10 @@ 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"]; @@ -53,6 +55,8 @@ // 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]; } diff --git a/SOGo/UI/Mailer/UIxMailPartTextViewer.wox b/SOGo/UI/Mailer/UIxMailPartTextViewer.wox index 4ce6474a..7e8d5f4c 100644 --- a/SOGo/UI/Mailer/UIxMailPartTextViewer.wox +++ b/SOGo/UI/Mailer/UIxMailPartTextViewer.wox @@ -6,6 +6,4 @@ xmlns:rsrc="OGo:url" xmlns:label="OGo:label" class="mailer_plaincontent" -> - - +> diff --git a/SOGo/UI/Mailer/UIxMailRenderingContext.m b/SOGo/UI/Mailer/UIxMailRenderingContext.m index 914dd2e3..f30f2240 100644 --- a/SOGo/UI/Mailer/UIxMailRenderingContext.m +++ b/SOGo/UI/Mailer/UIxMailRenderingContext.m @@ -62,12 +62,15 @@ 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 */ @@ -101,10 +104,12 @@ 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"]) @@ -112,9 +117,21 @@ } 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 */ diff --git a/SOGo/UI/Mailer/UIxMailView.m b/SOGo/UI/Mailer/UIxMailView.m index 8abb8a26..a1a6e8a2 100644 --- a/SOGo/UI/Mailer/UIxMailView.m +++ b/SOGo/UI/Mailer/UIxMailView.m @@ -93,7 +93,17 @@ 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]; } @@ -130,6 +140,8 @@ 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! @@ -143,9 +155,14 @@ 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]; diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index 27f42dca..33dfbe1b 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=16 +SUBMINOR_VERSION:=17