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
maint-2.0.2
Ludovic Marcotte 2009-09-27 17:24:20 +00:00
parent 30d6257136
commit 4abc5045aa
4 changed files with 19 additions and 160 deletions

View File

@ -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>
* Renamed SoObjects/Contacts/SOGoContactLDAPFolder to

View File

@ -23,22 +23,18 @@
#ifndef UIXMAILPARTSIGNEDVIEWER_H
#define UIXMAILPARTSIGNEDVIEWER_H
#import "UIxMailPartViewer.h"
#import "UIxMailPartMixedViewer.h"
@class NSMutableString;
@class NGPart;
@interface UIxMailPartSignedViewer : UIxMailPartViewer
@interface UIxMailPartSignedViewer : UIxMailPartMixedViewer
{
BOOL processed;
NGPart *messagePart;
BOOL validSignature;
NSMutableString *validationMessage;
}
- (NSString *) flatContentAsString;
- (BOOL) validSignature;
- (NSString *) validationMessage;

View File

@ -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
{

View File

@ -9,5 +9,14 @@
const:id="signedMessage"
var:valid="validSignature"
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>