diff --git a/ChangeLog b/ChangeLog index 52dce888d..d51c8b80b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-27 Ludovic Marcotte + + * Reworked the UIxMailPartSignedViewer to inherit + from UIxMailPartMixedViewer. + 2009-09-25 Ludovic Marcotte * Renamed SoObjects/Contacts/SOGoContactLDAPFolder to diff --git a/UI/MailPartViewers/UIxMailPartSignedViewer.h b/UI/MailPartViewers/UIxMailPartSignedViewer.h index 9d91755cb..ef3e32565 100644 --- a/UI/MailPartViewers/UIxMailPartSignedViewer.h +++ b/UI/MailPartViewers/UIxMailPartSignedViewer.h @@ -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; diff --git a/UI/MailPartViewers/UIxMailPartSignedViewer.m b/UI/MailPartViewers/UIxMailPartSignedViewer.m index 1343c1721..75f11db19 100644 --- a/UI/MailPartViewers/UIxMailPartSignedViewer.m +++ b/UI/MailPartViewers/UIxMailPartSignedViewer.m @@ -28,163 +28,12 @@ #include #import - -#import -#import -#import -#import -#import -#import #import - -#import #import -#import -#import - #import "UIxMailPartSignedViewer.h" -@interface NGMimeMessage (SOGoExtension) - -- (id ) mimePartFromPath: (NSArray *) path; - -@end - -@implementation NGMimeMessage (SOGoExtension) - -- (id ) mimePartFromPath: (NSArray *) path -{ - int count, max, partNumber; - BOOL overflow; - id 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 { diff --git a/UI/Templates/MailPartViewers/UIxMailPartSignedViewer.wox b/UI/Templates/MailPartViewers/UIxMailPartSignedViewer.wox index e6903d679..89b277006 100644 --- a/UI/Templates/MailPartViewers/UIxMailPartSignedViewer.wox +++ b/UI/Templates/MailPartViewers/UIxMailPartSignedViewer.wox @@ -9,5 +9,14 @@ const:id="signedMessage" var:valid="validSignature" var:error="validationMessage" - > +> +
+ +
+ +
+
+
+