#include "SOGoMailAccounts.h"
#include "common.h"
+#include <NGObjWeb/SoObject+SoDAV.h>
@implementation SOGoMailAccounts
/* 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:@"." 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 */
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 {
#import <Foundation/NSObject.h>
-@class NSString, NSMutableString, NSException;
+@class NSString, NSArray, NSMutableString, NSException;
@class OCSFolderManager, OCSFolder;
@class SOGoUserFolder, SOGoGroupsFolder;
- (void)sleep;
+/* hierarchy */
+
+- (NSArray *)fetchSubfolders;
+
/* operations */
- (NSException *)delete;
return [[self container] ownerInContext:_ctx];
}
+/* hierarchy */
+
+- (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;
+}
+
/* looking up shared objects */
- (SOGoUserFolder *)lookupUserFolder {
return [self nameInContainer];
}
+/* actions */
+
- (id)DELETEAction:(id)_ctx {
return [self delete];
}