Monotone-Parent: 8d4ca03b16c54609dce23f43fc358a43d7e96d99
Monotone-Revision: 047b040e318a98223980da2af8241b7eb6d75341 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-08-13T03:55:48 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
dd48699bb3
commit
e146ba68e6
|
@ -1,3 +1,8 @@
|
|||
2012-08-12 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OpenChange/MAPIStoreMapping.m (-updateID:withURL:): new method
|
||||
that perform a change of url on container and leaf entries.
|
||||
|
||||
2012-08-10 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OpenChange/MAPIStoreSOGo.m (sogo_properties_get_uri): new
|
||||
|
|
|
@ -54,6 +54,8 @@
|
|||
- (BOOL) registerURL: (NSString *) urlString
|
||||
withID: (uint64_t) idNbr;
|
||||
- (void) unregisterURLWithID: (uint64_t) idNbr;
|
||||
- (void) updateID: (uint64_t) idNbr
|
||||
withURL: (NSString *) urlString;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -204,6 +204,90 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2,
|
|||
return idNbr;
|
||||
}
|
||||
|
||||
- (void) _updateFolderWithURL: (NSString *) oldURL
|
||||
withURL: (NSString *) urlString
|
||||
{
|
||||
NSArray *allKeys;
|
||||
NSUInteger count, max;
|
||||
NSString *currentKey, *keyEnd, *newKey;
|
||||
NSUInteger oldURLLength;
|
||||
NSNumber *idKey;
|
||||
TDB_DATA key, dbuf;
|
||||
|
||||
oldURLLength = [oldURL length];
|
||||
|
||||
allKeys = [reverseMapping allKeys];
|
||||
max = [allKeys count];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
currentKey = [allKeys objectAtIndex: count];
|
||||
if ([currentKey hasPrefix: oldURL])
|
||||
{
|
||||
keyEnd = [currentKey substringFromIndex: oldURLLength];
|
||||
newKey = [NSString stringWithFormat: @"%@%@", urlString, keyEnd];
|
||||
|
||||
idKey = [reverseMapping objectForKey: currentKey];
|
||||
[mapping setObject: newKey forKey: idKey];
|
||||
[reverseMapping setObject: idKey forKey: newKey];
|
||||
[reverseMapping removeObjectForKey: currentKey];
|
||||
|
||||
/* update the record in the indexing database */
|
||||
key.dptr = (unsigned char *) talloc_asprintf (NULL, "0x%.16"PRIx64,
|
||||
(uint64_t) [idKey unsignedLongLongValue]);
|
||||
key.dsize = strlen ((const char *) key.dptr);
|
||||
|
||||
dbuf.dptr = (unsigned char *) talloc_strdup (NULL,
|
||||
[newKey UTF8String]);
|
||||
dbuf.dsize = strlen ((const char *) dbuf.dptr);
|
||||
tdb_store (indexing->tdb, key, dbuf, TDB_MODIFY);
|
||||
talloc_free (key.dptr);
|
||||
talloc_free (dbuf.dptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) updateID: (uint64_t) idNbr
|
||||
withURL: (NSString *) urlString
|
||||
{
|
||||
NSString *oldURL;
|
||||
NSNumber *idKey;
|
||||
TDB_DATA key, dbuf;
|
||||
|
||||
idKey = [NSNumber numberWithUnsignedLongLong: idNbr];
|
||||
oldURL = [mapping objectForKey: idKey];
|
||||
if (oldURL)
|
||||
{
|
||||
if ([oldURL hasSuffix: @"/"]) /* is container ? */
|
||||
{
|
||||
if (![urlString hasSuffix: @"/"])
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"a container url must have an ending '/'"];
|
||||
tdb_transaction_start (indexing->tdb);
|
||||
[self _updateFolderWithURL: oldURL withURL: urlString];
|
||||
tdb_transaction_commit (indexing->tdb);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([urlString hasSuffix: @"/"])
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"a leaf url must not have an ending '/'"];
|
||||
[mapping setObject: urlString forKey: idKey];
|
||||
[reverseMapping setObject: idKey forKey: urlString];
|
||||
[reverseMapping removeObjectForKey: oldURL];
|
||||
|
||||
/* update the record in the indexing database */
|
||||
key.dptr = (unsigned char *) talloc_asprintf(NULL, "0x%.16"PRIx64, idNbr);
|
||||
key.dsize = strlen((const char *) key.dptr);
|
||||
|
||||
dbuf.dptr = (unsigned char *) talloc_strdup (NULL, [urlString UTF8String]);
|
||||
dbuf.dsize = strlen((const char *) dbuf.dptr);
|
||||
tdb_store (indexing->tdb, key, dbuf, TDB_MODIFY);
|
||||
talloc_free (key.dptr);
|
||||
talloc_free (dbuf.dptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) registerURL: (NSString *) urlString
|
||||
withID: (uint64_t) idNbr
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue