[evolution-mapi] Adapt to libedata-book and libedata-cal API changes.



commit 991e4546035c1b6b4253df697a89dd3665a4db62
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Jul 21 08:12:25 2010 -0400

    Adapt to libedata-book and libedata-cal API changes.
    
    Bumps minimum E-D-S requirement to 2.31.6.

 configure.ac                                       |    2 +-
 .../exchange-mapi-account-setup.h                  |    2 -
 src/addressbook/e-book-backend-mapi.c              |   39 ++-------
 src/calendar/e-cal-backend-mapi.c                  |   89 +++++++------------
 src/camel/camel-mapi-folder.h                      |    2 -
 src/libexchangemapi/exchange-mapi-cal-utils.c      |    8 +--
 src/libexchangemapi/exchange-mapi-connection.c     |    7 +-
 7 files changed, 50 insertions(+), 99 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3876f27..079f6db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@ EDS_PACKAGE=1.2
 dnl *******************
 dnl Required Packages
 dnl *******************
-m4_define([eds_minimum_version], [2.31.1])
+m4_define([eds_minimum_version], [2.31.6])
 m4_define([evo_minimum_version], [2.31.1])
 m4_define([libmapi_minimum_version], [0.9])
 m4_define([glib_minimum_version], [2.16.1])
diff --git a/src/account-setup-eplugin/exchange-mapi-account-setup.h b/src/account-setup-eplugin/exchange-mapi-account-setup.h
index 0cab23b..9d5eb34 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-setup.h
+++ b/src/account-setup-eplugin/exchange-mapi-account-setup.h
@@ -29,8 +29,6 @@
 /* This definition should be in-sync with the definition in camel-mapi-store.c */
 #define EXCHANGE_MAPI_PASSWORD_COMPONENT "ExchangeMAPI"
 
-#define DEFAULT_PROF_PATH ".evolution/mapi-profiles.ldb"
-
 #define MAPI_URI_PREFIX   "mapi://" 
 #define MAPI_PREFIX_LENGTH 7
 
diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index 528114f..30b9f20 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -126,32 +126,6 @@ static const struct field_element_mapping {
 	/* { E_CONTACT_CATEGORIES, } */
 	};
 
