]> err.no Git - scalable-opengroupware.org/blob - dbd/DSoDatabase.m
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@54 d1b88da0-ebda-0310-925b-ed51d8...
[scalable-opengroupware.org] / dbd / DSoDatabase.m
1 /*
2   Copyright (C) 2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "DSoDatabase.h"
24 #include "DSoTable.h"
25 #include "DSoAuthenticator.h"
26 #include "common.h"
27
28 // TODO: PG databases do have an owner!
29 // TODO: PG databases have an ACL
30
31 @implementation DSoDatabase
32
33 - (id)initWithHostName:(NSString *)_hostname port:(int)_port 
34   databaseName:(NSString *)_dbname
35 {
36   if ((self = [super init])) {
37     self->hostName     = [_hostname copy];
38     self->databaseName = [_dbname copy];
39     self->port         = _port > 0 ? _port : 5432;
40   }
41   return self;
42 }
43
44 - (void)dealloc {
45   [self->databaseName release];
46   [self->hostName     release];
47   [super dealloc];
48 }
49
50 /* accessors */
51
52 - (NSString *)hostName {
53   return self->hostName;
54 }
55 - (int)port {
56   return self->port;
57 }
58
59 - (NSString *)databaseName {
60   return self->databaseName;
61 }
62
63 // TODO: add baseURL generation
64
65 /* support */
66
67 - (EOAdaptor *)adaptorInContext:(WOContext *)_ctx {
68   return [self adaptorForHostName:[self hostName] port:[self port]
69                databaseName:[self databaseName] inContext:_ctx];
70 }
71
72 /* authentication */
73
74 - (id)authenticatorInContext:(id)_ctx {
75   return [DSoAuthenticator authenticatorWithHostName:[self hostName]
76                            port:[self port] databaseName:[self databaseName]];
77 }
78
79 /* name lookup */
80
81 - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
82   id obj;
83   
84   /* 
85      Note: acquire:NO - otherwise acquired stuff will override the stuff
86            below!
87   */
88   if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]))
89     return obj;
90   
91   obj = [[DSoTable alloc] initWithName:_key inContainer:self];
92   return [obj autorelease];
93 }
94
95 @end /* DSoDatabase */