]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@46 d1b88da0-ebda-0310-925b-ed51d8...
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 17 Jun 2004 01:23:37 +0000 (01:23 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 17 Jun 2004 01:23:37 +0000 (01:23 +0000)
14 files changed:
dbd/DDatabase.m [new file with mode: 0644]
dbd/DDatabase.wox [new file with mode: 0644]
dbd/DDatabaseManager.m [new file with mode: 0644]
dbd/DDatabaseManager.wox [new file with mode: 0644]
dbd/DHostView.m
dbd/DSoDatabase.h
dbd/DSoDatabase.m
dbd/DSoDatabaseManager.m
dbd/DSoObject.m
dbd/DSoTable.h
dbd/DSoTable.m
dbd/GNUmakefile
dbd/README
dbd/product.plist

diff --git a/dbd/DDatabase.m b/dbd/DDatabase.m
new file mode 100644 (file)
index 0000000..f184b3a
--- /dev/null
@@ -0,0 +1,82 @@
+// $Id$
+
+#include <NGObjWeb/SoComponent.h>
+
+@class EOAdaptorChannel;
+
+@interface DDatabase : SoComponent
+{
+  EOAdaptorChannel *channel;
+  NSArray *tableNames;
+  id item;
+}
+
+@end
+
+#include "DSoDatabase.h"
+#include "common.h"
+
+@implementation DDatabase
+
+- (void)dealloc {
+  if ([self->channel isOpen])
+    [self->channel closeChannel];
+  [self->channel release];
+  
+  [self->tableNames release];
+  [self->item       release];
+  [super dealloc];
+}
+
+/* notifications */
+
+- (void)sleep {
+  if ([self->channel isOpen])
+    [self->channel closeChannel];
+  
+  [super sleep];
+}
+
+/* DB things */
+
+- (EOAdaptor *)adaptor {
+  return [(DSoDatabase *)[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;
+}
+
+/* accessors */
+
+- (void)setItem:(id)_item {
+  ASSIGN(self->item, _item);
+}
+- (id)item {
+  return self->item;
+}
+
+- (NSArray *)tableNames {
+  if (self->tableNames == nil)
+    self->tableNames = [[[self channel] describeTableNames] copy];
+  return self->tableNames;
+}
+
+- (NSString *)tabLink {
+  // this suxx, a) we need to write code, b) we need to attach the / manually
+  return [[self item] stringByAppendingString:@"/"];
+}
+
+@end /* DDatabase */
diff --git a/dbd/DDatabase.wox b/dbd/DDatabase.wox
new file mode 100644 (file)
index 0000000..9a2a405
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version='1.0' standalone='yes'?>
+<var:component className="Frame" 
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:var="http://www.skyrix.com/od/binding"
+  xmlns:const="http://www.skyrix.com/od/constant"
+>
+
+Host: <a href=".."><var:string value="clientObject.hostName"/></a><br />
+Port: <var:string value="clientObject.port"/><br />
+DB:   <var:string value="clientObject.databaseName"/><br />
+
+<h4>Tables</h4>
+<var:foreach list="tableNames" item="item">
+  <li><a var:href="tabLink"><var:string value="item" /></a></li>
+</var:foreach>
+
+</var:component>
diff --git a/dbd/DDatabaseManager.m b/dbd/DDatabaseManager.m
new file mode 100644 (file)
index 0000000..e995028
--- /dev/null
@@ -0,0 +1,88 @@
+// $Id$
+
+#include <NGObjWeb/SoComponent.h>
+
+@class EOAdaptorChannel;
+
+@interface DDatabaseManager : SoComponent
+{
+  EOAdaptorChannel *channel;
+  NSArray *databaseNames;
+  id item;
+}
+
+@end
+
+#include "DSoHost.h"
+#include "DSoDatabaseManager.h"
+#include "common.h"
+
+@interface EOAdaptorChannel(ModelFetching)
+- (NSArray *)describeDatabaseNames;
+@end
+
+@implementation DDatabaseManager
+
+- (void)dealloc {
+  if ([self->channel isOpen])
+    [self->channel closeChannel];
+  [self->channel release];
+  
+  [self->databaseNames release];
+  [self->item          release];
+  [super dealloc];
+}
+
+/* notifications */
+
+- (void)sleep {
+  if ([self->channel isOpen])
+    [self->channel closeChannel];
+  
+  [super sleep];
+}
+
+/* DB things */
+
+- (EOAdaptor *)adaptor {
+  return [[(DSoDatabaseManager *)[self clientObject] 
+                                host] 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;
+}
+
+/* accessors */
+
+- (void)setItem:(id)_item {
+  ASSIGN(self->item, _item);
+}
+- (id)item {
+  return self->item;
+}
+
+- (NSArray *)databaseNames {
+  if (self->databaseNames == nil)
+    self->databaseNames = [[[self channel] describeDatabaseNames] copy];
+  return self->databaseNames;
+}
+
+- (NSString *)dbLink {
+  // this suxx, a) we need to write code, b) we need to attach the / manually
+  return [[self item] stringByAppendingString:@"/"];
+}
+
+@end /* DDatabaseManager */
diff --git a/dbd/DDatabaseManager.wox b/dbd/DDatabaseManager.wox
new file mode 100644 (file)
index 0000000..16362b3
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version='1.0' standalone='yes'?>
+<var:component className="Frame" 
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:var="http://www.skyrix.com/od/binding"
+  xmlns:const="http://www.skyrix.com/od/constant"
+>
+
+Host: <var:string value="clientObject.host.hostName"/><br />
+Port: <var:string value="clientObject.host.port"/><br />
+
+<h4>Databases</h4>
+<var:foreach list="databaseNames" item="item">
+  <li><a var:href="dbLink"><var:string value="item" /></a></li>
+</var:foreach>
+
+<hr />
+<a href="../Users/">Users</a>
+
+</var:component>
index 37698adf3930a5e3971406bfbac3abbccb3caffc..ed6f1d9cec81b9796b4774759360f9d6f0d44ffd 100644 (file)
 // Note: it suxx that we need to write code for that ...
 
 - (NSString *)dbLink {
-  return [@"Databases/" stringByAppendingString:[self item]];
+  return [[@"Databases/" stringByAppendingString:[self item]]
+                        stringByAppendingString:@"/"];
 }
 - (NSString *)userLink {
-  return [@"Users/" stringByAppendingString:[self item]];
+  return [[@"Users/" stringByAppendingString:[self item]]
+                    stringByAppendingString:@"/"];
 }
 
 @end /* DHostView */
index e7402e8f893bb306ed696dded26e6ee61d493d23..48fc63bd1fa66054a8336efa50d66bd4519d907f 100644 (file)
 - (id)initWithHostName:(NSString *)_hostname port:(int)_port 
   databaseName:(NSString *)_dbname;
 
+/* support */
+
+- (EOAdaptor *)adaptorInContext:(WOContext *)_ctx;
+
 @end
 
 #endif /* __dbd_DSoDatabase_H__ */
index 8e82fa1c51485d7b91c57f078a4c005cacc1b284..0663657dc9e9ccbbd994fe1bfe09a8091218abe2 100644 (file)
 // $Id$
 
 #include "DSoDatabase.h"
+#include "DSoTable.h"
 #include "DSoAuthenticator.h"
 #include "common.h"
 
+// TODO: PG databases do have an owner!
+// TODO: PG databases have an ACL
+
 @implementation DSoDatabase
 
 - (id)initWithHostName:(NSString *)_hostname port:(int)_port 
   return self->databaseName;
 }
 
+/* support */
+
+- (EOAdaptor *)adaptorInContext:(WOContext *)_ctx {
+  return [self adaptorForHostName:[self hostName] port:[self port]
+              databaseName:[self databaseName] inContext:_ctx];
+}
+
 /* authentication */
 
 - (id)authenticatorInContext:(id)_ctx {
                           port:[self port] databaseName:[self databaseName]];
 }
 
+/* name lookup */
+
+- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
+  id obj;
+  
+  /* 
+     Note: acquire:NO - otherwise acquired stuff will override the stuff
+           below!
+  */
+  if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]))
+    return obj;
+  
+  obj = [[DSoTable alloc] initWithName:_key inContainer:self];
+  return [obj autorelease];
+}
+
 @end /* DSoDatabase */
