[evolution-mapi] Bug #636840 - Fails to build with openchange svn trunk (rev 2377)



commit 0a15150dbe067af0f3db9a1a2e9dbcc5b6784cdf
Author: Milan Crha <mcrha redhat com>
Date:   Tue Dec 14 19:50:58 2010 +0100

    Bug #636840 - Fails to build with openchange svn trunk (rev 2377)

 configure.ac                                   |   14 +++
 src/libexchangemapi/exchange-mapi-connection.c |  125 ++++++++++++++++++++----
 src/libexchangemapi/exchange-mapi-connection.h |    1 +
 src/libexchangemapi/exchange-mapi-utils.c      |    2 +-
 4 files changed, 122 insertions(+), 20 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2c8a9ad..a3f27a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -253,6 +253,20 @@ if test "x${ac_cv_have_prf}" = "xno"; then
 fi
 
 dnl ****************************
+dnl Check for MAPIInitialize function with two params
+dnl ****************************
+AC_MSG_CHECKING([libmapi MAPIInitialize function with two params])
+save_cflags=$CFLAGS; CFLAGS=$LIBMAPI_CFLAGS
+save_libs=$LIBS; LIBS="$LIBMAPI_LIBS"
+AC_LINK_IFELSE([AC_LANG_PROGRAM(
+	[[#include <libmapi/libmapi.h>]],
+	[[MAPIInitialize (NULL, NULL)]])],
+	[AC_DEFINE(HAVE_LIBMAPI_CONTEXT_PARAM, 1, [libmapi uses context parameters]) ac_cv_have_lcp=yes],[ac_cv_have_lcp=no])
+CFLAGS=$save_cflags
+LIBS=$save_libs
+AC_MSG_RESULT([$ac_cv_have_lcp])
+
+dnl ****************************
 dnl Expose version information
 dnl ****************************
 API_VERSION=$EDS_PACKAGE
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index c285365..a87dcb8 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -143,6 +143,10 @@ make_mapi_error (GError **perror, const gchar *context, enum MAPISTATUS mapi_sta
 	g_propagate_error (perror, error);
 }
 
+#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+struct mapi_context *mapi_ctx = NULL;
+#endif
+
 typedef struct _ExchangeMapiConnectionPrivate ExchangeMapiConnectionPrivate;
 
 struct _ExchangeMapiConnectionPrivate {
@@ -1304,7 +1308,11 @@ exchange_mapi_util_modify_recipients (ExchangeMapiConnection *conn, TALLOC_CTX *
 	enum MAPISTATUS	ms;
 	struct SPropTagArray	*SPropTagArray = NULL;
 	struct SRowSet		*SRowSet = NULL;
+	#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+	struct PropertyTagArray_r *FlagList = NULL;
+	#else
 	struct SPropTagArray	*FlagList = NULL;
+	#endif
 	GSList			*l;
 	const gchar		**users = NULL;
 	uint32_t		i, j, count = 0;
@@ -2814,7 +2822,11 @@ mapi_move_items (ExchangeMapiConnection *conn, mapi_id_t src_fid, guint32 src_fi
 
 	mapi_object_init(&obj_folder_src);
 	mapi_object_init(&obj_folder_dst);
-	mapi_id_array_init(&msg_id_array);
+	mapi_id_array_init (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		&msg_id_array);
 
 	for (l = mid_list; l != NULL; l = g_slist_next (l))
 		mapi_id_array_add_id (&msg_id_array, *((mapi_id_t *)l->data));
@@ -3353,7 +3365,11 @@ exchange_mapi_connection_ex_to_smtp (ExchangeMapiConnection *conn, const gchar *
 	TALLOC_CTX		*mem_ctx;
 	struct SPropTagArray	*SPropTagArray;
 	struct SRowSet		*SRowSet = NULL;
+	#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+	struct PropertyTagArray_r *flaglist = NULL;
+	#else
 	struct SPropTagArray	*flaglist = NULL;
+	#endif
 	const gchar		*str_array[2];
 	gchar			*smtp_addr = NULL;
 
@@ -3608,7 +3624,11 @@ ensure_mapi_init_called (GError **perror)
 		}
 	}
 
-	ms = MAPIInitialize (profpath);
+	ms = MAPIInitialize (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		&mapi_ctx,
+		#endif
+		profpath);
 	if (ms == MAPI_E_SESSION_LIMIT) {
 		/* do nothing, the profile store is already initialized */
 		/* but this shouldn't happen */
@@ -3670,15 +3690,31 @@ mapi_profile_load (const gchar *profname, const gchar *password, GError **perror
 	/* Initialize libmapi logger*/
 	if (g_getenv ("MAPI_DEBUG")) {
 		debug_log_level = atoi (g_getenv ("MAPI_DEBUG"));
-		SetMAPIDumpData(TRUE);
-		SetMAPIDebugLevel(debug_log_level);
+		SetMAPIDumpData (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			TRUE);
+		SetMAPIDebugLevel (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			debug_log_level);
 	}
 
 	g_debug("Loading profile %s ", profname);
 
-	ms = MapiLogonEx (&session, profname, password);
+	ms = MapiLogonEx (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		&session, profname, password);
 	if (ms == MAPI_E_NOT_FOUND && try_create_profile (profname, password))
-		ms = MapiLogonEx (&session, profname, password);
+		ms = MapiLogonEx (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			&session, profname, password);
 
 	if (ms != MAPI_E_SUCCESS) {
 		make_mapi_error (perror, "MapiLogonEx", ms);
@@ -3723,34 +3759,60 @@ mapi_profile_create (const gchar *username, const gchar *password, const gchar *
 	profname = exchange_mapi_util_profile_name (username, domain, server, TRUE);
 
 	/* Delete any existing profiles with the same profilename */
-	ms = DeleteProfile (profname);
+	ms = DeleteProfile (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		profname);
 	/* don't bother to check error - it would be valid if we got an error */
 
-	ms = CreateProfile (profname, username, password, OC_PROFILE_NOPASSWORD);
+	ms = CreateProfile (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		profname, username, password, OC_PROFILE_NOPASSWORD);
 	if (ms != MAPI_E_SUCCESS) {
 		make_mapi_error (perror, "CreateProfile", ms);
 		goto cleanup;
 	}
 
-	mapi_profile_add_string_attr(profname, "binding", server);
-	mapi_profile_add_string_attr(profname, "workstation", workstation);
-	mapi_profile_add_string_attr(profname, "domain", domain);
+	#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+	#define add_string_attr(_prof,_aname,_val)				\
+		mapi_profile_add_string_attr (mapi_ctx, _prof, _aname, _val)
+	#else
+	#define add_string_attr(_prof,_aname,_val)				\
+		mapi_profile_add_string_attr (_prof, _aname, _val)
+	#endif
+
+	add_string_attr (profname, "binding", server);
+	add_string_attr (profname, "workstation", workstation);
+	add_string_attr (profname, "domain", domain);
 
 	if ((flags & CREATE_PROFILE_FLAG_USE_SSL) != 0)
-		mapi_profile_add_string_attr (profname, "seal", "true");
+		add_string_attr (profname, "seal", "true");
 
 	/* This is only convenient here and should be replaced at some point */
-	mapi_profile_add_string_attr(profname, "codepage", "0x4e4");
-	mapi_profile_add_string_attr(profname, "language", "0x409");
-	mapi_profile_add_string_attr(profname, "method", "0x409");
+	add_string_attr (profname, "codepage", "0x4e4");
+	add_string_attr (profname, "language", "0x409");
+	add_string_attr (profname, "method", "0x409");
+
+	#undef add_string_attr
 
 	/* Login now */
 	g_debug("Logging into the server... ");
-	ms = MapiLogonProvider (&session, profname, password, PROVIDER_ID_NSPI);
+	ms = MapiLogonProvider (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		&session, profname, password, PROVIDER_ID_NSPI);
 	if (ms != MAPI_E_SUCCESS) {
 		make_mapi_error (perror, "MapiLogonProvider", ms);
 		g_debug ("Deleting profile %s ", profname);
-		DeleteProfile (profname);
+		DeleteProfile (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			profname);
 		goto cleanup;
 	}
 	g_debug("MapiLogonProvider : succeeded \n");
@@ -3759,7 +3821,11 @@ mapi_profile_create (const gchar *username, const gchar *password, const gchar *
 	if (ms != MAPI_E_SUCCESS) {
 		make_mapi_error (perror, "ProcessNetworkProfile", ms);
 		g_debug ("Deleting profile %s ", profname);
-		DeleteProfile (profname);
+		DeleteProfile (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			profname);
 		goto cleanup;
 	}
 	g_debug("ProcessNetworkProfile : succeeded \n");
@@ -3813,7 +3879,11 @@ exchange_mapi_delete_profile (const gchar *profile, GError **perror)
 
 		g_debug ("Deleting profile %s ", profile);
 
-		ms = DeleteProfile (profile);
+		ms = DeleteProfile (
+			#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+			mapi_ctx,
+			#endif
+			profile);
 		if (ms == MAPI_E_SUCCESS) {
 			result = TRUE;
 		} else {
@@ -3826,4 +3896,21 @@ exchange_mapi_delete_profile (const gchar *profile, GError **perror)
 	return result;
 }
 
+void
+exchange_mapi_rename_profile (const gchar *old_name, const gchar *new_name)
+{
+	g_return_if_fail (old_name != NULL);
+	g_return_if_fail (new_name != NULL);
+
+	g_static_rec_mutex_lock (&profile_mutex);
+
+	RenameProfile (
+		#ifdef HAVE_LIBMAPI_CONTEXT_PARAM
+		mapi_ctx,
+		#endif
+		old_name, new_name);
+
+	g_static_rec_mutex_unlock (&profile_mutex);
+}
+
 /* profile related functions - end */
diff --git a/src/libexchangemapi/exchange-mapi-connection.h b/src/libexchangemapi/exchange-mapi-connection.h
index 49948cb..4287dc1 100644
--- a/src/libexchangemapi/exchange-mapi-connection.h
+++ b/src/libexchangemapi/exchange-mapi-connection.h
@@ -240,6 +240,7 @@ gboolean		exchange_mapi_create_profile (const gchar *username, const gchar *pass
 				       mapi_profile_callback_t cb, gpointer data, GError **perror);
 
 gboolean		exchange_mapi_delete_profile (const gchar *profile, GError **perror);
+void			exchange_mapi_rename_profile (const gchar *old_name, const gchar *new_name);
 
 /* utility functions */
 
diff --git a/src/libexchangemapi/exchange-mapi-utils.c b/src/libexchangemapi/exchange-mapi-utils.c
index a5a04d7..d5adddc 100644
--- a/src/libexchangemapi/exchange-mapi-utils.c
+++ b/src/libexchangemapi/exchange-mapi-utils.c
@@ -947,7 +947,7 @@ exchange_mapi_util_profile_name (const gchar *username, const gchar *domain, con
 		old_name = g_strdup_printf ("%s %s", username, domain);
 		old_name = g_strcanon (old_name, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@", '_');
 
-		RenameProfile (old_name, res);
+		exchange_mapi_rename_profile (old_name, res);
 
 		g_free (old_name);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]