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->todos release];
29 [self->timezones release];
30 [self->events release];
31 [self->freeBusys release];
32 [self->journals release];
33 [self->version release];
34 [self->calscale release];
35 [self->prodId release];
41 - (void)setCalscale:(NSString *)_value {
42 ASSIGN(self->calscale, _value);
44 - (NSString *)calscale {
45 return self->calscale;
47 - (void)setVersion:(NSString *)_value {
48 ASSIGN(self->version, _value);
50 - (NSString *)version {
53 - (void)setProdId:(NSString *)_value {
54 ASSIGN(self->prodId, _value);
56 - (NSString *)prodId {
60 - (void)addToEvents:(iCalEvent *)_event {
61 if (_event == nil) return;
62 if (self->events == nil)
63 self->events = [[NSMutableArray alloc] initWithCapacity:4];
64 [self->events addObject:_event];
70 - (void)addToTimezones:(id)_tz {
73 if (_tz == nil) return;
74 if (self->timezones == nil)
75 self->timezones = [[NSMutableDictionary alloc] initWithCapacity:4];
77 if ((tzid = [_tz valueForKey:@"tzid"]) == nil) {
78 [self logWithFormat:@"ERROR: missing timezone-id in timezone: %@", _tz];
81 [self->timezones setObject:_tz forKey:tzid];
83 - (NSArray *)timezones {
84 return [self->timezones allValues];
87 - (void)addToTodos:(iCalToDo *)_todo {
88 if (_todo == nil) return;
89 if (self->todos == nil)
90 self->todos = [[NSMutableArray alloc] initWithCapacity:4];
91 [self->todos addObject:_todo];
97 - (void)addToJournals:(iCalJournal *)_obj {
98 if (_obj == nil) return;
99 if (self->journals == nil)
100 self->journals = [[NSMutableArray alloc] initWithCapacity:4];
101 [self->journals addObject:_obj];
103 - (NSArray *)journals {
104 return self->journals;
107 - (void)addToFreeBusys:(iCalJournal *)_obj {
108 if (_obj == nil) return;
109 if (self->freeBusys == nil)
110 self->freeBusys = [[NSMutableArray alloc] initWithCapacity:4];
111 [self->freeBusys addObject:_obj];
113 - (NSArray *)freeBusys {
114 return self->freeBusys;
119 - (NSArray *)allObjects {
122 ma = [NSMutableArray arrayWithCapacity:32];
123 if (self->events) [ma addObjectsFromArray:self->events];
124 if (self->todos) [ma addObjectsFromArray:self->todos];
125 if (self->freeBusys) [ma addObjectsFromArray:self->freeBusys];
126 if (self->journals) [ma addObjectsFromArray:self->journals];
129 - (NSEnumerator *)objectEnumerator {
130 return [[self allObjects] objectEnumerator];
135 - (NSString *)entityName {
141 - (NSString *)description {
144 ms = [NSMutableString stringWithCapacity:128];
145 [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
147 if (self->version) [ms appendFormat:@" v%@", self->version];
148 if (self->prodId) [ms appendFormat:@" product=%@", self->prodId];
149 if (self->calscale) [ms appendFormat:@" calscale=%@", self->calscale];
151 if ([self->events count] > 0)
152 [ms appendFormat:@" events=%@", self->events];
153 if ([self->todos count] > 0)
154 [ms appendFormat:@" todos=%@", self->todos];
155 if ([self->freeBusys count] > 0)
156 [ms appendFormat:@" fb=%@", self->freeBusys];
157 if ([self->journals count] > 0)
158 [ms appendFormat:@" journals=%@", self->journals];
160 if ([self->timezones count] > 0)
161 [ms appendFormat:@" tzs=%@", [self->timezones allKeys]];
163 [ms appendString:@">"];
167 @end /* iCalCalendar */