diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index 12bec8609..1b0cbd066 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -2507,7 +2507,7 @@ Defaults to `inline` when unset. |Show recipients or sender full email in mailboxes if set to `YES`. Default value is `NO`. |U |SOGoMailHideInlineAttachments -|Hide inline message as attachements if set to `YES`. Default value is `NO`. +|Hide inline images as attachements if set to `YES`. Default value is `NO`. |U |SOGoMailCustomFullName diff --git a/UI/MailPartViewers/UIxMailPartMixedViewer.m b/UI/MailPartViewers/UIxMailPartMixedViewer.m index 00f6b2123..e8756328a 100644 --- a/UI/MailPartViewers/UIxMailPartMixedViewer.m +++ b/UI/MailPartViewers/UIxMailPartMixedViewer.m @@ -31,9 +31,13 @@ #import +#import + #import "UIxMailRenderingContext.h" #import "UIxMailPartMixedViewer.h" +@class SOGoImageMailBodyPart; + @implementation UIxMailPartMixedViewer - (void) dealloc @@ -101,6 +105,7 @@ id viewer, info; NSArray *parts; SOGoUserDefaults *ud; + BOOL displayAttachment; NSUInteger i, max; @@ -127,13 +132,21 @@ viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info]; [viewer setBodyInfo: info]; [viewer setPartPath: [self childPartPath]]; + if ([self decodedFlatContent]) [viewer setDecodedContent: [parts objectAtIndex: i]]; - [viewer setAttachmentIds: attachmentIds - displayAttachment:!([info objectForKey:@"disposition"] + + contentType = [NSString stringWithFormat: @"%@/%@", + [info objectForKey: @"type"], + [info objectForKey: @"subtype"]]; + displayAttachment = !([info objectForKey:@"disposition"] && [[info objectForKey:@"disposition"] objectForKey:@"type"] && [[[[info objectForKey:@"disposition"] objectForKey:@"type"] uppercaseString] isEqualToString:@"INLINE"] - && [ud hideInlineAttachments])]; + && [ud hideInlineAttachments] + && [SOGoMailBodyPart bodyPartClassForMimeType: [contentType lowercaseString] inContext: [self context]] == [SOGoImageMailBodyPart class]); + + [viewer setAttachmentIds: attachmentIds + displayAttachment: displayAttachment]; [renderedParts addObject: [viewer renderedPart]]; } diff --git a/UI/MailerUI/UIxMailListActions.m b/UI/MailerUI/UIxMailListActions.m index 719d326fd..df44ce960 100644 --- a/UI/MailerUI/UIxMailListActions.m +++ b/UI/MailerUI/UIxMailListActions.m @@ -50,6 +50,7 @@ #import #import #import +#import #import #import #import @@ -67,6 +68,8 @@ #import "UIxMailListActions.h" +@class SOGoImageMailBodyPart; + // The maximum number of headers to prefetch when querying the UIDs list #define headersPrefetchMaxSize 100 @@ -318,20 +321,34 @@ NSEnumerator *part; NSDictionary *currentPart; SOGoUserDefaults *ud; - BOOL isInline; + BOOL isInline, isImage; + NSString *contentType; ud = [[[self context] activeUser] userDefaults]; - if ([parts count] > 1) + if ([parts count] > 0) { part = [parts objectEnumerator]; while (!hasAttachment && (currentPart = [part nextObject])) { if ([currentPart objectForKey: @"type"] && ![[[currentPart objectForKey: @"type"] uppercaseString] hasPrefix: @"MULTIPART"]) { + contentType = [NSString stringWithFormat: @"%@/%@", + [currentPart objectForKey: @"type"], + [currentPart objectForKey: @"subtype"]]; + isInline = currentPart && [currentPart objectForKey:@"disposition"] && [[currentPart objectForKey:@"disposition"] objectForKey:@"type"] && [[[[currentPart objectForKey:@"disposition"] objectForKey:@"type"] uppercaseString] isEqualToString:@"INLINE"]; - if (![ud hideInlineAttachments] || ([ud hideInlineAttachments] && !isInline)) { + isImage = [SOGoMailBodyPart bodyPartClassForMimeType: [contentType lowercaseString] inContext: [self context]] == [SOGoImageMailBodyPart class]; + + if (![ud hideInlineAttachments] || ([ud hideInlineAttachments] && !(isInline && isImage))) { + BOOL a = [currentPart objectForKey:@"disposition"] ; + BOOL b = [[[currentPart objectForKey:@"disposition"] allKeys] length] > 0 ; + BOOL c = [currentPart objectForKey:@"parameterList"] ; + BOOL d = [[currentPart objectForKey:@"parameterList"] objectForKey:@"name"]; + BOOL foo = ([currentPart objectForKey:@"parameterList"] + && [[currentPart objectForKey:@"parameterList"] objectForKey:@"name"] + ); hasAttachment = (([currentPart objectForKey:@"disposition"] && [[[currentPart objectForKey:@"disposition"] allKeys] length] > 0) || ([currentPart objectForKey:@"parameterList"] @@ -341,6 +358,9 @@ } else if ([currentPart objectForKey:@"parts"]) { hasAttachment = [self parseParts: [currentPart objectForKey:@"parts"] hasAttachment: hasAttachment]; } + + if (hasAttachment) + break; } } diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index b326ed1b5..de0385922 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -205,7 +205,7 @@ "Insert signature on reply" = "Insert signature on reply"; "Insert signature on forward" = "Insert signature on forward"; "Show recipients or sender full email in mailboxes" = "Show recipients or sender full email in mailboxes"; -"Hide inline attachments" = "Hide inline attachments"; +"Hide inline images" = "Hide inline images"; /* Base font size for messages composed in HTML */ "Default font size" = "Default font size"; diff --git a/UI/PreferencesUI/French.lproj/Localizable.strings b/UI/PreferencesUI/French.lproj/Localizable.strings index 329f82ac5..2841afd75 100644 --- a/UI/PreferencesUI/French.lproj/Localizable.strings +++ b/UI/PreferencesUI/French.lproj/Localizable.strings @@ -205,7 +205,7 @@ "Insert signature on reply" = "Insérer la signature sur une réponse"; "Insert signature on forward" = "Insérer la signature sur un transfert"; "Show recipients or sender full email in mailboxes" = "Afficher l'email complet du destinataire ou expéditeur dans les boîtes aux lettres"; -"Hide inline attachments" = "Cacher les pièces jointes 'inline'"; +"Hide inline images" = "Cacher les images 'inline'"; /* Base font size for messages composed in HTML */ "Default font size" = "Taille de la police par défaut"; diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index ca779bd24..91d2031c7 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -710,8 +710,8 @@ ng-model="app.preferences.defaults.SOGoMailHideInlineAttachments" ng-true-value="1" ng-false-value="0" - label:aria-label="Hide inline attachments"> - + label:aria-label="Hide inline images"> +