See ChangeLog
Monotone-Parent: a866a555c48a341d0c2a136b18f5d9b7474a4559 Monotone-Revision: b60d547047a2529bf2428a9d602340aa1c4f7f9b Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2009-09-27T17:24:20 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
30d6257136
commit
4abc5045aa
|
@ -1,3 +1,8 @@
|
||||||
|
2009-09-27 Ludovic Marcotte <lmarcotte@inverse.ca>
|
||||||
|
|
||||||
|
* Reworked the UIxMailPartSignedViewer to inherit
|
||||||
|
from UIxMailPartMixedViewer.
|
||||||
|
|
||||||
2009-09-25 Ludovic Marcotte <lmarcotte@inverse.ca>
|
2009-09-25 Ludovic Marcotte <lmarcotte@inverse.ca>
|
||||||
|
|
||||||
* Renamed SoObjects/Contacts/SOGoContactLDAPFolder to
|
* Renamed SoObjects/Contacts/SOGoContactLDAPFolder to
|
||||||
|
|
|
@ -23,22 +23,18 @@
|
||||||
#ifndef UIXMAILPARTSIGNEDVIEWER_H
|
#ifndef UIXMAILPARTSIGNEDVIEWER_H
|
||||||
#define UIXMAILPARTSIGNEDVIEWER_H
|
#define UIXMAILPARTSIGNEDVIEWER_H
|
||||||
|
|
||||||
#import "UIxMailPartViewer.h"
|
#import "UIxMailPartMixedViewer.h"
|
||||||
|
|
||||||
@class NSMutableString;
|
@class NSMutableString;
|
||||||
@class NGPart;
|
@class NGPart;
|
||||||
|
|
||||||
@interface UIxMailPartSignedViewer : UIxMailPartViewer
|
@interface UIxMailPartSignedViewer : UIxMailPartMixedViewer
|
||||||
{
|
{
|
||||||
BOOL processed;
|
BOOL processed;
|
||||||
NGPart *messagePart;
|
|
||||||
|
|
||||||
BOOL validSignature;
|
BOOL validSignature;
|
||||||
NSMutableString *validationMessage;
|
NSMutableString *validationMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) flatContentAsString;
|
|
||||||
|
|
||||||
- (BOOL) validSignature;
|
- (BOOL) validSignature;
|
||||||
- (NSString *) validationMessage;
|
- (NSString *) validationMessage;
|
||||||
|
|
||||||
|
|
|
@ -28,163 +28,12 @@
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
|
|
||||||
#import <Foundation/NSArray.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 <NGMime/NGPart.h>
|
||||||
|
|
||||||
#import <Mailer/SOGoMailBodyPart.h>
|
|
||||||
#import <Mailer/SOGoMailObject.h>
|
#import <Mailer/SOGoMailObject.h>
|
||||||
|
|
||||||
#import <SOGo/NSString+Utilities.h>
|
|
||||||
#import <Mailer/NSString+Mail.h>
|
|
||||||
|
|
||||||
#import "UIxMailPartSignedViewer.h"
|
#import "UIxMailPartSignedViewer.h"
|
||||||
|
|
||||||
@interface NGMimeMessage (SOGoExtension)
|
@implementation UIxMailPartSignedViewer : UIxMailPartMixedViewer
|
||||||
|
|
||||||
- (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;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (X509_STORE *) _setupVerify
|
- (X509_STORE *) _setupVerify
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,5 +9,14 @@
|
||||||
const:id="signedMessage"
|
const:id="signedMessage"
|
||||||
var:valid="validSignature"
|
var:valid="validSignature"
|
||||||
var:error="validationMessage"
|
var:error="validationMessage"
|
||||||
><var:string value="flatContentAsString" const:escapeHTML="NO"
|
>
|
||||||
/></div>
|
<div>
|
||||||
|
<var:foreach list="bodyInfo.parts" item="childInfo" index="childIndex">
|
||||||
|
<div>
|
||||||
|
<var:component value="contentViewerComponent"
|
||||||
|
bodyInfo="childInfo"
|
||||||
|
partPath="childPartPath" />
|
||||||
|
</div>
|
||||||
|
</var:foreach>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue