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)
\
SOGoDraftsFolder.m \
SOGoDraftObject.m \
+ \
+ SOGoMailTree.m \
Mailer_RESOURCE_FILES += \
Version \
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 {
- (void)flushMailCaches;
+@end
+
+@interface SOGoMailBaseObject(Tree)
+
/* UI navigation */
- (NSArray *)treeNavigationNodes;
@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;
[[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 {
--- /dev/null
+/*
+ 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) */
# Version file
-SUBMINOR_VERSION:=49
+SUBMINOR_VERSION:=50
# v0.9.44 requires NGMime v4.3.194
# v0.9.41 requires NGMime v4.3.190
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>
@interface UIxMailTree : UIxComponent
{
+ id rootNodes;
id item;
}
@end
@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];
}
# $Id$
-SUBMINOR_VERSION:=58
+SUBMINOR_VERSION:=59
# v0.9.50 requires NGMime v4.3.190
# v0.9.43 requires NGObjWeb v4.3.73