[evolution-ews] Set the uri for calendar and address-book based on the account uri. The address-book uri adds up the



commit e06e9fbe1b4338ac40cc9639894840b737666546
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Fri Sep 16 16:32:20 2011 +0530

    Set the uri for calendar and address-book based on the account uri.
    The address-book uri adds up the folder_id parameter as the backends are
    stored based on uri unlike calendar which is stored based on uids. For more info.,
    look at e-data-cal-factory.c and e-data-book-factory.c.

 .../exchange-ews-account-listener.c                |   10 ++++++----
 src/calendar/e-cal-backend-ews.c                   |   19 +++++++++++++------
 src/utils/ews-esource-utils.c                      |   10 +++++++---
 3 files changed, 26 insertions(+), 13 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-ews-account-listener.c b/src/account-setup-eplugin/exchange-ews-account-listener.c
index 737d4e7..78207a9 100644
--- a/src/account-setup-eplugin/exchange-ews-account-listener.c
+++ b/src/account-setup-eplugin/exchange-ews-account-listener.c
@@ -226,7 +226,8 @@ add_gal_esource (CamelURL *url)
 	GConfClient* client;
 	const gchar *conf_key, *email_id;
 	const gchar *oal_sel, *tmp, *oal_name;
-	gchar *source_uri, *oal_id = NULL;
+	gchar *oal_id = NULL;
+	gchar *account_uri, *source_uri;
 
 	conf_key = CONTACT_SOURCES;
 	client = gconf_client_get_default ();
@@ -242,9 +243,9 @@ add_gal_esource (CamelURL *url)
 	} else
 		oal_name = _("Global Address list");
 
-	/* hmm is it the right way to do ? */
-	source_uri = g_strdup_printf("ewsgal://%s/gal", oal_id ? oal_id : "nodownload");
-	source = e_source_new_with_absolute_uri (oal_name, source_uri);
+	account_uri = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
+	source_uri = g_strdup_printf ("%s?gal=1", account_uri + strlen (EWS_BASE_URI));
+	source = e_source_new (oal_name, source_uri);
 	
 	/* set properties */
 	e_source_set_property (source, "username", url->user);
@@ -274,6 +275,7 @@ add_gal_esource (CamelURL *url)
 	g_object_unref (source_list);
 	g_object_unref (client);
 	g_free (oal_id);
+	g_free (account_uri);
 	g_free (source_uri);
 
 	return;
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 2d167d3..42b9c5b 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -72,6 +72,7 @@ struct _ECalBackendEwsPrivate {
 	EEwsConnection *cnc;
 	gchar *folder_id;
 	gchar *user_email;
+	gchar *storage_path;
 
 	EDataCal *opening_cal;
 	EServerMethodContext opening_ctx;
@@ -663,6 +664,7 @@ e_cal_backend_ews_open (ECalBackend *backend, EDataCal *cal, EServerMethodContex
 {
 	ECalBackendEws *cbews;
 	ECalBackendEwsPrivate *priv;
+	ESource *esource;
 	const gchar *cache_dir;
 	GError *error = NULL;
 
@@ -670,26 +672,26 @@ e_cal_backend_ews_open (ECalBackend *backend, EDataCal *cal, EServerMethodContex
 	priv = cbews->priv;
 
 	cache_dir = e_cal_backend_get_cache_dir (backend);
+	esource = e_cal_backend_get_source (E_CAL_BACKEND (cbews));
 
 	PRIV_LOCK (priv);
 	if (!priv->store) {
-		priv->store = e_cal_backend_file_store_new (cache_dir);
+		priv->folder_id = e_source_get_duped_property (esource, "folder-id");
+		priv->storage_path = g_build_filename (cache_dir, priv->folder_id, NULL);
+		
+		priv->store = e_cal_backend_file_store_new (priv->storage_path);
 		e_cal_backend_store_load (priv->store);
 		add_comps_to_item_id_hash (cbews);
 		e_cal_backend_store_set_default_timezone (priv->store, priv->default_zone);
 	}
 
 	if (priv->mode != CAL_MODE_LOCAL && !priv->cnc) {
-		ESource *esource;
 		const gchar *host_url;
 
 		/* If we can be called a second time while the first is still
 		   "outstanding", we need a bit of a rethink... */
 		g_assert (!priv->opening_ctx && !priv->opening_cal);
 
-		esource = e_cal_backend_get_source (E_CAL_BACKEND (cbews));
-
-		priv->folder_id = e_source_get_duped_property (esource, "folder-id");
 		priv->user_email = e_source_get_duped_property (esource, "email");
 
 		host_url = e_source_get_property (esource, "hosturl");
@@ -2769,7 +2771,7 @@ ews_get_attachments (ECalBackendEws *cbews, EEwsItem *item)
 							EWS_PRIORITY_MEDIUM,
 							uid,
 							attachment_ids,
-							e_cal_backend_get_cache_dir(E_CAL_BACKEND(cbews)),
+							cbews->priv->storage_path,
 							TRUE,
 							ews_get_attachments_ready_callback,
 							NULL, NULL,
@@ -3644,6 +3646,11 @@ e_cal_backend_ews_finalize (GObject *object)
 		priv->user_email = NULL;
 	}
 
+	if (priv->storage_path) {
+		g_free (priv->storage_path);
+		priv->storage_path = NULL;
+	}
+
 	if (priv->default_zone) {
 		icaltimezone_free (priv->default_zone, 1);
 		priv->default_zone = NULL;
diff --git a/src/utils/ews-esource-utils.c b/src/utils/ews-esource-utils.c
index 285e8e3..87af59d 100644
--- a/src/utils/ews-esource-utils.c
+++ b/src/utils/ews-esource-utils.c
@@ -139,9 +139,12 @@ ews_esource_utils_add_esource	(EEwsFolder *folder,
 	   in *either* calendar or mail code. Note the tricks we have to
 	   play in the calendar back end to make the cache directory
 	   unique again. */
-	source_uri = g_strdup_printf("%s?folderid=%s", account_uri, fid->id);
-	source = e_source_new_with_absolute_uri (source_name, source_uri);
-	g_free (source_uri);
+	if (ftype == EWS_FOLDER_TYPE_CONTACTS)
+		source_uri = g_strdup_printf ("%s?folderid=%s", account_uri + strlen (EWS_BASE_URI), fid->id);
+	else
+		source_uri = g_strdup (account_uri + strlen (EWS_BASE_URI));
+
+	source = e_source_new (source_name, source_uri);
 	e_source_set_property (source, "username", username);
 	e_source_set_property (source, "auth-domain", "Ews");
 	e_source_set_property (source, "folder-id", fid->id);
@@ -152,6 +155,7 @@ ews_esource_utils_add_esource	(EEwsFolder *folder,
 	e_source_set_property (source, "offline_sync", "1");
 	e_source_set_color_spec (source, "#EEBC60");
 
+	g_free (source_uri);
 	/* set props required for contacts */
 	if (ftype == EWS_FOLDER_TYPE_CONTACTS) {
 		e_source_set_property (source, "auth", "plain/password");



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