(fix) cleanups

pull/239/head
Ludovic Marcotte 2017-12-23 08:57:45 -05:00
parent 496b402d17
commit 72273bf454
1 changed files with 35 additions and 24 deletions

View File

@ -45,38 +45,49 @@
- (id) renderedPart - (id) renderedPart
{ {
NSData *certificate;
id info, viewer; id info, viewer;
NSData *encryptedData; certificate = [[[self clientObject] mailAccountFolder] certificate];
#if 1 if (certificate)
NSData *pkcs12Data = [NSData dataWithContentsOfFile: @"/home/sogo/dropbucket/lmarcotte@inverse.ca.p12"]; {
[pkcs12Data convertPKCS12ToPEMUsingPassword: @"831af13d97576d74d574628c1d0e5abe"]; NSData *decryptedData, *encryptedData;
#endif
encryptedData = [[self clientObject] content];
[encryptedData writeToFile: @"/tmp/received.encrypted" atomically: 1];
//NSData *pem = [NSData dataWithContentsOfFile: @"/home/sogo/dropbucket/lmarcotte@inverse.ca.pem"]; encryptedData = [[self clientObject] content];
NSData *pem = [NSData dataWithContentsOfFile: @"/tmp/foofoo.newpem"]; decryptedData = [encryptedData decryptUsingCertificate: certificate];
NSData *decryptedData = [encryptedData decryptUsingCertificate: pem];
NGMimeMessageParser *parser = [[NGMimeMessageParser alloc] init]; if (decryptedData)
id part = [[parser parsePartFromData: decryptedData] retain]; {
NGMimeMessageParser *parser;
id part;
info = [NSDictionary dictionaryWithObjectsAndKeys: [[part contentType] type], @"type", parser = [[NGMimeMessageParser alloc] init];
[[part contentType] subType], @"subtype", nil]; part = [[parser parsePartFromData: decryptedData] retain];
info = [NSDictionary dictionaryWithObjectsAndKeys: [[part contentType] type], @"type",
[[part contentType] subType], @"subtype", nil];
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setFlatContent: decryptedData];
[viewer setDecodedContent: [part body]];
return [NSDictionary dictionaryWithObjectsAndKeys:
[self className], @"type",
[NSArray arrayWithObject: [viewer renderedPart]], @"content",
nil];
}
}
// Decryption failed, let's return the master viewer
// FIXME - does not work for now.
info = [NSDictionary dictionaryWithObjectsAndKeys: @"multipart", @"type",
@"mixed", @"subtype", nil];
[self setFlatContent: nil];
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info]; viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info]; [viewer setBodyInfo: info];
[viewer setFlatContent: decryptedData];
[viewer setDecodedContent: [part body]]; return [viewer renderedPart];
return [NSDictionary dictionaryWithObjectsAndKeys:
[self className], @"type",
[NSArray arrayWithObject: [viewer renderedPart]], @"content",
nil];
//return [viewer renderedPart];
} }
@end /* UIxMailPartAlternativeViewer */ @end /* UIxMailPartAlternativeViewer */