index ca7895585de8e3cd5d69f8c4f25af7dfef1f8c84..1529ba00dc283c639ae29f5932a9684797a71bab 100644 (file)
 - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
   id obj;
   
+  /* 
+     Note: acquire:NO - otherwise acquired stuff will override the stuff
+           below!
+  */
   if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]))
     return obj;
   
-  // TODO: create DSoDatabase object
   obj = [[DSoDatabase alloc] initWithHostName:[self->host hostName]
                             port:[self->host port]
                             databaseName:_key];
index f71d6d997e144379b6fdcc2207d9e54e83ced66f..e6ea9297337baa3b04738393e923840d5c9405cc 100644 (file)
 }
 #endif
 
+/* OSX hack */
+
+- (id)valueForUndefinedKey:(NSString *)_key {
+  [self debugWithFormat:@"queried undefined key: '%@'", _key];
+  return nil;
+}
+
+- (BOOL)isCollection {
+  return YES;
+}
+
 @end /* DSoObject */
index 1ac86c0338322c3026e7cd9ab1451a8b94adddf8..7bfac9226e706d7311bf408d37df3a784891af06 100644 (file)
 
 #include "DSoObject.h"
 
+@class NSString;
+@class DSoDatabase;
+
 @interface DSoTable : DSoObject
 {
+  DSoDatabase *database;
+  NSString    *tableName;
 }
 
