Skip to content

Commit

Permalink
fix(mail(dav)): fix mail-query response
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Nov 9, 2021
1 parent 563f1d2 commit 4df5e4b
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions SoObjects/Mailer/SOGoMailFolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@

static NSString *defaultUserID = @"anyone";

static NSComparisonResult
_compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
static NSComparisonResult _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
{
static NSNumber *zeroNumber = nil;
NSNumber *modseq1, *modseq2;
Expand All @@ -101,7 +100,7 @@
return [modseq1 compare: modseq2];
}

static NSComparisonResult _compareFetchResultsByUID (id entry1, id entry2, NSArray *uids)
static NSInteger _compareFetchResultsByUID (id entry1, id entry2, NSArray *uids)
{
NSString *uid1, *uid2;
NSUInteger pos1, pos2;
Expand Down Expand Up @@ -1866,7 +1865,7 @@ - (NSArray *) _fetchMessageProperties: (NSArray *) properties
{
NGImap4Client *client;
NSDictionary *response;
NSArray *messages, *values = nil;
NSArray *uids, *results, *sortedResults = nil;
NSString *resultKey;

client = [[self imap4Connection] client];
Expand All @@ -1886,15 +1885,17 @@ - (NSArray *) _fetchMessageProperties: (NSArray *) properties

if ([[response objectForKey: @"result"] boolValue])
{
messages = [response objectForKey: resultKey];
if ([messages count] > 0)
uids = [response objectForKey: resultKey];
if ([uids count] > 0)
{
response = [client fetchUids: messages parts: properties];
values = [response objectForKey: @"fetch"];
response = [client fetchUids: uids parts: properties];
results = [response objectForKey: @"fetch"];
sortedResults = (NSArray *)[results sortedArrayUsingFunction: _compareFetchResultsByUID
context: (void *)uids];
}
}

return values;
return sortedResults;
}

- (NSArray *) _davPropstatsWithProperties: (NSArray *) davProperties
Expand Down Expand Up @@ -1958,30 +1959,28 @@ - (void) _appendProperties: (NSArray *) properties
fromMessages: (NSArray *) messages
toResponse: (WOResponse *) response
{
NSDictionary *davElement;
NSDictionary *davElement, *message;
NSArray *propstats;
NSMutableArray *all;
NSString *message, *davString;
NSString *davString;
SEL *selectors;
int max, count;

max = [properties count];
selectors = NSZoneMalloc (NULL, sizeof (max * sizeof (SEL)));

for (count = 0; count < max; count++)
selectors[count]
= SOGoSelectorForPropertyGetter ([properties objectAtIndex: count]);
selectors[count] = SOGoSelectorForPropertyGetter ([properties objectAtIndex: count]);

max = [messages count];
all = [NSMutableArray array];
for (count = 0; count < max; count++)
{
message = [[messages objectAtIndex: count] stringValue];
message = [messages objectAtIndex: count];
propstats = [self _davPropstatsWithProperties: properties
andMethodSelectors: selectors
fromMessage: message];
davElement = davElementWithContent (@"response", XMLNS_WEBDAV,
propstats);
fromMessage: [[message objectForKey: @"uid"] stringValue]];
davElement = davElementWithContent (@"response", XMLNS_WEBDAV, propstats);

[all addObject: davElement];
}
Expand Down Expand Up @@ -2055,14 +2054,13 @@ - (id) davMailQuery: (id) queryContext
properties = [self parseDAVRequestedProperties: propElement];
filterElement = [documentElement firstElementWithTag: @"mail-filters"
inNamespace: XMLNS_INVERSEDAV];
searchQualifier = [EOQualifier
qualifierFromMailDAVMailFilters: filterElement];
searchQualifier = [EOQualifier qualifierFromMailDAVMailFilters: filterElement];
sortElement = (NGDOMNodeWithChildren *) [documentElement
firstElementWithTag: @"sort"
inNamespace: XMLNS_INVERSEDAV];
sortOrderings = [self _sortOrderingsFromSortElement: sortElement];

messages = [self _fetchMessageProperties: [properties allKeys]
messages = [self _fetchMessageProperties: [properties allValues]
matchingQualifier: searchQualifier
andSortOrderings: sortOrderings];
[self _appendProperties: [properties allKeys]
Expand Down Expand Up @@ -2374,7 +2372,7 @@ - (NSArray *) syncTokenFieldsWithProperties: (NSDictionary *) theProperties
}
else
{
sortedResults = [fetchResults sortedArrayUsingFunction: (int(*)(id, id, void*))_compareFetchResultsByUID
sortedResults = [fetchResults sortedArrayUsingFunction: _compareFetchResultsByUID
context: uids];
}

Expand Down

0 comments on commit 4df5e4b

Please sign in to comment.