From 4932394e20d5f8844e50a635066b959f88d14d59 Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 21 Jun 2004 12:40:06 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/trunk@54 d1b88da0-ebda-0310-925b-ed51d893ca5b --- dbd/DSoDatabase.h | 6 +++ dbd/DSoDatabase.m | 2 + dbd/DSoDatabaseManager.m | 7 ++++ dbd/DSoTable.h | 13 ++++++ dbd/DSoTable.m | 26 ++++++++++++ dbd/DTable.m | 87 ++++++++++++++++++++++++++++++++++++++++ dbd/DTable.wox | 18 +++++++++ dbd/GNUmakefile | 2 + dbd/product.plist | 16 +++++--- 9 files changed, 171 insertions(+), 6 deletions(-) create mode 100644 dbd/DTable.m create mode 100644 dbd/DTable.wox diff --git a/dbd/DSoDatabase.h b/dbd/DSoDatabase.h index 48fc63bd..60324b5e 100644 --- a/dbd/DSoDatabase.h +++ b/dbd/DSoDatabase.h @@ -35,6 +35,12 @@ - (id)initWithHostName:(NSString *)_hostname port:(int)_port databaseName:(NSString *)_dbname; +/* accessors */ + +- (NSString *)hostName; +- (int)port; +- (NSString *)databaseName; + /* support */ - (EOAdaptor *)adaptorInContext:(WOContext *)_ctx; diff --git a/dbd/DSoDatabase.m b/dbd/DSoDatabase.m index 0663657d..b848a1ca 100644 --- a/dbd/DSoDatabase.m +++ b/dbd/DSoDatabase.m @@ -60,6 +60,8 @@ return self->databaseName; } +// TODO: add baseURL generation + /* support */ - (EOAdaptor *)adaptorInContext:(WOContext *)_ctx { diff --git a/dbd/DSoDatabaseManager.m b/dbd/DSoDatabaseManager.m index 1529ba00..c99b933d 100644 --- a/dbd/DSoDatabaseManager.m +++ b/dbd/DSoDatabaseManager.m @@ -48,6 +48,13 @@ return self->host; } +- (id)container { + return [self host]; +} +- (NSString *)nameInContainer { + return @"Databases"; +} + /* name lookup */ - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { diff --git a/dbd/DSoTable.h b/dbd/DSoTable.h index 7bfac922..cdad265b 100644 --- a/dbd/DSoTable.h +++ b/dbd/DSoTable.h @@ -36,6 +36,19 @@ - (id)initWithName:(NSString *)_name inContainer:(id)_container; +/* accessors */ + +- (DSoDatabase *)database; +- (NSString *)tableName; + +- (NSString *)hostName; +- (int)port; +- (NSString *)databaseName; + +/* support */ + +- (EOAdaptor *)adaptorInContext:(WOContext *)_ctx; + @end #endif /* __dbd_DSoTable_H__ */ diff --git a/dbd/DSoTable.m b/dbd/DSoTable.m index 88a1821c..36df6c9e 100644 --- a/dbd/DSoTable.m +++ b/dbd/DSoTable.m @@ -40,6 +40,32 @@ [super dealloc]; } +/* accessors */ + +- (DSoDatabase *)database { + return self->database; +} +- (NSString *)tableName { + return self->tableName; +} + +- (NSString *)hostName { + return [[self database] hostName]; +} +- (int)port { + return [[self database] port]; +} +- (NSString *)databaseName { + return [[self database] databaseName]; +} + +- (id)container { + return [self database]; +} +- (NSString *)nameInContainer { + return [self tableName]; +} + /* support */ - (EOAdaptor *)adaptorInContext:(WOContext *)_ctx { diff --git a/dbd/DTable.m b/dbd/DTable.m new file mode 100644 index 00000000..89d303c0 --- /dev/null +++ b/dbd/DTable.m @@ -0,0 +1,87 @@ +// $Id$ + +#include + +@class EOAdaptorChannel; + +@interface DTable : SoComponent +{ + EOAdaptorChannel *channel; + NSArray *columnNames; + id item; +} + +@end + +#include "DSoTable.h" +#include "common.h" + +@implementation DTable + +- (void)dealloc { + if ([self->channel isOpen]) + [self->channel closeChannel]; + [self->channel release]; + + [self->columnNames release]; + [self->item release]; + [super dealloc]; +} + +/* notifications */ + +- (void)sleep { + if ([self->channel isOpen]) + [self->channel closeChannel]; + + [super sleep]; +} + +/* DB things */ + +- (EOAdaptor *)adaptor { + return [(DSoTable *)[self clientObject] adaptorInContext:[self context]]; +} + +- (EOAdaptorChannel *)channel { + EOAdaptorContext *ctx; + + if (self->channel) + return self->channel; + + ctx = [[self adaptor] createAdaptorContext]; + self->channel = [[ctx createAdaptorChannel] retain]; + if (![self->channel openChannel]) { + [self->channel release]; + self->channel = nil; + } + + return self->channel; +} + +- (EOModel *)_describeModel { + NSArray *tableNames; + + tableNames = [NSArray arrayWithObject:[[self clientObject] tableName]]; + return [[self channel] describeModelWithTableNames:tableNames]; +} + +/* accessors */ + +- (void)setItem:(id)_item { + ASSIGN(self->item, _item); +} +- (id)item { + return self->item; +} + +- (NSArray *)columnNames { + return self->columnNames; +} + +- (NSString *)itemSlashLink { + // this suxx, a) we need to write code, b) we need to attach the / manually + return [[self item] stringByAppendingString:@"/"]; +} + +@end /* DTable */ diff --git a/dbd/DTable.wox b/dbd/DTable.wox new file mode 100644 index 00000000..eb3ce5ff --- /dev/null +++ b/dbd/DTable.wox @@ -0,0 +1,18 @@ + + + +Host:
+Port:
+DB:
+Table:
+ +

