]> err.no Git - scalable-opengroupware.org/blob - SOGo/SoObjects/SOGo/SOGoObject.m
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@137 d1b88da0-ebda-0310-925b-ed51d...
[scalable-opengroupware.org] / SOGo / SoObjects / SOGo / SOGoObject.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 "SOGoObject.h"
24 #include "common.h"
25
26 @implementation SOGoObject
27
28 - (BOOL)doesRetainContainer {
29   return YES;
30 }
31
32 - (id)initWithName:(NSString *)_name inContainer:(id)_container {
33   if ((self = [super init])) {
34     self->nameInContainer = [_name copy];
35     self->container = 
36       [self doesRetainContainer] ? [_container retain] : _container;
37   }
38   return self;
39 }
40 - (id)init {
41   return [self initWithName:nil inContainer:nil];
42 }
43
44 - (void)dealloc {
45   if ([self doesRetainContainer])
46     [self->container release];
47   [self->nameInContainer release];
48   [super dealloc];
49 }
50
51 /* accessors */
52
53 - (NSString *)nameInContainer {
54   return self->nameInContainer;
55 }
56 - (id)container {
57   return self->container;
58 }
59
60 /* looking up shared objects */
61
62 - (SOGoUserFolder *)lookupUserFolder {
63   if (![self->container respondsToSelector:_cmd])
64     return nil;
65   
66   return [self->container lookupUserFolder];
67 }
68
69 /* operations */
70
71 - (NSException *)delete {
72   return [NSException exceptionWithHTTPStatus:500 /* not implemented */
73                       reason:@"delete not yet implemented, sorry ..."];
74 }
75
76 /* KVC hacks */
77
78 - (id)valueForUndefinedKey:(NSString *)_key {
79   return nil;
80 }
81
82 /* WebDAV */
83
84 - (NSString *)davDisplayName {
85   return [self nameInContainer];
86 }
87
88 - (id)DELETEAction:(id)_ctx {
89   return [self delete];
90 }
91
92 /* description */
93
94 - (void)appendAttributesToDescription:(NSMutableString *)_ms {
95   if (self->nameInContainer) 
96     [_ms appendFormat:@" name=%@", self->nameInContainer];
97   if (self->container) 
98     [_ms appendFormat:@" container=0x%08X", self->container];
99 }
100
101 - (NSString *)description {
102   NSMutableString *ms;
103
104   ms = [NSMutableString stringWithCapacity:64];
105   [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
106   [self appendAttributesToDescription:ms];
107   [ms appendString:@">"];
108   return ms;
109 }
110
111 @end /* SOGoObject */