--- /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$
+
+#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__ */
--- /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$
+
+#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) */
# $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 \
libOGoContentStore_OBJC_FILES += \
NSURL+OCS.m \
+ EOAdaptorChannel+OCS.m \
\
OCSContext.m \
OCSFieldInfo.m \
(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;
}
@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 */
#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__ */
#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 {
#include "OCSFolderType.h"
#include "OCSFolder.h"
#include "NSURL+OCS.h"
+#include "EOAdaptorChannel+OCS.h"
#include "common.h"
#include <GDLAccess/EOAdaptorChannel.h>
- (BOOL)canConnect {
EOAdaptorChannel *channel;
- NSString *sql;
- NSException *ex;
+ BOOL result;
/* check whether we can open a connection */
/* 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 {
--- /dev/null
+# $Id: Version,v 1.201 2004/06/29 13:45:54 helge Exp $
+
+MAJOR_VERSION=0
+MINOR_VERSION=9
+SUBMINOR_VERSION:=0