From 53e787d3a3ee685a92b1e2c69996abc03c234dac Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 7 Jul 2005 13:31:20 +0000 Subject: [PATCH] added account discovery git-svn-id: http://svn.opengroupware.org/SOGo/trunk@684 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Mailer/ChangeLog | 5 ++ SOGo/SoObjects/Mailer/SOGoMailAccount.m | 2 +- SOGo/SoObjects/Mailer/SOGoMailAccounts.m | 11 +++- SOGo/SoObjects/Mailer/Version | 2 +- SOGo/UI/MailerUI/ChangeLog | 6 ++ SOGo/UI/MailerUI/UIxMailTree.m | 83 +++++++++++++++++++++++- SOGo/UI/MailerUI/Version | 2 +- 7 files changed, 104 insertions(+), 7 deletions(-) diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 76ea86f1..9f1b93f8 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,8 @@ +2005-07-07 Helge Hess + + * SOGoMailAccounts.m: expose shared mailboxes retrieved via + AgenorUserManager (aka LDAP) in -toManyRelationshipKeys (v0.9.89) + 2005-07-07 Helge Hess * SOGoMailObject.m: implemented -trashInContext: method (v0.9.88) diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.m b/SOGo/SoObjects/Mailer/SOGoMailAccount.m index ec0707ab..f2b7fd88 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.m @@ -329,7 +329,7 @@ static BOOL useAltNamespace = NO; if ([login length] == 0) return host; - + r = [login rangeOfString:@"."]; if (r.length > 0) login = [login substringToIndex:r.location]; diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m index 2db0774e..d3e8d756 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m @@ -30,15 +30,22 @@ - (NSArray *)toManyRelationshipKeys { static AgenorUserManager *um = nil; - NSString *uid, *account; + NSString *uid; + id account; + NSArray *shares; if (um == nil) um = [[AgenorUserManager sharedUserManager] retain]; uid = [[self container] davDisplayName]; /* the uid part of the URL */ account = [um getIMAPAccountStringForUID:uid]; + shares = [um getSharedMailboxAccountStringsForUID:uid]; - return account ? [NSArray arrayWithObject:account] : nil; + if (account != nil) account = [NSArray arrayWithObject:account]; + + return ([shares count] == 0) + ? account + : [account arrayByAddingObjectsFromArray:shares]; } /* name lookup */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 9bc59574..483a62f8 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=88 +SUBMINOR_VERSION:=89 # v0.9.69 requires libNGMime v4.5.210 # v0.9.55 requires libNGExtensions v4.5.136 diff --git a/SOGo/UI/MailerUI/ChangeLog b/SOGo/UI/MailerUI/ChangeLog index 9fb669f6..aef0bc64 100644 --- a/SOGo/UI/MailerUI/ChangeLog +++ b/SOGo/UI/MailerUI/ChangeLog @@ -1,3 +1,9 @@ +2005-07-07 Helge Hess + + * UIxMailTree.m: properly display share names in account list (show + name of share instead of the cut-off account login). Added some + improved heuristics to determine a viably short name (v0.9.128) + 2005-07-07 Helge Hess * UIxMailView.m, product.plist: added -trash button and action diff --git a/SOGo/UI/MailerUI/UIxMailTree.m b/SOGo/UI/MailerUI/UIxMailTree.m index fac6cd89..a1c722d2 100644 --- a/SOGo/UI/MailerUI/UIxMailTree.m +++ b/SOGo/UI/MailerUI/UIxMailTree.m @@ -46,6 +46,12 @@ tbtv_trash_17x17.gif */ +@interface NSString(DotCutting) + +- (NSString *)stringByCuttingOffAtDotsWhenExceedingLength:(int)_maxLength; + +@end + @implementation UIxMailTree static BOOL debugBlocks = NO; @@ -161,7 +167,7 @@ static BOOL debugBlocks = NO; - (NSString *)treeNavigationLinkForObject:(id)_object atDepth:(int)_depth { NSString *link; unsigned i; - + link = [[_object nameInContainer] stringByAppendingString:@"/"]; link = [link stringByAppendingString:[self treeFolderAction]]; @@ -177,6 +183,43 @@ static BOOL debugBlocks = NO; return link; } +- (NSString *)titleForIMAP4String:(NSString *)_constr { + /* + eg: + guizmo.g.-.baluh.hommes.tests-montee-en-charge-ogo@\ + amelie-01.ac.melanie2.i2 + */ + static int CutOffLength = 16; + NSString *s; + NSRange r; + + s = _constr; + + /* check for connect strings without hostnames */ + + r = [s rangeOfString:@"@"]; + if (r.length == 0) { + /* no login provide, just use the hostname (without domain) */ + r = [s rangeOfString:@"."]; + return r.length > 0 ? [s substringToIndex:r.location] : s; + } + + s = [s substringToIndex:r.location]; + + /* check for shares */ + + r = [s rangeOfString:@".-."]; + if (r.length > 0) { + /* eg: 'baluh.hommes.tests-montee-en-charge-ogo' */ + s = [s substringFromIndex:(r.location + r.length)]; + + return [s stringByCuttingOffAtDotsWhenExceedingLength:CutOffLength]; + } + + /* just the login name, possibly long (test.et.di.cete-lyon) */ + return [s stringByCuttingOffAtDotsWhenExceedingLength:CutOffLength]; +} + - (void)getTitle:(NSString **)_t andIcon:(NSString **)_icon forObject:(id)_object { @@ -226,8 +269,12 @@ static BOOL debugBlocks = NO; if ([_object isKindOfClass:NSClassFromString(@"SOGoMailFolder")]) *_icon = nil; - else if ([_object isKindOfClass:NSClassFromString(@"SOGoMailAccount")]) + else if ([_object isKindOfClass:NSClassFromString(@"SOGoMailAccount")]) { *_icon = @"tbtv_inbox_17x17.gif"; + + /* title processing is somehow Agenor specific and should be done in UI */ + *_t = [self titleForIMAP4String:[_object nameInContainer]]; + } else if ([_object isKindOfClass:NSClassFromString(@"SOGoMailAccounts")]) *_icon = @"tbtv_inbox_17x17.gif"; else if ([_object isKindOfClass:NSClassFromString(@"SOGoUserFolder")]) @@ -478,3 +525,35 @@ static BOOL debugBlocks = NO; } @end /* UIxMailTree */ + + +@implementation NSString(DotCutting) + +- (NSString *)stringByCuttingOffAtDotsWhenExceedingLength:(int)_maxLength { + NSRange r, r2; + NSString *s; + int i; + + if ([self length] <= _maxLength) /* if length is small, return as is */ + return self; + + if ((r = [self rangeOfString:@"."]).length == 0) + /* no dots in share, return even if longer than boundary */ + return self; + + s = self; + i = r.location + r.length; + r2 = [s rangeOfString:@"." options:NSLiteralSearch + range:NSMakeRange(i, [s length] - i)]; + + if (r2.length > 0) { + s = [s substringToIndex:r2.location]; + if ([s length] <= _maxLength) /* if length is small, return as is */ + return s; + } + + /* no second dot, and the whole was too long => cut off after first */ + return [s substringToIndex:r.location]; +} + +@end /* NSString(DotCutting) */ diff --git a/SOGo/UI/MailerUI/Version b/SOGo/UI/MailerUI/Version index 179f28d6..bff1a237 100644 --- a/SOGo/UI/MailerUI/Version +++ b/SOGo/UI/MailerUI/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=127 +SUBMINOR_VERSION:=128 # v0.9.100 requires libNGMime v4.5.213 # v0.9.99 requires libNGMime v4.5.212 -- 2.39.5