Monotone-Parent: e13446efcded2d880cbb5bb48b3bde3b54faf46e

Monotone-Revision: ac435c09e6aeb4ef0087488eb9403ccc7f5fc64e

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-12-01T22:33:46
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau 2011-12-01 22:33:46 +00:00
parent 49f733033f
commit 6f78e819f9
2 changed files with 34 additions and 17 deletions

View file

@ -1,5 +1,9 @@
2011-12-01 Wolfgang Sourdeau <wsourdeau@inverse.ca> 2011-12-01 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreContext.m (_prepareContextClass): now return
the context via a pointer parameter. Return a proper "enum
mapistore_error" value.
* OpenChange/MAPIStoreCalendarMessage.m (-appointmentWrapper): * OpenChange/MAPIStoreCalendarMessage.m (-appointmentWrapper):
pass the owner user as parameter to the appointment wrapper pass the owner user as parameter to the appointment wrapper
contructor rather than the active user. contructor rather than the active user.

View file

@ -101,17 +101,21 @@ static NSMutableDictionary *contextClassMapping;
} }
} }
static inline MAPIStoreContext * static inline enum mapistore_error
_prepareContextClass (Class contextClass, _prepareContextClass (Class contextClass,
struct mapistore_connection_info *connInfo, struct mapistore_connection_info *connInfo,
struct tdb_wrap *indexingTdb, NSURL *url) struct tdb_wrap *indexingTdb, NSURL *url,
MAPIStoreContext **contextP)
{ {
MAPIStoreContext *context; MAPIStoreContext *context;
MAPIStoreAuthenticator *authenticator; MAPIStoreAuthenticator *authenticator;
enum mapistore_error rc;
context = [[contextClass alloc] initFromURL: url context = [[contextClass alloc] initFromURL: url
withConnectionInfo: connInfo withConnectionInfo: connInfo
andTDBIndexing: indexingTdb]; andTDBIndexing: indexingTdb];
if (context)
{
[context autorelease]; [context autorelease];
authenticator = [MAPIStoreAuthenticator new]; authenticator = [MAPIStoreAuthenticator new];
@ -123,8 +127,18 @@ _prepareContextClass (Class contextClass,
[context setupRequest]; [context setupRequest];
[context setupBaseFolder: url]; [context setupBaseFolder: url];
[context tearDownRequest]; [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 + (int) openContext: (MAPIStoreContext **) contextPtr
@ -157,16 +171,15 @@ _prepareContextClass (Class contextClass,
contextClass = [contextClassMapping objectForKey: module]; contextClass = [contextClassMapping objectForKey: module];
if (contextClass) if (contextClass)
{ {
context = _prepareContextClass (contextClass, rc = _prepareContextClass (contextClass,
newConnInfo, indexingTdb, newConnInfo, indexingTdb,
baseURL); baseURL, &context);
if (context) if (rc == MAPISTORE_SUCCESS)
{ {
*contextPtr = context; *contextPtr = context;
mapistore_mgmt_backend_register_user (newConnInfo, mapistore_mgmt_backend_register_user (newConnInfo,
"SOGo", "SOGo",
[[[context authenticator] username] UTF8String]); [[[context authenticator] username] UTF8String]);
rc = MAPISTORE_SUCCESS;
} }
} }
else else