#include "iCalRenderer.h"
#include "iCalEvent.h"
#include "iCalPerson.h"
+#include "iCalRecurrenceRule.h"
+#include "NSCalendarDate+ICal.h"
#include "common.h"
-@interface NSDate(UsedPrivates)
-- (NSString *)icalString; // declared in NGiCal
-@end
-
@implementation iCalRenderer
static iCalRenderer *renderer = nil;
[s appendString:@";"];
}
+ if ((x = [p partStat])) {
+ if ([p participationStatus] != iCalPersonPartStatNeedsAction) {
+ [s appendString:@"PARTSTAT="];
+ [s appendString:[x iCalSafeString]];
+ [s appendString:@";"];
+ }
+ }
+
[s appendString:@"CN=\""];
- if ((x = [p cn])) {
+ if ((x = [p cnWithoutQuotes])) {
[s appendString:[x iCalDQUOTESafeString]];
}
[s appendString:@"\""];
[s appendString:@"\r\n"];
}
-
- /* what's all this? */
- [s appendString:@"TRANSP:OPAQUE\r\n"]; /* transparency */
- [s appendString:@"CLASS:PRIVATE\r\n"]; /* classification [like 'top secret'] */
-
+ if ((tmp = [event transparency]) != nil) {
+ [s appendString:@"TRANSP:"];
+ [s appendString:tmp];
+ [s appendString:@"\r\n"];
+ }
+
+ [s appendString:@"CLASS:"];
+ [s appendString:[event accessClass]];
+ [s appendString:@"\r\n"];
+
+ /* recurrence rules */
+ if ([event hasRecurrenceRules]) {
+ NSArray *rules;
+ unsigned i, count;
+
+ rules = [event recurrenceRules];
+ count = [rules count];
+ for (i = 0; i < count; i++) {
+ iCalRecurrenceRule *rule;
+
+ rule = [rules objectAtIndex:i];
+ [s appendString:@"RRULE:"];
+ [s appendString:[rule iCalRepresentation]];
+ [s appendString:@"\r\n"];
+ }
+ }
+
+ /* exception rules */
+ if ([event hasExceptionRules]) {
+ NSArray *rules;
+ unsigned i, count;
+
+ rules = [event exceptionRules];
+ count = [rules count];
+ for (i = 0; i < count; i++) {
+ iCalRecurrenceRule *rule;
+
+ rule = [rules objectAtIndex:i];
+ [s appendString:@"EXRULE:"];
+ [s appendString:[rule iCalRepresentation]];
+ [s appendString:@"\r\n"];
+ }
+ }
+
+ /* exception dates */
+ if ([event hasExceptionDates]) {
+ NSArray *dates;
+ unsigned i, count;
+
+ dates = [event exceptionDates];
+ count = [dates count];
+ [s appendString:@"EXDATE:"];
+ for (i = 0; i < count; i++) {
+ if (i > 0)
+ [s appendString:@","];
+ [s appendString:[[dates objectAtIndex:i] icalString]];
+ }
+ [s appendString:@"\r\n"];
+ }
+
[self addOrganizer:[event organizer] toString:s];
[self addAttendees:[event attendees] toString:s];
return NO;
if ([[_apt uid] length] == 0) {
- [self logWithFormat:
- @"WARNING: got apt without uid, rejecting iCal generation: %@",
- _apt];
+ [self warnWithFormat:@"got apt without uid, rejecting iCal generation: %@",
+ _apt];
return NO;
}
if ([[[_apt startDate] icalString] length] == 0) {
- [self logWithFormat:
- @"WARNING: got apt without start date, "
- @"rejecting iCal generation: %@",
- _apt];
+ [self warnWithFormat:@"got apt without start date, "
+ @"rejecting iCal generation: %@",
+ _apt];
return NO;
}