From b050971d3854335a19804f15a8017eefd95e0540 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 30 May 2011 21:17:26 +0000 Subject: [PATCH] Monotone-Parent: e347244635dd06d86b291dac5a5f75e1f9d61eb9 Monotone-Revision: 9c0b64b5164d0b1f7b8b0a271122eb860a1f14df Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-05-30T21:17:26 Monotone-Branch: ca.inverse.sogo --- SOPE/GDLContentStore/ChangeLog | 6 ++++++ SOPE/GDLContentStore/GCSFolder.h | 2 ++ SOPE/GDLContentStore/GCSFolder.m | 30 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/SOPE/GDLContentStore/ChangeLog b/SOPE/GDLContentStore/ChangeLog index fda01529f..d570302cb 100644 --- a/SOPE/GDLContentStore/ChangeLog +++ b/SOPE/GDLContentStore/ChangeLog @@ -1,3 +1,9 @@ +2011-05-30 Wolfgang Sourdeau + + * GCSFolder.m (-lastModificationDate): new method that returns the + last modification date based on the higher value of the + "c_lastmodified" column. + 2010-12-30 Wolfgang Sourdeau * EOQualifier+GCS.m (_appendNotQualifier:toString:): new method diff --git a/SOPE/GDLContentStore/GCSFolder.h b/SOPE/GDLContentStore/GCSFolder.h index b1370b6e2..d10185a7e 100644 --- a/SOPE/GDLContentStore/GCSFolder.h +++ b/SOPE/GDLContentStore/GCSFolder.h @@ -140,6 +140,8 @@ - (unsigned int) recordsCountByExcludingDeleted: (BOOL) includeDeleted; +- (NSCalendarDate *) lastModificationDate; + @end #endif /* __GDLContentStore_GCSFolder_H__ */ diff --git a/SOPE/GDLContentStore/GCSFolder.m b/SOPE/GDLContentStore/GCSFolder.m index 4b26a124a..95eca6f52 100644 --- a/SOPE/GDLContentStore/GCSFolder.m +++ b/SOPE/GDLContentStore/GCSFolder.m @@ -1368,6 +1368,36 @@ static NSArray *contentFieldNames = nil; return count; } +- (NSCalendarDate *) lastModificationDate +{ + NSArray *records; + EOFetchSpecification *lmSpec; + EOSortOrdering *ordering; + NSNumber *lastModified; + NSCalendarDate *lastModificationDate = nil; + + ordering = [EOSortOrdering sortOrderingWithKey: @"c_lastmodified" + selector: EOCompareDescending]; + lmSpec = [EOFetchSpecification + fetchSpecificationWithEntityName: [self folderName] + qualifier: nil + sortOrderings: [NSArray arrayWithObject: ordering]]; + + records = [self fetchFields: [NSArray arrayWithObject: @"c_lastmodified"] + fetchSpecification: lmSpec + ignoreDeleted: NO]; + if ([records count]) + { + lastModified + = [[records objectAtIndex: 0] objectForKey: @"c_lastmodified"]; + lastModificationDate + = [NSCalendarDate dateWithTimeIntervalSince1970: + (NSTimeInterval) [lastModified intValue]]; + } + + return lastModificationDate; +} + /* description */ - (NSString *)description {