mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-23 23:22:45 +00:00
See ChangeLog
Monotone-Parent: a866a555c48a341d0c2a136b18f5d9b7474a4559 Monotone-Revision: b60d547047a2529bf2428a9d602340aa1c4f7f9b Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2009-09-27T17:24:20 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -28,163 +28,12 @@
|
||||
#include <openssl/x509.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
|
||||
#import <NGExtensions/NSString+misc.h>
|
||||
#import <NGMail/NGMimeMessage.h>
|
||||
#import <NGMail/NGMimeMessageParser.h>
|
||||
#import <NGMime/NGMimeBodyPart.h>
|
||||
#import <NGMime/NGMimeMultipartBody.h>
|
||||
#import <NGMime/NGMimeType.h>
|
||||
#import <NGMime/NGPart.h>
|
||||
|
||||
#import <Mailer/SOGoMailBodyPart.h>
|
||||
#import <Mailer/SOGoMailObject.h>
|
||||
|
||||
#import <SOGo/NSString+Utilities.h>
|
||||
#import <Mailer/NSString+Mail.h>
|
||||
|
||||
#import "UIxMailPartSignedViewer.h"
|
||||
|
||||
@interface NGMimeMessage (SOGoExtension)
|
||||
|
||||
- (id <NGMimePart>) mimePartFromPath: (NSArray *) path;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NGMimeMessage (SOGoExtension)
|
||||
|
||||
- (id <NGMimePart>) mimePartFromPath: (NSArray *) path
|
||||
{
|
||||
int count, max, partNumber;
|
||||
BOOL overflow;
|
||||
id <NGMimePart> currentPart, foundPart;
|
||||
NSArray *parts;
|
||||
|
||||
foundPart = nil;
|
||||
overflow = NO;
|
||||
|
||||
currentPart = [self body];
|
||||
|
||||
max = [path count];
|
||||
for (count = 0; (!overflow && !foundPart) && count < max; count++)
|
||||
{
|
||||
partNumber = [[path objectAtIndex: count] intValue];
|
||||
if (partNumber == 0)
|
||||
foundPart = currentPart;
|
||||
else
|
||||
{
|
||||
if ([currentPart isKindOfClass: [NGMimeMultipartBody class]])
|
||||
{
|
||||
parts = [(NGMimeMultipartBody *) currentPart parts];
|
||||
if (partNumber <= [parts count])
|
||||
currentPart = [parts objectAtIndex: partNumber - 1];
|
||||
else
|
||||
overflow = YES;
|
||||
}
|
||||
else
|
||||
overflow = YES;
|
||||
}
|
||||
}
|
||||
if (!overflow)
|
||||
foundPart = currentPart;
|
||||
|
||||
return foundPart;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface NGMimeType (SOGoExtension)
|
||||
|
||||
- (BOOL) isEqualToString: (NSString *) otherType;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NGMimeType (SOGoExtension)
|
||||
|
||||
- (BOOL) isEqualToString: (NSString *) otherType
|
||||
{
|
||||
NSString *thisString;
|
||||
|
||||
thisString = [NSString stringWithFormat: @"%@/%@",
|
||||
[self type], [self subType]];
|
||||
|
||||
return [thisString isEqualToString: otherType];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIxMailPartSignedViewer : UIxMailPartViewer
|
||||
|
||||
- (void) _setupParts
|
||||
{
|
||||
NSData *content;
|
||||
NGMimeMessageParser *parser;
|
||||
NGMimeMessage *message;
|
||||
NSArray *path;
|
||||
id co;
|
||||
NSArray *parts;
|
||||
|
||||
co = [self clientObject];
|
||||
|
||||
content = [co content];
|
||||
parser = [NGMimeMessageParser new];
|
||||
message = [parser parsePartFromData: content];
|
||||
if ([co respondsToSelector: @selector (bodyPartPath)])
|
||||
path = [(SOGoMailBodyPart *) co bodyPartPath];
|
||||
else
|
||||
path = [NSArray arrayWithObject: @"0"];
|
||||
parts = [(NGMimeMultipartBody *) [message mimePartFromPath: path] parts];
|
||||
if ([parts count] == 2)
|
||||
messagePart = [parts objectAtIndex: 0];
|
||||
|
||||
[parser release];
|
||||
}
|
||||
|
||||
- (NSString *) flatContentAsString
|
||||
{
|
||||
NSString *body, *content;
|
||||
NGMimeType *mimeType;
|
||||
|
||||
[self _setupParts];
|
||||
|
||||
mimeType = [messagePart contentType];
|
||||
if ([mimeType isEqualToString: @"text/plain"])
|
||||
{
|
||||
body = [[messagePart body] stringByEscapingHTMLString];
|
||||
content = [[body stringByDetectingURLs]
|
||||
stringByConvertingCRLNToHTML];
|
||||
}
|
||||
else if ([mimeType isEqualToString: @"multipart/alternative"])
|
||||
{
|
||||
NSArray *parts;
|
||||
int i;
|
||||
|
||||
parts = [(NGMimeMultipartBody *)[messagePart body] parts];
|
||||
|
||||
for (i = 0; i < [parts count]; i++)
|
||||
{
|
||||
mimeType = [[parts objectAtIndex: i] contentType];
|
||||
|
||||
if ([mimeType isEqualToString: @"text/plain"])
|
||||
{
|
||||
body = [[[parts objectAtIndex: i] body] stringByEscapingHTMLString];
|
||||
content = [[body stringByDetectingURLs]
|
||||
stringByConvertingCRLNToHTML];
|
||||
break;
|
||||
}
|
||||
else
|
||||
content = nil;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog (@"unhandled mime type in multipart/signed: '%@'", mimeType);
|
||||
content = nil;
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
@implementation UIxMailPartSignedViewer : UIxMailPartMixedViewer
|
||||
|
||||
- (X509_STORE *) _setupVerify
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user