]> err.no Git - sope/blob - sope-ical/NGiCal/iCalEntityObject.m
bugfixes for cycle calculation, modified implementations with future extensions in...
[sope] / sope-ical / NGiCal / iCalEntityObject.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE 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   SOPE 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 SOPE; 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
22 #include "iCalEntityObject.h"
23 #include "iCalPerson.h"
24 #include "common.h"
25
26
27 @implementation iCalEntityObject
28
29 - (void)dealloc {
30   [self->status       release];
31   [self->location     release];
32   [self->sequence     release];
33   [self->startDate    release];
34   [self->comment      release];
35   [self->uid          release];
36   [self->summary      release];
37   [self->created      release];
38   [self->lastModified release];
39   [self->startDate    release];
40   [self->accessClass  release];
41   [self->priority     release];
42   [self->alarms       release];
43   [self->organizer    release];
44   [self->attendees    release];
45   [self->categories   release];
46   [super dealloc];
47 }
48
49 /* accessors */
50
51 - (void)setUid:(NSString *)_value {
52   if (self->uid != _value) {
53     [self->uid autorelease];
54     self->uid = [_value retain];
55   }
56 }
57 - (NSString *)uid {
58   return self->uid;
59 }
60
61 - (void)setSummary:(NSString *)_value {
62   if (self->summary != _value) {
63     [self->summary autorelease];
64     self->summary = [_value retain];
65   }
66 }
67 - (NSString *)summary {
68   return self->summary;
69 }
70
71 - (void)setLocation:(NSString *)_value {
72   if (self->location != _value) {
73     [self->location autorelease];
74     self->location = [_value retain];
75   }
76 }
77 - (NSString *)location {
78   return self->location;
79 }
80
81 - (void)setComment:(NSString *)_value {
82   if (self->comment != _value) {
83     [self->comment autorelease];
84     self->comment = [_value retain];
85   }
86 }
87 - (NSString *)comment {
88   return self->comment;
89 }
90
91 - (void)setAccessClass:(NSString *)_value {
92   if (self->accessClass != _value) {
93     [self->accessClass autorelease];
94     self->accessClass = [_value retain];
95   }
96 }
97 - (NSString *)accessClass {
98   return self->accessClass;
99 }
100
101 - (void)setPriority:(NSString *)_value {
102   if (self->priority != _value) {
103     [self->priority autorelease];
104     self->priority = [_value retain];
105   }
106 }
107 - (NSString *)priority {
108   return self->priority;
109 }
110
111 - (void)setCategories:(NSString *)_value {
112   ASSIGN(self->categories, _value);
113 }
114 - (NSString *)categories {
115   return self->categories;
116 }
117
118 - (void)setSequence:(NSNumber *)_value {
119   if (![_value isNotNull]) _value = nil;
120   if (self->sequence != _value) {
121     if (_value != nil && ![_value isKindOfClass:[NSNumber class]])
122       _value = [NSNumber numberWithInt:[_value intValue]];
123     [self->sequence autorelease];
124     self->sequence = [_value retain];
125   }
126 }
127 - (NSNumber *)sequence {
128   return self->sequence;
129 }
130
131 - (void)setStatus:(NSString *)_value {
132   ASSIGNCOPY(self->status, _value);
133 }
134 - (NSString *)status {
135   // eg: STATUS:CONFIRMED
136   return self->status;
137 }
138
139 - (void)setCreated:(NSCalendarDate *)_value {
140   if (self->created != _value) {
141     [self->created autorelease];
142     self->created = [_value retain];
143   }
144 }
145 - (NSCalendarDate *)created {
146   return self->created;
147 }
148 - (void)setLastModified:(NSCalendarDate *)_value {
149   if (self->lastModified != _value) {
150     [self->lastModified autorelease];
151     self->lastModified = [_value retain];
152   }
153 }
154 - (NSCalendarDate *)lastModified {
155   return self->lastModified;
156 }
157
158 - (void)setTimeStampAsDate:(NSCalendarDate *)_date {
159   /* TODO: too be completed */
160 }
161 - (NSCalendarDate *)timeStampAsDate {
162   return [NSDate dateWithTimeIntervalSince1970:self->timestamp];
163 }
164
165 - (void)setStartDate:(NSCalendarDate *)_date {
166   if (self->startDate != _date) {
167     [self->startDate autorelease];
168     self->startDate = [_date retain];
169   }
170 }
171 - (NSCalendarDate *)startDate {
172   return self->startDate;
173 }
174
175 - (void)setOrganizer:(iCalPerson *)_organizer {
176   if (self->organizer != _organizer) {
177     [self->organizer autorelease];
178     self->organizer = [_organizer retain];
179   }
180 }
181 - (iCalPerson *)organizer {
182   return self->organizer;
183 }
184
185 - (void)removeAllAttendees {
186     [self->attendees removeAllObjects];
187 }
188 - (void)addToAttendees:(iCalPerson *)_person {
189   if (_person == nil) return;
190   if (self->attendees == nil)
191     self->attendees = [[NSMutableArray alloc] initWithCapacity:4];
192   [self->attendees addObject:_person];
193 }
194 - (NSArray *)attendees {
195   return self->attendees;
196 }
197
198 - (void)removeAllAlarms {
199     [self->alarms removeAllObjects];
200 }
201 - (void)addToAlarms:(id)_alarm {
202   if (_alarm == nil) return;
203   if (self->alarms == nil)
204     self->alarms = [[NSMutableArray alloc] initWithCapacity:1];
205   [self->alarms addObject:_alarm];
206 }
207 - (BOOL)hasAlarms {
208   return [self->alarms count] > 0 ? YES : NO;
209 }
210 - (NSArray *)alarms {
211   return self->alarms;
212 }
213
214 @end /* iCalEntityObject */