(feat) handle alarms for tasks (fixes #3964)
This commit is contained in:
parent
eb6d234c4b
commit
5c0229466e
|
@ -36,6 +36,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#import <NGCards/iCalAlarm.h>
|
#import <NGCards/iCalAlarm.h>
|
||||||
#import <NGCards/iCalEvent.h>
|
#import <NGCards/iCalEvent.h>
|
||||||
#import <NGCards/iCalTrigger.h>
|
#import <NGCards/iCalTrigger.h>
|
||||||
|
#import <NGCards/NSCalendarDate+NGCards.h>
|
||||||
|
|
||||||
|
#include "NSDate+ActiveSync.h"
|
||||||
|
|
||||||
@implementation iCalAlarm (ActiveSync)
|
@implementation iCalAlarm (ActiveSync)
|
||||||
|
|
||||||
|
@ -53,10 +56,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
nextAlarmDate = [self nextAlarmDate];
|
nextAlarmDate = [self nextAlarmDate];
|
||||||
delta = (int)(([[(iCalEvent *)parent startDate] timeIntervalSince1970] - [nextAlarmDate timeIntervalSince1970])/60);
|
delta = (int)(([[(iCalEvent *)parent startDate] timeIntervalSince1970] - [nextAlarmDate timeIntervalSince1970])/60);
|
||||||
|
|
||||||
|
if ([parent isKindOfClass: [iCalEvent class]])
|
||||||
|
{
|
||||||
// don't send negative reminder - not supported
|
// don't send negative reminder - not supported
|
||||||
if (delta > 0)
|
if (delta > 0)
|
||||||
[s appendFormat: @"<Reminder xmlns=\"Calendar:\">%d</Reminder>", (int)delta];
|
[s appendFormat: @"<Reminder xmlns=\"Calendar:\">%d</Reminder>", (int)delta];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[s appendFormat: @"<ReminderTime xmlns=\"Task:\">%@</ReminderTime>", [nextAlarmDate activeSyncRepresentationInContext: context]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -67,9 +77,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
iCalTrigger *trigger;
|
iCalTrigger *trigger;
|
||||||
id o;
|
id o;
|
||||||
|
|
||||||
o = [theValues objectForKey: @"Reminder"];
|
if ((o = [theValues objectForKey: @"Reminder"]))
|
||||||
|
{
|
||||||
// Outlook: if reminder is set to 0 minutes before start save it as 1 minute since -> 0 minutes in not accepted by SOGo
|
// Outlook: if reminder is set to 0 minutes before starttime, save it as 1 minute since -> 0 minutes in not accepted by SOGo
|
||||||
if ([o isEqualToString: @"0"])
|
if ([o isEqualToString: @"0"])
|
||||||
o = @"1";
|
o = @"1";
|
||||||
|
|
||||||
|
@ -99,5 +109,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ((o = [theValues objectForKey: @"ReminderTime"]))
|
||||||
|
{
|
||||||
|
o = [o calendarDate];
|
||||||
|
trigger = [iCalTrigger elementWithTag: @"TRIGGER"];
|
||||||
|
[trigger setValueType: @"DATE-TIME"];
|
||||||
|
[trigger setSingleValue: [NSString stringWithFormat: @"%@Z", [o iCalFormattedDateTimeString]] forKey: @""];
|
||||||
|
[self setTrigger: trigger];
|
||||||
|
[self setAction: @"DISPLAY"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -43,9 +43,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#import <NGCards/iCalDateTime.h>
|
#import <NGCards/iCalDateTime.h>
|
||||||
#import <NGCards/iCalTimeZone.h>
|
#import <NGCards/iCalTimeZone.h>
|
||||||
|
|
||||||
|
#import <Appointments/iCalEntityObject+SOGo.h>
|
||||||
|
|
||||||
#include "NSDate+ActiveSync.h"
|
#include "NSDate+ActiveSync.h"
|
||||||
#include "NSString+ActiveSync.h"
|
#include "NSString+ActiveSync.h"
|
||||||
#include "iCalRecurrenceRule+ActiveSync.h"
|
#include "iCalRecurrenceRule+ActiveSync.h"
|
||||||
|
#include "iCalAlarm+ActiveSync.h"
|
||||||
|
|
||||||
@implementation iCalToDo (ActiveSync)
|
@implementation iCalToDo (ActiveSync)
|
||||||
|
|
||||||
|
@ -95,8 +98,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
v = 1;
|
v = 1;
|
||||||
[s appendFormat: @"<Importance xmlns=\"Tasks:\">%d</Importance>", v];
|
[s appendFormat: @"<Importance xmlns=\"Tasks:\">%d</Importance>", v];
|
||||||
|
|
||||||
// Reminder - FIXME
|
// Reminder
|
||||||
|
if ([self hasAlarms])
|
||||||
|
{
|
||||||
|
iCalAlarm *alarm;
|
||||||
|
|
||||||
|
alarm = [self firstDisplayOrAudioAlarm];
|
||||||
|
[s appendFormat: @"<ReminderSet xmlns=\"Tasks:\">%d</ReminderSet>", 1];
|
||||||
|
[s appendString: [alarm activeSyncRepresentationInContext: context]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
[s appendFormat: @"<ReminderSet xmlns=\"Tasks:\">%d</ReminderSet>", 0];
|
[s appendFormat: @"<ReminderSet xmlns=\"Tasks:\">%d</ReminderSet>", 0];
|
||||||
|
}
|
||||||
|
|
||||||
// Sensitivity
|
// Sensitivity
|
||||||
if ([[self accessClass] isEqualToString: @"PRIVATE"])
|
if ([[self accessClass] isEqualToString: @"PRIVATE"])
|
||||||
|
@ -249,6 +263,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
if ((o = [theValues objectForKey: @"ReminderTime"]))
|
if ((o = [theValues objectForKey: @"ReminderTime"]))
|
||||||
{
|
{
|
||||||
|
iCalAlarm *alarm;
|
||||||
|
|
||||||
|
alarm = [[iCalAlarm alloc] init];
|
||||||
|
[alarm takeActiveSyncValues: theValues inContext: context];
|
||||||
|
|
||||||
|
[self removeAllAlarms];
|
||||||
|
[self addToAlarms: alarm];
|
||||||
|
RELEASE(alarm);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue