From: helge Date: Wed, 29 Sep 2004 00:37:52 +0000 (+0000) Subject: implement folder tree navigation X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81cb12d34abb3869e54db2919796d718af5a2df5;p=scalable-opengroupware.org implement folder tree navigation git-svn-id: http://svn.opengroupware.org/SOGo/trunk@329 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 07169710..8a465519 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,13 @@ +2004-09-29 Helge Hess + + * v0.9.12 + + * SOGoMailAccount.m: added -shortTitle and use that as the + -davDisplayName + + * SOGoMailBaseObject.m, SOGoMailAccounts.m: added path tree navigation + support + 2004-09-28 Helge Hess * SOGoMailManager.m: added caching of folder hierarchy (v0.9.11) diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.m b/SOGo/SoObjects/Mailer/SOGoMailAccount.m index a2442d8b..229f197c 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.m @@ -88,4 +88,36 @@ return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; } +/* WebDAV */ + +- (NSString *)shortTitle { + NSString *s, *login, *host; + NSRange r; + + s = [self nameInContainer]; + + r = [s rangeOfString:@"@"]; + if (r.length > 0) { + login = [s substringToIndex:r.location]; + host = [s substringFromIndex:(r.location + r.length)]; + } + else { + login = nil; + host = s; + } + + r = [host rangeOfString:@"."]; + if (r.length > 0) + host = [host substringToIndex:r.location]; + + if ([login length] == 0) + return host; + + return [NSString stringWithFormat:@"%@ (%@)", host, login]; +} + +- (NSString *)davDisplayName { + return [self shortTitle]; +} + @end /* SOGoMailAccount */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m index 1f27e1d9..609bec96 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m @@ -72,4 +72,12 @@ return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; } +/* tree navigation */ + +- (id)treeNavigationBlockWithActiveChildBlock:(id)_activeChildBlock + depth:(int)_depth +{ + return _activeChildBlock; +} + @end /* SOGoMailAccounts */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h index 5ca0a908..1ca8d15e 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h +++ b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h @@ -31,7 +31,7 @@ Common base class for mailer SoObjects. */ -@class NSURL; +@class NSString, NSArray, NSURL; @class NGImap4Client; @class SOGoMailManager; @class SOGoMailAccount; @@ -55,6 +55,10 @@ - (NSString *)imap4FolderName; - (NGImap4Client *)imap4Client; +/* UI navigation */ + +- (NSArray *)treeNavigationNodes; + @end #endif /* __Mailer_SOGoMailBaseObject_H__ */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m index 3eac2157..0b4de4da 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m @@ -23,6 +23,7 @@ #include "SOGoMailBaseObject.h" #include "SOGoMailManager.h" #include "common.h" +#include #include @implementation SOGoMailBaseObject @@ -54,6 +55,31 @@ return [[self container] mailAccountFolder]; } +- (NSArray *)fetchSubfolders { + NSMutableArray *ma; + NSArray *names; + unsigned i, count; + + if ((names = [self toManyRelationshipKeys]) == nil) + return nil; + + count = [names count]; + ma = [NSMutableArray arrayWithCapacity:count + 1]; + for (i = 0; i < count; i++) { + id folder; + + folder = [self lookupName:[names objectAtIndex:i] inContext:nil + acquire:NO]; + if (folder == nil) + continue; + if ([folder isKindOfClass:[NSException class]]) + continue; + + [ma addObject:folder]; + } + return ma; +} + /* IMAP4 */ - (SOGoMailManager *)mailManager { @@ -113,4 +139,114 @@ password:[self imap4Password]]; } +/* UI navigation */ + +- (NSString *)treeNavigationLinkAtDepth:(int)_depth { + NSString *link; + unsigned i; + + link = [[self nameInContainer] stringByAppendingString:@"/"]; + for (i = 0; i < _depth; i++) + link = [@"../" stringByAppendingString:link]; + return link; +} + +- (id)treeNavigationBlockForLeafNodeAtDepth:(int)_depth { + NSMutableDictionary *md; + + md = [NSMutableDictionary dictionaryWithCapacity:4]; + [md setObject:[self davDisplayName] forKey:@"title"]; + [md setObject:[self treeNavigationLinkAtDepth:_depth] forKey:@"link"]; + + if ([[self toManyRelationshipKeys] count] > 0) + /* trigger plus in treeview */ + [md setObject:[NSArray arrayWithObject:@"FAKE"] forKey:@"children"]; + return md; +} + +- (id)treeNavigationBlockForActiveNode { + /* this generates the block for the clientObject */ + NSMutableDictionary *md; + NSMutableArray *blocks; + NSArray *folders; + unsigned i, count; + + /* process child folders */ + + folders = [self fetchSubfolders]; + count = [folders count]; + blocks = [NSMutableArray arrayWithCapacity:count]; + for (i = 0; i < count; i++) { + id block; + + block = [[folders objectAtIndex:i] + treeNavigationBlockForLeafNodeAtDepth:0]; + if ([block isNotNull]) [blocks addObject:block]; + } + + /* build block */ + + md = [NSMutableDictionary dictionaryWithCapacity:4]; + [md setObject:[NSNumber numberWithBool:YES] forKey:@"isActiveNode"]; + [md setObject:[NSNumber numberWithBool:YES] forKey:@"isPathNode"]; + [md setObject:[self davDisplayName] forKey:@"title"]; + [md setObject:[self nameInContainer] forKey:@"name"]; + [md setObject:@"." forKey:@"link"]; + if ([blocks count] > 0) + [md setObject:blocks forKey:@"children"]; + return md; +} + +- (id)treeNavigationBlockWithActiveChildBlock:(id)_activeChildBlock + depth:(int)_depth +{ + NSMutableDictionary *md; + NSMutableArray *blocks; + NSString *activeName; + NSArray *folders; + unsigned i, count; + + activeName = [_activeChildBlock valueForKey:@"name"]; + + /* process child folders */ + + folders = [self fetchSubfolders]; + count = [folders count]; + blocks = [NSMutableArray arrayWithCapacity:count]; + for (i = 0; i < count; i++) { + id folder; + id block; + + folder = [folders objectAtIndex:i]; + if ([activeName isEqualToString:[folder nameInContainer]]) { + block = _activeChildBlock; + } + else { + block = [folder treeNavigationBlockForLeafNodeAtDepth:_depth]; + } + if ([block isNotNull]) [blocks addObject:block]; + } + + /* build block */ + + md = [NSMutableDictionary dictionaryWithCapacity:4]; + [md setObject:[self davDisplayName] forKey:@"title"]; + [md setObject:[self nameInContainer] forKey:@"name"]; + [md setObject:[NSNumber numberWithBool:YES] forKey:@"isPathNode"]; + [md setObject:[self treeNavigationLinkAtDepth:(_depth + 1)] forKey:@"link"]; + if ([blocks count] > 0) + [md setObject:blocks forKey:@"children"]; + + /* recurse up */ + + return [[self container] treeNavigationBlockWithActiveChildBlock:md + depth:(_depth + 1)]; +} + +- (id)treeNavigationNodes { + return [[self container] treeNavigationBlockWithActiveChildBlock: + [self treeNavigationBlockForActiveNode] + depth:1]; +} + @end /* SOGoMailBaseObject */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.m b/SOGo/SoObjects/Mailer/SOGoMailManager.m index 96a5026e..09b76747 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.m +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.m @@ -48,6 +48,7 @@ @implementation SOGoMailManager static BOOL debugOn = YES; +static BOOL debugCache = NO; static BOOL poolingOff = NO; static NSTimeInterval PoolScanInterval = 5 * 60; @@ -254,7 +255,8 @@ static NSTimeInterval PoolScanInterval = 5 * 60; if ([entry isValidPassword:_pwd]) { NSDictionary *allFolders; - [self debugWithFormat:@"valid password, reusing folder cache .."]; + if (debugCache) + [self logWithFormat:@"valid password, reusing folder cache .."]; if ((allFolders = [entry cachedHierarchyResults]) != nil) return [self extractSubfoldersForURL:_url fromResultSet:allFolders]; @@ -290,7 +292,8 @@ static NSTimeInterval PoolScanInterval = 5 * 60; entry = [self entryForURL:_url]; [entry cacheHierarchyResults:result]; - [self debugWithFormat:@"cached results in entry %@: %@", entry, result]; + if (debugCache) + [self logWithFormat:@"cached results in entry %@: %@", entry, result]; } /* extract list */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index c351558f..9cef7993 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=11 +SUBMINOR_VERSION:=12 diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index e62deea4..664b8632 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,3 +1,7 @@ +2004-09-29 Helge Hess + + * UIxMailTree.m: use new tree navigation methods in SoObjects (v0.9.5) + 2004-09-28 Helge Hess * more work on mailer UI, added tree based on WETreeView (v0.9.4) diff --git a/SOGo/UI/Mailer/UIxMailTree.m b/SOGo/UI/Mailer/UIxMailTree.m index 601acf47..32426ddf 100644 --- a/SOGo/UI/Mailer/UIxMailTree.m +++ b/SOGo/UI/Mailer/UIxMailTree.m @@ -28,6 +28,7 @@ } @end +#include #include "common.h" #include @@ -50,9 +51,9 @@ /* tree */ - (NSArray *)rootNodes { - // TODO: maybe we want to add this in WETreeView for convenience? - return [NSArray arrayWithObject:[[self clientObject] mailAccountFolder]]; + return [NSArray arrayWithObject:[[self clientObject] treeNavigationNodes]]; } + - (NSArray *)itemChildNodes { NSMutableArray *folders; NSArray *names; diff --git a/SOGo/UI/Mailer/UIxMailTree.wox b/SOGo/UI/Mailer/UIxMailTree.wox index 6da28b68..35287698 100644 --- a/SOGo/UI/Mailer/UIxMailTree.wox +++ b/SOGo/UI/Mailer/UIxMailTree.wox @@ -6,8 +6,8 @@ xmlns:label="OGo:label" > - + - + + + + + + diff --git a/SOGo/UI/Mailer/mailer.css b/SOGo/UI/Mailer/mailer.css index 5c580e90..25682e68 100644 --- a/SOGo/UI/Mailer/mailer.css +++ b/SOGo/UI/Mailer/mailer.css @@ -782,7 +782,7 @@ td.monthprintview_content_dimmed { background-color: white; /* height: 300px; */ - height: 100%; + /* height: 100%; */ } .titlediv { height: 24px;