now favor login@domain as the default email address if multiple mail: fields are specified

pull/74/merge
Ludovic Marcotte 2015-03-23 14:08:31 -04:00
parent 67139ce3e3
commit d2915add6d
3 changed files with 17 additions and 8 deletions

1
NEWS
View File

@ -4,6 +4,7 @@
Enhancements Enhancements
- support for mail prority using EAS - support for mail prority using EAS
- immediately delete mails from EAS clients when they are marked as deleted on the IMAP server - immediately delete mails from EAS clients when they are marked as deleted on the IMAP server
- now favor login@domain as the default email address if multiple mail: fields are specified
Bug fixes Bug fixes
- fixed login issue after password change (#2601) - fixed login issue after password change (#2601)

View File

@ -1,5 +1,5 @@
/* /*
Copyright (C) 2006-2013 Inverse inc. Copyright (C) 2006-2015 Inverse inc.
Copyright (C) 2005 SKYRIX Software AG Copyright (C) 2005 SKYRIX Software AG
This file is part of SOGo. This file is part of SOGo.

View File

@ -235,7 +235,6 @@
[currentPassword release]; [currentPassword release];
[cn release]; [cn release];
[loginInDomain release]; [loginInDomain release];
//[language release];
[super dealloc]; [super dealloc];
} }
@ -578,13 +577,13 @@
- (void) _appendSystemMailAccount - (void) _appendSystemMailAccount
{ {
NSString *fullName, *replyTo, *imapLogin, *imapServer, *cImapServer, *signature, NSString *fullName, *replyTo, *imapLogin, *imapServer, *cImapServer, *signature,
*encryption, *scheme, *action, *query, *customEmail, *sieveServer; *encryption, *scheme, *action, *query, *customEmail, *defaultEmail, *sieveServer;
NSMutableDictionary *mailAccount, *identity, *mailboxes, *receipts; NSMutableDictionary *mailAccount, *identity, *mailboxes, *receipts;
NSNumber *port; NSNumber *port;
NSMutableArray *identities; NSMutableArray *identities;
NSArray *mails; NSArray *mails;
NSURL *url, *cUrl; NSURL *url, *cUrl;
unsigned int count, max; unsigned int count, max, default_identity;
NSInteger defaultPort; NSInteger defaultPort;
[self userDefaults]; [self userDefaults];
@ -662,8 +661,9 @@
[mailAccount setObject: sieveServer forKey: @"sieveServerName"]; [mailAccount setObject: sieveServer forKey: @"sieveServerName"];
} }
// Identities
/* identities */ defaultEmail = [NSString stringWithFormat: @"%@@%@", [self loginInDomain], [self domain]];
default_identity = 0;
identities = [NSMutableArray new]; identities = [NSMutableArray new];
mails = [self allEmails]; mails = [self allEmails];
[mailAccount setObject: [mails objectAtIndex: 0] forKey: @"name"]; [mailAccount setObject: [mails objectAtIndex: 0] forKey: @"name"];
@ -703,6 +703,10 @@
if (signature) if (signature)
[identity setObject: signature forKey: @"signature"]; [identity setObject: signature forKey: @"signature"];
[identities addObject: identity]; [identities addObject: identity];
if ([[identity objectForKey: @"email"] caseInsensitiveCompare: defaultEmail] == NSOrderedSame)
default_identity = [identities count]-1;
[identity release]; [identity release];
} }
} }
@ -724,10 +728,14 @@
if (signature) if (signature)
[identity setObject: signature forKey: @"signature"]; [identity setObject: signature forKey: @"signature"];
[identities addObject: identity]; [identities addObject: identity];
if ([[identity objectForKey: @"email"] caseInsensitiveCompare: defaultEmail] == NSOrderedSame)
default_identity = [identities count]-1;
[identity release]; [identity release];
} }
[[identities objectAtIndex: 0] setObject: [NSNumber numberWithBool: YES] [[identities objectAtIndex: default_identity] setObject: [NSNumber numberWithBool: YES]
forKey: @"isDefault"]; forKey: @"isDefault"];
[mailAccount setObject: identities forKey: @"identities"]; [mailAccount setObject: identities forKey: @"identities"];
[identities release]; [identities release];