Prior I start implementing multiple session support in libmapi, I think it would be worthwhile to discuss it. This can be done fairly quickly, but we need to ensure initial design can next easily be extended (if needed).
1. What is a MAPI session?
The current libmapi implementation qualify a session as:
- single emsmdb context
- single nspi context
- MAPI profile structure
- MAPI notification context
Recent libmapi progresses on Public Folders address us a
warning: with the current implementation you need to choose
between Mailbox store and PF store context.
A trivial solution would be to add a emsmdb context for PF
within the session, and each time an object is initialized,
associate it to a particular provider kind. E.g.:
PROVIDER_ID_EMSMDB_PF = 0x0,
PROVIDER_ID_EMSMDB= 0x1,
PROVIDER_ID_NSPI=0x2.
Note: In current implementation mapi_object assigns a
mapi_session pointer to the global session (mapi_object_init in
libmapi/mapi_object.c). This may come from a previous design.
mapi_object.diff patch attached fixes this.
2. Outlook 2003 only supports one Exchange account at a time while
libmapi is potentially able to support multiples one.
This would require libmapi to use the mapi_session next/prev pointers or
similar and store a reference to the session ID within each MAPI object.
This would still be threaded-application compatible (session stored in
global context) and would keep mapi_object opaque.
For example we can have:
* mapi_object_get_session call which returns the global_mapi_ctx session
associated to the object.
* mapi_object_get_provider which returns the provider context from the
global session for a given object.
These functions would remain private and get used at the beginning of
each _PUBLIC_ libmapi functions. This would only be needed for libmapi
functions which generate EMSMDB/NSPI traffic.
--
Julien Kerihuel
[EMAIL PROTECTED]
OpenChange Project Manager
GPG Fingerprint: 0B55 783D A781 6329 108A B609 7EF6 FE11 A35F 1F79
Index: libmapi/mapi_object.c
===================================================================
--- libmapi/mapi_object.c (revision 240)
+++ libmapi/mapi_object.c (working copy)
@@ -37,7 +37,6 @@
{
obj->handle = INVALID_HANDLE_VALUE;
obj->id = 0;
- obj->session = 0;
obj->handles = 0;
obj->private_data = 0;
}
@@ -48,7 +47,6 @@
MAPI_RETVAL_IF(!global_mapi_ctx, MAPI_E_NOT_INITIALIZED, NULL);
- obj->session = global_mapi_ctx->session;
return MAPI_E_SUCCESS;
}
Index: libmapi/mapi_object.h
===================================================================
--- libmapi/mapi_object.h (revision 236)
+++ libmapi/mapi_object.h (working copy)
@@ -42,7 +42,6 @@
typedef struct mapi_object {
uint64_t id;
mapi_handle_t handle;
- struct mapi_session *session;
struct mapi_handles *handles;
void *private_data;
} mapi_object_t;
Index: libmapi/IMAPIProp.c
===================================================================
--- libmapi/IMAPIProp.c (revision 236)
+++ libmapi/IMAPIProp.c (working copy)
@@ -83,7 +83,7 @@
/* Read the SPropValue array from data blob.
fixme: replace the memory context by the object one.
*/
- mapistatus = emsmdb_get_SPropValue((TALLOC_CTX *)obj->session,
+ mapistatus = emsmdb_get_SPropValue((TALLOC_CTX *)mapi_ctx->session,
&mapi_response->mapi_repl->u.mapi_GetProps.prop_data,
tags, vals, cn_vals,
mapi_response->mapi_repl->u.mapi_GetProps.layout);
@@ -269,7 +269,7 @@
proptags->cValues = mapi_response->mapi_repl->u.mapi_GetPropList.count;
if (proptags->cValues) {
size = proptags->cValues * sizeof(enum MAPITAGS);
- proptags->aulPropTag = talloc_array((TALLOC_CTX *)obj->session,
+ proptags->aulPropTag = talloc_array((TALLOC_CTX *)mapi_ctx->session,
enum MAPITAGS, proptags->cValues);
memcpy((void*)proptags->aulPropTag,
(void*)mapi_response->mapi_repl->u.mapi_GetPropList.tags,
Index: libmapi/IMAPIContainer.c
===================================================================
--- libmapi/IMAPIContainer.c (revision 236)
+++ libmapi/IMAPIContainer.c (working copy)
@@ -75,7 +75,7 @@
mapi_object_set_handle(obj_table, mapi_response->handles[1]);
/* new table */
- obj_table->private_data = talloc((TALLOC_CTX *)obj_table->session, mapi_object_table_t);
+ obj_table->private_data = talloc((TALLOC_CTX *)mapi_ctx->session, mapi_object_table_t);
table = obj_table->private_data;
table->proptags.cValues = 0;
table->proptags.aulPropTag = 0;
@@ -141,7 +141,7 @@
mapi_object_set_handle(obj_table, mapi_response->handles[1]);
/* new table */
- obj_table->private_data = talloc((TALLOC_CTX *)obj_table->session, mapi_object_table_t);
+ obj_table->private_data = talloc((TALLOC_CTX *)mapi_ctx->session, mapi_object_table_t);
table = obj_table->private_data;
table->proptags.cValues = 0;
table->proptags.aulPropTag = 0;
@@ -205,7 +205,7 @@
mapi_object_set_handle(obj_table, mapi_response->handles[1]);
/* new table */
- obj_table->private_data = talloc((TALLOC_CTX *)obj_table->session, mapi_object_table_t);
+ obj_table->private_data = talloc((TALLOC_CTX *)mapi_ctx->session, mapi_object_table_t);
table = obj_table->private_data;
table->proptags.cValues = 0;
table->proptags.aulPropTag = 0;
Index: libmapi/IMAPITable.c
===================================================================
--- libmapi/IMAPITable.c (revision 236)
+++ libmapi/IMAPITable.c (working copy)
@@ -82,7 +82,7 @@
/* recopy property tags into table */
/* fixme: obj_table->private_data should be initialized during opening, not here */
if (obj_table->private_data == 0) {
- obj_table->private_data = talloc((TALLOC_CTX *)obj_table->session, mapi_object_table_t);
+ obj_table->private_data = talloc((TALLOC_CTX *)mapi_ctx->session, mapi_object_table_t);
}
table = (mapi_object_table_t *)obj_table->private_data;
signature.asc
Description: This is a digitally signed message part
_______________________________________________ devel mailing list [email protected] http://mailman.openchange.org/listinfo/devel
