2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #import <Foundation/NSObject.h>
24 @class NSUserDefaults, NSArray;
25 @class GCSFolderManager;
27 @interface Tool : NSObject
30 GCSFolderManager *folderManager;
33 + (int)runWithArgs:(NSArray *)_args;
38 #include <GDLContentStore/GCSFolder.h>
39 #include <GDLContentStore/GCSFolderManager.h>
45 if ((self = [super init])) {
46 self->ud = [[NSUserDefaults standardUserDefaults] retain];
47 self->folderManager = [[GCSFolderManager defaultFolderManager] retain];
53 [self->folderManager release];
59 - (int)runOnPath:(NSString *)_path {
64 [self logWithFormat:@"ls path: '%@'", _path];
66 #if 0 // we do not necessarily need the whole hierarchy
67 if (![self->folderManager folderExistsAtPath:_path])
68 [self logWithFormat:@"folder does not exist: '%@'", _path];
71 subfolders = [self->folderManager
72 listSubFoldersAtPath:_path
73 recursive:[ud boolForKey:@"r"]];
74 if (subfolders == nil) {
75 [self logWithFormat:@"cannot list folder: '%@'", _path];
79 for (i = 0, count = [subfolders count]; i < count; i++) {
80 printf("%s\n", [[subfolders objectAtIndex:i] cString]);
83 folder = [self->folderManager folderAtPath:_path];
85 if ([folder isNotNull]) {
86 NSLog(@"folder: %@", folder);
88 NSLog(@" can%s connect store: %@", [folder canConnectStore] ? "" : "not",
89 [[folder location] absoluteString]);
90 NSLog(@" can%s connect quick: %@", [folder canConnectQuick] ? "" : "not",
91 [[folder quickLocation] absoluteString]);
94 NSLog(@"ERROR: could not create folder object for path: '%@'", _path);
104 [self logWithFormat:@"manager: %@", self->folderManager];
106 if (![self->folderManager canConnect]) {
107 [self logWithFormat:@"cannot connect folder-info database!"];
111 e = [[[NSProcessInfo processInfo] argumentsWithoutDefaults]
113 [e nextObject]; // skip tool name
115 while ((path = [e nextObject]) != nil)
116 [self runOnPath:path];
120 + (int)runWithArgs:(NSArray *)_args {
121 return [(Tool *)[[[self alloc] init] autorelease] run];
126 int main(int argc, char **argv, char **env) {
127 NSAutoreleasePool *pool;
130 pool = [[NSAutoreleasePool alloc] init];
131 #if LIB_FOUNDATION_LIBRARY
132 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
135 rc = [Tool runWithArgs:
136 [[NSProcessInfo processInfo] argumentsWithoutDefaults]];