-static gchar *
-ebbm_get_filename_from_uri (const gchar *uri, const gchar *file)
-{
-	gchar *mangled_uri, *filename;
-	gint i;
-
-	/* mangle the URI to not contain invalid characters */
-	mangled_uri = g_strdup (uri);
-	for (i = 0; i < strlen (mangled_uri); i++) {
-		switch (mangled_uri[i]) {
-		case ':' :
-		case '/' :
-			mangled_uri[i] = '_';
-		}
-	}
-
-	/* generate the file name */
-	filename = g_build_filename (g_get_home_dir (), ".evolution", "cache", "addressbook",
-				     mangled_uri, file, NULL);
-
-	/* free memory */
-	g_free (mangled_uri);
-
-	return filename;
-}
-
 static gboolean
 ebbm_get_cache_time (EBookBackendMAPI *ebma, glong *cache_seconds)
 {
@@ -406,6 +380,7 @@ ebbm_load_source (EBookBackendMAPI *ebma, ESource *source, gboolean only_if_exis
 {
 	EBookBackendMAPIPrivate *priv = ebma->priv;
 	const gchar *offline;
+	const gchar *cache_dir;
 	gchar *summary_file_name;
 
 	if (e_book_backend_is_loaded (E_BOOK_BACKEND (ebma)))
@@ -421,7 +396,8 @@ ebbm_load_source (EBookBackendMAPI *ebma, ESource *source, gboolean only_if_exis
 	g_free (priv->profile);
 	priv->profile = g_strdup (e_source_get_property (source, "profile"));
 
-	summary_file_name = ebbm_get_filename_from_uri (priv->book_uri, "cache.summary");
+	cache_dir = e_book_backend_get_cache_dir (E_BOOK_BACKEND (ebma));
+	summary_file_name = g_build_filename (cache_dir, "cache.summary", NULL);
 	if (priv->summary)
 		g_object_unref (priv->summary);
 	priv->summary = e_book_backend_summary_new (summary_file_name, SUMMARY_FLUSH_TIMEOUT_SECS * 1000);
@@ -432,7 +408,7 @@ ebbm_load_source (EBookBackendMAPI *ebma, ESource *source, gboolean only_if_exis
 
 	if (priv->cache)
 		g_object_unref (priv->cache);
-	priv->cache = e_book_backend_cache_new (priv->book_uri);
+	priv->cache = e_book_backend_cache_new (summary_file_name);
 
 	g_free (summary_file_name);
 
@@ -459,6 +435,7 @@ static void
 ebbm_remove (EBookBackendMAPI *ebma, GError **error)
 {
 	EBookBackendMAPIPrivate *priv;
+	const gchar *cache_dir;
 	gchar *filename;
 
 	e_return_data_book_error_if_fail (ebma != NULL, E_DATA_BOOK_STATUS_INVALID_ARG);
@@ -482,12 +459,14 @@ ebbm_remove (EBookBackendMAPI *ebma, GError **error)
 		priv->cache = NULL;
 	}
 
-	filename = ebbm_get_filename_from_uri (priv->book_uri, "cache.summary");
+	cache_dir = e_book_backend_get_cache_dir (E_BOOK_BACKEND (ebma));
+
+	filename = g_build_filename (cache_dir, "cache.summary", NULL);
 	if (g_file_test (filename, G_FILE_TEST_EXISTS))
 			g_unlink (filename);
 	g_free (filename);
 
-	filename = ebbm_get_filename_from_uri (priv->book_uri, "cache.xml");
+	filename = g_build_filename (cache_dir, "cache.xml", NULL);
 	if (g_file_test (filename, G_FILE_TEST_EXISTS))
 			g_unlink (filename);
 	g_free (filename);
diff --git a/src/calendar/e-cal-backend-mapi.c b/src/calendar/e-cal-backend-mapi.c
index 60ba38f..9c29e90 100644
--- a/src/calendar/e-cal-backend-mapi.c
+++ b/src/calendar/e-cal-backend-mapi.c
@@ -93,8 +93,6 @@ struct _ECalBackendMAPIPrivate {
 	/* timeout handler for syncing sendoptions */
 	guint			sendoptions_sync_timeout;
 
-	gchar			*local_attachments_store;
-
 	/* used exclusively for delta fetching */
 	guint			timeout_id;
 	GThread			*dthread;
@@ -136,17 +134,6 @@ mapi_error_to_edc_error (GError **perror, const GError *mapi_error, EDataCalCall
 }
 
 /* **** UTILITY FUNCTIONS **** */
-#if 0
-static const gchar *
-ecbm_get_local_attachments_store (ECalBackendMAPI *cbmapi)
-{
-	ECalBackendMAPIPrivate *priv;
-
-	priv = cbmapi->priv;
-
-	return priv->local_attachments_store;
-}
-#endif
 
 static const gchar *
 ecbm_get_owner_name (ECalBackendMAPI *cbmapi)
@@ -389,11 +376,15 @@ mapi_cal_get_changes_cb (FetchItemsCallbackData *item_data, gpointer data)
 	GSList *attachments = item_data->attachments;
 	ECalBackendMAPI *cbmapi	= data;
 	ECalBackendMAPIPrivate *priv = cbmapi->priv;
-	icalcomponent_kind kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbmapi));
+	icalcomponent_kind kind;
 	gchar *tmp = NULL;
 	ECalComponent *cache_comp = NULL;
+	const gchar *cache_dir;
 	const bool *recurring;
 
+	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbmapi));
+	cache_dir = e_cal_backend_get_cache_dir (E_CAL_BACKEND (cbmapi));
+
 //	exchange_mapi_debug_property_dump (array);
 
 	recurring = NULL;
@@ -413,7 +404,7 @@ mapi_cal_get_changes_cb (FetchItemsCallbackData *item_data, gpointer data)
 	if (cache_comp == NULL) {
 		ECalComponent *comp = exchange_mapi_cal_util_mapi_props_to_comp (item_data->conn, kind, tmp, array,
 									streams, recipients, attachments,
-									priv->local_attachments_store, priv->default_zone);
+									cache_dir, priv->default_zone);
 
 		if (E_IS_CAL_COMPONENT (comp)) {
 			gchar *comp_str;
@@ -446,7 +437,7 @@ mapi_cal_get_changes_cb (FetchItemsCallbackData *item_data, gpointer data)
 
 				comp = exchange_mapi_cal_util_mapi_props_to_comp (item_data->conn, kind, tmp, array,
 									streams, recipients, attachments,
-									priv->local_attachments_store, priv->default_zone);
+									cache_dir, priv->default_zone);
 
 				e_cal_component_commit_sequence (comp);
 				modif_comp_str = e_cal_component_get_as_string (comp);
@@ -1150,10 +1141,14 @@ mapi_cal_cache_create_cb (FetchItemsCallbackData *item_data, gpointer data)
 	GSList *attachments = item_data->attachments;
 	ECalBackendMAPI *cbmapi	= E_CAL_BACKEND_MAPI (data);
 	ECalBackendMAPIPrivate *priv = cbmapi->priv;
-	icalcomponent_kind kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbmapi));
+	icalcomponent_kind kind;
         ECalComponent *comp = NULL;
 	gchar *tmp = NULL;
 	const bool *recurring = NULL;
