diff --git a/ChangeLog b/ChangeLog index 5a4393a3e..5d3fb4434 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2010-08-03 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoUser.m (-_appendSystemMailAccount): new + private method with the mailbox code split from -[mailAccounts]. + * UI/WebServerResources/MailerUI.js (composeNewMessage): the first account is always identified as "0". diff --git a/SoObjects/SOGo/SOGoUser.h b/SoObjects/SOGo/SOGoUser.h index b196c3003..4cdddacaf 100644 --- a/SoObjects/SOGo/SOGoUser.h +++ b/SoObjects/SOGo/SOGoUser.h @@ -40,7 +40,6 @@ @class NSMutableArray; @class NSMutableDictionary; @class NSString; -@class NSURL; @class WOContext; @@ -69,7 +68,7 @@ NSString *domainId; NSString *language; NSArray *allEmails; - NSArray *mailAccounts; + NSMutableArray *mailAccounts; NSString *cn; BOOL propagateCache; } diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 15b217c28..6a7c88176 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -436,7 +436,7 @@ } /* mail */ -- (NSArray *) mailAccounts +- (void) _appendSystemMailAccount { NSMutableDictionary *mailAccount, *identity; NSMutableArray *identities; @@ -444,45 +444,49 @@ NSArray *mails; unsigned int count, max; + mailAccount = [NSMutableDictionary new]; + + imapLogin = [[SOGoUserManager sharedUserManager] + getImapLoginForUID: login]; + imapServer = [self _fetchFieldForUser: @"c_imaphostname"]; + if (!imapServer) + imapServer = [[self domainDefaults] imapServer]; + [mailAccount setObject: imapLogin forKey: @"userName"]; + [mailAccount setObject: imapServer forKey: @"serverName"]; + + identities = [NSMutableArray new]; + mails = [self allEmails]; + [mailAccount setObject: [mails objectAtIndex: 0] forKey: @"name"]; + + max = [mails count]; + if (max > 1) + max--; + for (count = 0; count < max; count++) + { + identity = [NSMutableDictionary new]; + fullName = [self cn]; + if (![fullName length]) + fullName = login; + [identity setObject: fullName forKey: @"fullName"]; + [identity setObject: [mails objectAtIndex: count] forKey: @"email"]; + [identities addObject: identity]; + [identity release]; + } + [[identities objectAtIndex: 0] setObject: [NSNumber numberWithBool: YES] + forKey: @"isDefault"]; + + [mailAccount setObject: identities forKey: @"identities"]; + [identities release]; + [mailAccounts addObject: mailAccount]; + [mailAccount release]; +} + +- (NSArray *) mailAccounts +{ if (!mailAccounts) { - imapLogin = [[SOGoUserManager sharedUserManager] - getImapLoginForUID: login]; - imapServer = [self _fetchFieldForUser: @"c_imaphostname"]; - if (!imapServer) - imapServer = [[self domainDefaults] imapServer]; - mailAccount = [NSMutableDictionary new]; - [mailAccount setObject: imapLogin forKey: @"userName"]; - [mailAccount setObject: imapServer forKey: @"serverName"]; - - identities = [NSMutableArray new]; - mails = [self allEmails]; - [mailAccount setObject: [mails objectAtIndex: 0] - forKey: @"name"]; - - max = [mails count]; - if (max > 1) - max--; - for (count = 0; count < max; count++) - { - identity = [NSMutableDictionary new]; - fullName = [self cn]; - if (![fullName length]) - fullName = login; - [identity setObject: fullName forKey: @"fullName"]; - [identity setObject: [mails objectAtIndex: count] forKey: @"email"]; - [identities addObject: identity]; - [identity release]; - } - [[identities objectAtIndex: 0] setObject: [NSNumber numberWithBool: YES] - forKey: @"isDefault"]; - - [mailAccount setObject: identities forKey: @"identities"]; - [identities release]; - - mailAccounts = [NSArray arrayWithObject: mailAccount]; - [mailAccounts retain]; - [mailAccount release]; + mailAccounts = [NSMutableArray new]; + [self _appendSystemMailAccount]; } return mailAccounts;