2006-06-15 21:34:10 +02:00
|
|
|
/*
|
2017-12-23 15:07:14 +01:00
|
|
|
Copyright (C) 2007-2017 Inverse inc.
|
2006-06-15 21:34:10 +02:00
|
|
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
|
|
|
|
2009-04-01 15:49:24 +02:00
|
|
|
This file is part of SOGo.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2009-04-01 15:49:24 +02:00
|
|
|
SOGo is free software; you can redistribute it and/or modify it under
|
2006-06-15 21:34:10 +02:00
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
2009-04-01 15:49:24 +02:00
|
|
|
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
2006-06-15 21:34:10 +02:00
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2015-05-13 04:37:58 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
|
2018-01-23 16:35:46 +01:00
|
|
|
#import <SOGo/NSObject+Utilities.h>
|
|
|
|
|
|
|
|
#import <NGMime/NGMimeBodyPart.h>
|
2017-12-23 15:07:14 +01:00
|
|
|
#import <NGMime/NGMimeMultipartBody.h>
|
|
|
|
|
2007-07-30 16:10:18 +02:00
|
|
|
#import <UI/MailerUI/WOContext+UIxMailer.h>
|
|
|
|
|
|
|
|
#import "UIxMailRenderingContext.h"
|
2009-09-13 17:17:27 +02:00
|
|
|
#import "UIxMailPartMixedViewer.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
@implementation UIxMailPartMixedViewer
|
|
|
|
|
2018-01-23 16:35:46 +01:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
[self->childInfo release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2018-01-23 16:35:46 +01:00
|
|
|
- (void)resetBodyInfoCaches
|
|
|
|
{
|
|
|
|
DESTROY(self->childInfo);
|
2006-06-15 21:34:10 +02:00
|
|
|
[super resetBodyInfoCaches];
|
|
|
|
}
|
|
|
|
|
2018-01-23 16:35:46 +01:00
|
|
|
- (void) setChildInfo:(id)_info
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
ASSIGN(self->childInfo, _info);
|
|
|
|
}
|
2018-01-23 16:35:46 +01:00
|
|
|
|
|
|
|
- (id) childInfo
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return self->childInfo;
|
|
|
|
}
|
|
|
|
|
2017-12-23 15:07:14 +01:00
|
|
|
- (void) setChildIndex: (NSUInteger) _index
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
self->childIndex = _index;
|
|
|
|
}
|
2018-01-23 16:35:46 +01:00
|
|
|
|
2017-12-23 15:07:14 +01:00
|
|
|
- (NSUInteger) childIndex
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return self->childIndex;
|
|
|
|
}
|
|
|
|
|
2017-12-23 15:07:14 +01:00
|
|
|
- (NSString *) childPartName
|
|
|
|
{
|
2015-05-13 04:37:58 +02:00
|
|
|
return [NSString stringWithFormat: @"%u",
|
|
|
|
(unsigned int) ([self childIndex] + 1)];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2018-01-23 16:35:46 +01:00
|
|
|
- (id) childPartPath
|
2017-12-23 15:07:14 +01:00
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
NSArray *pp;
|
|
|
|
|
|
|
|
pp = [self partPath];
|
|
|
|
return [pp count] > 0
|
2009-04-01 15:49:24 +02:00
|
|
|
? (id)[pp arrayByAddingObject:[self childPartName]]
|
|
|
|
: (id)[NSArray arrayWithObject:[self childPartName]];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nested viewers */
|
|
|
|
|
2017-12-23 15:07:14 +01:00
|
|
|
- (id)contentViewerComponent
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
id info;
|
|
|
|
|
|
|
|
info = [self childInfo];
|
2017-12-23 15:07:14 +01:00
|
|
|
return [[[self context] mailRenderingContext] viewerForBodyInfo: info];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2017-12-23 15:07:14 +01:00
|
|
|
- (id) renderedPart
|
|
|
|
{
|
2015-05-13 04:37:58 +02:00
|
|
|
NSMutableArray *renderedParts;
|
2015-10-06 21:38:37 +02:00
|
|
|
NSString *contentType;
|
2017-12-23 15:07:14 +01:00
|
|
|
id viewer, info;
|
|
|
|
NSArray *parts;
|
|
|
|
|
2015-05-13 04:37:58 +02:00
|
|
|
NSUInteger i, max;
|
|
|
|
|
2018-01-23 16:35:46 +01:00
|
|
|
if ([self decodedFlatContent])
|
2017-12-23 15:07:14 +01:00
|
|
|
parts = [[self decodedFlatContent] parts];
|
|
|
|
else
|
|
|
|
parts = [[self bodyInfo] valueForKey: @"parts"];
|
|
|
|
|
2015-05-13 04:37:58 +02:00
|
|
|
max = [parts count];
|
|
|
|
renderedParts = [NSMutableArray arrayWithCapacity: max];
|
2017-12-23 15:07:14 +01:00
|
|
|
|
2015-05-13 04:37:58 +02:00
|
|
|
for (i = 0; i < max; i++)
|
|
|
|
{
|
|
|
|
[self setChildIndex: i];
|
2017-12-23 15:07:14 +01:00
|
|
|
|
2018-01-23 16:35:46 +01:00
|
|
|
if ([self decodedFlatContent])
|
2017-12-23 15:07:14 +01:00
|
|
|
[self setChildInfo: [[parts objectAtIndex: i] bodyInfo]];
|
|
|
|
else
|
|
|
|
[self setChildInfo: [parts objectAtIndex: i]];
|
|
|
|
|
2015-05-13 04:37:58 +02:00
|
|
|
info = [self childInfo];
|
|
|
|
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
|
|
|
|
[viewer setBodyInfo: info];
|
|
|
|
[viewer setPartPath: [self childPartPath]];
|
2018-01-23 16:35:46 +01:00
|
|
|
if ([self decodedFlatContent])
|
2017-12-23 15:07:14 +01:00
|
|
|
[viewer setDecodedContent: [parts objectAtIndex: i]];
|
2018-01-23 16:35:46 +01:00
|
|
|
[viewer setAttachmentIds: attachmentIds];
|
|
|
|
|
2015-05-13 04:37:58 +02:00
|
|
|
[renderedParts addObject: [viewer renderedPart]];
|
|
|
|
}
|
2017-12-23 15:07:14 +01:00
|
|
|
|
2015-10-06 21:38:37 +02:00
|
|
|
contentType = [NSString stringWithFormat: @"%@/%@",
|
|
|
|
[[self bodyInfo] objectForKey: @"type"],
|
|
|
|
[[self bodyInfo] objectForKey: @"subtype"]];
|
2015-05-13 04:37:58 +02:00
|
|
|
|
|
|
|
return [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
[self className], @"type",
|
2015-10-06 21:38:37 +02:00
|
|
|
contentType, @"contentType",
|
2015-05-13 04:37:58 +02:00
|
|
|
renderedParts, @"content",
|
|
|
|
nil];
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@end /* UIxMailPartMixedViewer */
|