(feat) added S/MIME file download support

pull/239/head
Ludovic Marcotte 2017-12-23 06:06:23 -05:00
parent 64a7b8a797
commit 6294d91180
1 changed files with 31 additions and 8 deletions

View File

@ -1,14 +1,15 @@
/*
Copyright (C) 2005-2017 Inverse inc.
Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of OpenGroupware.org.
This file is part of SOGo.
OGo is free software; you can redistribute it and/or modify it under
SOGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
@ -32,12 +33,15 @@
#import <NGExtensions/NGBase64Coding.h>
#import <NGExtensions/NGQuotedPrintableCoding.h>
#import <NGImap4/NGImap4Connection.h>
#import <NGMail/NGMimeMessage.h>
#import <NGMime/NGMimeMultipartBody.h>
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
#import "NSData+SMIME.h"
#import "NSDictionary+Mail.h"
#import "SOGoMailObject.h"
#import "SOGoMailAccount.h"
#import "SOGoMailBodyPart.h"
@implementation SOGoMailBodyPart
@ -250,10 +254,9 @@ static BOOL debugOn = NO;
NSString *enc;
NSData *data;
data = [[self imap4Connection] fetchContentOfBodyPart:
[self bodyPartIdentifier]
atURL:[self imap4URL]
withPeek: withPeek];
data = [[self imap4Connection] fetchContentOfBodyPart: [self bodyPartIdentifier]
atURL: [self imap4URL]
withPeek: withPeek];
if (data == nil) return nil;
/* check for content encodings */
@ -289,6 +292,26 @@ static BOOL debugOn = NO;
- (NSData *) fetchBLOB
{
if ([[self container] isEncrypted])
{
NSData *certificate;
certificate = [[self mailAccountFolder] certificate];
// If we got a user certificate, let's use it. Otherwise we fallback
// to the current BLOB fetching code.
if (certificate)
{
NGMimeMessage *m;
id part;
m = [[container content] messageFromEncryptedDataAndCertificate: certificate];
part = [[[m body] parts] objectAtIndex: ([[self nameInContainer] intValue]-1)];
return [part body];
}
}
return [self fetchBLOBWithPeek: NO];
}