diff --git a/ChangeLog b/ChangeLog index e8437d9d4..1ef9cac00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-07-08 Wolfgang Sourdeau + + * SoObjects/Mailer/SOGoMailFolder.m + (_fetchMessageProperties:matchingQualifier:andSortOrderings::): + properly implement this method, as properties should be an array + instead of a dictionary. + (-mostRecentMessageDate): new method that returns the date of the + last available message. + 2011-07-07 Francis Lachapelle * UI/WebServerResources/UIxListEditor.js (endEditable): when a diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index 53a7c0183..f0cc8c553 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -80,6 +80,8 @@ - (NSException *) expunge; +- (NSCalendarDate *) mostRecentMessageDate; + /* flags */ - (NSException *) addFlagsToAllMessages: (id) _f; diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 71a2ef435..e393bd9ac 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -1330,13 +1330,13 @@ static NSString *defaultUserID = @"anyone"; return sortOrderings; } -- (NSArray *) _fetchMessageProperties: (NSDictionary *) properties +- (NSArray *) _fetchMessageProperties: (NSArray *) properties matchingQualifier: (EOQualifier *) searchQualifier andSortOrderings: (NSArray *) sortOrderings { NGImap4Client *client; NSDictionary *response; - NSArray *messages; + NSArray *messages, *values = nil; NSString *resultKey; client = [[self imap4Connection] client]; @@ -1355,11 +1355,16 @@ static NSString *defaultUserID = @"anyone"; } if ([[response objectForKey: @"result"] boolValue]) - messages = [response objectForKey: resultKey]; - else - messages = nil; + { + messages = [response objectForKey: resultKey]; + if ([messages count] > 0) + { + response = [client fetchUids: messages parts: properties]; + values = [response objectForKey: @"fetch"]; + } + } - return messages; + return values; } - (NSArray *) _davPropstatsWithProperties: (NSArray *) davProperties @@ -1524,7 +1529,7 @@ static NSString *defaultUserID = @"anyone"; inNamespace: XMLNS_INVERSEDAV]; sortOrderings = [self _sortOrderingsFromSortElement: sortElement]; - messages = [self _fetchMessageProperties: properties + messages = [self _fetchMessageProperties: [properties allKeys] matchingQualifier: searchQualifier andSortOrderings: sortOrderings]; [self _appendProperties: [properties allKeys] @@ -1603,6 +1608,20 @@ static NSString *defaultUserID = @"anyone"; return response; } +- (NSCalendarDate *) mostRecentMessageDate +{ + NSArray *values; + NSCalendarDate *date = nil; + + values = [self _fetchMessageProperties: [NSArray arrayWithObject: @"ENVELOPE"] + matchingQualifier: nil + andSortOrderings: [NSArray arrayWithObject: @"REVERSE DATE"]]; + if ([values count] > 0) + date = [[[values objectAtIndex: 0] objectForKey: @"envelope"] date]; + + return date; +} + @end /* SOGoMailFolder */ @implementation SOGoSpecialMailFolder