View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002681 | SOGo | ActiveSync | public | 2014-03-24 21:08 | 2014-03-28 18:44 |
Reporter | tfu | Assigned To | ludovic | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | [Client] Microsoft | OS | Windows | OS Version | 7 |
Product Version | 2.2.3 | ||||
Fixed in Version | 2.2.3 | ||||
Summary | 0002681: calender events don't support reminders yet | ||||
Description | Reminders are currently not supported for calendar events. Attached patch provides a simple implementation. There is additional work needed when exceptions with recurring events are supported/implemented but it could be a starting point. | ||||
Tags | Patch | ||||
0001-basic-reminder.patch (3,969 bytes)
From 36e39eb7e12c67acbdca4f45316e079c69a35588 Mon Sep 17 00:00:00 2001 From: root <root@example.com> Date: Mon, 24 Mar 2014 21:57:23 +0100 Subject: [PATCH] basic reminder --- ActiveSync/iCalEvent+ActiveSync.m | 65 +++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/ActiveSync/iCalEvent+ActiveSync.m b/ActiveSync/iCalEvent+ActiveSync.m index 05f18a3..df7a78b 100644 --- a/ActiveSync/iCalEvent+ActiveSync.m +++ b/ActiveSync/iCalEvent+ActiveSync.m @@ -55,6 +55,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "NSDate+ActiveSync.h" #include "NSString+ActiveSync.h" +#import <NGCards/iCalAlarm.h> + + @implementation iCalEvent (ActiveSync) - (int) _attendeeStatus: (iCalPerson *) attendee @@ -210,6 +213,26 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Reminder -- http://msdn.microsoft.com/en-us/library/ee219691(v=exchg.80).aspx // TODO + if ([self hasAlarms] ) { + NSLog(@"tfu reminder hasAlarm=True"); + NSLog(@"tfu reminder startDate %@", [[self startDate] activeSyncRepresentationWithoutSeparatorsInContext: context]); + + iCalAlarm *anAlarm; + NSCalendarDate *nextAlarmDate; + NSInteger delta; + + anAlarm = [[self alarms] objectAtIndex: 0]; + if ([[anAlarm action] caseInsensitiveCompare: @"DISPLAY"] == NSOrderedSame) { + nextAlarmDate = [anAlarm nextAlarmDate]; + delta = (int)(([[self startDate] timeIntervalSince1970] - [nextAlarmDate timeIntervalSince1970] )/60); + + NSLog(@"tfu reminder nextAlarmDate %@", [nextAlarmDate activeSyncRepresentationWithoutSeparatorsInContext: context]); + NSLog(@"tfu reminder Reminder %d", delta); + // don't send negative reminder - not supported + if (delta >0) + [s appendFormat: @"<Reminder xmlns=\"Calendar:\">%d</Reminder>", delta]; + } + } // Recurrence rules if ([self isRecurrent]) @@ -390,6 +413,48 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } } + // tfu if an alarm is deinfed with an action != DISPLAY ignore the alarm - don't want to overwrite + if ([self hasAlarms] && [[[[self alarms] objectAtIndex: 0] action] caseInsensitiveCompare: @"DISPLAY"] != NSOrderedSame) { + NSLog(@"tfu reminder received hasAlarms != DISPLAY ignore client"); + } + else { + // tfu add an alarm specified in msg + if ((o = [theValues objectForKey: @"Reminder"])) { + NSLog(@"tfu reminder received %@", o); + + // tfu NOTE: outlook sends a 15 min reminder (18 hour for allday) if no reminder is specified + // although no default reminder is defined (File -> Options -> Clendar -> Calendar Options - > Default Reminders) + // http://answers.microsoft.com/en-us/office/forum/office_2013_release-outlook/desktop-outlook-calendar-creates-entries-with/9aef72d8-81bb-4a32-a6ab-bf7d216fb811?page=5&tm=1395690285088 + + // outlook: if reminder is set to 0 minutes before start save it as 1 minute since -> 0 minutes in not accepted by sogo + if ([o isEqualToString: @"0"]) + o=@"1"; + + iCalAlarm *alarm = nil; + iCalTrigger *trigger; + + alarm = [iCalAlarm new]; + trigger = [iCalTrigger elementWithTag: @"TRIGGER"]; + [trigger setValueType: @"DURATION"]; + [alarm setTrigger: trigger]; + [alarm setAction: @"DISPLAY"]; + [trigger setSingleValue: [NSString stringWithFormat: @"-PT%@M", o] forKey: @""]; + + + [self removeAllAlarms]; + + [self addToAlarms: alarm]; + [alarm release]; + //} + } else { + // tfu remove existing alarm since no reminder in msg + NSLog(@"tfu reminder removeAllAlarms"); + [self removeAllAlarms]; + } + + } + + // Recurrence if ((o = [theValues objectForKey: @"Recurrence"])) { -- 1.7.9.5 |
|
alarm.patch (3,185 bytes)
diff --git a/ActiveSync/GNUmakefile b/ActiveSync/GNUmakefile index 12f12e5..9695806 100644 --- a/ActiveSync/GNUmakefile +++ b/ActiveSync/GNUmakefile @@ -9,6 +9,7 @@ ActiveSync_PRINCIPAL_CLASS = ActiveSyncProduct ActiveSync_OBJC_FILES = \ ActiveSyncProduct.m \ + iCalAlarm+ActiveSync.m \ iCalEvent+ActiveSync.m \ iCalRecurrenceRule+ActiveSync.m \ iCalTimeZone+ActiveSync.m \ @@ -30,7 +31,7 @@ ActiveSync_RESOURCE_FILES += \ ADDITIONAL_OBJCFLAGS += -Wno-deprecated-declarations ADDITIONAL_INCLUDE_DIRS += -I../SOPE/ -I../SoObjects/ -ADDITIONAL_LIB_DIRS += -L../../SOPE/GDLContentStore/obj/ +ADDITIONAL_LIB_DIRS += -L../SOPE/GDLContentStore/obj/ -L../SOPE/NGCards/obj/ ADDITIONAL_INCLUDE_DIRS += -I/usr/include/libwbxml-1.0/ ADDITIONAL_LDFLAGS += -Wl,--no-as-needed -lwbxml2 diff --git a/ActiveSync/iCalEvent+ActiveSync.m b/ActiveSync/iCalEvent+ActiveSync.m index 05f18a3..a6b4c80 100644 --- a/ActiveSync/iCalEvent+ActiveSync.m +++ b/ActiveSync/iCalEvent+ActiveSync.m @@ -50,6 +50,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import <Appointments/iCalEntityObject+SOGo.h> +#include "iCalAlarm+ActiveSync.h" #include "iCalRecurrenceRule+ActiveSync.h" #include "iCalTimeZone+ActiveSync.h" #include "NSDate+ActiveSync.h" @@ -209,7 +210,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [s appendFormat: @"<Sensitivity xmlns=\"Calendar:\">%d</Sensitivity>", v]; // Reminder -- http://msdn.microsoft.com/en-us/library/ee219691(v=exchg.80).aspx - // TODO + // TODO: improve this to handle more alarm types + if ([self hasAlarms]) + { + iCalAlarm *alarm; + + alarm = [[self alarms] objectAtIndex: 0]; + [s appendString: [alarm activeSyncRepresentationInContext: context]]; + } // Recurrence rules if ([self isRecurrent]) @@ -390,6 +398,35 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } } + // + // If an alarm is deinfed with an action != DISPLAY, we ignore the alarm - don't want to overwrite. + // + if ([self hasAlarms] && [[[[self alarms] objectAtIndex: 0] action] caseInsensitiveCompare: @"DISPLAY"] != NSOrderedSame) + { + // Ignore the alarm for now + } + else if ((o = [theValues objectForKey: @"Reminder"])) + { + // NOTE: Outlook sends a 15 min reminder (18 hour for allday) if no reminder is specified + // although no default reminder is defined (File -> Options -> Clendar -> Calendar Options - > Default Reminders) + // + // http://answers.microsoft.com/en-us/office/forum/office_2013_release-outlook/desktop-outlook-calendar-creates-entries-with/9aef72d8-81bb-4a32-a6ab-bf7d216fb811?page=5&tm=1395690285088 + // + iCalAlarm *alarm; + + alarm = [[iCalAlarm alloc] init]; + [alarm takeActiveSyncValues: theValues inContext: context]; + + [self removeAllAlarms]; + [self addToAlarms: alarm]; + RELEASE(alarm); + } + else + { + // We remove existing alarm since no reminder in the ActiveSync payload + [self removeAllAlarms]; + } + // Recurrence if ((o = [theValues objectForKey: @"Recurrence"])) { |
|
Nice work! Can you try the attached patch (+ 2 new files) based on your work? It fits more the current model to use Objective-C categories on top of existing objects. This code is totally untested. |
|
As fare I was able to test it is working. I added a few lines to iCalAlarm+ActiveSync.m to do a better conversion of the alarm time. |
|
https://github.com/inverse-inc/sogo/commit/633723a4708db1a807c69aae8204a39213941b54 |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2014-03-24 21:08 | tfu | New Issue | |
2014-03-24 21:08 | tfu | File Added: 0001-basic-reminder.patch | |
2014-03-25 00:06 | ludovic | File Added: alarm.patch | |
2014-03-25 00:06 | ludovic | File Added: iCalAlarm+ActiveSync.h | |
2014-03-25 00:06 | ludovic | File Added: iCalAlarm+ActiveSync.m | |
2014-03-25 00:07 | ludovic | Note Added: 0006775 | |
2014-03-25 08:38 | Christian Mack | Tag Attached: Patch | |
2014-03-25 19:12 | tfu | File Added: iCalAlarm+ActiveSync.m_new | |
2014-03-25 19:13 | tfu | Note Added: 0006780 | |
2014-03-26 18:31 | ludovic | Product Version | 2.2.2 => 2.2.3 |
2014-03-28 18:44 | ludovic | Note Added: 0006802 | |
2014-03-28 18:44 | ludovic | Status | new => closed |
2014-03-28 18:44 | ludovic | Assigned To | => ludovic |
2014-03-28 18:44 | ludovic | Resolution | open => fixed |
2014-03-28 18:44 | ludovic | Fixed in Version | => 2.2.3 |