JSONify mail parts

This commit is contained in:
Francis Lachapelle
2015-05-12 22:37:58 -04:00
parent 6cd02043af
commit 9ed65e34ad
9 changed files with 215 additions and 103 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2007-2009 Inverse inc.
Copyright (C) 2007-2015 Inverse inc.
Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of SOGo.
@@ -20,6 +20,8 @@
02111-1307, USA.
*/
#import <Foundation/NSDictionary.h>
#import <UI/MailerUI/WOContext+UIxMailer.h>
#import "UIxMailRenderingContext.h"
@@ -48,14 +50,16 @@
return self->childInfo;
}
- (void)setChildIndex:(unsigned int)_index {
- (void) setChildIndex: (NSUInteger) _index {
self->childIndex = _index;
}
- (unsigned int)childIndex {
- (NSUInteger) childIndex {
return self->childIndex;
}
- (NSString *)childPartName {
return [NSString stringWithFormat: @"%u",
(unsigned int) ([self childIndex] + 1)];
char buf[8];
sprintf(buf, "%d", [self childIndex] + 1);
return [NSString stringWithCString:buf];
@@ -79,4 +83,30 @@
return [[[self context] mailRenderingContext] viewerForBodyInfo:info];
}
- (id) renderedPart {
id info, viewer;
NSArray *parts;
NSMutableArray *renderedParts;
NSUInteger i, max;
parts = [[self bodyInfo] objectForKey: @"parts"];
max = [parts count];
renderedParts = [NSMutableArray arrayWithCapacity: max];
for (i = 0; i < max; i++)
{
[self setChildIndex: i];
[self setChildInfo: [parts objectAtIndex: i]];
info = [self childInfo];
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [self childPartPath]];
[renderedParts addObject: [viewer renderedPart]];
}
return [NSDictionary dictionaryWithObjectsAndKeys:
[self className], @"type",
renderedParts, @"content",
nil];
}
@end /* UIxMailPartMixedViewer */