2 Copyright (C) 2003-2004 Max Berger
3 Copyright (C) 2004 OpenGroupware.org
5 This file is part of versitSaxDriver, written for the OpenGroupware.org
8 SOPE is free software; you can redistribute it and/or modify it under
9 the terms of the GNU Lesser General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
13 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with SOPE; see the file COPYING. If not, write to the
20 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #include "VSiCalSaxDriver.h"
25 #include <SaxObjC/XMLNamespaces.h>
28 @implementation VSiCalSaxDriver
30 static NSSet *defElementNames = nil;
31 static NSArray *defGeoMappings = nil;
34 static BOOL didInit = NO;
40 defElementNames = [[NSSet alloc] initWithObjects:
46 defGeoMappings = [[NSArray alloc] initWithObjects:
52 + (NSDictionary *)xcalMapping {
53 static NSDictionary *dict = nil;
55 NSMutableDictionary *xcal;
57 xcal = [[NSMutableDictionary alloc] initWithCapacity:60];
59 +---------------+-----------+-----------+-----------------+
60 | Calendar | Attribute | Attribute | Default |
61 | Property Name | Name | Type | Value |
62 +---------------+-----------+-----------+-----------------+
63 | CALSCALE | calscale | CDATA | IMPLIED |
64 | METHOD | method | NMTOKEN | PUBLISH |
65 | VERSION | version | CDATA | REQUIRED |
66 | PRODID | prodid | CDATA | IMPLIED |
67 +---------------+-----------+-----------+-----------------+
69 [xcal setObject:@"calscale" forKey:@"CALSCALE"];
70 [xcal setObject:@"method" forKey:@"METHOD"];
71 [xcal setObject:@"version" forKey:@"VERSION"];
72 [xcal setObject:@"prodid" forKey:@"PRODID"];
75 Descriptive Component Properties
76 +----------------+-------------+-----------------------------+
77 | Component | Element | Element Content Model |
78 | Property Name | Name | |
79 +----------------+-------------+-----------------------------+
80 | ATTACH | attach | extref or b64bin |
83 | CATEGORIES | categories | Any number of item elements |
85 | CLASS | class | PCDATA |
86 | COMMENT | comment | PCDATA |
87 | DESCRIPTION | description | PCDATA |
88 | GEO | geo | lat followed by lon element |
91 | LOCATION | location | PCDATA |
92 | PERCENT | percent | PCDATA |
93 | PRIORITY | priority | PCDATA |
94 | RESOURCES | resources | Any number of item elements |
95 | STATUS | status | PCDATA |
96 | SUMMARY | summary | PCDATA |
97 +----------------+-------------+-----------------------------+
100 [xcal setObject:@"attach" forKey:@"ATTACH"];
101 [xcal setObject:@"categories" forKey:@"CATEGORIES"];
102 [xcal setObject:@"class" forKey:@"CLASS"];
103 [xcal setObject:@"comment" forKey:@"COMMENT"];
104 [xcal setObject:@"description" forKey:@"DESCRIPTION"];
105 [xcal setObject:@"geo" forKey:@"GEO"];
106 [xcal setObject:@"location" forKey:@"LOCATION"];
107 [xcal setObject:@"percent" forKey:@"PERCENT"];
108 [xcal setObject:@"priority" forKey:@"PRIORITY"];
109 [xcal setObject:@"resources" forKey:@"RESOURCES"];
110 [xcal setObject:@"status" forKey:@"STATUS"];
111 [xcal setObject:@"summary" forKey:@"SUMMARY"];
114 Date and Time Component Properties
115 +----------------+------------+-----------------------------+
116 | Component | Element | Element Content Model |
117 | Property Name | Name | |
118 +----------------+------------+-----------------------------+
119 | COMPLETED | completed | PCDATA |
120 | DTEND | dtend | PCDATA |
121 | DUE | due | PCDATA |
122 | DTSTART | dtstart | PCDATA |
123 | DURATION | duration | PCDATA |
124 | FREEBUSY | freebusy | PCDATA |
125 | TRANSP | transp | PCDATA |
126 +----------------+------------+-----------------------------+
129 [xcal setObject:@"completed" forKey:@"COMPLETED"];
130 [xcal setObject:@"dtend" forKey:@"DTEND"];
131 [xcal setObject:@"due" forKey:@"DUE"];
132 [xcal setObject:@"dtstart" forKey:@"DTSTART"];
133 [xcal setObject:@"duration" forKey:@"DURATION"];
134 [xcal setObject:@"freebusy" forKey:@"FREEBUSY"];
135 [xcal setObject:@"transp" forKey:@"TRANSP"];
138 Time Zone Component Properties
139 +----------------+-------------+-----------------------------+
140 | Component | Element | Element Content Model |
141 | Property Name | Name | |
142 +----------------+-------------+-----------------------------+
143 | TZID | tzid | PCDATA |
144 | TZNAME | tzname | PCDATA |
145 | TZOFFSETFROM | tzoffsetfrom| PCDATA |
146 | TZOFFSETTO | tzoffsetto | PCDATA |
147 | TZURL | tzurl | EMPTY |
148 +----------------+-------------+-----------------------------+
151 [xcal setObject:@"tzid" forKey:@"TZID"];
152 [xcal setObject:@"tzname" forKey:@"TZNAME"];
153 [xcal setObject:@"tzoffsetfrom" forKey:@"TZOFFSETFROM"];
154 [xcal setObject:@"tzoffsetto" forKey:@"TZOFFSETTO"];
155 [xcal setObject:@"tzurl" forKey:@"TZURL"];
158 Relationship Component Properties
159 +----------------+---------------+--------------------------+
160 | Component | Element | Element Content Model |
161 | Property Name | Name | |
162 +----------------+---------------+--------------------------+
163 | ATTENDEE | attendee | PCDATA |
164 | CONTACT | contact | PCDATA |
165 | ORGANIZER | organizer | PCDATA |
166 | RECURRENCE-ID | recurrence-id | PCDATA |
167 | RELATED-TO | related-to | PCDATA |
168 | URL | url | EMPTY |
169 | UID | uid | PCDATA |
170 +----------------+---------------+--------------------------+
172 [xcal setObject:@"attendee" forKey:@"ATTENDEE"];
173 [xcal setObject:@"contact" forKey:@"CONTACT"];
174 [xcal setObject:@"organizer" forKey:@"ORGANIZER"];
175 [xcal setObject:@"recurrence-id" forKey:@"RECURRENCE-ID"];
176 [xcal setObject:@"related-to" forKey:@"RELATED-TO"];
177 [xcal setObject:@"url" forKey:@"URL"];
178 [xcal setObject:@"uid" forKey:@"UID"];
181 Recurrence Component Properties
182 +----------------+------------+-----------------------------+
183 | Component | Element | Element Content Model |
184 | Property Name | Name | |
185 +----------------+------------+-----------------------------+
186 | EXDATE | exdate | PCDATA |
187 | EXRULE | exrule | PCDATA |
188 | RDATE | rdate | PCDATA |
189 | RRULE | rrule | PCDATA |
190 +----------------+------------+-----------------------------+
193 [xcal setObject:@"exdate" forKey:@"EXDATE"];
194 [xcal setObject:@"exrule" forKey:@"EXRULE"];
195 [xcal setObject:@"rdate" forKey:@"RDATE"];
196 [xcal setObject:@"rrule" forKey:@"RRULE"];
199 Alarm Component Properties
200 +----------------+------------+-----------------------------+
201 | Component | Element | Element Content Model |
202 | Property Name | Name | |
203 +----------------+------------+-----------------------------+
204 | ACTION | action | PCDATA |
205 | REPEAT | repeat | PCDATA |
206 | TRIGGER | trigger | PCDATA |
207 +----------------+------------+-----------------------------+
209 [xcal setObject:@"action" forKey:@"ACTION"];
210 [xcal setObject:@"repeat" forKey:@"REPEAT"];
211 [xcal setObject:@"trigger" forKey:@"TRIGGER"];
214 Change Management Component Properties
215 +----------------+---------------+--------------------------+
216 | Component | Element | Element Content Model |
217 | Property Name | Name | |
218 +----------------+---------------+--------------------------+
219 | CREATED | created | PCDATA |
220 | DTSTAMP | dtstamp | PCDATA |
221 | LAST-MODIFIED | last-modified | PCDATA |
222 | SEQUENCE | sequence | PCDATA |
223 +----------------+---------------+--------------------------+
225 [xcal setObject:@"created" forKey:@"CREATED"];
226 [xcal setObject:@"dtstamp" forKey:@"DTSTAMP"];
227 [xcal setObject:@"last-modified" forKey:@"LAST-MODIFIED"];
228 [xcal setObject:@"sequence" forKey:@"SEQUENCE"];
231 Miscellaneous Component Properties
232 +----------------+----------------+-------------------------+
233 | Component | Element | Element Content Model |
234 | Property Name | Name | |
235 +----------------+----------------+-------------------------+
236 | REQUEST-STATUS | request-status | PCDATA |
237 +----------------+----------------+-------------------------+
239 [xcal setObject:@"request-status" forKey:@"REQUEST-STATUS"];
243 Component Structuring Properties
244 +----------------+------------+-------------------------------+
245 | Component | Element | Element Content Model |
246 | Property Name | Name | |
247 +----------------+------------+-------------------------------+
248 | Multiple iCal- | iCalendar | One or more iCal elements |
249 | endar objects | | |
250 | VCALENDAR | vcalendar | calcomp parameter entity |
251 | VEVENT | vevent | vevent.opt1 and vevent.optm |
252 | | | parameter entity and valarm |
254 | VTODO | vtodo | vtodo.opt1 and vtodo.optm |
255 | | | parameter entity and valarm |
257 | VJOURNAL | vjournal | vjournal.opt1 and |
258 | | | vjournal.optm parameter |
260 | VFREEBUSY | vfreebusy | vfreebusy.opt1 and |
261 | | | vfreebusy.optm parameter |
263 | VTIMEZONE | vtimezone | vtimezone.man, |
264 | | | vtimezone.opt1, |
265 | | | vtimezone.mann parameter |
267 | STANDARD | standard | standard.man or standard.optm |
269 | DAYLIGHT | daylight | daylight.man or daylight.optm |
271 | VALARM | valarm | valarm.audio, valarm.display, |
272 | | | valarm.email and |
273 | | | valarm.procedure entity |
274 +----------------+------------+-------------------------------+
277 [xcal setObject:@"vcalendar" forKey:@"VCALENDAR"];
278 [xcal setObject:@"vevent" forKey:@"VEVENT"];
279 [xcal setObject:@"vtodo" forKey:@"VTODO"];
280 [xcal setObject:@"vjournal" forKey:@"VJOURNAL"];
281 [xcal setObject:@"vfreebusy" forKey:@"VFREEBUSY"];
282 [xcal setObject:@"vtimezone" forKey:@"VTIMEZONE"];
283 [xcal setObject:@"standard" forKey:@"STANDARD"];
284 [xcal setObject:@"daylight" forKey:@"DAYLIGHT"];
285 [xcal setObject:@"valarm" forKey:@"VALARM"];
293 + (NSDictionary *)xcalAttrMapping
295 static NSDictionary *dict = nil;
297 NSMutableDictionary *xcal;
299 xcal = [[NSMutableDictionary alloc] initWithCapacity:20];
301 ----------------+----------------+-----------+-----------------+
302 | Property | Attribute | Attribute | Default |
303 | Parameter Name | Name | Type | Value |
304 +----------------+----------------+-----------+-----------------+
305 | ALTREP | altrep | ENTITY | IMPLIED |
306 | CN | cn | CDATA | Null String |
307 | CUTYPE | cutype | NMTOKEN | INDIVIDUAL |
308 | DELEGATED-FROM | delegated-from | CDATA | IMPLIED |
309 | DELEGATED-TO | delegated-to | CDATA | IMPLIED |
310 | DIR | dir | ENTITY | IMPLIED |
311 | ENCODING | Not Used | n/a | n/a |
312 | FMTTYPE | fmttype | CDATA | REQUIRED |
313 | FBTYPE | fbtype | NMTOKEN | BUSY |
314 | LANGUAGE | language | CDATA | IMPLIED |
315 | MEMBER | member | CDATA | IMPLIED |
316 | PARTSTAT | partstat | NMTOKEN | NEEDS-ACTION |
317 | RANGE | range | NMTOKEN | THISONLY |
318 | RELATED | related | NMTOKEN | START |
319 | RELTYPE | reltype | NMTOKEN | PARENT |
320 | ROLE | role | NMTOKEN | REQ-PARTICIPANT |
321 | RSVP | rsvp | NMTOKEN | FALSE |
322 | SENT-BY | sent-by | CDATA | IMPLIED |
323 | TZID | tzid | CDATA | IMPLIED |
324 | VALUE | value | NOTATION | See elements |
325 +----------------+----------------+-----------+-----------------+
327 [xcal setObject:@"altrep" forKey:@"ALTREP"];
328 [xcal setObject:@"cn" forKey:@"CN"];
329 [xcal setObject:@"cutype" forKey:@"CUTYPE"];
330 [xcal setObject:@"delegated-from" forKey:@"DELEGATED-FROM"];
331 [xcal setObject:@"delegated-to" forKey:@"DELEGATED-TO"];
332 [xcal setObject:@"dir" forKey:@"DIR"];
333 [xcal setObject:@"Not" forKey:@"ENCODING"];
334 [xcal setObject:@"fmttype" forKey:@"FMTTYPE"];
335 [xcal setObject:@"fbtype" forKey:@"FBTYPE"];
336 [xcal setObject:@"language" forKey:@"LANGUAGE"];
337 [xcal setObject:@"member" forKey:@"MEMBER"];
338 [xcal setObject:@"partstat" forKey:@"PARTSTAT"];
339 [xcal setObject:@"range" forKey:@"RANGE"];
340 [xcal setObject:@"related" forKey:@"RELATED"];
341 [xcal setObject:@"reltype" forKey:@"RELTYPE"];
342 [xcal setObject:@"role" forKey:@"ROLE"];
343 [xcal setObject:@"rsvp" forKey:@"RSVP"];
344 [xcal setObject:@"sent-by" forKey:@"SENT-BY"];
345 [xcal setObject:@"tzid" forKey:@"TZID"];
346 [xcal setObject:@"value" forKey:@"VALUE"];
355 if ((self = [super init])) {
356 [self setPrefixURI:XMLNS_XCAL_01];
357 [self setElementMapping:[[self class] xcalMapping]];
358 [self setAttributeElements:defElementNames];
360 [self setAttributeMapping:[[self class] xcalAttrMapping]];
361 [self setSubItemMapping:defGeoMappings forElement:@"geo"];
366 @end /* ICalendarSaxDriver */