From: helge Date: Fri, 22 Jul 2005 10:24:49 +0000 (+0000) Subject: work on identities X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b63a839d466de4c78faf572d596717845efaa50;p=scalable-opengroupware.org work on identities git-svn-id: http://svn.opengroupware.org/SOGo/trunk@887 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 654c8260..9a8d4570 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,17 @@ +2005-07-22 Helge Hess + + * v0.9.120 + + * SOGoMailBaseObject.m: added a method to locate the mail accounts + folderby traversing the container hierarchy + + * SOGoMailIdentity.m: include sent folder in -description + + * SOGoMailAccounts.m: added method to fetch just the identities with + emitter permissions + + * SOGoUser+Mail.m: properly create mail identity objects + 2005-07-21 Helge Hess * v0.9.119 diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.m b/SOGo/SoObjects/Mailer/SOGoMailAccount.m index b6479a92..03d8478b 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.m @@ -271,7 +271,7 @@ static BOOL useAltNamespace = NO; ud = [NSUserDefaults standardUserDefaults]; s = [[ud stringForKey:@"SOGoSentFolderName"] copy]; if ([s length] == 0) s = @"Sent"; - NSLog(@"Note: using SOGoSentFolderName: '%@'", s); + [self logWithFormat:@"Note: using SOGoSentFolderName: '%@'", s]; } return s; } diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccounts.h b/SOGo/SoObjects/Mailer/SOGoMailAccounts.h index 0b22916f..3bccf908 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccounts.h +++ b/SOGo/SoObjects/Mailer/SOGoMailAccounts.h @@ -44,6 +44,7 @@ } - (NSArray *)fetchAllIdentities; +- (NSArray *)fetchIdentitiesWithEmitterPermissions; @end diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m index fa3eab5a..002de868 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m @@ -94,7 +94,7 @@ static NSString *AgenorShareLoginMarker = @".-."; : [account arrayByAddingObjectsFromArray:shares]; } -- (NSArray *)fetchAllIdentities { +- (NSArray *)fetchIdentitiesWithOnlyEmitterAccess:(BOOL)_flag { WOContext *ctx; if ((ctx = [[WOApplication application] context]) == nil) { @@ -105,10 +105,19 @@ static NSString *AgenorShareLoginMarker = @".-."; if ([self isInternetRequest]) { /* only show primary mailbox in Internet */ // just return the primary identity - return [[ctx activeUser] primaryMailIdentity]; + id identity; + + identity = [[ctx activeUser] primaryMailIdentity]; + return [identity isNotNull] ? [NSArray arrayWithObject:identity] : nil; } - return [[ctx activeUser] fetchAllMailIdentitiesWithOnlyEmitterAccess:NO]; + return [[ctx activeUser] fetchAllMailIdentitiesWithOnlyEmitterAccess:_flag]; +} +- (NSArray *)fetchAllIdentities { + return [self fetchIdentitiesWithOnlyEmitterAccess:NO]; +} +- (NSArray *)fetchIdentitiesWithEmitterPermissions { + return [self fetchIdentitiesWithOnlyEmitterAccess:YES]; } /* name lookup */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h index cc0de820..ad12a417 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h +++ b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h @@ -40,7 +40,7 @@ @class NSString, NSArray, NSURL; @class NGImap4ConnectionManager, NGImap4Connection; -@class SOGoMailAccount; +@class SOGoMailAccount, SOGoMailAccounts; @interface SOGoMailBaseObject : SOGoObject { @@ -53,6 +53,7 @@ /* hierarchy */ - (SOGoMailAccount *)mailAccountFolder; +- (SOGoMailAccounts *)mailAccountsFolder; /* IMAP4 */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m index ecd1a45f..26d996b8 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m @@ -68,6 +68,16 @@ static BOOL debugOn = YES; return [[self container] mailAccountFolder]; } +- (SOGoMailAccounts *)mailAccountsFolder { + id o; + + for (o = [self container]; [o isNotNull]; o = [o container]) { + if ([o isKindOfClass:NSClassFromString(@"SOGoMailAccounts")]) + return o;; + } + return nil; +} + /* IMAP4 */ - (NGImap4ConnectionManager *)mailManager { diff --git a/SOGo/SoObjects/Mailer/SOGoMailIdentity.m b/SOGo/SoObjects/Mailer/SOGoMailIdentity.m index 2debef06..a9373dfa 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailIdentity.m +++ b/SOGo/SoObjects/Mailer/SOGoMailIdentity.m @@ -127,6 +127,9 @@ if (self->name != nil) [ms appendFormat:@" name='%@'", self->name]; if (self->email != nil) [ms appendFormat:@" email='%@'", self->email]; + if (self->sentFolderName != nil) + [ms appendFormat:@" sent='%@'", self->sentFolderName]; + if ([self->sentBCC length] > 0) [ms appendString:@" sent-bcc"]; if ([self->vCard length] > 0) [ms appendString:@" vcard"]; diff --git a/SOGo/SoObjects/Mailer/SOGoUser+Mail.m b/SOGo/SoObjects/Mailer/SOGoUser+Mail.m index 0b5d5e2f..c32a2a8b 100644 --- a/SOGo/SoObjects/Mailer/SOGoUser+Mail.m +++ b/SOGo/SoObjects/Mailer/SOGoUser+Mail.m @@ -25,20 +25,57 @@ @implementation SOGoUser(Mail) +- (NSString *)agenorSentFolderName { + /* Note: specialty: the Sent folder is called the same in all accounts */ + static NSString *s = nil; + if (s == nil) { + NSUserDefaults *ud; + + ud = [NSUserDefaults standardUserDefaults]; + s = [[ud stringForKey:@"SOGoSentFolderName"] copy]; + if (![s isNotEmpty]) s = @"Sent"; + [self logWithFormat:@"Note: using SOGoSentFolderName: '%@'", s]; + } + return s; +} + +- (NSString *)agenorSentFolderForAccount:(NSString *)_account { + // TODO: support different locations for shares! + NSString *p; + + if (![_account isNotEmpty]) + return nil; + + // if ([_account rangeOfString:@".-."].length == 0) + // TODO: check whether we need special handling for shares! + p = [_account stringByAppendingString:@"/"]; + p = [p stringByAppendingString:[self agenorSentFolderName]]; + return p; +} + - (SOGoMailIdentity *)primaryMailIdentity { + SOGoMailIdentity *identity; NSString *account; - + account = [self valueForKey:@"primaryIMAP4AccountString"]; -#warning IMPLEMENT ME - return nil; + identity = [[[SOGoMailIdentity alloc] init] autorelease]; + [identity setName:[self cn]]; + [identity setEmail:[self email]]; + [identity setSentFolderName:[self agenorSentFolderForAccount:account]]; + return identity; } - (SOGoMailIdentity *)mailIdentityForAccount:(NSString *)_account emitter:(NSString *)_em { -#warning IMPLEMENT ME - return nil; + SOGoMailIdentity *identity; + + identity = [[[SOGoMailIdentity alloc] init] autorelease]; + [identity setName:[self cn]]; // TODO: should we use something else? + if ([_em isNotEmpty]) [identity setName:_em]; + [identity setSentFolderName:[self agenorSentFolderForAccount:_account]]; + return identity; } - (NSArray *)fetchAllMailIdentitiesWithOnlyEmitterAccess:(BOOL)_onlyGC { @@ -68,8 +105,7 @@ [identities addObject:identity]; } - [self logWithFormat:@"TODO: WORK ON IDENTITIES: %@", shares]; - return nil; + return identities; } @end /* SOGoUser(Mail) */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 8a6b1aad..125f0739 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=119 +SUBMINOR_VERSION:=120 # v0.9.114 requires libNGMime v4.5.229 # v0.9.114 requires libNGExtensions v4.5.165