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)
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;
#include "SOGoMailFolder.h"
#include "SOGoMailManager.h"
#include "SOGoDraftsFolder.h"
+#include "SOGoUser+Mail.h"
#include <NGObjWeb/SoHTTPAuthenticator.h>
#include "common.h"
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 {
- (SOGoMailIdentity *)primaryMailIdentity;
- (NSArray *)fetchAllMailIdentitiesWithOnlyEmitterAccess:(BOOL)_onlyGC;
+- (SOGoMailIdentity *)primaryMailIdentityForAccount:(NSString *)_account;
@end
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) */
# Version file
-SUBMINOR_VERSION:=122
+SUBMINOR_VERSION:=123
# v0.9.114 requires libNGMime v4.5.229
# v0.9.114 requires libNGExtensions v4.5.165