diff --git a/ChangeLog b/ChangeLog index a8e575350..44d3cd86a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2007-11-16 Ludovic Marcotte + + * SoObjects/Mailer/SOGoMailBaseObject.m + Fixed typo. + + * SoObjects/Mailer/SOGoMailBodyPart.m + We also grok image/jpeg and return the SOGoMailBodyPart + for attachments fetching. + + * SoObjects/Mailer/SOGoMailObject+Draft.m + Prevent a crash in case body decoding failed during + a reply. + + * SoObjects/Mailer/SOGoMailObject.m + Improved body decoding during a reply to also try + latin1 as an encoding. + + * UI/MailPartViewers/UIxMailRenderingContext.m + Greatly improved the display mechanisms for emails. + Also properly consider the content disposition for + most content types. + + * UI/MailerUI/UIxMailToSelection.m + Removed worthless code. + + * UI/WebServerResources/MailerUI.css + CSS fix for table views. + 2007-11-15 Ludovic Marcotte * UI/WebServerResources/MailerUI.js diff --git a/SoObjects/Mailer/SOGoMailBaseObject.m b/SoObjects/Mailer/SOGoMailBaseObject.m index 6feb888a7..d4387d523 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SoObjects/Mailer/SOGoMailBaseObject.m @@ -207,7 +207,7 @@ static BOOL debugOn = YES; - (BOOL)isBodyPartKey:(NSString *)_key inContext:(id)_ctx { /* - Every key starting with a digit is consider an IMAP4 mime part key, used in + Every key starting with a digit is considered an IMAP4 mime part key, used in SOGoMailObject and SOGoMailBodyPart. */ if ([_key length] == 0) diff --git a/SoObjects/Mailer/SOGoMailBodyPart.m b/SoObjects/Mailer/SOGoMailBodyPart.m index 78be1fb67..808291277 100644 --- a/SoObjects/Mailer/SOGoMailBodyPart.m +++ b/SoObjects/Mailer/SOGoMailBodyPart.m @@ -349,7 +349,8 @@ static BOOL debugOn = NO; if ([mimeType isEqualToString: @"image/gif"] || [mimeType isEqualToString: @"image/png"] - || [mimeType isEqualToString: @"image/jpg"]) + || [mimeType isEqualToString: @"image/jpg"] + || [mimeType isEqualToString: @"image/jpeg"]) classString = @"SOGoImageMailBodyPart"; else if ([mimeType isEqualToString: @"text/calendar"]) classString = @"SOGoCalendarMailBodyPart"; @@ -366,7 +367,7 @@ static BOOL debugOn = NO; if (classString) klazz = NSClassFromString (classString); else - klazz = Nil; + klazz = [SOGoMailBodyPart class]; return klazz; } diff --git a/SoObjects/Mailer/SOGoMailObject+Draft.m b/SoObjects/Mailer/SOGoMailObject+Draft.m index c267eec30..ee5425613 100644 --- a/SoObjects/Mailer/SOGoMailObject+Draft.m +++ b/SoObjects/Mailer/SOGoMailObject+Draft.m @@ -80,6 +80,8 @@ int index; BOOL htmlContent; + content = @""; + if ([keys count]) { types = [keys objectsForKey: @"mimeType"]; @@ -91,23 +93,23 @@ } else htmlContent = NO; - if (index == NSNotFound) - content = @""; - else + + if (index != NSNotFound) { contentKey = [keys objectAtIndex: index]; parts = [self fetchPlainTextStrings: [NSArray arrayWithObject: contentKey]]; - rawPart = [[parts allValues] objectAtIndex: 0]; - if (htmlContent) - content = [rawPart htmlToText]; - else - content = rawPart; + if ([parts count] > 0) + { + rawPart = [[parts allValues] objectAtIndex: 0]; + if (htmlContent) + content = [rawPart htmlToText]; + else + content = rawPart; + } } } - else - content = @""; - + return content; } diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index f6969e972..4c44bd993 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -656,8 +656,13 @@ static BOOL debugSoParts = NO; [s autorelease]; } else - s = [NSString stringWithData: mailData - usingEncodingNamed: charset]; + { + s = [NSString stringWithData: mailData usingEncodingNamed: charset]; + + // If it has failed, we try at least using UTF-8. Normally, this can NOT fail + if (!s) + s = [[[NSString alloc] initWithData: mailData encoding: NSISOLatin1StringEncoding] autorelease]; + } } else s = nil; diff --git a/UI/MailPartViewers/UIxMailRenderingContext.m b/UI/MailPartViewers/UIxMailRenderingContext.m index e60be0bbc..11d289f39 100644 --- a/UI/MailPartViewers/UIxMailRenderingContext.m +++ b/UI/MailPartViewers/UIxMailRenderingContext.m @@ -29,6 +29,25 @@ #import "UIxMailRenderingContext.h" +@interface UIxMailRenderingContext (Private) + +- (BOOL) _shouldDisplayAsAttachment: (NSDictionary *) info; + +@end + +@implementation UIxMailRenderingContext (Private) + +- (BOOL) _shouldDisplayAsAttachment: (NSDictionary *) info +{ + NSString *s; + + s = [[info objectForKey:@"disposition"] objectForKey: @"type"]; + + return (s && [s caseInsensitiveCompare: @"ATTACHMENT"] == NSOrderedSame); +} + +@end + @implementation UIxMailRenderingContext static BOOL showNamedTextAttachmentsInline = NO; @@ -235,13 +254,12 @@ static BOOL showNamedTextAttachmentsInline = NO; if ([mt isEqualToString:@"multipart"]) { - if ([st isEqualToString:@"mixed"]) + if ([st isEqualToString:@"mixed"] || [st isEqualToString:@"related"]) return [self mixedViewer]; else if ([st isEqualToString:@"signed"]) return [self signedViewer]; - else if ([st isEqualToString:@"alternative"] - || [st isEqualToString:@"related"]) - return [self alternativeViewer]; + else if ([st isEqualToString:@"alternative"]) + return [self alternativeViewer]; if ([st isEqualToString:@"report"]) /* this is used by mail-delivery reports */ @@ -249,19 +267,9 @@ static BOOL showNamedTextAttachmentsInline = NO; } else if ([mt isEqualToString:@"text"]) { - /* - Note: in the _info dictionary we do not get the content-disposition - information (inline vs attachment). Our hack is to check for the - 'name' parameter. - */ if ([st isEqualToString:@"plain"] || [st isEqualToString:@"html"]) { - if (!showNamedTextAttachmentsInline) { - NSString *n; - - n = [[_info objectForKey:@"parameterList"] objectForKey:@"name"]; - if ([n isNotNull] && [n length] > 0) - return [self linkViewer]; - } + if (!showNamedTextAttachmentsInline && [self _shouldDisplayAsAttachment: _info]) + return [self linkViewer]; return [st isEqualToString:@"html"] ? [self htmlViewer] : [self textViewer]; @@ -269,10 +277,15 @@ static BOOL showNamedTextAttachmentsInline = NO; if ([st isEqualToString:@"calendar"]) return [self iCalViewer]; - } + } if ([mt isEqualToString:@"image"]) - return [self imageViewer]; + { + if ([self _shouldDisplayAsAttachment: _info]) + return [self linkViewer]; + + return [self imageViewer]; + } if ([mt isEqualToString:@"message"] && [st isEqualToString:@"rfc822"]) return [self messageViewer]; diff --git a/UI/MailerUI/UIxMailToSelection.m b/UI/MailerUI/UIxMailToSelection.m index cdcc83bf0..71c09f18b 100644 --- a/UI/MailerUI/UIxMailToSelection.m +++ b/UI/MailerUI/UIxMailToSelection.m @@ -64,8 +64,6 @@ - (void) setBcc: (NSArray *) _bcc; - (NSArray *) bcc; -- (NSArray *) properlySplitAddresses: (NSArray *) _addresses; - - (void) getAddressesFromFormValues: (NSDictionary *) _dict; - (NSString *) getIndexFromIdentifier: (NSString *) _identifier; @@ -108,7 +106,7 @@ static NSArray *headers = nil; - (void) setTo: (NSArray *) _to { - ASSIGN (to, [self properlySplitAddresses: _to]); + ASSIGN (to, _to); } - (NSArray *) to @@ -127,7 +125,7 @@ static NSArray *headers = nil; - (void) setCc: (NSArray *) _cc { - ASSIGN (cc, [self properlySplitAddresses: _cc]); + ASSIGN (cc, _cc); } - (NSArray *) cc @@ -137,7 +135,7 @@ static NSArray *headers = nil; - (void) setBcc: (NSArray *) _bcc { - ASSIGN (bcc, [self properlySplitAddresses: _bcc]); + ASSIGN (bcc, _bcc); } - (NSArray *) bcc @@ -237,52 +235,6 @@ static NSArray *headers = nil; return @""; } -/* address handling */ - -- (NSArray *) properlySplitAddresses: (NSArray *) _addresses -{ - NSString *addrs; - NGMailAddressParser *parser; - NSArray *result; - NSMutableArray *ma; - unsigned i, count; - - if (!_addresses || [_addresses count] == 0) - return nil; - - /* create one huge string, then split it using the parser */ - addrs = [_addresses componentsJoinedByString:@","]; - parser = [NGMailAddressParser mailAddressParserWithString:addrs]; - result = [parser parseAddressList]; - if(result == nil) { - [self debugWithFormat:@"Couldn't parse given addresses:%@", _addresses]; - return _addresses; - } - - count = [result count]; - ma = [NSMutableArray arrayWithCapacity:count]; - for (i = 0; i < count; i++) { - NGMailAddress *addr; - NSMutableString *s; - BOOL hasName = NO; - - s = [[NSMutableString alloc] init]; - addr = [result objectAtIndex:i]; - if([addr displayName]) { - [s appendString:[addr displayName]]; - [s appendString:@" "]; - hasName = YES; - } - if(hasName) - [s appendString:@"<"]; - [s appendString:[addr address]]; - if(hasName) - [s appendString:@">"]; - [ma addObject:s]; - } - return ma; -} - /* handling requests */ - (void) _fillAddresses: (NSMutableArray *) addresses diff --git a/UI/WebServerResources/MailerUI.css b/UI/WebServerResources/MailerUI.css index ead44e6fc..04970b43a 100644 --- a/UI/WebServerResources/MailerUI.css +++ b/UI/WebServerResources/MailerUI.css @@ -379,6 +379,11 @@ DIV.mailer_mailcontent bottom: 0px; overflow: auto; } +DIV.mailer_mailcontent TABLE +{ + table-layout: auto; +} + TD.mailer_fieldname { white-space: nowrap;