From 641eb8013b270a016ef78d3e8bffb3dcf384badc Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 12 Oct 2012 17:44:26 -0400 Subject: [PATCH] -registerURLs:withIDs: new method to register multiple urls at once --- OpenChange/MAPIStoreMapping.h | 2 ++ OpenChange/MAPIStoreMapping.m | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/OpenChange/MAPIStoreMapping.h b/OpenChange/MAPIStoreMapping.h index 22ba052d3..0b1aa3f53 100644 --- a/OpenChange/MAPIStoreMapping.h +++ b/OpenChange/MAPIStoreMapping.h @@ -53,6 +53,8 @@ - (uint64_t) idFromURL: (NSString *) url; - (BOOL) registerURL: (NSString *) urlString withID: (uint64_t) idNbr; +- (void) registerURLs: (NSArray *) urlString + withIDs: (struct UI8Array_r *) idNbrs; - (void) unregisterURLWithID: (uint64_t) idNbr; - (void) updateID: (uint64_t) idNbr withURL: (NSString *) urlString; diff --git a/OpenChange/MAPIStoreMapping.m b/OpenChange/MAPIStoreMapping.m index 7e8dca116..770721b23 100644 --- a/OpenChange/MAPIStoreMapping.m +++ b/OpenChange/MAPIStoreMapping.m @@ -333,6 +333,25 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2, return rc; } +- (void) registerURLs: (NSArray *) urlStrings + withIDs: (struct UI8Array_r *) idNbrs +{ + uint64_t count, max; + + max = [urlStrings count]; + if (max == idNbrs->cValues) + { + tdb_transaction_start (indexing->tdb); + for (count = 0; count < max; count++) + [self registerURL: [urlStrings objectAtIndex: count] + withID: idNbrs->lpui8[count]]; + tdb_transaction_commit (indexing->tdb); + } + else + [NSException raise: NSInvalidArgumentException + format: @"number of urls and ids do not match"]; +} + - (void) unregisterURLWithID: (uint64_t) idNbr { NSString *urlString;