From 6f78e819f97ff5a9069aaaa86c416da80e1657b1 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 1 Dec 2011 22:33:46 +0000 Subject: [PATCH] Monotone-Parent: e13446efcded2d880cbb5bb48b3bde3b54faf46e Monotone-Revision: ac435c09e6aeb4ef0087488eb9403ccc7f5fc64e Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-12-01T22:33:46 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 +++ OpenChange/MAPIStoreContext.m | 47 ++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e3fba14b..d1ac3b235 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-12-01 Wolfgang Sourdeau + * OpenChange/MAPIStoreContext.m (_prepareContextClass): now return + the context via a pointer parameter. Return a proper "enum + mapistore_error" value. + * OpenChange/MAPIStoreCalendarMessage.m (-appointmentWrapper): pass the owner user as parameter to the appointment wrapper contructor rather than the active user. diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index 3236a4603..07ac7116a 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -101,30 +101,44 @@ static NSMutableDictionary *contextClassMapping; } } -static inline MAPIStoreContext * +static inline enum mapistore_error _prepareContextClass (Class contextClass, struct mapistore_connection_info *connInfo, - struct tdb_wrap *indexingTdb, NSURL *url) + struct tdb_wrap *indexingTdb, NSURL *url, + MAPIStoreContext **contextP) { MAPIStoreContext *context; MAPIStoreAuthenticator *authenticator; + enum mapistore_error rc; context = [[contextClass alloc] initFromURL: url withConnectionInfo: connInfo andTDBIndexing: indexingTdb]; - [context autorelease]; + if (context) + { + [context autorelease]; - authenticator = [MAPIStoreAuthenticator new]; - [authenticator setUsername: [url user]]; - [authenticator setPassword: [url password]]; - [context setAuthenticator: authenticator]; - [authenticator release]; + authenticator = [MAPIStoreAuthenticator new]; + [authenticator setUsername: [url user]]; + [authenticator setPassword: [url password]]; + [context setAuthenticator: authenticator]; + [authenticator release]; - [context setupRequest]; - [context setupBaseFolder: url]; - [context tearDownRequest]; + [context setupRequest]; + [context setupBaseFolder: url]; + [context tearDownRequest]; + if (context->baseFolder && [context->baseFolder sogoObject]) + { + *contextP = context; + rc = MAPISTORE_SUCCESS; + } + else + rc = MAPISTORE_ERR_DENIED; + } + else + rc = MAPISTORE_ERROR; - return context; + return rc; } + (int) openContext: (MAPIStoreContext **) contextPtr @@ -157,16 +171,15 @@ _prepareContextClass (Class contextClass, contextClass = [contextClassMapping objectForKey: module]; if (contextClass) { - context = _prepareContextClass (contextClass, - newConnInfo, indexingTdb, - baseURL); - if (context) + rc = _prepareContextClass (contextClass, + newConnInfo, indexingTdb, + baseURL, &context); + if (rc == MAPISTORE_SUCCESS) { *contextPtr = context; mapistore_mgmt_backend_register_user (newConnInfo, "SOGo", [[[context authenticator] username] UTF8String]); - rc = MAPISTORE_SUCCESS; } } else