]> err.no Git - scalable-opengroupware.org/blob - SOGo/SoObjects/SOGo/SOGoObject.m
ad29501b0db42a02f96dff648194bc4bac000ac0
[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 /* KVC hacks */
70
71 - (id)valueForUndefinedKey:(NSString *)_key {
72   return nil;
73 }
74
75 /* WebDAV */
76
77 - (NSString *)davDisplayName {
78   return [self nameInContainer];
79 }
80
81 /* description */
82
83 - (void)appendAttributesToDescription:(NSMutableString *)_ms {
84   if (self->nameInContainer) 
85     [_ms appendFormat:@" name=%@", self->nameInContainer];
86   if (self->container) 
87     [_ms appendFormat:@" container=0x%08X", self->container];
88 }
89
90 - (NSString *)description {
91   NSMutableString *ms;
92
93   ms = [NSMutableString stringWithCapacity:64];
94   [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
95   [self appendAttributesToDescription:ms];
96   [ms appendString:@">"];
97   return ms;
98 }
99
100 @end /* SOGoObject */