Monotone-Parent: 4138731669f6496c58a7c665ee66513f2b2304ab
Monotone-Revision: 5c85a1a1d9228ad7653497f882f4fccc69f1d924 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-08-10T18:32:53 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
fcc41a86ba
commit
d873840031
|
@ -1,3 +1,12 @@
|
|||
2011-08-10 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OpenChange/MAPIStoreMapping.m
|
||||
(+mappingForUsername:withIndexing:): modified contrusctor to make
|
||||
use of a "username" parameter that enable per-user "singletons".
|
||||
(-increateUseCount, -decreaseUseCount): new accessors that enable
|
||||
the registration/unregistration of the mapping object from the
|
||||
singleton registry.
|
||||
|
||||
2011-08-08 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OpenChange/MAPIStoreFolder.m (-lookupMessage:): set the WOContext
|
||||
|
|
|
@ -30,14 +30,22 @@
|
|||
|
||||
@interface MAPIStoreMapping : NSObject
|
||||
{
|
||||
NSString *username;
|
||||
struct tdb_wrap *indexing;
|
||||
NSMutableDictionary *mapping; /* FID/MID -> url */
|
||||
NSMutableDictionary *reverseMapping; /* url -> FID/MID */
|
||||
struct tdb_wrap *indexing;
|
||||
NSUInteger useCount;
|
||||
}
|
||||
|
||||
+ (id) mappingWithIndexing: (struct tdb_wrap *) indexing;
|
||||
+ (id) mappingForUsername: (NSString *) username
|
||||
withIndexing: (struct tdb_wrap *) indexing;
|
||||
|
||||
- (id) initWithIndexing: (struct tdb_wrap *) indexing;
|
||||
- (id) initForUsername: (NSString *) username
|
||||
withIndexing: (struct tdb_wrap *) indexing;
|
||||
|
||||
|
||||
- (void) increaseUseCount;
|
||||
- (void) decreaseUseCount;
|
||||
|
||||
- (NSString *) urlFromID: (uint64_t) idKey;
|
||||
|
||||
|
|
|
@ -38,8 +38,15 @@
|
|||
#include <tdb.h>
|
||||
#include <tdb_wrap.h>
|
||||
|
||||
static NSMutableDictionary *mappingRegistry = nil;
|
||||
|
||||
@implementation MAPIStoreMapping
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
mappingRegistry = [NSMutableDictionary new];
|
||||
}
|
||||
|
||||
static int
|
||||
MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2,
|
||||
void *data)
|
||||
|
@ -67,14 +74,20 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2,
|
|||
return 0;
|
||||
}
|
||||
|
||||
+ (id) mappingWithIndexing: (struct tdb_wrap *) indexing
|
||||
+ (id) mappingForUsername: (NSString *) username
|
||||
withIndexing: (struct tdb_wrap *) indexing
|
||||
{
|
||||
id newMapping;
|
||||
id mapping;
|
||||
|
||||
newMapping = [[self alloc] initWithIndexing: indexing];
|
||||
[newMapping autorelease];
|
||||
mapping = [mappingRegistry objectForKey: username];
|
||||
if (!mapping)
|
||||
{
|
||||
mapping = [[self alloc] initForUsername: username
|
||||
withIndexing: indexing];
|
||||
[mapping autorelease];
|
||||
}
|
||||
|
||||
return newMapping;
|
||||
return mapping;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
|
@ -84,12 +97,34 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2,
|
|||
mapping = [NSMutableDictionary new];
|
||||
reverseMapping = [NSMutableDictionary new];
|
||||
indexing = NULL;
|
||||
useCount = 0;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithIndexing: (struct tdb_wrap *) newIndexing
|
||||
- (void) increaseUseCount
|
||||
{
|
||||
if (useCount == 0)
|
||||
{
|
||||
[mappingRegistry setObject: self forKey: username];
|
||||
[self logWithFormat: @"mapping registered (%@)", username];
|
||||
}
|
||||
useCount++;
|
||||
}
|
||||
|
||||
- (void) decreaseUseCount
|
||||
{
|
||||
useCount--;
|
||||
if (useCount == 0)
|
||||
{
|
||||
[mappingRegistry removeObjectForKey: username];
|
||||
[self logWithFormat: @"mapping deregistered (%@)", username];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initForUsername: (NSString *) newUsername
|
||||
withIndexing: (struct tdb_wrap *) newIndexing
|
||||
{
|
||||
NSNumber *idNbr;
|
||||
NSString *uri;
|
||||
|
@ -98,6 +133,7 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2,
|
|||
|
||||
if ((self = [self init]))
|
||||
{
|
||||
ASSIGN (username, newUsername);
|
||||
indexing = newIndexing;
|
||||
tdb_traverse_read (indexing->tdb, MAPIStoreMappingTDBTraverse, mapping);
|
||||
keys = [mapping allKeys];
|
||||
|
@ -116,6 +152,7 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2,
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
[username release];
|
||||
[mapping release];
|
||||
[reverseMapping release];
|
||||
[super dealloc];
|
||||
|
|
Loading…
Reference in New Issue