Moved to abstract index_context instead of tdb_wrap

pull/49/head
Carlos Pérez-Aradros Herce 2013-11-08 17:02:50 +01:00 committed by Julio García
parent 660f39a980
commit 33b353b974
11 changed files with 38 additions and 42 deletions

View File

@ -61,10 +61,10 @@
} }
+ (struct mapistore_contexts_list *) listAllContextsForUser: (NSString *) userName + (struct mapistore_contexts_list *) listAllContextsForUser: (NSString *) userName
withTDBIndexing: (struct tdb_wrap *) indexingTdb withIndexing: (struct indexing_context *) indexing
inMemCtx: (TALLOC_CTX *) memCtx; inMemCtx: (TALLOC_CTX *) memCtx;
+ (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName + (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName
withTDBIndexing: (struct tdb_wrap *) indexingTdb withIndexing: (struct indexing_context *) indexing
inMemCtx: (TALLOC_CTX *) memCtx; inMemCtx: (TALLOC_CTX *) memCtx;
+ (enum mapistore_error) createRootFolder: (NSString **) mapistoreUriP + (enum mapistore_error) createRootFolder: (NSString **) mapistoreUriP
withFID: (uint64_t ) fid withFID: (uint64_t ) fid
@ -75,11 +75,11 @@
+ (int) openContext: (MAPIStoreContext **) contextPtr + (int) openContext: (MAPIStoreContext **) contextPtr
withURI: (const char *) newUri withURI: (const char *) newUri
connectionInfo: (struct mapistore_connection_info *) newConnInfo connectionInfo: (struct mapistore_connection_info *) newConnInfo
andTDBIndexing: (struct tdb_wrap *) indexingTdb; andTDBIndexing: (struct indexing_context *) indexing;
- (id) initFromURL: (NSURL *) newUri - (id) initFromURL: (NSURL *) newUri
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
andTDBIndexing: (struct tdb_wrap *) indexingTdb; andTDBIndexing: (struct indexing_context *) indexing;
- (NSURL *) url; - (NSURL *) url;
- (struct mapistore_connection_info *) connectionInfo; - (struct mapistore_connection_info *) connectionInfo;

View File

@ -100,7 +100,7 @@ static NSMutableDictionary *contextClassMapping;
} }
+ (struct mapistore_contexts_list *) listAllContextsForUser: (NSString *) userName + (struct mapistore_contexts_list *) listAllContextsForUser: (NSString *) userName
withTDBIndexing: (struct tdb_wrap *) indexingTdb withIndexing: (struct indexing_context *) indexing
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
struct mapistore_contexts_list *list, *current; struct mapistore_contexts_list *list, *current;
@ -112,7 +112,7 @@ static NSMutableDictionary *contextClassMapping;
list = NULL; list = NULL;
userContext = [MAPIStoreUserContext userContextWithUsername: userName userContext = [MAPIStoreUserContext userContextWithUsername: userName
andTDBIndexing: indexingTdb]; andTDBIndexing: indexing];
[userContext activateWithUser: [userContext sogoUser]]; [userContext activateWithUser: [userContext sogoUser]];
classes = GSObjCAllSubclassesOfClass (self); classes = GSObjCAllSubclassesOfClass (self);
@ -121,7 +121,7 @@ static NSMutableDictionary *contextClassMapping;
{ {
currentClass = [classes objectAtIndex: count]; currentClass = [classes objectAtIndex: count];
current = [currentClass listContextsForUser: userName current = [currentClass listContextsForUser: userName
withTDBIndexing: indexingTdb withIndexing: indexing
inMemCtx: memCtx]; inMemCtx: memCtx];
if (current) if (current)
DLIST_CONCATENATE(list, current, void); DLIST_CONCATENATE(list, current, void);
@ -131,7 +131,7 @@ static NSMutableDictionary *contextClassMapping;
} }
+ (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName + (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName
withTDBIndexing: (struct tdb_wrap *) indexingTdb withIndexing: (struct indexing_context *) indexing
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
return NULL; return NULL;
@ -216,7 +216,7 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri)
+ (int) openContext: (MAPIStoreContext **) contextPtr + (int) openContext: (MAPIStoreContext **) contextPtr
withURI: (const char *) newUri withURI: (const char *) newUri
connectionInfo: (struct mapistore_connection_info *) newConnInfo connectionInfo: (struct mapistore_connection_info *) newConnInfo
andTDBIndexing: (struct tdb_wrap *) indexingTdb andTDBIndexing: (struct indexing_context *) indexing
{ {
MAPIStoreContext *context; MAPIStoreContext *context;
Class contextClass; Class contextClass;
@ -239,7 +239,7 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri)
{ {
context = [[contextClass alloc] initFromURL: baseURL context = [[contextClass alloc] initFromURL: baseURL
withConnectionInfo: newConnInfo withConnectionInfo: newConnInfo
andTDBIndexing: indexingTdb]; andTDBIndexing: indexing];
if (context) if (context)
{ {
[context autorelease]; [context autorelease];
@ -272,7 +272,7 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri)
- (id) initFromURL: (NSURL *) newUrl - (id) initFromURL: (NSURL *) newUrl
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
andTDBIndexing: (struct tdb_wrap *) indexingTdb andTDBIndexing: (struct indexing_context *) indexing
{ {
NSString *username; NSString *username;
@ -291,7 +291,7 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri)
ASSIGN (userContext, ASSIGN (userContext,
[MAPIStoreUserContext userContextWithUsername: username [MAPIStoreUserContext userContextWithUsername: username
andTDBIndexing: indexingTdb]); andTDBIndexing: indexing]);
#if 0 #if 0
mapistore_mgmt_backend_register_user (newConnInfo, mapistore_mgmt_backend_register_user (newConnInfo,

View File

@ -45,7 +45,7 @@
} }
+ (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName + (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName
withTDBIndexing: (struct tdb_wrap *) indexingTdb withIndexing: (struct indexing_context *) indexing
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
struct mapistore_contexts_list *firstContext = NULL, *context; struct mapistore_contexts_list *firstContext = NULL, *context;
@ -72,7 +72,7 @@
inContainer: nil]; inContainer: nil];
[root setOwner: userName]; [root setOwner: userName];
userContext = [MAPIStoreUserContext userContextWithUsername: userName userContext = [MAPIStoreUserContext userContextWithUsername: userName
andTDBIndexing: indexingTdb]; andTDBIndexing: indexing];
[userContext ensureFolderTableExists]; [userContext ensureFolderTableExists];
[root setTableUrl: [userContext folderTableURL]]; [root setTableUrl: [userContext folderTableURL]];
names = [root toManyRelationshipKeys]; names = [root toManyRelationshipKeys];

View File

@ -64,7 +64,7 @@
} }
+ (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName + (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName
withTDBIndexing: (struct tdb_wrap *) indexingTdb withIndexing: (struct indexing_context *) indexing
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
struct mapistore_contexts_list *firstContext = NULL, *context; struct mapistore_contexts_list *firstContext = NULL, *context;
@ -79,7 +79,7 @@
if (moduleName) if (moduleName)
{ {
userContext = [MAPIStoreUserContext userContextWithUsername: userName userContext = [MAPIStoreUserContext userContextWithUsername: userName
andTDBIndexing: indexingTdb]; andTDBIndexing: indexing];
parentFolder = [[userContext rootFolders] objectForKey: moduleName]; parentFolder = [[userContext rootFolders] objectForKey: moduleName];
baseUrl = [NSString stringWithFormat: @"sogo://%@@%@/", baseUrl = [NSString stringWithFormat: @"sogo://%@@%@/",
userName, moduleName]; userName, moduleName];

View File

@ -83,7 +83,7 @@ MakeDisplayFolderName (NSString *folderName)
} }
+ (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName + (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName
withTDBIndexing: (struct tdb_wrap *) indexingTdb withIndexing: (struct indexing_context *) indexing
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
struct mapistore_contexts_list *firstContext = NULL, *context; struct mapistore_contexts_list *firstContext = NULL, *context;
@ -100,7 +100,7 @@ MakeDisplayFolderName (NSString *folderName)
WOContext *woContext; WOContext *woContext;
userContext = [MAPIStoreUserContext userContextWithUsername: userName userContext = [MAPIStoreUserContext userContextWithUsername: userName
andTDBIndexing: indexingTdb]; andTDBIndexing: indexing];
accountFolder = [[userContext rootFolders] objectForKey: @"mail"]; accountFolder = [[userContext rootFolders] objectForKey: @"mail"];
woContext = [userContext woContext]; woContext = [userContext woContext];
@ -245,7 +245,7 @@ MakeDisplayFolderName (NSString *folderName)
} }
+ (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName + (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName
withTDBIndexing: (struct tdb_wrap *) indexingTdb withIndexing: (struct indexing_context *) indexing
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
struct mapistore_contexts_list *context; struct mapistore_contexts_list *context;
@ -256,7 +256,7 @@ MakeDisplayFolderName (NSString *folderName)
WOContext *woContext; WOContext *woContext;
userContext = [MAPIStoreUserContext userContextWithUsername: userName userContext = [MAPIStoreUserContext userContextWithUsername: userName
andTDBIndexing: indexingTdb]; andTDBIndexing: indexing];
accountFolder = [[userContext rootFolders] objectForKey: @"mail"]; accountFolder = [[userContext rootFolders] objectForKey: @"mail"];
woContext = [userContext woContext]; woContext = [userContext woContext];

View File

@ -32,17 +32,17 @@
{ {
void *memCtx; void *memCtx;
NSString *username; NSString *username;
struct tdb_wrap *indexing; struct indexing_context *indexing;
NSMutableDictionary *mapping; /* FID/MID -> url */ NSMutableDictionary *mapping; /* FID/MID -> url */
NSMutableDictionary *reverseMapping; /* url -> FID/MID */ NSMutableDictionary *reverseMapping; /* url -> FID/MID */
NSUInteger useCount; NSUInteger useCount;
} }
+ (id) mappingForUsername: (NSString *) username + (id) mappingForUsername: (NSString *) username
withIndexing: (struct tdb_wrap *) indexing; withIndexing: (struct indexing_context *) indexing;
- (id) initForUsername: (NSString *) username - (id) initForUsername: (NSString *) username
withIndexing: (struct tdb_wrap *) indexing; withIndexing: (struct indexing_context *) indexing;
- (void) increaseUseCount; - (void) increaseUseCount;

View File

@ -39,10 +39,6 @@
#include <talloc.h> #include <talloc.h>
#include <tdb.h> #include <tdb.h>
struct tdb_wrap {
struct tdb_context *tdb;
};
static NSMutableDictionary *mappingRegistry = nil; static NSMutableDictionary *mappingRegistry = nil;
@ -103,7 +99,7 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2,
} }
+ (id) mappingForUsername: (NSString *) username + (id) mappingForUsername: (NSString *) username
withIndexing: (struct tdb_wrap *) indexing withIndexing: (struct indexing_context *) indexing
{ {
id mapping; id mapping;
@ -153,7 +149,7 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2,
} }
- (id) initForUsername: (NSString *) newUsername - (id) initForUsername: (NSString *) newUsername
withIndexing: (struct tdb_wrap *) newIndexing withIndexing: (struct indexing_context *) newIndexing
{ {
NSString *idNbr, *uri; NSString *idNbr, *uri;
NSArray *keys; NSArray *keys;

View File

@ -38,7 +38,7 @@
} }
+ (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName + (struct mapistore_contexts_list *) listContextsForUser: (NSString *) userName
withTDBIndexing: (struct tdb_wrap *) indexingTdb withIndexing: (struct indexing_context *) indexing
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
struct mapistore_contexts_list *context; struct mapistore_contexts_list *context;

View File

@ -144,7 +144,7 @@ sogo_backend_init (void)
static enum mapistore_error static enum mapistore_error
sogo_backend_create_context(TALLOC_CTX *mem_ctx, sogo_backend_create_context(TALLOC_CTX *mem_ctx,
struct mapistore_connection_info *conn_info, struct mapistore_connection_info *conn_info,
struct tdb_wrap *indexingTdb, struct indexing_context *indexing,
const char *uri, void **context_object) const char *uri, void **context_object)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
@ -161,7 +161,7 @@ sogo_backend_create_context(TALLOC_CTX *mem_ctx,
rc = [MAPIStoreContextK openContext: &context rc = [MAPIStoreContextK openContext: &context
withURI: uri withURI: uri
connectionInfo: conn_info connectionInfo: conn_info
andTDBIndexing: indexingTdb]; andTDBIndexing: indexing];
if (rc == MAPISTORE_SUCCESS) if (rc == MAPISTORE_SUCCESS)
*context_object = [context tallocWrapper: mem_ctx]; *context_object = [context tallocWrapper: mem_ctx];
} }
@ -178,7 +178,7 @@ static enum mapistore_error
sogo_backend_create_root_folder (const char *username, sogo_backend_create_root_folder (const char *username,
enum mapistore_context_role role, enum mapistore_context_role role,
uint64_t fid, const char *name, uint64_t fid, const char *name,
// struct tdb_wrap *indexingTdb, // struct indexing_context *indexing,
TALLOC_CTX *mem_ctx, char **mapistore_urip) TALLOC_CTX *mem_ctx, char **mapistore_urip)
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
@ -213,7 +213,7 @@ sogo_backend_create_root_folder (const char *username,
} }
static enum mapistore_error static enum mapistore_error
sogo_backend_list_contexts(const char *username, struct tdb_wrap *indexingTdb, sogo_backend_list_contexts(const char *username, struct indexing_context *indexing,
TALLOC_CTX *mem_ctx, TALLOC_CTX *mem_ctx,
struct mapistore_contexts_list **contexts_listp) struct mapistore_contexts_list **contexts_listp)
{ {
@ -230,7 +230,7 @@ sogo_backend_list_contexts(const char *username, struct tdb_wrap *indexingTdb,
{ {
userName = [NSString stringWithUTF8String: username]; userName = [NSString stringWithUTF8String: username];
*contexts_listp = [MAPIStoreContextK listAllContextsForUser: userName *contexts_listp = [MAPIStoreContextK listAllContextsForUser: userName
withTDBIndexing: indexingTdb withIndexing: indexing
inMemCtx: mem_ctx]; inMemCtx: mem_ctx];
rc = MAPISTORE_SUCCESS; rc = MAPISTORE_SUCCESS;
} }

View File

@ -63,10 +63,10 @@
} }
+ (id) userContextWithUsername: (NSString *) username + (id) userContextWithUsername: (NSString *) username
andTDBIndexing: (struct tdb_wrap *) indexingTdb; andTDBIndexing: (struct indexing_context *) indexing;
- (id) initWithUsername: (NSString *) newUsername - (id) initWithUsername: (NSString *) newUsername
andTDBIndexing: (struct tdb_wrap *) indexingTdb; andTDBIndexing: (struct indexing_context *) indexing;
- (NSString *) username; - (NSString *) username;
- (SOGoUser *) sogoUser; - (SOGoUser *) sogoUser;

View File

@ -60,7 +60,7 @@ static NSMapTable *contextsTable = nil;
} }
+ (id) userContextWithUsername: (NSString *) username + (id) userContextWithUsername: (NSString *) username
andTDBIndexing: (struct tdb_wrap *) indexingTdb; andTDBIndexing: (struct indexing_context *) indexing;
{ {
id userContext; id userContext;
@ -68,7 +68,7 @@ static NSMapTable *contextsTable = nil;
if (!userContext) if (!userContext)
{ {
userContext = [[self alloc] initWithUsername: username userContext = [[self alloc] initWithUsername: username
andTDBIndexing: indexingTdb]; andTDBIndexing: indexing];
[userContext autorelease]; [userContext autorelease];
[contextsTable setObject: userContext forKey: username]; [contextsTable setObject: userContext forKey: username];
} }
@ -125,7 +125,7 @@ static NSMapTable *contextsTable = nil;
} }
- (id) initWithUsername: (NSString *) newUsername - (id) initWithUsername: (NSString *) newUsername
andTDBIndexing: (struct tdb_wrap *) indexingTdb andTDBIndexing: (struct indexing_context *) indexing
{ {
NSString *userPassword; NSString *userPassword;
@ -133,9 +133,9 @@ static NSMapTable *contextsTable = nil;
{ {
/* "username" will be retained by table */ /* "username" will be retained by table */
username = newUsername; username = newUsername;
if (indexingTdb) if (indexing)
ASSIGN (mapping, [MAPIStoreMapping mappingForUsername: username ASSIGN (mapping, [MAPIStoreMapping mappingForUsername: username
withIndexing: indexingTdb]); withIndexing: indexing]);
authenticator = [MAPIStoreAuthenticator new]; authenticator = [MAPIStoreAuthenticator new];
[authenticator setUsername: username]; [authenticator setUsername: username];