2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
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
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.
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
22 #include "iCalCalendar.h"
25 @implementation iCalCalendar
28 [self->version release];
29 [self->calscale release];
30 [self->prodId release];
31 [self->method release];
33 [self->todos release];
34 [self->events release];
35 [self->journals release];
36 [self->freeBusys release];
37 [self->timezones release];
43 - (void)setCalscale:(NSString *)_value {
44 ASSIGNCOPY(self->calscale, _value);
46 - (NSString *)calscale {
47 return self->calscale;
49 - (void)setVersion:(NSString *)_value {
50 ASSIGNCOPY(self->version, _value);
52 - (NSString *)version {
55 - (void)setProdId:(NSString *)_value {
56 ASSIGNCOPY(self->prodId, _value);
58 - (NSString *)prodId {
61 - (void)setMethod:(NSString *)_method {
62 ASSIGNCOPY(self->method, _method);
64 - (NSString *)method {
68 - (void)addToEvents:(iCalEvent *)_event {
69 if (_event == nil) return;
70 if (self->events == nil)
71 self->events = [[NSMutableArray alloc] initWithCapacity:4];
72 [self->events addObject:_event];
78 - (void)addToTimezones:(id)_tz {
81 if (_tz == nil) return;
82 if (self->timezones == nil)
83 self->timezones = [[NSMutableDictionary alloc] initWithCapacity:4];
85 if ((tzid = [_tz valueForKey:@"tzid"]) == nil) {
86 [self logWithFormat:@"ERROR: missing timezone-id in timezone: %@", _tz];
89 [self->timezones setObject:_tz forKey:tzid];
91 - (NSArray *)timezones {
92 return [self->timezones allValues];
95 - (void)addToTodos:(iCalToDo *)_todo {
96 if (_todo == nil) return;
97 if (self->todos == nil)
98 self->todos = [[NSMutableArray alloc] initWithCapacity:4];
99 [self->todos addObject:_todo];
105 - (void)addToJournals:(iCalJournal *)_obj {
106 if (_obj == nil) return;
107 if (self->journals == nil)
108 self->journals = [[NSMutableArray alloc] initWithCapacity:4];
109 [self->journals addObject:_obj];
111 - (NSArray *)journals {
112 return self->journals;
115 - (void)addToFreeBusys:(iCalJournal *)_obj {
116 if (_obj == nil) return;
117 if (self->freeBusys == nil)
118 self->freeBusys = [[NSMutableArray alloc] initWithCapacity:4];
119 [self->freeBusys addObject:_obj];
121 - (NSArray *)freeBusys {
122 return self->freeBusys;
127 - (NSArray *)allObjects {
130 ma = [NSMutableArray arrayWithCapacity:32];
131 if (self->events) [ma addObjectsFromArray:self->events];
132 if (self->todos) [ma addObjectsFromArray:self->todos];
133 if (self->freeBusys) [ma addObjectsFromArray:self->freeBusys];
134 if (self->journals) [ma addObjectsFromArray:self->journals];
137 - (NSEnumerator *)objectEnumerator {
138 return [[self allObjects] objectEnumerator];
143 - (NSString *)entityName {
149 - (NSString *)description {
152 ms = [NSMutableString stringWithCapacity:128];
153 [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
155 if (self->version) [ms appendFormat:@" v%@", self->version];
156 if (self->method) [ms appendFormat:@" method=%@", self->method];
157 if (self->prodId) [ms appendFormat:@" product=%@", self->prodId];
158 if (self->calscale) [ms appendFormat:@" calscale=%@", self->calscale];
160 if ([self->events count] > 0)
161 [ms appendFormat:@" events=%@", self->events];
162 if ([self->todos count] > 0)
163 [ms appendFormat:@" todos=%@", self->todos];
164 if ([self->freeBusys count] > 0)
165 [ms appendFormat:@" fb=%@", self->freeBusys];
166 if ([self->journals count] > 0)
167 [ms appendFormat:@" journals=%@", self->journals];
169 if ([self->timezones count] > 0)
170 [ms appendFormat:@" tzs=%@", [self->timezones allKeys]];
172 [ms appendString:@">"];
176 @end /* iCalCalendar */