diff --git a/ChangeLog b/ChangeLog index 862cd95fb..0d67ba961 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2012-03-16 Wolfgang Sourdeau + * OpenChange/MAPIStoreGCSFolder.m + (-updateVersionsForMessageWithKey:withChangeKey:): new method, + common to all GCS messages, that updates the folder cache and + insert the PidTagChangeKey provided by the client during the save + operations. + + * OpenChange/MAPIStoreGCSMessage.m (-updateVersions): new proxy + method for -[MAPIStoreGCSFolder + updateVersionsForMessageWithKey:withChangeKey:]. + * OpenChange/MAPIStoreGCSBaseContext.m (+createRootSecondaryFolderWithFID:andName:forUser:): setup the userContext in the MAPIApp object. diff --git a/OpenChange/MAPIStoreCalendarMessage.m b/OpenChange/MAPIStoreCalendarMessage.m index bd299eb35..3c657b47d 100644 --- a/OpenChange/MAPIStoreCalendarMessage.m +++ b/OpenChange/MAPIStoreCalendarMessage.m @@ -1064,12 +1064,7 @@ if (newParticipationStatus) [sogoObject changeParticipationStatus: newParticipationStatus withDelegate: nil]; - - [(MAPIStoreCalendarFolder *) container synchroniseCache]; - value = [properties objectForKey: MAPIPropertyKey (PR_CHANGE_KEY)]; - if (value) - [(MAPIStoreCalendarFolder *) container - setChangeKey: value forMessageWithKey: [self nameInContainer]]; + [self updateVersions]; } - (id) lookupAttachment: (NSString *) childKey diff --git a/OpenChange/MAPIStoreContactsMessage.m b/OpenChange/MAPIStoreContactsMessage.m index d1bdebadc..c8af5c05b 100644 --- a/OpenChange/MAPIStoreContactsMessage.m +++ b/OpenChange/MAPIStoreContactsMessage.m @@ -1157,11 +1157,8 @@ fromProperties: (NSDictionary *) attachmentProps // we save the new/modified card // [sogoObject saveContentString: [newCard versitString]]; - [(MAPIStoreContactsFolder *) container synchroniseCache]; - value = [properties objectForKey: MAPIPropertyKey (PR_CHANGE_KEY)]; - if (value) - [(MAPIStoreContactsFolder *) container - setChangeKey: value forMessageWithKey: [self nameInContainer]]; + + [self updateVersions]; } @end diff --git a/OpenChange/MAPIStoreGCSFolder.h b/OpenChange/MAPIStoreGCSFolder.h index d87c9c63c..0d0c1e6df 100644 --- a/OpenChange/MAPIStoreGCSFolder.h +++ b/OpenChange/MAPIStoreGCSFolder.h @@ -41,6 +41,8 @@ /* synchronisation */ - (BOOL) synchroniseCache; +- (void) updateVersionsForMessageWithKey: (NSString *) messageKey + withChangeKey: (NSData *) newChangeKey; - (NSNumber *) lastModifiedFromMessageChangeNumber: (NSNumber *) changeNum; - (NSNumber *) changeNumberForMessageWithKey: (NSString *) messageKey; diff --git a/OpenChange/MAPIStoreGCSFolder.m b/OpenChange/MAPIStoreGCSFolder.m index 74c784c93..57cb9b123 100644 --- a/OpenChange/MAPIStoreGCSFolder.m +++ b/OpenChange/MAPIStoreGCSFolder.m @@ -252,7 +252,7 @@ static Class NSNumberK; ... }; VersionMapping = { - Version = MessageKey; + Version = last-modified; ... } } @@ -458,6 +458,15 @@ static Class NSNumberK; return rc; } + +- (void) updateVersionsForMessageWithKey: (NSString *) messageKey + withChangeKey: (NSData *) newChangeKey +{ + [self synchroniseCache]; + + if (newChangeKey) + [self setChangeKey: newChangeKey forMessageWithKey: messageKey]; +} - (NSNumber *) lastModifiedFromMessageChangeNumber: (NSNumber *) changeNum { diff --git a/OpenChange/MAPIStoreGCSMessage.h b/OpenChange/MAPIStoreGCSMessage.h index 883923e5f..5ada9290b 100644 --- a/OpenChange/MAPIStoreGCSMessage.h +++ b/OpenChange/MAPIStoreGCSMessage.h @@ -29,6 +29,9 @@ { } +/* subclass helpers */ +- (void) updateVersions; + @end #endif /* MAPISTOREGCSMESSAGE_H */ diff --git a/OpenChange/MAPIStoreGCSMessage.m b/OpenChange/MAPIStoreGCSMessage.m index 4d7ea0c07..c62f87990 100644 --- a/OpenChange/MAPIStoreGCSMessage.m +++ b/OpenChange/MAPIStoreGCSMessage.m @@ -21,6 +21,7 @@ */ #import +#import #import #import #import @@ -204,4 +205,15 @@ return version; } +- (void) updateVersions +{ + NSData *newChangeKey; + + newChangeKey = [properties objectForKey: MAPIPropertyKey (PR_CHANGE_KEY)]; + + [(MAPIStoreGCSFolder *) container + updateVersionsForMessageWithKey: [self nameInContainer] + withChangeKey: newChangeKey]; +} + @end diff --git a/OpenChange/MAPIStoreTasksMessage.m b/OpenChange/MAPIStoreTasksMessage.m index 28d690b74..5e123fab7 100644 --- a/OpenChange/MAPIStoreTasksMessage.m +++ b/OpenChange/MAPIStoreTasksMessage.m @@ -462,11 +462,8 @@ [vToDo setTimeStampAsDate: now]; [sogoObject saveContentString: [vCalendar versitString]]; - [(MAPIStoreTasksFolder *) container synchroniseCache]; - value = [properties objectForKey: MAPIPropertyKey (PR_CHANGE_KEY)]; - if (value) - [(MAPIStoreTasksFolder *) container - setChangeKey: value forMessageWithKey: [self nameInContainer]]; + + [self updateVersions]; } @end