]> err.no Git - scalable-opengroupware.org/commitdiff
determine 'enddate' correctly for recurrent events, otherwise these wouldn't get...
authorznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 14 Feb 2005 12:22:17 +0000 (12:22 +0000)
committerznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 14 Feb 2005 12:22:17 +0000 (12:22 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@555 d1b88da0-ebda-0310-925b-ed51d893ca5b

OGoContentStore/ChangeLog
OGoContentStore/OCSiCalFieldExtractor.m
OGoContentStore/Version

index e70e89c593368b2f14501786d030b7894b8e0e2c..ff081cfe526b3956ef35e7512e6a4b3da5a21983 100644 (file)
@@ -1,3 +1,9 @@
+2005-02-12  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * OCSiCalFieldExtractor.m: uses new iCalEvent API to determine correct
+         'enddate' for recurrent events. This is an optimization which can
+         save quite some time for complex rules. (v0.9.19)
+
 2004-12-17  Marcus Mueller  <znek@mulle-kybernetik.com>
 
        * v0.9.18
index 6afdac26730b69d6dd58ffef08375227aeb58f32..cefa04ba1d1ce21a215aa272e7f519fbd23f1af9 100644 (file)
 
 @implementation OCSiCalFieldExtractor
 
-static id<NSObject,SaxXMLReader> parser = nil;
-static SaxObjectDecoder          *sax   = nil;
-static OCSiCalFieldExtractor *extractor = nil;
+static id<NSObject,SaxXMLReader> parser               = nil;
+static SaxObjectDecoder          *sax                 = nil;
+static OCSiCalFieldExtractor     *extractor           = nil;
+static NSCalendarDate            *distantFuture       = nil;
+static NSNumber                  *distantFutureNumber = nil;
 
 + (void)initialize {
-  if (parser == nil) {
-    parser = [[[SaxXMLReaderFactory standardXMLReaderFactory] 
+  static BOOL didInit = NO;
+  
+  if (didInit) return;
+  didInit = YES;
+
+  parser = [[[SaxXMLReaderFactory standardXMLReaderFactory] 
                createXMLReaderForMimeType:@"text/calendar"]
                retain];
-    if (parser == nil)
-      NSLog(@"ERROR: did not find a parser for text/calendar!");
-  }
-  if (sax == nil) {
-    sax = [[SaxObjectDecoder alloc] initWithMappingNamed:@"NGiCal"];
-    if (sax == nil)
+  if (parser == nil)
+    NSLog(@"ERROR: did not find a parser for text/calendar!");
+  sax = [[SaxObjectDecoder alloc] initWithMappingNamed:@"NGiCal"];
+  if (sax == nil)
       NSLog(@"ERROR: could not create the iCal SAX handler!");
-  }
-  
   [parser setContentHandler:sax];
   [parser setErrorHandler:sax];
+
+  distantFuture       = [[NSCalendarDate distantFuture] retain];
+  /* INT_MAX due to Postgres constraint */
+  distantFutureNumber = [[NSNumber numberWithUnsignedInt:INT_MAX] retain];
 }
 
 + (id)sharedICalFieldExtractor {
@@ -60,6 +66,8 @@ static OCSiCalFieldExtractor *extractor = nil;
 /* operations */
 
 - (NSNumber *)numberForDate:(NSCalendarDate *)_date {
+  if (_date == distantFuture)
+    return distantFutureNumber;
   return [NSNumber numberWithUnsignedInt:[_date timeIntervalSince1970]];
 }
 
@@ -116,9 +124,22 @@ static OCSiCalFieldExtractor *extractor = nil;
   
   if ([startDate isNotNull]) 
     [row setObject:[self numberForDate:startDate] forKey:@"startdate"];
-  if ([endDate isNotNull]) 
-    [row setObject:[self numberForDate:endDate] forKey:@"enddate"];
-  
+  if (![_event isRecurrent]) {
+    if ([endDate isNotNull]) 
+      [row setObject:[self numberForDate:endDate] forKey:@"enddate"];
+  }
+  else {
+    NSCalendarDate *date;
+    
+    date = [_event lastPossibleRecurrenceStartDate];
+    if (!date) {
+      /* date might be nil, indicating an unbound recurrence - we substitute
+         this with a very distant date since 'enddate' is not allowed to be
+         NULL */
+      date = distantFuture;
+    }
+    [row setObject:[self numberForDate:date] forKey:@"enddate"];
+  }
   if ([participants length] > 0)
     [row setObject:participants forKey:@"participants"];
   if ([partmails length] > 0)
index 1adba52a3a88ed791ca0f7bfbe16ad4408676d4d..ad8d9fe8651490765e8b1c5a4498a0cbcca385be 100644 (file)
@@ -2,8 +2,9 @@
 
 MAJOR_VERSION=0
 MINOR_VERSION=9
-SUBMINOR_VERSION:=18
+SUBMINOR_VERSION:=19
 
+# v0.9.19 requires libNGiCal       v4.5.40
 # v0.9.18 requires libNGiCal       v4.5.38
 # v0.9.17 requires libNGiCal       v4.5.37
 # v0.9.11 requires libFoundation   v1.0.63