mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-23 03:08:54 +00:00
feat(acccount): Add read only account
This commit is contained in:
1 parent
01f545b0b3
commit
370a4a433c
9 files changed
+120
-40
No files matched your search
@@ -506,31 +506,7 @@ static SoProduct *preferencesProduct = nil;
|
||||
// Add timezone offset
|
||||
[values setObject: [NSNumber numberWithInt: [[defaults timeZone] secondsFromGMT]] forKey: @"UserTimeZoneSecondsFromGMT"];
|
||||
|
||||
accounts = [NSMutableArray arrayWithArray: [values objectForKey: @"AuxiliaryMailAccounts"]];
|
||||
if ([accounts count])
|
||||
{
|
||||
int i;
|
||||
NSDictionary *security, *accountPassword;
|
||||
NSMutableDictionary *auxAccount, *limitedSecurity;
|
||||
NSString *password, *encryptedPassword, *sogoSecret, *iv, *tag;
|
||||
NSException* exception = nil;
|
||||
|
||||
for (i = 0; i < [accounts count]; i++)
|
||||
{
|
||||
auxAccount = [accounts objectAtIndex: i];
|
||||
security = [auxAccount objectForKey: @"security"];
|
||||
if (security && [domainDefaults mailCertificateEnabled])
|
||||
{
|
||||
limitedSecurity = [NSMutableDictionary dictionaryWithDictionary: security];
|
||||
if ([limitedSecurity objectForKey: @"certificate"])
|
||||
{
|
||||
[limitedSecurity setObject: [NSNumber numberWithBool: YES] forKey: @"hasCertificate"];
|
||||
[limitedSecurity removeObjectForKey: @"certificate"];
|
||||
}
|
||||
[auxAccount setObject: limitedSecurity forKey: @"security"];
|
||||
}
|
||||
}
|
||||
}
|
||||
NSMutableArray *clean_accounts = [NSMutableArray array];
|
||||
// We inject our default mail account
|
||||
account = [[[context activeUser] mailAccountsNoRawHtmlSignature] objectAtIndex: 0];
|
||||
if (![account objectForKey: @"receipts"])
|
||||
@@ -542,8 +518,44 @@ static SoProduct *preferencesProduct = nil;
|
||||
forKey: @"receipts"];
|
||||
}
|
||||
if (account)
|
||||
[accounts insertObject: account atIndex: 0];
|
||||
[values setObject: accounts forKey: @"AuxiliaryMailAccounts"];
|
||||
[clean_accounts addObject: account];
|
||||
|
||||
//Now check external account
|
||||
if (![domainDefaults mailAuxiliaryUserAccountsReadOnly] && [domainDefaults mailAuxiliaryUserAccountsEnabled])
|
||||
{
|
||||
accounts = [NSMutableArray arrayWithArray: [values objectForKey: @"AuxiliaryMailAccounts"]];
|
||||
if ([accounts count])
|
||||
{
|
||||
int i;
|
||||
NSDictionary *security, *accountPassword;
|
||||
NSMutableDictionary *auxAccount, *limitedSecurity;
|
||||
NSString *password, *encryptedPassword, *sogoSecret, *iv, *tag;
|
||||
NSException* exception = nil;
|
||||
|
||||
BOOL isReadOnly = [domainDefaults mailAuxiliaryUserAccountsReadOnly];
|
||||
for (i = 0; i < [accounts count]; i++)
|
||||
{
|
||||
auxAccount = [accounts objectAtIndex: i];
|
||||
if(isReadOnly && [auxAccount objectForKey: @"readOnly"])
|
||||
continue;
|
||||
security = [auxAccount objectForKey: @"security"];
|
||||
if (security && [domainDefaults mailCertificateEnabled])
|
||||
{
|
||||
limitedSecurity = [NSMutableDictionary dictionaryWithDictionary: security];
|
||||
if ([limitedSecurity objectForKey: @"certificate"])
|
||||
{
|
||||
[limitedSecurity setObject: [NSNumber numberWithBool: YES] forKey: @"hasCertificate"];
|
||||
[limitedSecurity removeObjectForKey: @"certificate"];
|
||||
}
|
||||
[auxAccount setObject: limitedSecurity forKey: @"security"];
|
||||
}
|
||||
[clean_accounts addObject: auxAccount];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[values setObject: clean_accounts forKey: @"AuxiliaryMailAccounts"];
|
||||
|
||||
// Ignore parameters as they are injected in the system mail account ([SOGoUser mailAccounts])
|
||||
[values removeObjectForKey: @"SOGoMailIdentities"];
|
||||
|
||||
@@ -1230,6 +1230,11 @@ static NSArray *reminderValues = nil;
|
||||
return [[user domainDefaults] mailAuxiliaryUserAccountsEnabled];
|
||||
}
|
||||
|
||||
- (BOOL) mailAuxiliaryUserAccountsReadOnly
|
||||
{
|
||||
return [[user domainDefaults] mailAuxiliaryUserAccountsReadOnly];
|
||||
}
|
||||
|
||||
//
|
||||
// Used internally
|
||||
//
|
||||
@@ -1534,15 +1539,30 @@ static NSArray *reminderValues = nil;
|
||||
//
|
||||
- (NSArray *) _extractAuxiliaryAccounts: (NSArray *) accounts
|
||||
{
|
||||
int count, max;
|
||||
int count, i;
|
||||
id isReadOnly;
|
||||
NSMutableArray *auxAccounts;
|
||||
NSMutableDictionary *account;
|
||||
NSDictionary *currentAux, *auxAccount;
|
||||
NSString *sogoSecret, *password;
|
||||
|
||||
max = [accounts count];
|
||||
auxAccounts = [NSMutableArray arrayWithCapacity: max];
|
||||
auxAccounts = [NSMutableArray array];
|
||||
|
||||
for (count = 1; count < max; count++)
|
||||
if ([self mailAuxiliaryUserAccountsReadOnly]) {
|
||||
//External account are read only. Meaning we don't accept any data from accounts
|
||||
//Instead we fetch the current ones to not lost them
|
||||
currentAux = [[[user userDefaults] source] objectForKey: @"AuxiliaryMailAccounts"];
|
||||
for (i = 0; i < [currentAux count]; i++)
|
||||
{
|
||||
auxAccount = [currentAux objectAtIndex: i];
|
||||
isReadOnly = [auxAccount objectForKey: @"readOnly"];
|
||||
if(isReadOnly)
|
||||
[auxAccounts addObject: auxAccount];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (count = 1; count < [accounts count]; count++)
|
||||
{
|
||||
account = [accounts objectAtIndex: count];
|
||||
if ([self _validateAccount: account])
|
||||
@@ -1569,6 +1589,7 @@ static NSArray *reminderValues = nil;
|
||||
[auxAccounts addObject: account];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return auxAccounts;
|
||||
}
|
||||
@@ -1863,7 +1884,7 @@ static NSArray *reminderValues = nil;
|
||||
accounts = [v objectForKey: @"AuxiliaryMailAccounts"];
|
||||
if (accounts && [accounts isKindOfClass: [NSArray class]])
|
||||
{
|
||||
if ([accounts count] > 0)
|
||||
if ([accounts count] > 0 || [self mailAuxiliaryUserAccountsReadOnly]) //in the second case it's expected to have only the main account
|
||||
{
|
||||
// The first account is the main system account. The following mapping is required:
|
||||
// - forceDefaultIdentity => SOGoMailForceDefaultIdentity
|
||||
|
||||
Reference in new issue
Block a user