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 #import <Foundation/NSArray.h>
23 #import <Foundation/NSString.h>
27 #import "iCalJournal.h"
28 #import "iCalFreeBusy.h"
29 #import "iCalEntityObject.h"
30 #import "iCalTimeZone.h"
32 #import "iCalCalendar.h"
34 @interface iCalCalendar (Privates)
35 - (void) addToEvents: (iCalEvent *) _event;
36 - (void) addToTimezones: (iCalTimeZone *) _tz;
37 - (void) addToTodos: (iCalToDo *) _todo;
38 - (void) addToJournals: (iCalJournal *) _obj;
39 - (void) addToFreeBusys: (iCalFreeBusy *) _obj;
42 @implementation iCalCalendar
45 - (Class) classForTag: (NSString *) classTag
50 if ([classTag isEqualToString: @"VEVENT"])
51 tagClass = [iCalEvent class];
52 else if ([classTag isEqualToString: @"VTODO"])
53 tagClass = [iCalToDo class];
54 else if ([classTag isEqualToString: @"VJOURNAL"])
55 tagClass = [iCalJournal class];
56 else if ([classTag isEqualToString: @"VFREEBUSY"])
57 tagClass = [iCalFreeBusy class];
58 else if ([classTag isEqualToString: @"VTIMEZONE"])
59 tagClass = [iCalTimeZone class];
60 else if ([classTag isEqualToString: @"METHOD"]
61 || [classTag isEqualToString: @"PRODID"]
62 || [classTag isEqualToString: @"VERSION"])
63 tagClass = [CardElement class];
65 tagClass = [super classForTag: classTag];
72 - (void) setCalscale: (NSString *) _calscale
74 [[self uniqueChildWithTag: @"calscale"] setValue: 0 to: _calscale];
77 - (NSString *) calscale
79 return [[self uniqueChildWithTag: @"calscale"] value: 0];
82 - (void) setVersion: (NSString *) _version
84 [[self uniqueChildWithTag: @"version"] setValue: 0 to: _version];
87 - (NSString *) version
89 return [[self uniqueChildWithTag: @"version"] value: 0];
92 - (void) setProdID: (NSString *) _value
94 [[self uniqueChildWithTag: @"prodid"] setValue: 0 to: _value];
99 return [[self uniqueChildWithTag: @"prodid"] value: 0];
102 - (void) setMethod: (NSString *) _value
104 [[self uniqueChildWithTag: @"method"] setValue: 0 to: _value];
107 - (NSString *) method
109 return [[self uniqueChildWithTag: @"method"] value: 0];
112 - (void) addToEvents: (iCalEvent *) _event
114 [self addChild: _event];
119 return [self childrenWithTag: @"vevent"];
122 - (void) addToTimezones: (iCalTimeZone *) _tz
124 [self addChild: _tz];
127 - (NSArray *) timezones
129 return [self childrenWithTag: @"vtimezone"];
132 - (void) addToTodos: (iCalToDo *) _todo
134 [self addChild: _todo];
139 return [self childrenWithTag: @"vtodo"];
142 - (void) addToJournals: (iCalJournal *) _todo
144 [self addChild: _todo];
147 - (NSArray *) journals
149 return [self childrenWithTag: @"vjournal"];
152 - (void) addToFreeBusys: (iCalFreeBusy *) _fb
154 [self addChild: _fb];
157 - (NSArray *) freeBusys
159 return [self childrenWithTag: @"vfreebusy"];
162 - (void) addTimeZone: (iCalTimeZone *) iTZ
164 iCalTimeZone *possibleTz;
166 possibleTz = [self timeZoneWithId: [iTZ tzId]];
168 [self addChild: iTZ];
171 - (iCalTimeZone *) timeZoneWithId: (NSString *) tzId
173 NSArray *matchingTimeZones;
174 iCalTimeZone *timeZone;
176 matchingTimeZones = [self childrenGroupWithTag: @"vtimezone"
178 havingSimpleValue: tzId];
179 if ([matchingTimeZones count])
180 timeZone = [matchingTimeZones objectAtIndex: 0];
189 - (NSArray *) allObjects
193 ma = [NSMutableArray new];
194 [ma addObjectsFromArray: [self events]];
195 [ma addObjectsFromArray: [self todos]];
196 [ma addObjectsFromArray: [self journals]];
197 [ma addObjectsFromArray: [self freeBusys]];
204 - (NSString *) entityName
209 @end /* iCalCalendar */