From 3a56a68fc9bb109b5d383a7b3292a742311a6cef Mon Sep 17 00:00:00 2001 From: helge Date: Fri, 22 Jul 2005 12:56:19 +0000 Subject: [PATCH] improved identity support git-svn-id: http://svn.opengroupware.org/SOGo/trunk@896 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Mailer/ChangeLog | 7 +++++++ SOGo/SoObjects/Mailer/SOGoMailAccount.h | 8 +++++-- SOGo/SoObjects/Mailer/SOGoMailAccount.m | 16 ++++++++++++++ SOGo/SoObjects/Mailer/SOGoUser+Mail.h | 1 + SOGo/SoObjects/Mailer/SOGoUser+Mail.m | 28 +++++++++++++++++++++++++ SOGo/SoObjects/Mailer/Version | 2 +- 6 files changed, 59 insertions(+), 3 deletions(-) diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 9bb16810..230be68e 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,5 +1,12 @@ 2005-07-22 Helge Hess + * v0.9.123 + + * SOGoMailAccount.m: added -preferredIdentity method + + * SOGoUser+Mail.m: added a method to retrieve the primary identity of + an account + * SOGoSharedMailAccount.m: do not show the drafts folder in share mailboxes (v0.9.122) diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.h b/SOGo/SoObjects/Mailer/SOGoMailAccount.h index 783c192b..00fa792f 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.h +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.h @@ -33,8 +33,8 @@ password, etc) */ -@class NSArray; -@class SOGoMailFolder; +@class NSString, NSArray; +@class SOGoMailFolder, SOGoMailIdentity; @interface SOGoMailAccount : SOGoMailBaseObject { @@ -53,6 +53,10 @@ - (BOOL)isSharedAccount; - (NSString *)sharedAccountName; +/* identity */ + +- (SOGoMailIdentity *)preferredIdentity; + /* special folders */ - (NSString *)inboxFolderNameInContext:(id)_ctx; diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.m b/SOGo/SoObjects/Mailer/SOGoMailAccount.m index bcb0ea6b..aee34c26 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.m @@ -23,6 +23,7 @@ #include "SOGoMailFolder.h" #include "SOGoMailManager.h" #include "SOGoDraftsFolder.h" +#include "SOGoUser+Mail.h" #include #include "common.h" @@ -101,6 +102,21 @@ static BOOL useAltNamespace = NO; return [b count] > 0 ? [b arrayByAddingObjectsFromArray:a] : a; } +/* identity */ + +- (SOGoMailIdentity *)preferredIdentity { + WOContext *ctx; + + if ((ctx = [[WOApplication application] context]) == nil) { + [self logWithFormat:@"ERROR(%s): cannot procede without context!", + __PRETTY_FUNCTION__]; + return nil; + } + + return [[ctx activeUser] primaryMailIdentityForAccount: + [self nameInContainer]]; +} + /* hierarchy */ - (SOGoMailAccount *)mailAccountFolder { diff --git a/SOGo/SoObjects/Mailer/SOGoUser+Mail.h b/SOGo/SoObjects/Mailer/SOGoUser+Mail.h index 2442f336..432de0f1 100644 --- a/SOGo/SoObjects/Mailer/SOGoUser+Mail.h +++ b/SOGo/SoObjects/Mailer/SOGoUser+Mail.h @@ -41,6 +41,7 @@ - (SOGoMailIdentity *)primaryMailIdentity; - (NSArray *)fetchAllMailIdentitiesWithOnlyEmitterAccess:(BOOL)_onlyGC; +- (SOGoMailIdentity *)primaryMailIdentityForAccount:(NSString *)_account; @end diff --git a/SOGo/SoObjects/Mailer/SOGoUser+Mail.m b/SOGo/SoObjects/Mailer/SOGoUser+Mail.m index 5441ec08..db6ce190 100644 --- a/SOGo/SoObjects/Mailer/SOGoUser+Mail.m +++ b/SOGo/SoObjects/Mailer/SOGoUser+Mail.m @@ -108,4 +108,32 @@ return identities; } +- (SOGoMailIdentity *)primaryMailIdentityForAccount:(NSString *)_account { + NSEnumerator *accounts; + NSDictionary *shares; + NSString *account; + id identity; + + identity = [self primaryMailIdentity]; + shares = [self valueForKey:@"additionalIMAP4AccountsAndEMails"]; + if ([shares count] == 0) + return identity; + + /* scan shares for ID */ + accounts = [shares keyEnumerator]; + while ((account = [accounts nextObject]) != nil) { + NSString *emitter; + + if (![account isEqualToString:_account]) + continue; + + emitter = [shares objectForKey:account]; + identity = [self mailIdentityForAccount:_account emitter:emitter]; + if ([identity isNotNull]) + return identity; + } + + return identity; +} + @end /* SOGoUser(Mail) */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 8fa04cfc..ad018463 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=122 +SUBMINOR_VERSION:=123 # v0.9.114 requires libNGMime v4.5.229 # v0.9.114 requires libNGExtensions v4.5.165 -- 2.39.5