Monotone-Parent: f4e8a715d67a12fea729843b1401f636ce05ed66

Monotone-Revision: 86ef6adf2b0443af39cafaac0b9a9d66fb753576

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2012-03-16T21:09:10
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2012-03-16 21:09:10 +00:00
parent 26701b7c71
commit ff26754291
5 changed files with 77 additions and 10 deletions

View File

@ -1,5 +1,16 @@
2012-03-16 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreGCSFolder.m
(-predecessorChangeListForMessageWithKey:): same as below.
* OpenChange/MAPIStoreMailFolder.m
(-predecessorChangeListForMessageWithKey:): the returned list must
be binary ordered by GUID (as specified in the SPEC). We now do so
using the new function below.
* OpenChange/MAPIStoreTypes.m (MAPIChangeKeyGUIDCompare): new
comparator function to compare the GUID of two change key streams.
* OpenChange/MAPIStoreGCSFolder.m
(-updateVersionsForMessageWithKey:withChangeKey:): new method,
common to all GCS messages, that updates the folder cache and

View File

@ -527,9 +527,10 @@ static Class NSNumberK;
- (NSData *) predecessorChangeListForMessageWithKey: (NSString *) messageKey
{
NSMutableData *changeKeys = nil;
NSMutableData *list = nil;
NSDictionary *messages, *changeListDict;
NSArray *keys;
NSMutableArray *changeKeys;
NSUInteger count, max;
NSData *changeKey;
NSString *guid;
@ -540,21 +541,30 @@ static Class NSNumberK;
objectForKey: @"PredecessorChangeList"];
if (changeListDict)
{
changeKeys = [NSMutableData data];
keys = [changeListDict allKeys];
max = [keys count];
changeKeys = [NSMutableArray arrayWithCapacity: max];
for (count = 0; count < max; count++)
{
guid = [keys objectAtIndex: count];
globCnt = [changeListDict objectForKey: guid];
changeKey = [NSData dataWithChangeKeyGUID: guid andCnt: globCnt];
[changeKeys appendUInt8: [changeKey length]];
[changeKeys appendData: changeKey];
[changeKeys addObject: changeKey];
}
[changeKeys sortUsingFunction: MAPIChangeKeyGUIDCompare
context: nil];
list = [NSMutableData data];
for (count = 0; count < max; count++)
{
changeKey = [changeKeys objectAtIndex: count];
[list appendUInt8: [changeKey length]];
[list appendData: changeKey];
}
}
return changeKeys;
return list;
}
- (NSArray *) getDeletedKeysFromChangeNumber: (uint64_t) changeNum

View File

@ -709,9 +709,10 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
- (NSData *) predecessorChangeListForMessageWithKey: (NSString *) messageKey
{
NSMutableData *changeKeys = nil;
NSMutableData *list = nil;
NSDictionary *messages, *changeListDict;
NSArray *keys;
NSMutableArray *changeKeys;
NSUInteger count, max;
NSData *changeKey;
NSString *guid;
@ -724,21 +725,30 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
objectForKey: @"PredecessorChangeList"];
if (changeListDict)
{
changeKeys = [NSMutableData data];
keys = [changeListDict allKeys];
max = [keys count];
changeKeys = [NSMutableArray arrayWithCapacity: max];
for (count = 0; count < max; count++)
{
guid = [keys objectAtIndex: count];
globCnt = [changeListDict objectForKey: guid];
changeKey = [NSData dataWithChangeKeyGUID: guid andCnt: globCnt];
[changeKeys appendUInt8: [changeKey length]];
[changeKeys appendData: changeKey];
[changeKeys addObject: changeKey];
}
[changeKeys sortUsingFunction: MAPIChangeKeyGUIDCompare
context: nil];
list = [NSMutableData data];
for (count = 0; count < max; count++)
{
changeKey = [changeKeys objectAtIndex: count];
[list appendUInt8: [changeKey length]];
[list appendData: changeKey];
}
}
return changeKeys;
return list;
}
- (NSArray *) getDeletedKeysFromChangeNumber: (uint64_t) changeNum

View File

@ -43,6 +43,7 @@ id NSObjectFromMAPISPropValue (const struct mapi_SPropValue *);
id NSObjectFromValuePointer (enum MAPITAGS, const void *);
NSComparisonResult MAPICNCompare (uint64_t cn1, uint64_t cn2);
NSComparisonResult MAPIChangeKeyGUIDCompare (NSData *ck1, NSData *ck2, void *);
static inline NSNumber *
MAPIPropertyKey (enum MAPITAGS propTag)

View File

@ -298,6 +298,41 @@ MAPICNCompare (uint64_t cn1, uint64_t cn2)
return result;
}
NSComparisonResult MAPIChangeKeyGUIDCompare (NSData *ck1, NSData *ck2, void *unused)
{
NSUInteger count;
const unsigned char *ptr1, *ptr2;
NSComparisonResult result = NSOrderedSame;
if ([ck1 length] < 16)
{
NSLog (@"ck1 has a length < 16");
abort ();
}
if ([ck2 length] < 16)
{
NSLog (@"ck2 has a length < 16");
abort ();
}
ptr1 = [ck1 bytes];
ptr2 = [ck2 bytes];
for (count = 0; result == NSOrderedSame && count < 16; count++)
{
if (*ptr1 < *ptr2)
result = NSOrderedAscending;
else if (*ptr1 > *ptr2)
result = NSOrderedDescending;
else
{
ptr1++;
ptr2++;
}
}
return result;
}
void
MAPIStoreDumpMessageProperties (NSDictionary *properties)
{