]> err.no Git - scalable-opengroupware.org/commitdiff
improved identity support
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 22 Jul 2005 12:56:19 +0000 (12:56 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 22 Jul 2005 12:56:19 +0000 (12:56 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@896 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Mailer/ChangeLog
SOGo/SoObjects/Mailer/SOGoMailAccount.h
SOGo/SoObjects/Mailer/SOGoMailAccount.m
SOGo/SoObjects/Mailer/SOGoUser+Mail.h
SOGo/SoObjects/Mailer/SOGoUser+Mail.m
SOGo/SoObjects/Mailer/Version

index 9bb16810998a7e1b9859e7b6f4e0a97ab490e269..230be68ec788746d44ff8d40d7edc8e3ee9cf76e 100644 (file)
@@ -1,5 +1,12 @@
 2005-07-22  Helge Hess  <helge.hess@opengroupware.org>
 
+       * 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)
 
index 783c192b2f6043e4eefe9c76b1dabc922d2f28c5..00fa792f6f44d976a1a261d26264ad869fec9d0b 100644 (file)
@@ -33,8 +33,8 @@
   password, etc)
 */
 
-@class NSArray;
-@class SOGoMailFolder;
+@class NSString, NSArray;
+@class SOGoMailFolder, SOGoMailIdentity;
 
 @interface SOGoMailAccount : SOGoMailBaseObject
 {
 - (BOOL)isSharedAccount;
 - (NSString *)sharedAccountName;
 
+/* identity */
+
+- (SOGoMailIdentity *)preferredIdentity;
+
 /* special folders */
 
 - (NSString *)inboxFolderNameInContext:(id)_ctx;
index bcb0ea6b74958530a92f0b7777a28b380031cdc2..aee34c2641f0e8cb459d02200b585c6dfb33f7a7 100644 (file)
@@ -23,6 +23,7 @@
 #include "SOGoMailFolder.h"
 #include "SOGoMailManager.h"
 #include "SOGoDraftsFolder.h"
+#include "SOGoUser+Mail.h"
 #include <NGObjWeb/SoHTTPAuthenticator.h>
 #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 {
index 2442f336f88197e208fab91aefd0242b87770db7..432de0f1d6062db291641ba7734f9eb0c448bac1 100644 (file)
@@ -41,6 +41,7 @@
 
 - (SOGoMailIdentity *)primaryMailIdentity;
 - (NSArray *)fetchAllMailIdentitiesWithOnlyEmitterAccess:(BOOL)_onlyGC;
+- (SOGoMailIdentity *)primaryMailIdentityForAccount:(NSString *)_account;
 
 @end
 
index 5441ec08ccbf7ee9a6f2336b30b5b12348904b0a..db6ce1900fcb2aaf0460706fc8c855be104f6e25 100644 (file)
   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) */
index 8fa04cfc46422e83dc3b36d502469e586c587d68..ad01846343ce3fa7208c95047a4f75e33422e4fc 100644 (file)
@@ -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