See ChangeLog

Monotone-Parent: c4a5b31204ccd4c09e85262d9b5609b788a8380a
Monotone-Revision: 9057f51730136ddbcf1d8e64c8029ea9a4e6c991

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2009-04-22T21:02:11
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle
2009-04-22 21:02:11 +00:00
parent 143c91bc2d
commit 6e5d968de3
18 changed files with 375 additions and 65 deletions
@@ -96,6 +96,9 @@
- (NSArray *) fetchFreeBusyInfosFrom: (NSCalendarDate *) _startDate
to: (NSCalendarDate *) _endDate;
- (NSArray *) fetchAlarmInfosFrom: (NSNumber *) _startUTCDate
to: (NSNumber *) _endUTCDate;
/* URL generation */
- (NSString *) baseURLForAptWithUID: (NSString *) _uid
+29 -1
View File
@@ -1,5 +1,5 @@
/*
Copyright (C) 2007-2008 Inverse inc.
Copyright (C) 2007-2009 Inverse inc.
Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of OpenGroupware.org.
@@ -2290,6 +2290,34 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
includeProtectedInformation: NO];
}
- (NSArray *) fetchAlarmInfosFrom: (NSNumber *) _startUTCDate
to: (NSNumber *) _endUTCDate
{
static NSArray *nameFields = nil;
EOQualifier *qualifier;
GCSFolder *folder;
NSArray *records;
NSString *sql;
if (!nameFields)
nameFields = [[NSArray alloc] initWithObjects: @"c_name", @"c_nextalarm", @"c_iscycle", nil];
folder = [self ocsFolder];
if (!folder)
{
[self errorWithFormat:@"(%s): missing folder for fetch!",
__PRETTY_FUNCTION__];
return nil;
}
sql = [NSString stringWithFormat: @"((c_nextalarm <= %u) AND (c_nextalarm >= %u)) OR ((c_nextalarm > 0) AND (c_enddate > %u))",
[_endUTCDate unsignedIntValue], [_startUTCDate unsignedIntValue], [_startUTCDate unsignedIntValue]];
qualifier = [EOQualifier qualifierWithQualifierFormat: sql];
records = [folder fetchFields: nameFields matchingQualifier: qualifier];
return records;
}
/* URL generation */
- (NSString *) baseURLForAptWithUID: (NSString *)_uid
+15 -34
View File
@@ -206,14 +206,18 @@
if ([self hasAlarms])
{
// We currently have the following limitations for alarms:
// - the event 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.
// - 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".
iCalAlarm *anAlarm;
iCalTrigger *aTrigger;
NSCalendarDate *relationDate;
NSString *relation;
NSString *relation, *webstatus;
NSTimeInterval anInterval;
anAlarm = [[self alarms] objectAtIndex: 0];
@@ -222,45 +226,22 @@
anInterval = [[aTrigger value] durationAsTimeInterval];
if ([[anAlarm action] caseInsensitiveCompare: @"DISPLAY"] == NSOrderedSame &&
[[aTrigger valueType] caseInsensitiveCompare: @"DURATION"] == NSOrderedSame)
[[aTrigger valueType] caseInsensitiveCompare: @"DURATION"] == NSOrderedSame &&
![self isRecurrent])
{
if ([self isRecurrent])
webstatus = [aTrigger value: 0 ofAttribute: @"x-webstatus"];
if (!webstatus ||
[webstatus caseInsensitiveCompare: @"TRIGGERED"] != NSOrderedSame)
{
if ([self isStillRelevant])
{
NSArray *occurrences;
NSCalendarDate *now, *later;
NGCalendarDateRange *range;
// We only compute the next occurrence of the repeating event
// for the next 48 hours
now = [NSCalendarDate calendarDate];
later = [now addTimeInterval: (60*60*48)];
range = [NGCalendarDateRange calendarDateRangeWithStartDate: now
endDate: later];
occurrences = [self recurrenceRangesWithinCalendarDateRange: range];
if ([occurrences count] > 0)
{
range = [occurrences objectAtIndex: 0];
if ([relation caseInsensitiveCompare: @"END"] == NSOrderedSame)
relationDate = [range endDate];
else
relationDate = [range startDate];
}
}
}
else
{
// Event is not reccurent
if ([relation caseInsensitiveCompare: @"END"] == NSOrderedSame)
relationDate = endDate;
else
relationDate = startDate;
// Compute the next alarm date with respect to the reference date
if ([relationDate isNotNull])
nextAlarmDate = [relationDate addTimeInterval: anInterval];
}
// Compute the next alarm date with respect to the reference date
if ([relationDate isNotNull])
nextAlarmDate = [relationDate addTimeInterval: anInterval];
}
}
if ([nextAlarmDate isNotNull])
+45 -1
View File
@@ -30,7 +30,10 @@
#import <NGExtensions/NSNull+misc.h>
#import <NGExtensions/NSObject+Logs.h>
#import <NGCards/iCalAlarm.h>
#import <NGCards/iCalPerson.h>
#import <NGCards/iCalTrigger.h>
#import <NGCards/NSString+NGCards.h>
#import "iCalRepeatableEntityObject+SOGo.h"
@@ -41,7 +44,7 @@
- (NSMutableDictionary *) quickRecord
{
NSMutableDictionary *row;
NSCalendarDate *startDate, *dueDate;
NSCalendarDate *startDate, *dueDate, *nextAlarmDate;
NSArray *attendees;
NSString *uid, *title, *location, *status;
NSNumber *sequence;
@@ -55,6 +58,7 @@
startDate = [self startDate];
dueDate = [self due];
nextAlarmDate = nil;
uid = [self uid];
title = [self summary];
if (![title isNotNull])
@@ -167,6 +171,46 @@
[row setObject:partstates forKey: @"c_partstates"];
[partstates release];
if ([self hasAlarms])
{
// We currently have the following limitations for alarms:
// - 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".
iCalAlarm *anAlarm;
iCalTrigger *aTrigger;
NSString *webstatus;
NSTimeInterval anInterval;
anAlarm = [[self alarms] objectAtIndex: 0];
aTrigger = [anAlarm trigger];
anInterval = [[aTrigger value] durationAsTimeInterval];
if ([[anAlarm action] caseInsensitiveCompare: @"DISPLAY"] == NSOrderedSame &&
[[aTrigger valueType] caseInsensitiveCompare: @"DURATION"] == NSOrderedSame &&
![self isRecurrent])
{
webstatus = [aTrigger value: 0 ofAttribute: @"x-webstatus"];
if (!webstatus ||
[webstatus caseInsensitiveCompare: @"TRIGGERED"] != NSOrderedSame)
{
// Compute the next alarm date with respect to the due date
if ([dueDate isNotNull])
nextAlarmDate = [dueDate addTimeInterval: anInterval];
}
}
}
if ([nextAlarmDate isNotNull])
[row setObject: [NSNumber numberWithInt: [nextAlarmDate timeIntervalSince1970]]
forKey: @"c_nextalarm"];
else
[row setObject: [NSNumber numberWithInt: 0] forKey: @"c_nextalarm"];
return row;
}