]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@76 d1b88da0-ebda-0310-925b-ed51d8...
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 29 Jun 2004 15:46:08 +0000 (15:46 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 29 Jun 2004 15:46:08 +0000 (15:46 +0000)
OGoContentStore/OCSChannelManager.h
OGoContentStore/OCSChannelManager.m
OGoContentStore/OCSFolder.h
OGoContentStore/OCSFolder.m
OGoContentStore/OCSFolderManager.m
OGoContentStore/ocs_ls.m
OGoContentStore/sql/folderinfo-create.psql [moved from OGoContentStore/sql/folderinfo.psql with 100% similarity]

index acfde2dd8b75ef83d0fe1dc2054e4f07e10250e4..c95ccc9902fa98d47d5a73f30f0de304c8e727dd 100644 (file)
 - (EOAdaptorChannel *)acquireOpenChannelForURL:(NSURL *)_url;
 - (void)releaseChannel:(EOAdaptorChannel *)_channel;
 
+/* checking for tables */
+
+- (BOOL)canConnect:(NSURL *)_url;
+
 @end
 
 #endif /* __OGoContentStore_OCSChannelManager_H__ */
index 2bc60053d22a1eff4c00175cee6f445a4c2a0b6d..881f9c30f0bf0169af8d62c15923940d23dbf9cc 100644 (file)
@@ -202,6 +202,37 @@ static BOOL debugOn = YES;
   [_channel release];
 }
 
+/* checking for tables */
+
+- (BOOL)canConnect:(NSURL *)_url {
+  /* 
+     this can check for DB connect as well as for table URLs (whether a table
+     exists)
+  */
+  EOAdaptorChannel *channel;
+  NSString *table;
+  BOOL     result;
+  
+  if ((channel = [self acquireOpenChannelForURL:_url]) == nil) {
+    if (debugOn) [self debugWithFormat:@"could not acquire channel: %@", _url];
+    return NO;
+  }
+  if (debugOn) [self debugWithFormat:@"acquired channel: %@", channel];
+  result = YES; /* could open channel */
+  
+  /* check whether table exists */
+  
+  table = [_url ocsTableName];
+  if ([table length] > 0)
+    result = [channel tableExistsWithName:table];
+  
+  /* release channel */
+  
+  [self releaseChannel:channel]; channel = nil;
+  
+  return result;
+}
+
 /* debugging */
 
 - (BOOL)isDebuggingEnabled {
index c26e2a8dd807563a34161f10499601c5b7423b5d..cf9dbc8447cce82fbacd41e5137e610a578adf09 100644 (file)
@@ -25,7 +25,7 @@
 
 #import <Foundation/NSObject.h>
 
-@class NSString, NSURL, NSNumber;
+@class NSString, NSURL, NSNumber, NSArray;
 @class EOAdaptorChannel;
 @class OCSFolderManager, OCSFolderType, OCSChannelManager;
 
 - (NSString *)storeTableName;
 - (NSString *)quickTableName;
 
-/* channels */
+/* connection */
 
 - (EOAdaptorChannel *)acquireStoreChannel;
 - (EOAdaptorChannel *)acquireQuickChannel;
 - (void)releaseChannel:(EOAdaptorChannel *)_channel;
 
+- (BOOL)canConnectStore;
+- (BOOL)canConnectQuick;
+
+/* operations */
+
+- (NSArray *)subFolderNames;
+- (NSArray *)allSubFolderNames;
+
 @end
 
 #endif /* __OGoContentStore_OCSFolder_H__ */
index 795ff5dc393fa22e005ab8b4d47d2a989cfd5f1b..2bde8671bec7f8eb4eb11c57d81267beef37df82 100644 (file)
@@ -127,6 +127,24 @@ static BOOL debugOn = YES;
   if (debugOn) [self debugWithFormat:@"released channel: %@", _channel];
 }
 
+- (BOOL)canConnectStore {
+  return [[self channelManager] canConnect:[self location]];
+}
+- (BOOL)canConnectQuick {
+  return [[self channelManager] canConnect:[self quickLocation]];
+}
+
+/* operations */
+
+- (NSArray *)subFolderNames {
+  return [[self folderManager] listSubFoldersAtPath:[self path]
+                              recursive:NO];
+}
+- (NSArray *)allSubFolderNames {
+  return [[self folderManager] listSubFoldersAtPath:[self path]
+                              recursive:YES];
+}
+
 /* description */
 
 - (NSString *)description {
@@ -144,7 +162,7 @@ static BOOL debugOn = YES;
   if ((tmp = [self path]))           [ms appendFormat:@" path=%@", tmp];
   if ((tmp = [self folderTypeName])) [ms appendFormat:@" type=%@", tmp];
   if ((tmp = [self location]))
-    [ms appendFormat:@" db=%@",   [tmp absoluteString]];
+    [ms appendFormat:@" loc=%@", [tmp absoluteString]];
   
   [ms appendString:@">"];
   return ms;
index 842eb33077b9fd4043a9f44936117f1379ed1734..560544f4ba9f1caa445720eac6c0f95e173152b3 100644 (file)
@@ -145,23 +145,7 @@ static const char *OCSPathColumnPattern     = "c_path%i";
 }
 
 - (BOOL)canConnect {
-  EOAdaptorChannel *channel;
-  BOOL result;
-
-  /* check whether we can open a connection */
-  
-  if ((channel = [self acquireOpenChannel]) == nil) {
-    if (debugOn) [self debugWithFormat:@"could not acquire channel!"];
-    return NO;
-  }
-  if (debugOn) [self debugWithFormat:@"acquired channel: %@", channel];
-  
-  /* check whether table exists */
-  
-  result = [channel tableExistsWithName:[self folderInfoTableName]];
-  [self releaseChannel:channel]; channel = nil;
-  
-  return result;
+  return [[self channelManager] canConnect:[self folderInfoLocation]];
 }
 
 - (NSArray *)performSQL:(NSString *)_sql {
index dba6ac3744967f0a5684bff7dbc2567058b0efb7..47706d2952c11e5e555d417137c22dbc4c728aae 100644 (file)
@@ -1,7 +1,6 @@
 // $Id$
 
-#include <OGoContentStore/OCSFolderManager.h>
-#include "common.h"
+#import <Foundation/NSObject.h>
 
 @class NSUserDefaults;
 @class OCSFolderManager;
 
 @end
 
+#include <OGoContentStore/OCSFolder.h>
+#include <OGoContentStore/OCSFolderManager.h>
+#include "common.h"
+
 @implementation Tool
 
 - (id)init {
@@ -34,8 +37,9 @@
 /* operation */
 
 - (int)runOnPath:(NSString *)_path {
-  NSArray  *subfolders;
-  unsigned i, count;
+  NSArray   *subfolders;
+  unsigned  i, count;
+  OCSFolder *folder;
   
   [self logWithFormat:@"ls path: '%@'", _path];
   
   for (i = 0, count = [subfolders count]; i < count; i++) {
     printf("%s\n", [[subfolders objectAtIndex:i] cString]);
   }
+
+  folder = [self->folderManager folderAtPath:_path];
   
-  NSLog(@"folder: %@", [self->folderManager folderAtPath:_path]);
+  NSLog(@"folder: %@", folder);
+  NSLog(@"  can%s connect store.", [folder canConnectStore] ? "" : "not");
+  NSLog(@"  can%s connect quick.", [folder canConnectQuick] ? "" : "not");
 
   return 0;
 }