From 88207d27c4dbeae3ec5bf8ff85989b68f751a4aa Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 22 Jan 2016 13:35:02 -0500 Subject: [PATCH] (fix) now always generate invitation updates when using EAS Conflicts: NEWS --- ActiveSync/SOGoActiveSyncDispatcher+Sync.m | 44 +++++++--------------- ActiveSync/iCalEvent+ActiveSync.h | 4 +- ActiveSync/iCalEvent+ActiveSync.m | 35 ++++++++++++++++- NEWS | 11 +++++- 4 files changed, 60 insertions(+), 34 deletions(-) diff --git a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m index ca675983e..2152b730c 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m +++ b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m @@ -78,6 +78,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import #import +#import #import #import #import @@ -473,8 +474,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. case ActiveSyncTaskFolder: { o = [sogoObject component: NO secure: NO]; - [o takeActiveSyncValues: allChanges inContext: context]; - [sogoObject saveComponent: o]; + + if (theFolderType == ActiveSyncEventFolder && + [(iCalEvent *)o userIsAttendee: [context activeUser]]) + { + [o changeParticipationStatus: allChanges inContext: context component: sogoObject]; + } + else + { + [o takeActiveSyncValues: allChanges inContext: context]; + [sogoObject saveComponent: o]; + } if ([syncCache objectForKey: serverId]) [syncCache setObject: [NSString stringWithFormat:@"%f", [[sogoObject lastModified] timeIntervalSince1970]] forKey: serverId]; @@ -911,35 +921,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (theFolderType == ActiveSyncContactFolder) componentObject = [sogoObject vCard]; else - componentObject = [sogoObject component: NO secure: NO]; - - // - // We do NOT synchronize NEW events that are in fact, invitations - // to events. This is due to the fact that Outlook 2013 creates - // "phantom" events in the calendar that are mapped to invitations mails. - // If we synchronize these events too, it'll interfere with the whole thing - // and prevent Outlook from properly calling MeetingResponse. - // - if (!updated && theFolderType == ActiveSyncEventFolder) - { - iCalPersonPartStat partstat; - iCalPerson *attendee; - NSString *email; - - email = [[[context activeUser] allEmails] objectAtIndex: 0]; - attendee = [componentObject findAttendeeWithEmail: email]; - - if (attendee) - { - partstat = [attendee participationStatus]; - - if (partstat == iCalPersonPartStatNeedsAction) - { - DESTROY(pool); - continue; - } - } - } + componentObject = [sogoObject component: NO secure: NO]; [syncCache setObject: [component objectForKey: @"c_lastmodified"] forKey: uid]; diff --git a/ActiveSync/iCalEvent+ActiveSync.h b/ActiveSync/iCalEvent+ActiveSync.h index 90fa92cd5..582501aa7 100644 --- a/ActiveSync/iCalEvent+ActiveSync.h +++ b/ActiveSync/iCalEvent+ActiveSync.h @@ -41,7 +41,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - (NSString *) activeSyncRepresentationInContext: (WOContext *) context; - (void) takeActiveSyncValues: (NSDictionary *) theValues inContext: (WOContext *) context; - +- (void) changeParticipationStatus: (NSDictionary *) theValues + inContext: (WOContext *) context + component: (id) component; @end #endif diff --git a/ActiveSync/iCalEvent+ActiveSync.m b/ActiveSync/iCalEvent+ActiveSync.m index d5b85093f..a7e51cfde 100644 --- a/ActiveSync/iCalEvent+ActiveSync.m +++ b/ActiveSync/iCalEvent+ActiveSync.m @@ -57,6 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import #import +#import #include "iCalAlarm+ActiveSync.h" #include "iCalRecurrenceRule+ActiveSync.h" @@ -810,7 +811,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. { // Windows phones sens sometimes an empty Attendees tag. // We check it's an array before processing it. - if ((o = [theValues objectForKey: @"Attendees"])&& [o isKindOfClass: [NSArray class]]) + if ((o = [theValues objectForKey: @"Attendees"]) && [o isKindOfClass: [NSArray class]]) { NSMutableArray *attendees; NSDictionary *attendee; @@ -859,4 +860,36 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } } +- (void) changeParticipationStatus: (NSDictionary *) theValues + inContext: (WOContext *) context + component: (id) component +{ + NSString *status; + id o; + + // See: https://msdn.microsoft.com/en-us/library/ee202290(v=exchg.80).aspx + // + // 0 == Free + // 1 == Tentative + // 2 == Busy + // 3 == Out of Office + // 4 == Working elsehwere + // + if ((o = [theValues objectForKey: @"BusyStatus"])) + { + // We translate >= 2 into ACCEPTED + if ([o intValue] == 0) + status = @"NEEDS-ACTION"; + else if ([o intValue] >= 2) + status = @"ACCEPTED"; + else + status = @"TENTATIVE"; + + // There's no delegate in EAS + [(SOGoAppointmentObject *) component changeParticipationStatus: status + withDelegate: nil + alarm: nil]; + } +} + @end diff --git a/NEWS b/NEWS index 3612f2c2f..be199cbe5 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,13 @@ -2.3.6 (2016-01-XX) +2.3.7 (2016-01-XX) +------------------ + +New features + - new junk/not junk capability with generic SMTP integration + +Buf fixes + - now always generate invitation updates when using EAS + +2.3.6 (2016-01-18) ------------------ New features