[evolution-data-server] EClient: Remove internal property cache.



commit 4d53616a866b9d433f6b9182db534c007d8ad291
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Jan 26 10:51:26 2013 -0500

    EClient: Remove internal property cache.
    
    GDBusProxy already caches property values, so no need for this.

 calendar/libecal/e-cal-client.c   |  102 ++++--------------------------------
 libedataserver/e-client-private.h |    3 -
 libedataserver/e-client.c         |   48 -----------------
 3 files changed, 12 insertions(+), 141 deletions(-)
---
diff --git a/calendar/libecal/e-cal-client.c b/calendar/libecal/e-cal-client.c
index 3571a5b..5403c96 100644
--- a/calendar/libecal/e-cal-client.c
+++ b/calendar/libecal/e-cal-client.c
@@ -540,32 +540,6 @@ icalcomponent_slist_to_string_slist (GSList *icalcomponents)
 	return g_slist_reverse (strings);
 }
 
-static gboolean
-cal_client_get_backend_property_from_cache_finish (EClient *client,
-                                                   GAsyncResult *result,
-                                                   gchar **prop_value,
-                                                   GError **error)
-{
-	GSimpleAsyncResult *simple;
-	GError *local_error = NULL;
-
-	g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
-	g_return_val_if_fail (result != NULL, FALSE);
-	g_return_val_if_fail (prop_value != NULL, FALSE);
-	g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (client), cal_client_get_backend_property_from_cache_finish), FALSE);
-
-	simple = G_SIMPLE_ASYNC_RESULT (result);
-
-	if (g_simple_async_result_propagate_error (simple, &local_error)) {
-		e_client_unwrap_dbus_error (client, local_error, error);
-		return FALSE;
-	}
-
-	*prop_value = g_strdup (g_simple_async_result_get_op_res_gpointer (simple));
-
-	return *prop_value != NULL;
-}
-
 static void
 cal_client_set_source_type (ECalClient *cal_client,
                             ECalClientSourceType source_type)
@@ -714,17 +688,10 @@ cal_client_get_backend_property (EClient *client,
                                  GAsyncReadyCallback callback,
                                  gpointer user_data)
 {
-	gchar *prop_value;
-
-	prop_value = e_client_get_backend_property_from_cache (client, prop_name);
-	if (prop_value) {
-		e_client_finish_async_without_dbus (client, cancellable, callback, user_data, cal_client_get_backend_property_from_cache_finish, prop_value, g_free);
-	} else {
-		e_client_proxy_call_string_with_res_op_data (
-			client, prop_name, cancellable, callback, user_data, cal_client_get_backend_property, prop_name,
-			e_gdbus_cal_call_get_backend_property,
-			NULL, NULL, e_gdbus_cal_call_get_backend_property_finish, NULL, NULL);
-	}
+	e_client_proxy_call_string_with_res_op_data (
+		client, prop_name, cancellable, callback, user_data, cal_client_get_backend_property, prop_name,
+		e_gdbus_cal_call_get_backend_property,
+		NULL, NULL, e_gdbus_cal_call_get_backend_property_finish, NULL, NULL);
 }
 
 static gboolean
@@ -733,26 +700,9 @@ cal_client_get_backend_property_finish (EClient *client,
                                         gchar **prop_value,
                                         GError **error)
 {
-	gchar *str = NULL;
-	gboolean res;
-
 	g_return_val_if_fail (prop_value != NULL, FALSE);
 
-	if (g_simple_async_result_get_source_tag (G_SIMPLE_ASYNC_RESULT (result)) == cal_client_get_backend_property_from_cache_finish) {
-		res = cal_client_get_backend_property_from_cache_finish (client, result, &str, error);
-	} else {
-		res = e_client_proxy_call_finish_string (client, result, &str, error, cal_client_get_backend_property);
-		if (res && str) {
-			const gchar *prop_name = g_object_get_data (G_OBJECT (result), "res-op-data");
-
-			if (prop_name && *prop_name)
-				e_client_update_backend_property_cache (client, prop_name, str);
-		}
-	}
-
-	*prop_value = str;
-
-	return res;
+	return e_client_proxy_call_finish_string (client, result, prop_value, error, cal_client_get_backend_property);
 }
 
 static gboolean
