2004-10-19 Helge Hess <helge.hess@opengroupware.org>
+ * v0.9.21
+
+ * SOGoAppointment.m: added the -vEventString method (base on the new
+ renderer method)
+
+ * SOGoAppointmentICalRenderer.m :added -vEventStringForAppointment:
+ method to render a SOGoAppointment as just a vevent (without the
+ vcalendar wrapper)
+
* SOGoAppointment.m: added a -description (v0.9.20)
2004-10-17 Marcus Mueller <znek@mulle-kybernetik.com>
return [[SOGoAppointmentICalRenderer sharedAppointmentRenderer]
stringForAppointment:self];
}
+- (NSString *)vEventString {
+ return [[SOGoAppointmentICalRenderer sharedAppointmentRenderer]
+ vEventStringForAppointment:self];
+}
/* forwarded methods */
static SOGoAppointmentICalRenderer *renderer = nil;
+/* assume length of 1K - reasonable ? */
+static unsigned DefaultICalStringCapacity = 1024;
+
+ (id)sharedAppointmentRenderer {
if (renderer == nil)
renderer = [[self alloc] init];
[s appendString:@"END:VEVENT\r\n"];
}
-- (NSString *)stringForAppointment:(SOGoAppointment *)_apt {
- NSMutableString *s;
-
- if (_apt == nil)
- return nil;
+- (BOOL)isValidAppointment:(SOGoAppointment *)_apt {
+ if (![_apt isNotNull])
+ return NO;
if ([[_apt uid] length] == 0) {
[self logWithFormat:
@"WARNING: got apt without uid, rejecting iCal generation: %@",
_apt];
- return nil;
+ return NO;
}
if ([[[_apt startDate] icalString] length] == 0) {
[self logWithFormat:
@"WARNING: got apt without start date, "
@"rejecting iCal generation: %@",
_apt];
- return nil;
+ return NO;
}
- /* assume length of 1K - reasonable ? */
- s = [NSMutableString stringWithCapacity:1024];
+ return YES;
+}
+
+- (NSString *)vEventStringForAppointment:(SOGoAppointment *)_apt {
+ NSMutableString *s;
+
+ if (![self isValidAppointment:_apt])
+ return nil;
+
+ s = [NSMutableString stringWithCapacity:DefaultICalStringCapacity];
+ [self addVEventForAppointment:_apt toString:s];
+ return s;
+}
+
+- (NSString *)stringForAppointment:(SOGoAppointment *)_apt {
+ NSMutableString *s;
+
+ if (![self isValidAppointment:_apt])
+ return nil;
+
+ s = [NSMutableString stringWithCapacity:DefaultICalStringCapacity];
[self addPreambleForAppointment:_apt toString:s];
[self addVEventForAppointment:_apt toString:s];
[self addPostambleForAppointment:_apt toString:s];