From ca4a754f2c12784ff437df34c255d3dccbf5c6f2 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 22 Dec 2014 12:39:58 -0500 Subject: [PATCH] Use the right cutoff date --- ActiveSync/SOGoActiveSyncDispatcher+Sync.m | 23 +++++++++++++++------- NEWS | 1 + SoObjects/SOGo/SOGoGCSFolder.m | 17 +++++++++++++--- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m index 48f2b10b6..100c85807 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m +++ b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m @@ -738,17 +738,26 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } [syncCache setObject: [component objectForKey: @"c_lastmodified"] forKey: uid]; + + // No need to set dateCache for Contacts + if ((theFolderType == ActiveSyncEventFolder || theFolderType == ActiveSyncTaskFolder)) + { + NSCalendarDate *d; + + if ([[component objectForKey: @"c_cycleenddate"] intValue]) + d = [NSCalendarDate dateWithTimeIntervalSince1970: [[component objectForKey: @"c_cycleenddate"] intValue]]; + else if ([[component objectForKey: @"c_enddate"] intValue]) + d = [NSCalendarDate dateWithTimeIntervalSince1970: [[component objectForKey: @"c_enddate"] intValue]]; + else + d = [NSCalendarDate distantFuture]; + + [dateCache setObject: d forKey: uid]; + } if (updated) [s appendString: @""]; else - { - // no need to set dateCache for Contacts - if ((theFolderType == ActiveSyncEventFolder || theFolderType == ActiveSyncTaskFolder)) - [dateCache setObject: [componentObject startDate] ? [componentObject startDate] : [NSCalendarDate date] forKey: uid]; // FIXME: need to set proper date for recurring events - softDelete - - [s appendString: @""]; - } + [s appendString: @""]; [s appendFormat: @"%@", uid]; [s appendString: @""]; diff --git a/NEWS b/NEWS index 190d8d262..5502f1d45 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ Enhancements - initial support for empty sync request/response for EAS - added the SOGoMaximumSyncResponseSize EAS configuration parameter to support memory-limited sync response sizes + - we now not only use the creation date for event's cutoff date (EAS) 2.2.12a (2014-12-19) -------------------- diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index ac43d1529..9f77359e9 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -1165,7 +1165,14 @@ static NSArray *childRecordFields = nil; int syncTokenInt; fields = [NSMutableArray arrayWithObjects: @"c_name", @"c_component", - @"c_creationdate", @"c_lastmodified", nil]; + @"c_creationdate", @"c_lastmodified", nil]; + + if ([[self folderType] isEqualToString: @"Appointment"]) + { + [fields addObject: @"c_enddate"]; + [fields addObject: @"c_cycleenddate"]; + } + addFields = [[properties allValues] objectEnumerator]; while ((currentField = [addFields nextObject])) if ([currentField length]) @@ -1181,7 +1188,9 @@ static NSArray *childRecordFields = nil; if (theStartDate) { EOQualifier *sinceDateQualifier = [EOQualifier qualifierWithQualifierFormat: - @"c_creationdate > %d", (int)[theStartDate timeIntervalSince1970]]; + @"(c_enddate > %d OR c_enddate = NULL) OR (c_iscycle = 1 and (c_cycleenddate > %d OR c_cycleenddate = NULL))", + (int)[theStartDate timeIntervalSince1970], + (int)[theStartDate timeIntervalSince1970]]; qualifier = [[EOAndQualifier alloc] initWithQualifiers: sinceDateQualifier, qualifier, nil]; @@ -1211,7 +1220,9 @@ static NSArray *childRecordFields = nil; if (theStartDate) { EOQualifier *sinceDateQualifier = [EOQualifier qualifierWithQualifierFormat: - @"c_creationdate > %d", (int)[theStartDate timeIntervalSince1970]]; + @"(c_enddate > %d OR c_enddate = NULL) OR (c_iscycle = 1 and (c_cycleenddate > %d OR c_cycleenddate = NULL))", + (int)[theStartDate timeIntervalSince1970], + (int)[theStartDate timeIntervalSince1970]]; qualifier = [[EOAndQualifier alloc] initWithQualifiers: sinceDateQualifier, qualifier, nil];