@@ -763,8 +713,6 @@ cal_client_get_backend_property_sync (EClient *client,
                                       GError **error)
 {
 	ECalClient *cal_client;
-	gchar *prop_val;
-	gboolean res;
 
 	g_return_val_if_fail (E_IS_CAL_CLIENT (client), FALSE);
 
@@ -775,21 +723,7 @@ cal_client_get_backend_property_sync (EClient *client,
 		return FALSE;
 	}
 
-	prop_val = e_client_get_backend_property_from_cache (client, prop_name);
-	if (prop_val) {
-		g_return_val_if_fail (prop_value != NULL, FALSE);
-
-		*prop_value = prop_val;
-
-		return TRUE;
-	}
-
-	res = e_client_proxy_call_sync_string__string (client, prop_name, prop_value, cancellable, error, e_gdbus_cal_call_get_backend_property_sync);
-
-	if (res && prop_value)
-		e_client_update_backend_property_cache (client, prop_name, *prop_value);
-
-	return res;
+	return e_client_proxy_call_sync_string__string (client, prop_name, prop_value, cancellable, error, e_gdbus_cal_call_get_backend_property_sync);
 }
 
 static gboolean
@@ -1306,9 +1240,7 @@ e_cal_client_get_local_attachment_store (ECalClient *client)
 	if (client->priv->cache_dir || !client->priv->dbus_proxy)
 		return client->priv->cache_dir;
 
-	cache_dir = e_client_get_backend_property_from_cache (E_CLIENT (client), CLIENT_BACKEND_PROPERTY_CACHE_DIR);
-	if (!cache_dir)
-		e_gdbus_cal_call_get_backend_property_sync (client->priv->dbus_proxy, CLIENT_BACKEND_PROPERTY_CACHE_DIR, &cache_dir, NULL, &error);
+	e_gdbus_cal_call_get_backend_property_sync (client->priv->dbus_proxy, CLIENT_BACKEND_PROPERTY_CACHE_DIR, &cache_dir, NULL, &error);
 
 	if (error == NULL) {
 		client->priv->cache_dir = cache_dir;
@@ -2731,18 +2663,12 @@ e_cal_client_get_default_object (ECalClient *client,
                                  GAsyncReadyCallback callback,
                                  gpointer user_data)
 {
-	gchar *prop_value;
 	EClient *base_client = E_CLIENT (client);
 
-	prop_value = e_client_get_backend_property_from_cache (base_client, CAL_BACKEND_PROPERTY_DEFAULT_OBJECT);
-	if (prop_value) {
-		e_client_finish_async_without_dbus (base_client, cancellable, callback, user_data, cal_client_get_default_object_from_cache_finish, prop_value, g_free);
-	} else {
-		e_client_proxy_call_string (
-			base_client, CAL_BACKEND_PROPERTY_DEFAULT_OBJECT, cancellable, callback, user_data, e_cal_client_get_default_object,
-			e_gdbus_cal_call_get_backend_property,
-			NULL, NULL, e_gdbus_cal_call_get_backend_property_finish, NULL, NULL);
-	}
+	e_client_proxy_call_string (
+		base_client, CAL_BACKEND_PROPERTY_DEFAULT_OBJECT, cancellable, callback, user_data, e_cal_client_get_default_object,
+		e_gdbus_cal_call_get_backend_property,
+		NULL, NULL, e_gdbus_cal_call_get_backend_property_finish, NULL, NULL);
 }
 
 static gboolean
@@ -2844,11 +2770,7 @@ e_cal_client_get_default_object_sync (ECalClient *client,
 		return FALSE;
 	}
 
-	out_string = e_client_get_backend_property_from_cache (E_CLIENT (client), CAL_BACKEND_PROPERTY_DEFAULT_OBJECT);
-	if (out_string)
-		res = TRUE;
-	else
-		res = e_client_proxy_call_sync_string__string (E_CLIENT (client), CAL_BACKEND_PROPERTY_DEFAULT_OBJECT, &out_string, cancellable, error, e_gdbus_cal_call_get_backend_property_sync);
+	res = e_client_proxy_call_sync_string__string (E_CLIENT (client), CAL_BACKEND_PROPERTY_DEFAULT_OBJECT, &out_string, cancellable, error, e_gdbus_cal_call_get_backend_property_sync);
 
 	return complete_get_object (res, out_string, icalcomp, TRUE, error);
 }
