]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@75 d1b88da0-ebda-0310-925b-ed51d8...
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 29 Jun 2004 14:59:00 +0000 (14:59 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 29 Jun 2004 14:59:00 +0000 (14:59 +0000)
OGoContentStore/EOAdaptorChannel+OCS.h [new file with mode: 0644]
OGoContentStore/EOAdaptorChannel+OCS.m [new file with mode: 0644]
OGoContentStore/GNUmakefile
OGoContentStore/OCSChannelManager.m
OGoContentStore/OCSFolder.h
OGoContentStore/OCSFolder.m
OGoContentStore/OCSFolderManager.m
OGoContentStore/Version [new file with mode: 0644]

diff --git a/OGoContentStore/EOAdaptorChannel+OCS.h b/OGoContentStore/EOAdaptorChannel+OCS.h
new file mode 100644 (file)
index 0000000..10c9eab
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+  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$
+
+#ifndef __OGoContentStore_EOAdaptorChannel_OCS_H__
+#define __OGoContentStore_EOAdaptorChannel_OCS_H__
+
+#include <GDLAccess/EOAdaptorChannel.h>
+
+@interface EOAdaptorChannel(OCS)
+
+- (BOOL)tableExistsWithName:(NSString *)_tableName;
+
+@end
+
+#endif /* __OGoContentStore_EOAdaptorChannel_OCS_H__ */
diff --git a/OGoContentStore/EOAdaptorChannel+OCS.m b/OGoContentStore/EOAdaptorChannel+OCS.m
new file mode 100644 (file)
index 0000000..9050e42
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+  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$
+
+#include "EOAdaptorChannel+OCS.h"
+#include "common.h"
+
+@implementation EOAdaptorChannel(OCS)
+
+- (BOOL)tableExistsWithName:(NSString *)_tableName {
+  NSException *ex;
+  NSString    *sql;
+  BOOL        didOpen;
+  
+  didOpen = NO;
+  if (![self isOpen]) {
+    if (![self openChannel])
+      return NO;
+    didOpen = YES;
+  }
+  
+  sql = @"SELECT COUNT(*) FROM ";
+  sql = [sql stringByAppendingString:_tableName];
+  sql = [sql stringByAppendingString:@" WHERE 1 = 2"];
+  
+  ex = [[[self evaluateExpressionX:sql] retain] autorelease];
+  [self cancelFetch];
+  
+  if (didOpen) [self closeChannel];
+  return ex != nil ? NO : YES;
+}
+
+@end /* EOAdaptorChannel(OCS) */
index c1fef708d3ee5601a92588fe66767bd458294625..e79f9b016483e3c1e77f95f95eef464bb93cd029 100644 (file)
@@ -1,12 +1,14 @@
 # $Id$
 
 include $(GNUSTEP_MAKEFILES)/common.make
+include ./Version
 
 LIBRARY_NAME = libOGoContentStore
 TOOL_NAME = ocs_ls
 
 libOGoContentStore_HEADER_FILES += \
        NSURL+OCS.h             \
+       EOAdaptorChannel+OCS.h  \
        \
        OCSContext.h            \
        OCSFieldInfo.h          \
@@ -17,6 +19,7 @@ libOGoContentStore_HEADER_FILES += \
 
 libOGoContentStore_OBJC_FILES += \
        NSURL+OCS.m             \
+       EOAdaptorChannel+OCS.m  \
        \
        OCSContext.m            \
        OCSFieldInfo.m          \
index d7a09d09b6361c630e4071d439f23eaaeedef398..2bc60053d22a1eff4c00175cee6f445a4c2a0b6d 100644 (file)
     (eg missing release due to an exception)
 */
 
+@interface OCSChannelHandle : NSObject
+{
+@public
+  EOAdaptorChannel *channel;
+  NSDate           *creationTime;
+  NSDate           *lastReleaseTime;
+  NSDate           *lastAcquireTime;
+}
+
+@end
+
 @implementation OCSChannelManager
 
 static BOOL debugOn = YES;
@@ -212,3 +223,40 @@ static BOOL debugOn = YES;
 }
 
 @end /* OCSChannelManager */
