(fix) properly handle subparts compilation for message/rfc822 message parts

This commit is contained in:
Ludovic Marcotte
2015-07-29 15:37:55 -04:00
parent d3a233b222
commit 16885f4ebf
3 changed files with 83 additions and 30 deletions

View File

@@ -31,6 +31,8 @@
#import <UI/MailerUI/WOContext+UIxMailer.h>
#import "UIxMailRenderingContext.h"
#import <Foundation/NSDictionary.h>
#import "UIxMailPartViewer.h"
/*
@@ -205,4 +207,48 @@
return [@"mailto:" stringByAppendingString:[_address baseEMail]];
}
- (id) renderedPart
{
id info, viewer;
NSArray *parts;
NSMutableArray *renderedParts;
NSUInteger i, max;
parts = [[self contentInfo] objectForKey: @"parts"];
renderedParts = [NSMutableArray array];
max = [parts count];
// Might get a multipart/*
if (max)
{
for (i = 0; i < max; i++)
{
info = [parts objectAtIndex: i];
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [[self contentPartPath] arrayByAddingObject: [NSString stringWithFormat: @"%d", i+1]]];
[renderedParts addObject: [viewer renderedPart]];
}
}
else
{
info = [self contentInfo];
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [self contentPartPath]];
[renderedParts addObject: [viewer renderedPart]];
}
// We inject the output of our UIxMailPartMessageViewer template
// in order to pretty-format the parts following it.
info = [NSDictionary dictionaryWithObjectsAndKeys: @"text/plain", @"contentType", @"UIxMailPartTextViewer", @"type",
[[self generateResponse] contentAsString], @"content", nil];
[renderedParts insertObject: info atIndex: 0];
return [NSDictionary dictionaryWithObjectsAndKeys:
[self className], @"type",
renderedParts, @"content",
nil];
}
@end /* UIxMailPartMessageViewer */