diff --git a/libedataserver/e-client-private.h b/libedataserver/e-client-private.h
index f1da0c4..826853e 100644
--- a/libedataserver/e-client-private.h
+++ b/libedataserver/e-client-private.h
@@ -37,9 +37,6 @@ void		e_client_emit_backend_error	(EClient *client, const gchar *error_msg);
 void		e_client_emit_backend_died	(EClient *client);
 void		e_client_emit_backend_property_changed   (EClient *client, const gchar *prop_name, const gchar *prop_value);
 
-void		e_client_update_backend_property_cache   (EClient *client, const gchar *prop_name, const gchar *prop_value);
-gchar *		e_client_get_backend_property_from_cache (EClient *client, const gchar *prop_name);
-
 /* protected functions simplifying sync/async calls */
 void		e_client_finish_async_without_dbus (EClient *client, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data, gpointer soure_tag, gpointer op_res, GDestroyNotify destroy_op_res);
 GDBusProxy *	e_client_get_dbus_proxy		(EClient *client);
diff --git a/libedataserver/e-client.c b/libedataserver/e-client.c
index 62f1fbc..c92b2a6 100644
--- a/libedataserver/e-client.c
+++ b/libedataserver/e-client.c
@@ -48,8 +48,6 @@ struct _EClientPrivate {
 	gboolean capabilities_retrieved;
 	GSList *capabilities;
 
-	GHashTable *backend_property_cache;
-
 	GRecMutex ops_mutex;
 	guint32 last_opid;
 	GHashTable *ops; /* opid to GCancellable */
@@ -206,7 +204,6 @@ e_client_init (EClient *client)
 	client->priv->readonly = TRUE;
 
 	g_rec_mutex_init (&client->priv->prop_mutex);
-	client->priv->backend_property_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 
 	g_rec_mutex_init (&client->priv->ops_mutex);
 	client->priv->last_opid = 0;
@@ -249,11 +246,6 @@ client_finalize (GObject *object)
 		priv->capabilities = NULL;
 	}
 
-	if (priv->backend_property_cache) {
-		g_hash_table_destroy (priv->backend_property_cache);
-		priv->backend_property_cache = NULL;
-	}
-
 	if (priv->ops) {
 		g_hash_table_destroy (priv->ops);
 		priv->ops = NULL;
@@ -1293,49 +1285,9 @@ e_client_emit_backend_property_changed (EClient *client,
 	g_return_if_fail (*prop_name);
 	g_return_if_fail (prop_value != NULL);
 
-	e_client_update_backend_property_cache (client, prop_name, prop_value);
-
 	g_signal_emit (client, signals[BACKEND_PROPERTY_CHANGED], 0, prop_name, prop_value);
 }
 
-void
-e_client_update_backend_property_cache (EClient *client,
-                                        const gchar *prop_name,
-                                        const gchar *prop_value)
-{
-	g_return_if_fail (E_IS_CLIENT (client));
-	g_return_if_fail (prop_name != NULL);
-	g_return_if_fail (*prop_name);
-	g_return_if_fail (prop_value != NULL);
-
-	g_rec_mutex_lock (&client->priv->prop_mutex);
-
-	if (client->priv->backend_property_cache)
-		g_hash_table_insert (client->priv->backend_property_cache, g_strdup (prop_name), g_strdup (prop_value));
-
-	g_rec_mutex_unlock (&client->priv->prop_mutex);
-}
-
-gchar *
-e_client_get_backend_property_from_cache (EClient *client,
-                                          const gchar *prop_name)
-{
-	gchar *prop_value = NULL;
-
-	g_return_val_if_fail (E_IS_CLIENT (client), NULL);
-	g_return_val_if_fail (prop_name != NULL, NULL);
-	g_return_val_if_fail (*prop_name, NULL);
-
-	g_rec_mutex_lock (&client->priv->prop_mutex);
-
-	if (client->priv->backend_property_cache)
-		prop_value = g_strdup (g_hash_table_lookup (client->priv->backend_property_cache, prop_name));
-
-	g_rec_mutex_unlock (&client->priv->prop_mutex);
-
-	return prop_value;
-}
-
 /**
  * e_client_retrieve_capabilities:
  * @client: an #EClient



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