From 8a4ebe2c609d14320e69169fd139f46e2f578c80 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Sat, 23 Dec 2017 04:53:41 -0500 Subject: [PATCH] (feat) can now associate certificate (PEM format) on mail account --- SoObjects/Mailer/SOGoMailAccount.h | 6 +++++- SoObjects/Mailer/SOGoMailAccount.m | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/SoObjects/Mailer/SOGoMailAccount.h b/SoObjects/Mailer/SOGoMailAccount.h index 83a03ad80..2b6c871a3 100644 --- a/SoObjects/Mailer/SOGoMailAccount.h +++ b/SoObjects/Mailer/SOGoMailAccount.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2016 Inverse inc. + Copyright (C) 2009-2017 Inverse inc. This file is part of SOGo. @@ -126,6 +126,10 @@ typedef enum { - (void) addDelegates: (NSArray *) newDelegates; - (void) removeDelegates: (NSArray *) oldDelegates; +/* S/MIME certificate */ +- (NSData *) certificate; +- (void) setCertificate: (NSData *) theData; + @end #endif /* __Mailer_SOGoMailAccount_H__ */ diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index f8342a65c..095f7a180 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -26,6 +26,7 @@ #import #import +#import #import #import #import @@ -1184,4 +1185,25 @@ static NSString *inboxFolderName = @"INBOX"; return [[self _mailAccount] objectForKey: @"name"]; } +- (NSData *) certificate +{ + SOGoUserDefaults *ud; + + ud = [[context activeUser] userDefaults]; + return [[ud stringForKey: @"SOGoMailCertificate"] dataByDecodingBase64]; +} + +- (void) setCertificate: (NSData *) theData +{ + SOGoUserDefaults *ud; + + ud = [[context activeUser] userDefaults]; + + if ([theData length]) + [ud setObject: [theData stringByEncodingBase64] forKey: @"SOGoMailCertificate"]; + else + [ud removeObjectForKey: @"SOGoMailCertificate"]; +} + + @end /* SOGoMailAccount */