]> err.no Git - scalable-opengroupware.org/commitdiff
implement folder tree navigation
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 29 Sep 2004 00:37:52 +0000 (00:37 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 29 Sep 2004 00:37:52 +0000 (00:37 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@329 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Mailer/ChangeLog
SOGo/SoObjects/Mailer/SOGoMailAccount.m
SOGo/SoObjects/Mailer/SOGoMailAccounts.m
SOGo/SoObjects/Mailer/SOGoMailBaseObject.h
SOGo/SoObjects/Mailer/SOGoMailBaseObject.m
SOGo/SoObjects/Mailer/SOGoMailManager.m
SOGo/SoObjects/Mailer/Version
SOGo/UI/Mailer/ChangeLog
SOGo/UI/Mailer/UIxMailTree.m
SOGo/UI/Mailer/UIxMailTree.wox
SOGo/UI/Mailer/mailer.css

index 07169710990d7f54f369c8e6bc777fdbefe50a09..8a46551925e820f3880938044631b40ec9edf4da 100644 (file)
@@ -1,3 +1,13 @@
+2004-09-29  Helge Hess  <helge.hess@opengroupware.org>
+
+       * 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  <helge.hess@opengroupware.org>
 
        * SOGoMailManager.m: added caching of folder hierarchy (v0.9.11)
index a2442d8b17857d8b9076c720285409ae4f522322..229f197ca8f500191fbf57d469ec1ad0e8d3978d 100644 (file)
   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 */
index 1f27e1d9be05258b0700e22f1db31741597fe70e..609bec963311965d521a66550b550b156341b71c 100644 (file)
   return [NSException exceptionWithHTTPStatus:404 /* Not Found */];
 }
 
+/* tree navigation */
+
+- (id)treeNavigationBlockWithActiveChildBlock:(id)_activeChildBlock 
+  depth:(int)_depth
+{
+  return _activeChildBlock;
+}
+
 @end /* SOGoMailAccounts */
index 5ca0a908ef9d4d7bce4bc21dc3a9fb5f76d74d8f..1ca8d15ea4cfa8443e076db469f52e316e04642f 100644 (file)
@@ -31,7 +31,7 @@
   Common base class for mailer SoObjects.
 */
 
-@class NSURL;
+@class NSString, NSArray, NSURL;
 @class NGImap4Client;
 @class SOGoMailManager;
 @class SOGoMailAccount;
 - (NSString *)imap4FolderName;
 - (NGImap4Client *)imap4Client;
 
+/* UI navigation */
+
+- (NSArray *)treeNavigationNodes;
+
 @end
 
 #endif /* __Mailer_SOGoMailBaseObject_H__ */
index 3eac2157b55c7d23508f344688fc4eb59876bafe..0b4de4daee38abbacaa5b791b8c8402fb9a6dea0 100644 (file)
@@ -23,6 +23,7 @@
 #include "SOGoMailBaseObject.h"
 #include "SOGoMailManager.h"
 #include "common.h"
+#include <WebDAV/SoObject+SoDAV.h>
 #include <NGExtensions/NSURL+misc.h>
 
 @implementation SOGoMailBaseObject
   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 {
               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 */
index 96a5026ee1dcf8e6205c2b17ab402bcb981c26b6..09b7674737dd1c30c765eb51e085a41d94cde457 100644 (file)
@@ -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 */
index c351558f441a4d159527ee99c46d76a467ff4349..9cef79939ea704d51f0e6725b9964991d0cafe31 100644 (file)
@@ -1,3 +1,3 @@
 # $Id$
 
-SUBMINOR_VERSION:=11
+SUBMINOR_VERSION:=12
index e62deea4673a9270e69d3d05e5aefedcb4594655..664b86321b8744ea206a69d02b0f2552e30daeb5 100644 (file)
@@ -1,3 +1,7 @@
+2004-09-29  Helge Hess  <helge.hess@opengroupware.org>
+
+       * UIxMailTree.m: use new tree navigation methods in SoObjects (v0.9.5)
+
 2004-09-28  Helge Hess  <helge.hess@opengroupware.org>
 
        * more work on mailer UI, added tree based on WETreeView (v0.9.4)
index 601acf478b08ea9d5536cfbc88c9f05114dffdff..32426ddf6c738d09b34586a2edc8301bc0256c29 100644 (file)
@@ -28,6 +28,7 @@
 }
 @end
 
+#include <SOGo/SoObjects/Mailer/SOGoMailBaseObject.h>
 #include "common.h"
 #include <NGObjWeb/SoComponent.h>
 
@@ -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;
index 6da28b680cff2fc5603fc1483a9d4eb72c50e1b7..35287698851623a69d6e722669f3059876544b9a 100644 (file)
@@ -6,8 +6,8 @@
       xmlns:label="OGo:label"
 >
   <var:treeview
-    list="rootNodes" item="item" sublist="itemChildNodes"
-    currentPath="currentPath" zoom="isItemExpanded"
+    list="rootNodes" item="item" sublist="item.children"
+    zoom="item.isPathNode"
     const:iconWidth       = "17"
     const:plusIcon        = "tbtv_plus_17x17.gif"
     const:minusIcon       = "tbtv_minus_17x17.gif"
     const:spaceIcon       = "tbtv_space_17x17.gif"
   >
     <var:tree-data const:isTreeElement="YES" const:treeLink="">
-      <a href="#">
+      <a var:href="item.link">
         <span class="treecell">
-          <var:string value="item.davDisplayName" />
+          <var:if condition="item.isActiveNode">
+            <b><var:string value="item.title" /></b>
+          </var:if>
+          <var:if condition="item.isActiveNode" const:negate="YES">
+            <var:string value="item.title" />
+          </var:if>
         </span>
       </a>
     </var:tree-data>
index 5c580e908e62289f0ca306601467c5eb0e46f70b..25682e68c404f70938035b3924fdb259a4d6b262 100644 (file)
@@ -782,7 +782,7 @@ td.monthprintview_content_dimmed {
 
   background-color:    white;
   /* height:              300px; */
-  height: 100%;
+  /* height: 100%; */
 }
 .titlediv {
   height:         24px;