+
+@implementation OCSChannelHandle
+
+- (void)dealloc {
+  [self->channel         release];
+  [self->creationTime    release];
+  [self->lastReleaseTime release];
+  [self->lastAcquireTime release];
+  [super dealloc];
+}
+
+/* accessors */
+
+- (EOAdaptorChannel *)channel {
+  return self->channel;
+}
+
+/* description */
+
+- (NSString *)description {
+  NSMutableString *ms;
+
+  ms = [NSMutableString stringWithCapacity:256];
+  [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
+  
+  [ms appendFormat:@" channel=0x%08X", self->channel];
+  if (self->creationTime) [ms appendFormat:@" created=%@", self->creationTime];
+  if (self->lastReleaseTime) 
+    [ms appendFormat:@" last-released=%@", self->lastReleaseTime];
+  if (self->lastAcquireTime) 
+    [ms appendFormat:@" last-acquired=%@", self->lastAcquireTime];
+  
+  [ms appendString:@">"];
+  return ms;
+}
+
+@end /* OCSChannelHandle */
index e1ff59fc3a942f75ee6b2af51e7ba2f9d429737c..c26e2a8dd807563a34161f10499601c5b7423b5d 100644 (file)
@@ -26,6 +26,7 @@
 #import <Foundation/NSObject.h>
 
 @class NSString, NSURL, NSNumber;
+@class EOAdaptorChannel;
 @class OCSFolderManager, OCSFolderType, OCSChannelManager;
 
 @interface OCSFolder : NSObject
 - (OCSFolderManager *)folderManager;
 - (OCSChannelManager *)channelManager;
 
+- (NSString *)storeTableName;
+- (NSString *)quickTableName;
+
+/* channels */
+
+- (EOAdaptorChannel *)acquireStoreChannel;
+- (EOAdaptorChannel *)acquireQuickChannel;
+- (void)releaseChannel:(EOAdaptorChannel *)_channel;
+
 @end
 
 #endif /* __OGoContentStore_OCSFolder_H__ */
index 0995f86098f5c3abc876fc743bbb6772d404f8ba..795ff5dc393fa22e005ab8b4d47d2a989cfd5f1b 100644 (file)
 #include "OCSFolder.h"
 #include "OCSFolderManager.h"
 #include "OCSFolderType.h"
+#include "OCSChannelManager.h"
+#include "NSURL+OCS.h"
+#include "EOAdaptorChannel+OCS.h"
 #include "common.h"
 
 @implementation OCSFolder
 
+static BOOL debugOn = YES;
+
++ (void)initialize {
+  NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+  
+  debugOn = [ud boolForKey:@"OCSFolderDebugEnabled"];
+}
+
 - (id)initWithPath:(NSString *)_path primaryKey:(id)_folderId
   folderTypeName:(NSString *)_ftname folderType:(OCSFolderType *)_ftype
   location:(NSURL *)_loc quickLocation:(NSURL *)_qloc
   folderManager:(OCSFolderManager *)_fm
 {
   if ((self = [super init])) {
-    self->folderManager = [_fm    retain];
-    self->folderInfo    = [_ftype retain];
+    self->folderManager  = [_fm    retain];
+    self->folderInfo     = [_ftype retain];
     
-    self->folderId      = [_folderId copy];
-    self->folderName    = [[_path lastPathComponent] copy];
-    self->path          = [_path   copy];
-    self->location      = [_loc    retain];
-    self->quickLocation = [_qloc   retain];
-    self->folderTypeName    = [_ftname copy];
+    self->folderId       = [_folderId copy];
+    self->folderName     = [[_path lastPathComponent] copy];
+    self->path           = [_path   copy];
+    self->location       = [_loc    retain];
+    self->quickLocation  = [_qloc   retain];
+    self->folderTypeName = [_ftname copy];
   }
   return self;
 }
 }
 
 - (void)dealloc {
-  [self->folderManager release];
-  [self->folderInfo    release];
-  [self->folderId      release];
-  [self->folderName    release];
-  [self->path          release];
-  [self->location      release];
-  [self->quickLocation release];
-  [self->folderTypeName    release];
+  [self->folderManager  release];
+  [self->folderInfo     release];
+  [self->folderId       release];
+  [self->folderName     release];
+  [self->path           release];
+  [self->location       release];
+  [self->quickLocation  release];
+  [self->folderTypeName release];
   [super dealloc];
 }
 
 - (NSURL *)location {
   return self->location;
 }
