]> err.no Git - scalable-opengroupware.org/blob - SOGoLogic/SOGoAppointment.m
ede2088ecad642e39cd67cc4a50680b491bcc66c
[scalable-opengroupware.org] / SOGoLogic / SOGoAppointment.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
6   OGo 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
9   later version.
10
11   OGo 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.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23
24 #include "SOGoAppointment.h"
25 #include <SaxObjC/SaxObjC.h>
26
27
28 @implementation SOGoAppointment
29
30 - (id)initWithiCalString:(NSString *)_iCal {
31     if ((self = [self init])) {
32         id<NSObject,SaxXMLReader> parser;
33         SaxObjectDecoder *sax;
34
35         parser =
36             [[[SaxXMLReaderFactory standardXMLReaderFactory] 
37               createXMLReaderForMimeType:@"text/calendar"]
38               retain];
39         if (parser == nil) {
40             NSLog(@"did not find a parser for text/calendar !");
41             [self release];
42             return nil;
43         }
44         
45         sax = [[SaxObjectDecoder alloc] initWithMappingNamed:@"NGiCal"];
46         if (sax == nil) {
47             NSLog(@"could not create the iCal SAX handler !");
48             [self release];
49             return nil;
50         }
51         
52         [parser setContentHandler:sax];
53         [parser setErrorHandler:sax];
54         
55         [parser parseFromSource:_iCal];
56         self->event = [[sax rootObject] retain];
57         [parser release];
58         [sax release];
59     }
60     return self;
61 }
62
63 - (void)dealloc {
64     [self->event release];
65     [super dealloc];
66 }
67
68 - (id)event {
69     return self->event;
70 }
71
72 @end