Columns

+ +
  • +
    + +
    diff --git a/dbd/GNUmakefile b/dbd/GNUmakefile index 8520dc67..07f17ab7 100644 --- a/dbd/GNUmakefile +++ b/dbd/GNUmakefile @@ -23,6 +23,7 @@ dbd_OBJC_FILES += \ DHostView.m \ DDatabaseManager.m \ DDatabase.m \ + DTable.m \ dbd_RESOURCE_FILES += \ Version \ @@ -34,6 +35,7 @@ dbd_RESOURCE_FILES += \ DHostView.wox \ DDatabaseManager.wox \ DDatabase.wox \ + DTable.wox \ dbd_WEBSERVER_RESOURCE_FILES += diff --git a/dbd/product.plist b/dbd/product.plist index fa259229..6d55643e 100644 --- a/dbd/product.plist +++ b/dbd/product.plist @@ -13,15 +13,15 @@ "WebDAV Access" = "Authenticated"; }; methods = { - "index" = { + index = { protectedBy = "View"; pageName = "MainPage"; }; - "GET" = { // more or less a hack, see README + GET = { // more or less a hack, see README protectedBy = "View"; pageName = "MainPage"; }; - "connect" = { + connect = { protectedBy = "View"; pageName = "MainPage"; actionName = "connect"; @@ -43,7 +43,7 @@ DSoHost = { superclass = "DSoObject"; methods = { - "index" = { + index = { protectedBy = "View"; pageName = "DHostView"; }; @@ -52,12 +52,16 @@ DSoTable = { superclass = "DSoObject"; methods = { + index = { + protectedBy = "View"; + pageName = "DTable"; + }; }; }; DSoDatabase = { superclass = "DSoObject"; methods = { - "index" = { + index = { protectedBy = "View"; pageName = "DDatabase"; }; @@ -66,7 +70,7 @@ DSoDatabaseManager = { superclass = "DSoObject"; methods = { - "index" = { + index = { protectedBy = "View"; pageName = "DDatabaseManager"; }; -- 2.39.2