]> err.no Git - scalable-opengroupware.org/commitdiff
mailtree cleanups
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 9 Nov 2004 15:02:56 +0000 (15:02 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 9 Nov 2004 15:02:56 +0000 (15:02 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@449 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Mailer/ChangeLog
SOGo/SoObjects/Mailer/GNUmakefile
SOGo/SoObjects/Mailer/SOGoMailAccounts.m
SOGo/SoObjects/Mailer/SOGoMailBaseObject.h
SOGo/SoObjects/Mailer/SOGoMailBaseObject.m
SOGo/SoObjects/Mailer/SOGoMailTree.m [new file with mode: 0644]
SOGo/SoObjects/Mailer/Version
SOGo/UI/Mailer/ChangeLog
SOGo/UI/Mailer/UIxMailTree.m
SOGo/UI/Mailer/Version

index 1d7f9be3c9c225470b6c99bfd5b68cb735db87f1..bd3ccc1e089ff986a1c518ecb3a1b4a465d936ba 100644 (file)
@@ -1,5 +1,8 @@
 2004-11-09  Helge Hess  <helge.hess@skyrix.com>
 
+       * SOGoMailBaseObject.m, SOGoMailAccounts.m: moved tree code to separate
+         file (v0.9.50)
+
        * SOGoMailBaseObject.m, SOGoMailManager.m, SOGoMailConnectionEntry.m:
          added cache flush operations for getmail (v0.9.49)
 
index ef4c0b921b57dd95dd151eac05d39c246e3f5bf3..847b0a8783cdd8432b9a005a62397c8e6f168300 100644 (file)
@@ -21,6 +21,8 @@ Mailer_OBJC_FILES += \
        \
        SOGoDraftsFolder.m              \
        SOGoDraftObject.m               \
+       \
+       SOGoMailTree.m                  \
 
 Mailer_RESOURCE_FILES += \
        Version         \
index 27e9355ddde28bdf20d407149257301f4ffe284e..6536f0b3348b8e6932abff4b690ab3aa4e0b8eee 100644 (file)
   return [NSException exceptionWithHTTPStatus:404 /* Not Found */];
 }
 
-/* tree 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:[@"../" stringByAppendingString:[self nameInContainer]]
-      forKey:@"link"];
-  if ([blocks count] > 0)
-    [md setObject:blocks forKey:@"children"];
-  return md;
-}
-
-- (id)treeNavigationBlockWithActiveChildBlock:(id)_activeChildBlock 
-  depth:(int)_depth
-{
-  return _activeChildBlock;
-}
-
-- (id)treeNavigationNodes {
-  return [self treeNavigationBlockForActiveNode];
-}
-
 /* WebDAV */
 
 - (BOOL)davIsCollection {
index 4be1129d166c153649d495db68de974ba4267367..8df1bbe4e13df8112c56951a9c7ef28df7f118f7 100644 (file)
 
 - (void)flushMailCaches;
 
+@end
+
+@interface SOGoMailBaseObject(Tree)
+
 /* UI navigation */
 
 - (NSArray *)treeNavigationNodes;
index 37a3a5558534ea79e5e4846bdcde8e50767de97c..b242f6979715f5cbd209fe0ad56f7ef6e16e1041 100644 (file)
@@ -29,8 +29,9 @@
 
 @implementation SOGoMailBaseObject
 
-//static BOOL debugOn   = YES;
-static BOOL debugTree = NO;
+#if 0
+static BOOL debugOn = YES;
+#endif
 
 - (id)initWithImap4URL:(NSURL *)_url inContainer:(id)_container {
   NSString *n;
@@ -144,121 +145,6 @@ static BOOL debugTree = NO;
   [[self mailManager] flushCachesForURL:[self imap4URL]];
 }
 
-/* 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 {
-  id block;
-
-  block = [self treeNavigationBlockForActiveNode];
-  if (debugTree) [self logWithFormat:@"own block: %@", block];
-  block = [[self container] treeNavigationBlockWithActiveChildBlock:block
-                           depth:1];
-  if (debugTree) [self logWithFormat:@"  root block: %@", block];
-  return block;
-}
-
 /* debugging */
 
 - (NSString *)loggingPrefix {
diff --git a/SOGo/SoObjects/Mailer/SOGoMailTree.m b/SOGo/SoObjects/Mailer/SOGoMailTree.m
new file mode 100644 (file)
index 0000000..0c3dd1d
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+  Copyright (C) 2004 SKYRIX Software AG
+
+  This file is part of OpenGroupware.org.
+
+  OGo is free software; you can redistribute it and/or modify it under
+  the terms of the GNU Lesser General Public License as published by the
+  Free Software Foundation; either version 2, or (at your option) any
+  later version.
+
+  OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+  License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with OGo; see the file COPYING.  If not, write to the
+  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+  02111-1307, USA.
+*/
+// $Id: SOGoMailAccounts.m 274 2004-08-26 13:10:49Z znek $
+
+#include "SOGoMailBaseObject.h"
+#include "SOGoMailAccounts.h"
+#include <NGObjWeb/SoObject+SoDAV.h>
+#include "common.h"
+
+static BOOL debugTree = NO;
+
+@implementation SOGoMailBaseObject(Tree)
+
+- (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 {
+  id block;
+
+  block = [self treeNavigationBlockForActiveNode];
+  if (debugTree) [self logWithFormat:@"own block: %@", block];
+  block = [[self container] treeNavigationBlockWithActiveChildBlock:block
+                           depth:1];
+  if (debugTree) [self logWithFormat:@"  root block: %@", block];
+  return block;
+}
+
+@end /* SOGoMailBaseObject(Tree) */
+
+@implementation SOGoMailAccounts(Tree)
+
+- (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:[@"../" stringByAppendingString:[self nameInContainer]]
+      forKey:@"link"];
+  if ([blocks count] > 0)
+    [md setObject:blocks forKey:@"children"];
+  return md;
+}
+
+- (id)treeNavigationBlockWithActiveChildBlock:(id)_activeChildBlock 
+  depth:(int)_depth
+{
+  return _activeChildBlock;
+}
+
+- (id)treeNavigationNodes {
+  return [self treeNavigationBlockForActiveNode];
+}
+
+@end /* SOGoMailAccounts(Tree) */
index e3b5ed0933aed736c8e21133ed4b317b083f1404..a4adf0cd1d39a80dbed868b07a666dde4d7abc19 100644 (file)
@@ -1,6 +1,6 @@
 # Version file
 
-SUBMINOR_VERSION:=49
+SUBMINOR_VERSION:=50
 
 # v0.9.44 requires NGMime    v4.3.194
 # v0.9.41 requires NGMime    v4.3.190
index cb81e431bb4a3dc917ffc8971b8b073b65a7697a..6dc546cc2914a3821c30aa4c7a9d80bfee354d50 100644 (file)
@@ -1,5 +1,7 @@
 2004-11-09  Helge Hess  <helge.hess@skyrix.com>
 
+       * UIxMailTree.m: removed unused code (v0.9.59)
+
        * UIxMailListView.m: flush mail caches in the getMail action (v0.9.58)
 
 2004-10-29  Helge Hess  <helge.hess@skyrix.com>
index 32426ddf6c738d09b34586a2edc8301bc0256c29..29780be3966667d6a4db1bb424537bece4bc5da9 100644 (file)
@@ -24,6 +24,7 @@
 
 @interface UIxMailTree : UIxComponent
 {
+  id rootNodes;
   id item;
 }
 @end
@@ -35,7 +36,8 @@
 @implementation UIxMailTree
 
 - (void)dealloc {
-  [self->item        release];
+  [self->rootNodes release];
+  [self->item      release];
   [super dealloc];
 }
 
   return self->item;
 }
 
-/* tree */
+/* navigation nodes */
 
-- (NSArray *)rootNodes {
-  return [NSArray arrayWithObject:[[self clientObject] treeNavigationNodes]];
+- (id)buildNavigationNodesForObject:(id)_object {
+  return [_object treeNavigationNodes];
 }
 
-- (NSArray *)itemChildNodes {
-  NSMutableArray *folders;
-  NSArray  *names;
-  unsigned i, count;
+/* tree */
+
+- (NSArray *)rootNodes {
+  id navNode;
   
-  names   = [[self item] toManyRelationshipKeys];
-  count   = [names count];
-  folders = [NSMutableArray arrayWithCapacity:count];
-
-  for (i = 0; i < count; i++) {
-    id folder;
-
-    folder = [[self item] lookupName:[names objectAtIndex:i]
-                         inContext:[self context]
-                         acquire:NO];
-    if (folder)
-      [folders addObject:folder];
-  }
+  if (self->rootNodes != nil)
+    return self->rootNodes;
   
-  return folders;
-}
-
-- (BOOL)isItemExpanded {
-  return YES;
+  navNode = [self buildNavigationNodesForObject:[self clientObject]];
+  self->rootNodes = [[NSArray alloc] initWithObjects:&navNode count:1];
+  return self->rootNodes;
 }
 
 /* notifications */
 
 - (void)sleep {
-  [self->item release]; self->item = nil;
+  [self->item      release]; self->item      = nil;
+  [self->rootNodes release]; self->rootNodes = nil;
   [super sleep];
 }
 
index 6b08a245bb66937668b4d318d5f2bf86f347d608..156d56d8b915d2e5e498f1b07f2f02d9581acba2 100644 (file)
@@ -1,6 +1,6 @@
 # $Id$
 
-SUBMINOR_VERSION:=58
+SUBMINOR_VERSION:=59
 
 # v0.9.50 requires NGMime   v4.3.190
 # v0.9.43 requires NGObjWeb v4.3.73