diff --git a/SOPE/NGCards/CardGroup.m b/SOPE/NGCards/CardGroup.m index 7a659a1db..1a1ef2c27 100644 --- a/SOPE/NGCards/CardGroup.m +++ b/SOPE/NGCards/CardGroup.m @@ -159,28 +159,28 @@ static NGCardsSaxHandler *sax = nil; CardElement *newChild; if (aChild) - { - childTag = [aChild tag]; - newChild = nil; - mappedClass = [self classForTag: [childTag uppercaseString]]; - if (mappedClass) - { - if (![aChild isKindOfClass: mappedClass]) + { + childTag = [aChild tag]; + newChild = nil; + mappedClass = [self classForTag: [childTag uppercaseString]]; + if (mappedClass) + { + if (![aChild isKindOfClass: mappedClass]) { //NSLog (@"warning: new child to entity '%@': '%@' converted to '%@'", // tag, childTag, NSStringFromClass(mappedClass)); newChild = [aChild elementWithClass: mappedClass]; } - } + } // else // NSLog (@"warning: no mapped class for tag '%@'", // childTag); - if (!newChild) - newChild = aChild; - [children addObject: newChild]; - [newChild setParent: self]; - } + if (!newChild) + newChild = aChild; + [children addObject: newChild]; + [newChild setParent: self]; + } } - (CardElement *) uniqueChildWithTag: (NSString *) aTag diff --git a/SOPE/NGCards/iCalRecurrenceCalculator.m b/SOPE/NGCards/iCalRecurrenceCalculator.m index 7b4330467..af169b93f 100644 --- a/SOPE/NGCards/iCalRecurrenceCalculator.m +++ b/SOPE/NGCards/iCalRecurrenceCalculator.m @@ -235,19 +235,18 @@ static Class yearlyCalcClass = Nil; dates = [[self _dates: exdates withinRange: limits startingWithDate: first] objectEnumerator]; while ((currentDate = [dates nextObject])) - { - maxRanges = [ranges count]; - for (count = maxRanges; count > 0; count--) - { - currentRange = [ranges objectAtIndex: count - 1]; - compare = [[currentRange startDate] compare: currentDate]; - if ((compare == NSOrderedAscending || compare == NSOrderedSame) && - [[currentRange endDate] compare: currentDate] == NSOrderedDescending) - { - [ranges removeObjectAtIndex: count - 1]; - } - } - } + { + maxRanges = [ranges count]; + for (count = maxRanges; count > 0; count--) + { + currentRange = [ranges objectAtIndex: count - 1]; + compare = [[currentRange startDate] compare: currentDate]; + if ( compare == NSOrderedSame) + { + [ranges removeObjectAtIndex: count - 1]; + } + } + } } + (NSArray *) @@ -255,7 +254,7 @@ static Class yearlyCalcClass = Nil; firstInstanceCalendarDateRange: (NGCalendarDateRange *) _fir recurrenceRules: (NSArray *) _rRules exceptionRules: (NSArray *) _exRules - recurrenceDates: (NSArray *) _rDates + recurrenceDates: (NSArray *) _rDates exceptionDates: (NSArray *) _exDates { NSMutableArray *ranges; @@ -264,14 +263,10 @@ static Class yearlyCalcClass = Nil; if ([_rRules count] > 0 || [_rDates count] > 0) { - [self _fillRanges: ranges fromRules: _rRules - withinRange: _r startingWithDate: _fir]; - [self _fillRanges: ranges fromDates: _rDates - withinRange: _r startingWithDate: _fir]; - [self _removeExceptionsFromRanges: ranges withRules: _exRules - withinRange: _r startingWithDate: _fir]; - [self _removeExceptionDatesFromRanges: ranges withDates: _exDates - withinRange: _r startingWithDate: _fir]; + [self _fillRanges: ranges fromRules: _rRules withinRange: _r startingWithDate: _fir]; + [self _fillRanges: ranges fromDates: _rDates withinRange: _r startingWithDate: _fir]; + [self _removeExceptionsFromRanges: ranges withRules: _exRules withinRange: _r startingWithDate: _fir]; + [self _removeExceptionDatesFromRanges: ranges withDates: _exDates withinRange: _r startingWithDate: _fir]; } return ranges; diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 93cb3fd40..01ea41156 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -105,21 +105,21 @@ interval = [[master endDate] timeIntervalSinceDate: firstDate]; if ([newOccurence isAllDay]) - { - nbrDays = ((float) abs (interval) / 86400); - [newOccurence setAllDayWithStartDate: date + { + nbrDays = ((float) abs (interval) / 86400); + [newOccurence setAllDayWithStartDate: date duration: nbrDays]; - } + } else - { - [newOccurence setStartDate: date]; - [newOccurence setEndDate: [date addYear: 0 - month: 0 - day: 0 - hour: 0 - minute: 0 - second: interval]]; - } + { + [newOccurence setStartDate: date]; + [newOccurence setEndDate: [date addYear: 0 + month: 0 + day: 0 + hour: 0 + minute: 0 + second: interval]]; + } return newOccurence; } diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index 8124b810b..7355af7cc 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -391,28 +391,28 @@ inContext: localContext acquire: acquire]; if (!obj) - { - if ([lookupName isEqualToString: @"master"]) - obj = [self occurence: [self component: NO secure: NO]]; - else if ([lookupName hasPrefix: @"occurence"]) - { - recID = [lookupName substringFromIndex: 9]; - occurence = [self lookupOccurrence: recID]; - if (occurence) - isNewOccurence = NO; - else + { + if ([lookupName isEqualToString: @"master"]) + obj = [self occurence: [self component: NO secure: NO]]; + else if ([lookupName hasPrefix: @"occurence"]) + { + recID = [lookupName substringFromIndex: 9]; + occurence = [self lookupOccurrence: recID]; + if (occurence) + isNewOccurence = NO; + else { occurence = [self newOccurenceWithID: recID]; isNewOccurence = YES; } - if (occurence) + if (occurence) { obj = [self occurence: occurence]; if (isNewOccurence) - [obj setIsNew: isNewOccurence]; + [obj setIsNew: isNewOccurence]; } - } - } + } + } return obj; } @@ -470,36 +470,33 @@ calendar = &fullCalendar; if (!*calendar) - { - if (secure) - iCalString = [self secureContentAsString]; - else - iCalString = content; + { + if (secure) + iCalString = [self secureContentAsString]; + else + iCalString = content; - if ([iCalString length] > 0) - { - ASSIGN (*calendar, [iCalCalendar parseSingleFromSource: iCalString]); - if (!secure) - originalCalendar = [*calendar copy]; - } - else - { - if (create) - { - ASSIGN (*calendar, [iCalCalendar groupWithTag: @"vcalendar"]); - [*calendar setVersion: @"2.0"]; - prodID = [NSString stringWithFormat: - @"-//Inverse inc./SOGo %@//EN", - SOGoVersion]; - [*calendar setProdID: prodID]; - tag = [[self componentTag] uppercaseString]; - newComponent = [[*calendar classForTag: tag] - groupWithTag: tag]; - [newComponent setUid: [self globallyUniqueObjectId]]; - [*calendar addChild: newComponent]; - } - } + if ([iCalString length] > 0) + { + ASSIGN (*calendar, [iCalCalendar parseSingleFromSource: iCalString]); + if (!secure) + originalCalendar = [*calendar copy]; } + else + { + if (create) + { + ASSIGN (*calendar, [iCalCalendar groupWithTag: @"vcalendar"]); + [*calendar setVersion: @"2.0"]; + prodID = [NSString stringWithFormat:@"-//Inverse inc./SOGo %@//EN", SOGoVersion]; + [*calendar setProdID: prodID]; + tag = [[self componentTag] uppercaseString]; + newComponent = [[*calendar classForTag: tag] groupWithTag: tag]; + [newComponent setUid: [self globallyUniqueObjectId]]; + [*calendar addChild: newComponent]; + } + } + } returnedCopy = [*calendar mutableCopy]; [returnedCopy autorelease]; diff --git a/SoObjects/Appointments/iCalCalendar+SOGo.m b/SoObjects/Appointments/iCalCalendar+SOGo.m index 0d1a2d7cd..a3f4a8070 100644 --- a/SoObjects/Appointments/iCalCalendar+SOGo.m +++ b/SoObjects/Appointments/iCalCalendar+SOGo.m @@ -39,6 +39,7 @@ id occurrence; iCalRepeatableEntityObject *component; NSUInteger count, max, seconds, recSeconds; + NSCalendarDate* recId; occurrence = nil; @@ -50,26 +51,27 @@ component = [components objectAtIndex: 0]; if ([component isRecurrent] || [component recurrenceId]) - { - // Skip the master event if required - count = ([component recurrenceId] ? 0 : 1); - while (!occurrence && count < max) - { - component = [components objectAtIndex: count]; - recSeconds = [[component recurrenceId] timeIntervalSince1970]; - if (recSeconds == seconds) - occurrence = component; - else - count++; - } - } + { + // Skip the master event if required + recId = [component recurrenceId]; + count = (recID ? 0 : 1); + while (!occurrence && count < max) + { + component = [components objectAtIndex: count]; + recSeconds = [recId timeIntervalSince1970]; + if (recSeconds == seconds) + occurrence = component; + else + count++; + } + } else - { - /* The "master" event could be that occurrence. */ - recSeconds = [[component recurrenceId] timeIntervalSince1970]; - if (recSeconds == seconds) - occurrence = component; - } + { + /* The "master" event could be that occurrence. */ + recSeconds = [[component recurrenceId] timeIntervalSince1970]; + if (recSeconds == seconds) + occurrence = component; + } return occurrence; } diff --git a/SoObjects/Appointments/iCalRepeatableEntityObject+SOGo.m b/SoObjects/Appointments/iCalRepeatableEntityObject+SOGo.m index 9b59d2fdb..30eaea757 100644 --- a/SoObjects/Appointments/iCalRepeatableEntityObject+SOGo.m +++ b/SoObjects/Appointments/iCalRepeatableEntityObject+SOGo.m @@ -408,24 +408,23 @@ doesOccur = [self isRecurrent]; if (doesOccur) - { - // Retrieve the range of the first event - firstRange = [self firstOccurenceRange]; // returns GMT dates + { + // Retrieve the range of the first event + firstRange = [self firstOccurenceRange]; // returns GMT dates - // Set the range to check with respect to the event timezone (extracted from the start date) - firstStartDate = (iCalDateTime *)[self uniqueChildWithTag: @"dtstart"]; - timeZone = [(iCalDateTime *)firstStartDate timeZone]; - if (timeZone) - startDate = [(iCalTimeZone *)timeZone computedDateForDate: theOccurenceDate]; - else - startDate = theOccurenceDate; - endDate = [startDate addTimeInterval: [self occurenceInterval]]; - checkRange = [NGCalendarDateRange calendarDateRangeWithStartDate: startDate + // Set the range to check with respect to the event timezone (extracted from the start date) + firstStartDate = (iCalDateTime *)[self uniqueChildWithTag: @"dtstart"]; + timeZone = [(iCalDateTime *)firstStartDate timeZone]; + if (timeZone) + startDate = [(iCalTimeZone *)timeZone computedDateForDate: theOccurenceDate]; + else + startDate = theOccurenceDate; + endDate = [startDate addTimeInterval: [self occurenceInterval]]; + checkRange = [NGCalendarDateRange calendarDateRangeWithStartDate: startDate endDate: endDate]; - // Calculate the occurrences for the given date - ranges = - [NSMutableArray arrayWithArray: + // Calculate the occurrences for the given date + ranges = [NSMutableArray arrayWithArray: [iCalRecurrenceCalculator recurrenceRangesWithinCalendarDateRange: checkRange firstInstanceCalendarDateRange: firstRange recurrenceRules: [self recurrenceRulesWithTimeZone: timeZone] @@ -433,19 +432,18 @@ recurrenceDates: [self recurrenceDatesWithTimeZone: timeZone] exceptionDates: [self exceptionDatesWithTimeZone: timeZone]]]; - // Add the master occurrence when dealing with RDATES. - // However, the master event must not be flagged with X-MOZ-FAKED-MASTER. - if ([self hasRecurrenceDates] && - ![[[self uniqueChildWithTag: @"x-moz-faked-master"] - flattenedValuesForKey: @""] isEqualToString: @"1"] && - [checkRange doesIntersectWithDateRange: firstRange]) - { - [ranges insertObject: firstRange atIndex: 0]; - } - - doesOccur = [ranges dateRangeArrayContainsDate: startDate]; + // Add the master occurrence when dealing with RDATES. + // However, the master event must not be flagged with X-MOZ-FAKED-MASTER. + if ([self hasRecurrenceDates] && + ![[[self uniqueChildWithTag: @"x-moz-faked-master"] flattenedValuesForKey: @""] isEqualToString: @"1"] && + [checkRange doesIntersectWithDateRange: firstRange]) + { + [ranges insertObject: firstRange atIndex: 0]; } + doesOccur = [ranges dateRangeArrayContainsDate: startDate]; + } + return doesOccur; }