+- (NSURL *)quickLocation {
+  return self->quickLocation;
+}
 
 - (NSString *)folderTypeName {
   return self->folderTypeName;
 }
 
-
 - (OCSFolderManager *)folderManager {
   return self->folderManager;
 }
   return [[self folderManager] channelManager];
 }
 
+- (NSString *)storeTableName {
+  return [[self location] ocsTableName];
+}
+- (NSString *)quickTableName {
+  return [[self quickLocation] ocsTableName];
+}
+
+/* channels */
+
+- (EOAdaptorChannel *)acquireStoreChannel {
+  return [[self channelManager] acquireOpenChannelForURL:[self location]];
+}
+- (EOAdaptorChannel *)acquireQuickChannel {
+  return [[self channelManager] acquireOpenChannelForURL:[self quickLocation]];
+}
+
+- (void)releaseChannel:(EOAdaptorChannel *)_channel {
+  [[self channelManager] releaseChannel:_channel];
+  if (debugOn) [self debugWithFormat:@"released channel: %@", _channel];
+}
+
 /* description */
 
 - (NSString *)description {
index d11ca83c0a112b8b984bfa3d989411e2949af8d3..842eb33077b9fd4043a9f44936117f1379ed1734 100644 (file)
@@ -25,6 +25,7 @@
 #include "OCSFolderType.h"
 #include "OCSFolder.h"
 #include "NSURL+OCS.h"
+#include "EOAdaptorChannel+OCS.h"
 #include "common.h"
 #include <GDLAccess/EOAdaptorChannel.h>
 
@@ -145,8 +146,7 @@ static const char *OCSPathColumnPattern     = "c_path%i";
 
 - (BOOL)canConnect {
   EOAdaptorChannel *channel;
-  NSString    *sql;
-  NSException *ex;
+  BOOL result;
 
   /* check whether we can open a connection */
   
@@ -158,17 +158,10 @@ static const char *OCSPathColumnPattern     = "c_path%i";
   
   /* check whether table exists */
   
-  sql = @"SELECT COUNT(*) FROM ";
-  sql = [sql stringByAppendingString:[self folderInfoTableName]];
-  sql = [sql stringByAppendingString:@" WHERE 1 = 2"];
+  result = [channel tableExistsWithName:[self folderInfoTableName]];
+  [self releaseChannel:channel]; channel = nil;
   
-  ex = [[[channel evaluateExpressionX:sql] retain] autorelease];
-  [channel cancelFetch];
-  [self releaseChannel:channel];
-
-  if (debugOn && ex != nil) [self debugWithFormat:@"  folder-eval: %@", ex];
-  
-  return ex != nil ? NO : YES;
+  return result;
 }
 
 - (NSArray *)performSQL:(NSString *)_sql {
diff --git a/OGoContentStore/Version b/OGoContentStore/Version
new file mode 100644 (file)
index 0000000..7d481ef
--- /dev/null
@@ -0,0 +1,5 @@
+# $Id: Version,v 1.201 2004/06/29 13:45:54 helge Exp $
+
+MAJOR_VERSION=0
+MINOR_VERSION=9
+SUBMINOR_VERSION:=0