+	const gchar *cache_dir;
+
+	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbmapi));
+	cache_dir = e_cal_backend_get_cache_dir (E_CAL_BACKEND (cbmapi));
 
 //	exchange_mapi_debug_property_dump (properties);
 
@@ -1179,7 +1174,7 @@ mapi_cal_cache_create_cb (FetchItemsCallbackData *item_data, gpointer data)
 	tmp = exchange_mapi_util_mapi_id_to_string (mid);
 	comp = exchange_mapi_cal_util_mapi_props_to_comp (item_data->conn, kind, tmp, properties,
 							streams, recipients, attachments,
-							priv->local_attachments_store, priv->default_zone);
+							cache_dir, priv->default_zone);
 	g_free (tmp);
 
 	if (E_IS_CAL_COMPONENT (comp)) {
@@ -1396,10 +1391,9 @@ ecbm_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists, const g
 	ECalBackendMAPIPrivate *priv;
 	ECalSourceType source_type;
 	ESource *esource;
-	const gchar *source = NULL, *fid = NULL;
+	const gchar *fid = NULL;
+	const gchar *cache_dir;
 	gchar *filename;
-	gchar *mangled_uri;
-	gint i;
 	gboolean res;
 	uint32_t olFolder = 0;
 
@@ -1423,17 +1417,14 @@ ecbm_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists, const g
 	switch (e_cal_backend_get_kind (E_CAL_BACKEND (cbmapi))) {
 	case ICAL_VEVENT_COMPONENT:
 		source_type = E_CAL_SOURCE_TYPE_EVENT;
-		source = "calendar";
 		olFolder = olFolderCalendar;
 		break;
 	case ICAL_VTODO_COMPONENT:
 		source_type = E_CAL_SOURCE_TYPE_TODO;
-		source = "tasks";
 		olFolder = olFolderTasks;
 		break;
 	case ICAL_VJOURNAL_COMPONENT:
 		source_type = E_CAL_SOURCE_TYPE_JOURNAL;
-		source = "journal";
 		olFolder = olFolderNotes;
 		break;
 	default:
@@ -1447,7 +1438,11 @@ ecbm_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists, const g
 	}
 
 	/* Always create cache here */
-	priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbmapi)), source_type);
+	cache_dir = e_cal_backend_get_cache_dir (backend);
+	filename = g_build_filename (cache_dir, "cache.xml", NULL);
+	priv->cache = e_cal_backend_cache_new (filename);
+	g_free (filename);
+
 	if (!priv->cache) {
 		g_mutex_unlock (priv->mutex);
 		g_propagate_error (perror, EDC_ERROR_EX (OtherError, _("Could not create cache file")));
@@ -1486,28 +1481,6 @@ ecbm_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists, const g
 	exchange_mapi_util_mapi_id_from_string (fid, &priv->fid);
 	priv->olFolder = olFolder;
 
-	/* Set the local attachment store */
-	mangled_uri = g_strdup (e_cal_backend_get_uri (E_CAL_BACKEND (cbmapi)));
-	/* mangle the URI to not contain invalid characters */
-	for (i = 0; i < strlen (mangled_uri); i++) {
-		switch (mangled_uri[i]) {
-		case ':' :
-		case '/' :
-			mangled_uri[i] = '_';
-		}
-	}
-
-	filename = g_build_filename (g_get_home_dir (),
-				     ".evolution/cache/", source,
-				     mangled_uri,
-				     G_DIR_SEPARATOR_S,
-				     NULL);
-
-	g_free (mangled_uri);
-	priv->local_attachments_store =
-		g_filename_to_uri (filename, NULL, NULL);
-	g_free (filename);
-
 	g_mutex_unlock (priv->mutex);
 
 	g_static_mutex_lock (&auth_mutex);
@@ -1656,11 +1629,14 @@ ecbm_create_object (ECalBackend *backend, EDataCal *cal, gchar **calobj, gchar *
 	struct cal_cbdata cbdata = { 0 };
 	struct Binary_r globalid;
 	struct icaltimetype current;
+	const gchar *cache_dir;
 	GError *mapi_error = NULL;
 
 	cbmapi = E_CAL_BACKEND_MAPI (backend);
 	priv = cbmapi->priv;
+
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
+	cache_dir = e_cal_backend_get_cache_dir (E_CAL_BACKEND (backend));
 
 	e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
 	e_return_data_cal_error_if_fail (calobj != NULL && *calobj != NULL, InvalidArg);
@@ -1707,7 +1683,7 @@ ecbm_create_object (ECalBackend *backend, EDataCal *cal, gchar **calobj, gchar *
 		exchange_mapi_cal_util_fetch_recipients (comp, &recipients);
 
 	if (e_cal_component_has_attachments (comp))
-		exchange_mapi_cal_util_fetch_attachments (comp, &attachments, priv->local_attachments_store);
+		exchange_mapi_cal_util_fetch_attachments (comp, &attachments, cache_dir);
 
 	cbdata.kind = kind;
 	cbdata.username = (gchar *) ecbm_get_user_name (cbmapi);
@@ -1854,12 +1830,15 @@ ecbm_modify_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj, Ca
 	gboolean no_increment = FALSE;
 	icalproperty *prop;
 	struct icaltimetype current;
+	const gchar *cache_dir;
 	GError *mapi_error = NULL;
 
 	*old_object = *new_object = NULL;
 	cbmapi = E_CAL_BACKEND_MAPI (backend);
 	priv = cbmapi->priv;
-	kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
+
+	kind = e_cal_backend_get_kind (backend);
+	cache_dir = e_cal_backend_get_cache_dir (backend);
 
 	e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
 	e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
@@ -1913,7 +1892,7 @@ ecbm_modify_object (ECalBackend *backend, EDataCal *cal, const gchar *calobj, Ca
 		exchange_mapi_cal_util_fetch_recipients (comp, &recipients);
 
 	if (e_cal_component_has_attachments (comp))
-		exchange_mapi_cal_util_fetch_attachments (comp, &attachments, priv->local_attachments_store);
+		exchange_mapi_cal_util_fetch_attachments (comp, &attachments, cache_dir);
 
 	e_cal_component_get_uid (comp, &uid);
 //	rid = e_cal_component_get_recurid_as_string (comp);
@@ -2119,11 +2098,14 @@ ecbm_send_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj, GLi
 	ECalBackendMAPIPrivate *priv;
 	icalcomponent_kind kind;
 	icalcomponent *icalcomp;
+	const gchar *cache_dir;
 	GError *mapi_error = NULL;
 
 	cbmapi = E_CAL_BACKEND_MAPI (backend);
 	priv = cbmapi->priv;
+
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (backend));
+	cache_dir = e_cal_backend_get_cache_dir (E_CAL_BACKEND (backend));
 
 	e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
 	e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
@@ -2171,7 +2153,7 @@ ecbm_send_objects (ECalBackend *backend, EDataCal *cal, const gchar *calobj, GLi
 			}
 
 			if (e_cal_component_has_attachments (comp))
-				exchange_mapi_cal_util_fetch_attachments (comp, &attachments, priv->local_attachments_store);
+				exchange_mapi_cal_util_fetch_attachments (comp, &attachments, cache_dir);
 
 			cbdata.kind = kind;
 			cbdata.comp = comp;
@@ -3595,11 +3577,6 @@ ecbm_finalize (GObject *object)
 		priv->owner_email = NULL;
 	}
 
-	if (priv->local_attachments_store) {
-		g_free (priv->local_attachments_store);
-		priv->local_attachments_store = NULL;
-	}
-
 	if (priv->sendoptions_sync_timeout) {
 		g_source_remove (priv->sendoptions_sync_timeout);
 		priv->sendoptions_sync_timeout = 0;
diff --git a/src/camel/camel-mapi-folder.h b/src/camel/camel-mapi-folder.h
index 69a9881..ab8f604 100644
--- a/src/camel/camel-mapi-folder.h
+++ b/src/camel/camel-mapi-folder.h
@@ -28,8 +28,6 @@
 #include <libmapi/libmapi.h>
 #include <exchange-mapi-connection.h>
 
-#define PATH_FOLDER ".evolution/mail/mapi"
-
 /* Standard GObject macros */
 #define CAMEL_TYPE_MAPI_FOLDER \
 	(camel_mapi_folder_get_type ())
diff --git a/src/libexchangemapi/exchange-mapi-cal-utils.c b/src/libexchangemapi/exchange-mapi-cal-utils.c
index 64239e6..f1ae838 100644
--- a/src/libexchangemapi/exchange-mapi-cal-utils.c
+++ b/src/libexchangemapi/exchange-mapi-cal-utils.c
@@ -967,8 +967,6 @@ exchange_mapi_cal_util_mapi_props_to_comp (ExchangeMapiConnection *conn, icalcom
 	return comp;
 }
 
-#define TEMP_ATTACH_STORE ".evolution/cache/tmp"
-
 struct fetch_camel_cal_data {
 	icalcomponent_kind kind;
 	icalproperty_method method;
@@ -982,13 +980,12 @@ fetch_camel_cal_comp_cb (FetchItemsCallbackData *item_data, gpointer data)
 	ECalComponent *comp = NULL;
 	mapi_id_t mid = 0;
 	icalcomponent *icalcomp = NULL;
-	gchar *str = NULL, *smid = NULL, *filename, *fileuri;
+	gchar *str = NULL, *smid = NULL, *fileuri;
 
 	g_return_val_if_fail (item_data != NULL, FALSE);
 	g_return_val_if_fail (fccd != NULL, FALSE);
 
-	filename = g_build_filename (g_get_home_dir (), TEMP_ATTACH_STORE, NULL);
-	fileuri = g_filename_to_uri (filename, NULL, NULL);
+	fileuri = g_filename_to_uri (g_get_tmp_dir (), NULL, NULL);
 
 	if (!comp) {
 		/* read component from a mail, if not found in the calendar */
@@ -1007,7 +1004,6 @@ fetch_camel_cal_comp_cb (FetchItemsCallbackData *item_data, gpointer data)
 	}
 
 	g_free (fileuri);
-	g_free (filename);
 
 	icalcomp = e_cal_util_new_top_level ();
 	icalcomponent_set_method (icalcomp, fccd->method);
diff --git a/src/libexchangemapi/exchange-mapi-connection.c b/src/libexchangemapi/exchange-mapi-connection.c
index dbcb4f5..e27b606 100644
--- a/src/libexchangemapi/exchange-mapi-connection.c
+++ b/src/libexchangemapi/exchange-mapi-connection.c
@@ -28,6 +28,7 @@
 
 #include <glib/gi18n-lib.h>
 #include <camel/camel.h>
+#include <libedataserver/e-data-server-util.h>
 
 #include "exchange-mapi-connection.h"
 #include "exchange-mapi-folder.h"
@@ -35,7 +36,7 @@
 #include "exchange-mapi-mail-utils.h"
 #include <param.h>
 
-#define DEFAULT_PROF_PATH ".evolution/mapi-profiles.ldb"
+#define DEFAULT_PROF_NAME "mapi-profiles.ldb"
 
 static void register_connection (ExchangeMapiConnection *conn);
 static void unregister_connection (ExchangeMapiConnection *conn);
@@ -3461,6 +3462,7 @@ ensure_mapi_init_called (GError **perror)
 {
 	static gboolean called = FALSE;
 	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+	const gchar *user_data_dir;
 	gchar *profpath;
 	enum MAPISTATUS ms;
 
@@ -3470,7 +3472,8 @@ ensure_mapi_init_called (GError **perror)
 		return TRUE;
 	}
 
-	profpath = g_build_filename (g_get_home_dir (), DEFAULT_PROF_PATH, NULL);
+	user_data_dir = e_get_user_data_dir ();
+	profpath = g_build_filename (user_data_dir, DEFAULT_PROF_NAME, NULL);
 
 	if (!g_file_test (profpath, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
 		/* Create a ProfileStore */



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