+- (id)initWithName:(NSString *)_name inContainer:(id)_container;
+
 @end
 
 #endif /* __dbd_DSoTable_H__ */
index d72fa3fcf42d44873691c85eb2d7a2d3575e4cc8..99fabeb8112a30b330dcc47d20c3a8cc579a221d 100644 (file)
 // $Id$
 
 #include "DSoTable.h"
+#include "DSoDatabase.h"
 #include "common.h"
 
 @implementation DSoTable
 
+- (id)initWithName:(NSString *)_name inContainer:(id)_container {
+  if ((self = [super init])) {
+    self->tableName = [_name      copy];
+    self->database  = [_container retain];
+  }
+  return self;
+}
+
 - (void)dealloc {
+  [self->database  release];
+  [self->tableName release];
   [super dealloc];
 }
 
+/* support */
+
+- (EOAdaptor *)adaptorInContext:(WOContext *)_ctx {
+  return [self->database adaptorInContext:_ctx];
+}
+
 @end /* DSoTable */
index a47d4d8a1480c6a21cff01bfe56446ec8273d552..8520dc6733ca681844189fd79ae31cd801b83e5e 100644 (file)
@@ -22,6 +22,7 @@ dbd_OBJC_FILES += \
        \
        DHostView.m             \
        DDatabaseManager.m      \
+       DDatabase.m             \
 
 dbd_RESOURCE_FILES += \
        Version                 \
@@ -32,6 +33,7 @@ dbd_RESOURCE_FILES += \
        \
        DHostView.wox           \
        DDatabaseManager.wox    \
+       DDatabase.wox           \
 
 dbd_WEBSERVER_RESOURCE_FILES +=
 
index 4e85a13926c1dd423cd9b0a712b82b22d50a660f..63ac658e9e3082b365b7c96e1af87b4623a3fcf8 100644 (file)
@@ -26,6 +26,11 @@ Class Hierarchy
 Tricks used
 ===========
 
+- *always* remember that SOPE objects which are looked up in the traversal
+  process are conceptually *UI* objects, not datamodel objects (though this
+  might be done for simplistic applications)
+  - the idea is: the URL is UI
+
 - small hack in MainPage.m to make a redirect to a "valid" WO URL if the
   request-handler-key is missing
   - should be made by SOPE itself?
@@ -72,6 +77,8 @@ Tricks used
   - in theory SOPE should make a redirect to the default method, not sure why
     this isn't happening
   - ZideStore always makes such a redirect?
+  - maybe any folderish object when being at the end of a traversal stack 
+    should check that?
 
 - acquisition
   - if you override -lookupName:inContext:acquire:, you should probably
@@ -81,3 +88,14 @@ Tricks used
   - note that acquisition is also done on the traversal path! if the lookup
     returns nil on an URL path being traversed, URL acquisition will occure
     (except on non-acquisition protocols like WebDAV)
+
+- baseURL
+  - calculation of base URL requires you to either override -baseURLInContext:
+    or implement -container and -nameInContainer
+
+- enabling WebDAV
+  - implemented -isCollection in DSoObject
+  - per default the baseURL is broken - you need to ensure that it returns
+    a proper value, see above
+    - if the baseURL doesn't match the requested WebDAV URL, we run into
+      problems, maybe need to fix something in the SOPE WebDAV layer here
index 3ff18ae94c700bc349f1cbe390f7b4457074ee45..fa25922985f814e935e5f201e85e2be2c927dc46 100644 (file)
     DSoDatabase = {
       superclass    = "DSoObject";
       methods = {
+        "index" = { 
+          protectedBy = "View";
+          pageName    = "DDatabase"; 
+        };
       };
     };
     DSoDatabaseManager = {