From 2f69dee9d60467e59efd9de7d392c709c77f586e Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 3 Aug 2010 18:54:49 +0000 Subject: [PATCH] Monotone-Parent: d63a2f0e9c958ba01af4295fd9477e41e87bd84e Monotone-Revision: e9ca26d51aa3d10c2258ad11e5ed08cf1cdc234c Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-08-03T18:54:49 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 ++ SoObjects/SOGo/SOGoUser.h | 3 +- SoObjects/SOGo/SOGoUser.m | 80 ++++++++++++++++++++------------------- 3 files changed, 46 insertions(+), 40 deletions(-) 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;