#include "SOGoAppointment.h"
#include <SaxObjC/SaxObjC.h>
#include <NGiCal/NGiCal.h>
+#include "common.h"
+@interface NSDate(UsedPrivates)
+- (NSString *)icalString; // declared in NGiCal
+@end
@implementation SOGoAppointment
- (id)initWithICalString:(NSString *)_iCal {
if ((self = [self init])) {
+ id root;
+
if (parser == nil || sax == nil) {
[self release];
return nil;
}
-
+
+ /* parse */
+
[parser parseFromSource:_iCal];
- self->calendar = [[sax rootObject] retain];
- self->event = [[[self->calendar events] lastObject] retain];
+ root = [[sax rootObject] retain];
[sax reset];
+
+ /* fill */
+
+ [self logWithFormat:@"root is: %@", root];
+
+ if ([root isKindOfClass:[iCalEvent class]]) {
+ self->event = root;
+ }
+ else {
+ self->calendar = root;
+ self->event = [[[self->calendar events] lastObject] retain];
+ }
}
return self;
}
/* assume length of 1K - reasonable ? */
s = [[NSMutableString alloc] initWithCapacity:1024];
[s appendString:@"BEGIN:VCALENDAR\nMETHOD:REQUEST\nPRODID:"];
- [s appendString:[self->calendar prodId]];
+ if (self->calendar == nil)
+ [s appendString:@"SOGo/0.9"];
+ else
+ [s appendString:[self->calendar prodId]];
[s appendString:@"\nVERSION:"];
- [s appendString:[self->calendar version]];
+ if (self->calendar == nil)
+ [s appendString:@"2.0"];
+ else
+ [s appendString:[(iCalCalendar *)self->calendar version]];
[s appendString:@"\nBEGIN:VEVENT"];
[s appendString:@"\nSUMMARY:"];
[s appendString:[self summary]];