Monotone-Parent: 404335da627fa036cf3569cb9212b3d2c29785a6

Monotone-Revision: b58773ad261dd708b850c5cd63f53133730d2c59

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2012-04-20T16:01:00
maint-2.0.2
Wolfgang Sourdeau 2012-04-20 16:01:00 +00:00
parent 2708e84549
commit 5d2d426e33
5 changed files with 64 additions and 33 deletions

View File

@ -1,3 +1,12 @@
2012-04-20 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* iCalTrigger.m (-nextAlarmDate): new method including most of
the old code from -[iCalAlarm nextAlarmDate]. Added support for
DATE-TIME values.
* iCalAlarm.m (-nextAlarmDate): now a proxy method for
-[iCalTrigger nextAlarmDate].
2012-04-18 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* iCalRecurrenceRule.m (-orderOfValueKeys): overrriden method.

View File

@ -142,45 +142,20 @@
- (NSCalendarDate *) nextAlarmDate
{
iCalTrigger *aTrigger;
NSCalendarDate *relationDate, *nextAlarmDate;
NSString *relation;
NSTimeInterval anInterval;
NSCalendarDate *nextAlarmDate;
// We currently have the following limitations for alarms:
// - the alarm's trigger value type must be DURATION;
nextAlarmDate = nil;
if ([parent isKindOfClass: [iCalEvent class]]
|| [parent isKindOfClass: [iCalToDo class]])
{
aTrigger = [self trigger];
if ([[aTrigger valueType] caseInsensitiveCompare: @"DURATION"]
== NSOrderedSame)
{
relation = [aTrigger relationType];
anInterval = [[aTrigger flattenedValuesForKey: @""]
durationAsTimeInterval];
if ([relation caseInsensitiveCompare: @"END"] == NSOrderedSame)
{
if ([parent isKindOfClass: [iCalEvent class]])
relationDate = [(iCalEvent *) parent endDate];
else
relationDate = [(iCalToDo *) parent due];
}
else
relationDate = [(iCalEntityObject *) parent startDate];
// Compute the next alarm date with respect to the reference date
if ([relationDate isNotNull])
nextAlarmDate = [relationDate addTimeInterval: anInterval];
}
}
nextAlarmDate = [[self trigger] nextAlarmDate];
else
[self warnWithFormat: @"alarms not handled for elements of class '%@'",
NSStringFromClass ([parent class])];
{
nextAlarmDate = nil;
[self errorWithFormat: @"alarms not handled for elements of class '%@'",
NSStringFromClass ([parent class])];
}
return nextAlarmDate;
}

View File

@ -32,6 +32,8 @@
- (void) setRelationType: (NSString *) theRelationType;
- (NSString *) relationType;
- (NSCalendarDate *) nextAlarmDate;
@end
#endif /* __NGCards_iCalTrigger_H__ */

View File

@ -21,7 +21,11 @@
#import <Foundation/NSString.h>
#import "iCalEvent.h"
#import "iCalTrigger.h"
#import "iCalToDo.h"
#import "NSString+NGCards.h"
@implementation iCalTrigger
@ -47,4 +51,46 @@
return [self value: 0 ofAttribute: @"related"];
}
- (NSCalendarDate *) nextAlarmDate
{
NSCalendarDate *relationDate, *nextAlarmDate;
NSString *relation, *triggerValue;
NSTimeInterval anInterval;
id grandParent;
triggerValue = [[self valueType] uppercaseString];
if ([triggerValue length] == 0)
triggerValue = @"DURATION";
if ([triggerValue isEqualToString: @"DURATION"])
{
relation = [[self relationType] uppercaseString];
grandParent = [parent parent];
if ([relation isEqualToString: @"END"])
{
if ([grandParent isKindOfClass: [iCalEvent class]])
relationDate = [(iCalEvent *) grandParent endDate];
else
relationDate = [(iCalToDo *) grandParent due];
}
else
relationDate = [(iCalEntityObject *) grandParent startDate];
// Compute the next alarm date with respect to the reference date
if (relationDate)
{
anInterval = [[self flattenedValuesForKey: @""]
durationAsTimeInterval];
nextAlarmDate = [relationDate addTimeInterval: anInterval];
}
}
else if ([triggerValue isEqualToString: @"DATE-TIME"])
nextAlarmDate = [[self flattenedValuesForKey: @""] asCalendarDate];
else
nextAlarmDate = nil;
return nextAlarmDate;
}
@end /* iCalTrigger */

View File

@ -234,7 +234,6 @@
// - the component must not be recurrent;
// - only the first alarm is considered;
// - the alarm's action must be of type DISPLAY;
// - the alarm's trigger value type must be DURATION;
//
// Morever, we don't update the quick table if the property X-WebStatus
// of the trigger is set to "triggered".