feat(mail): handle multiple mail identities
Create read-only identities for email addresses for which no identity has been defined. This way, when visiting the message editor, the user will have access to all of her known email addresses. Fixes #768, fixes #4602pull/284/head
parent
cecf157dca
commit
208ee08960
|
@ -784,26 +784,41 @@
|
||||||
[identities replaceObjectAtIndex: count withObject: identity];
|
[identities replaceObjectAtIndex: count withObject: identity];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![identities count])
|
// Create an identity for each missing email address
|
||||||
|
max = [mails count];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
{
|
{
|
||||||
// Create an identity for each email address
|
BOOL noIdentityForEmail;
|
||||||
max = [mails count];
|
NSString *identityEmail;
|
||||||
for (count = 0; count < max; count++)
|
|
||||||
|
noIdentityForEmail = YES;
|
||||||
|
customEmail = [mails objectAtIndex: count];
|
||||||
|
for (index = 0; noIdentityForEmail && index < [identities count]; index++)
|
||||||
|
{
|
||||||
|
identity = [identities objectAtIndex: index];
|
||||||
|
identityEmail = [identity objectForKey: @"email"];
|
||||||
|
if ([customEmail caseInsensitiveCompare: identityEmail] == NSOrderedSame)
|
||||||
|
{
|
||||||
|
noIdentityForEmail = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noIdentityForEmail)
|
||||||
{
|
{
|
||||||
identity = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
identity = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||||
fullName, @"fullName",
|
fullName, @"fullName",
|
||||||
[mails objectAtIndex: count], @"email", nil];
|
customEmail, @"email", nil];
|
||||||
if (appendDeletegatedIdentities)
|
if (appendDeletegatedIdentities &&
|
||||||
|
count == 0 &&
|
||||||
|
[identities count] == 0)
|
||||||
{
|
{
|
||||||
if (count == 0)
|
// First identity uses the system email -- mark it as the default and keep it editable
|
||||||
{
|
[identity setObject: [NSNumber numberWithBool: YES] forKey: @"isDefault"];
|
||||||
// First identity uses the system email -- mark it as the default
|
hasDefaultIdentity = YES;
|
||||||
[identity setObject: [NSNumber numberWithBool: YES] forKey: @"isDefault"];
|
|
||||||
hasDefaultIdentity = YES;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// This additional identity should not appear in the identity manager of the Preferences
|
||||||
[identity setObject: [NSNumber numberWithBool: YES] forKey: @"isReadOnly"];
|
[identity setObject: [NSNumber numberWithBool: YES] forKey: @"isReadOnly"];
|
||||||
}
|
}
|
||||||
[identities addObject: identity];
|
[identities addObject: identity];
|
||||||
|
|
Loading…
Reference in New Issue