From 63abe73c29bc7d211a22722e8f3c489e1601b967 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 12 Oct 2012 23:28:47 -0400 Subject: [PATCH] ensureIDsForChildKeys: new helper method that ensure that the child keys have a corresponding fmid and register them with -[MAPIStoreMapping registerURLs:withIDs:] if needed --- OpenChange/MAPIStoreFolder.h | 1 + OpenChange/MAPIStoreFolder.m | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/OpenChange/MAPIStoreFolder.h b/OpenChange/MAPIStoreFolder.h index 79235da87..c5a7bd72e 100644 --- a/OpenChange/MAPIStoreFolder.h +++ b/OpenChange/MAPIStoreFolder.h @@ -183,6 +183,7 @@ /* subclass helpers */ - (void) setupVersionsMessage; +- (void) ensureIDsForChildKeys: (NSArray *) keys; - (void) postNotificationsForMoveCopyMessagesWithMIDs: (uint64_t *) srcMids andMessageURLs: (NSArray *) oldMessageURLs andCount: (uint32_t) midCount diff --git a/OpenChange/MAPIStoreFolder.m b/OpenChange/MAPIStoreFolder.m index fd9774f2d..e3ec06976 100644 --- a/OpenChange/MAPIStoreFolder.m +++ b/OpenChange/MAPIStoreFolder.m @@ -911,6 +911,35 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe { } +- (void) ensureIDsForChildKeys: (NSArray *) keys +{ + NSMutableArray *missingURLs; + MAPIStoreMapping *mapping; + NSUInteger count, max; + NSString *baseURL, *URL, *key; + NSArray *newIDs; + uint64_t idNbr; + + baseURL = [self url]; + + mapping = [self mapping]; + max = [keys count]; + missingURLs = [NSMutableArray arrayWithCapacity: max]; + for (count = 0; count < max; count++) + { + key = [keys objectAtIndex: count]; + URL = [NSString stringWithFormat: @"%@%@", baseURL, key]; + idNbr = [mapping idFromURL: URL]; + if (idNbr == NSNotFound) + [missingURLs addObject: URL]; + } + + max = [missingURLs count]; + newIDs = [[self context] getNewFMIDs: max]; + [mapping registerURLs: missingURLs + withIDs: newIDs]; +} + - (void) postNotificationsForMoveCopyMessagesWithMIDs: (uint64_t *) srcMids andMessageURLs: (NSArray *) oldMessageURLs andCount: (uint32_t) midCount