]> err.no Git - sope/blobdiff - sope-ical/NGiCal/iCalRenderer.m
bumped framework versions
[sope] / sope-ical / NGiCal / iCalRenderer.m
index 35361299d5e2548a0578a90e522f2656be6a0d44..c7e108afbc8d9036b24d551b6fb4de2a006f4f95 100644 (file)
 #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;
@@ -91,8 +89,16 @@ static unsigned DefaultICalStringCapacity = 1024;
       [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:@"\""];
@@ -165,11 +171,66 @@ static unsigned DefaultICalStringCapacity = 1024;
     [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];
   
@@ -182,16 +243,14 @@ static unsigned DefaultICalStringCapacity = 1024;
     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;
   }