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];
32 [self->todos release];
33 [self->events release];
34 [self->journals release];
35 [self->freeBusys release];
36 [self->timezones release];
42 - (void)setCalscale:(NSString *)_value {
43 ASSIGN(self->calscale, _value);
45 - (NSString *)calscale {
46 return self->calscale;
48 - (void)setVersion:(NSString *)_value {
49 ASSIGN(self->version, _value);
51 - (NSString *)version {
54 - (void)setProdId:(NSString *)_value {
55 ASSIGN(self->prodId, _value);
57 - (NSString *)prodId {
61 - (void)addToEvents:(iCalEvent *)_event {
62 if (_event == nil) return;
63 if (self->events == nil)
64 self->events = [[NSMutableArray alloc] initWithCapacity:4];
65 [self->events addObject:_event];
71 - (void)addToTimezones:(id)_tz {
74 if (_tz == nil) return;
75 if (self->timezones == nil)
76 self->timezones = [[NSMutableDictionary alloc] initWithCapacity:4];
78 if ((tzid = [_tz valueForKey:@"tzid"]) == nil) {
79 [self logWithFormat:@"ERROR: missing timezone-id in timezone: %@", _tz];
82 [self->timezones setObject:_tz forKey:tzid];
84 - (NSArray *)timezones {
85 return [self->timezones allValues];
88 - (void)addToTodos:(iCalToDo *)_todo {
89 if (_todo == nil) return;
90 if (self->todos == nil)
91 self->todos = [[NSMutableArray alloc] initWithCapacity:4];
92 [self->todos addObject:_todo];
98 - (void)addToJournals:(iCalJournal *)_obj {
99 if (_obj == nil) return;
100 if (self->journals == nil)
101 self->journals = [[NSMutableArray alloc] initWithCapacity:4];
102 [self->journals addObject:_obj];
104 - (NSArray *)journals {
105 return self->journals;
108 - (void)addToFreeBusys:(iCalJournal *)_obj {
109 if (_obj == nil) return;
110 if (self->freeBusys == nil)
111 self->freeBusys = [[NSMutableArray alloc] initWithCapacity:4];
112 [self->freeBusys addObject:_obj];
114 - (NSArray *)freeBusys {
115 return self->freeBusys;
120 - (NSArray *)allObjects {
123 ma = [NSMutableArray arrayWithCapacity:32];
124 if (self->events) [ma addObjectsFromArray:self->events];
125 if (self->todos) [ma addObjectsFromArray:self->todos];
126 if (self->freeBusys) [ma addObjectsFromArray:self->freeBusys];
127 if (self->journals) [ma addObjectsFromArray:self->journals];
130 - (NSEnumerator *)objectEnumerator {
131 return [[self allObjects] objectEnumerator];
136 - (NSString *)entityName {
142 - (NSString *)description {
145 ms = [NSMutableString stringWithCapacity:128];
146 [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
148 if (self->version) [ms appendFormat:@" v%@", self->version];
149 if (self->prodId) [ms appendFormat:@" product=%@", self->prodId];
150 if (self->calscale) [ms appendFormat:@" calscale=%@", self->calscale];
152 if ([self->events count] > 0)
153 [ms appendFormat:@" events=%@", self->events];
154 if ([self->todos count] > 0)
155 [ms appendFormat:@" todos=%@", self->todos];
156 if ([self->freeBusys count] > 0)
157 [ms appendFormat:@" fb=%@", self->freeBusys];
158 if ([self->journals count] > 0)
159 [ms appendFormat:@" journals=%@", self->journals];
161 if ([self->timezones count] > 0)
162 [ms appendFormat:@" tzs=%@", [self->timezones allKeys]];
164 [ms appendString:@">"];
168 @end /* iCalCalendar */