[empathy] rely on the factory to prepare TP_CONNECTION_FEATURE_BALANCE



commit fb56e32dcdc0ad78c59c3d34d500a24c954a6ab0
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Thu Aug 18 17:29:56 2011 +0200

    rely on the factory to prepare TP_CONNECTION_FEATURE_BALANCE
    
    https://bugzilla.gnome.org/show_bug.cgi?id=656831

 libempathy/empathy-client-factory.c |    3 ++
 src/empathy-main-window.c           |   36 +++++++---------------------------
 2 files changed, 11 insertions(+), 28 deletions(-)
---
diff --git a/libempathy/empathy-client-factory.c b/libempathy/empathy-client-factory.c
index 200ea5f..d3cc57e 100644
--- a/libempathy/empathy-client-factory.c
+++ b/libempathy/empathy-client-factory.c
@@ -146,6 +146,9 @@ empathy_client_factory_dup_connection_features (TpSimpleClientFactory *factory,
   feature = TP_CONNECTION_FEATURE_CONTACT_INFO;
   g_array_append_val (features, feature);
 
+  feature = TP_CONNECTION_FEATURE_BALANCE;
+  g_array_append_val (features, feature);
+
   return features;
 }
 
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 3ecb939..e3588c2 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -1063,24 +1063,20 @@ main_window_setup_balance_create_widget (EmpathyMainWindow *window,
 }
 
 static void
-main_window_setup_balance_conn_ready (GObject      *source,
-				      GAsyncResult *result,
-				      gpointer      user_data)
+main_window_setup_balance (EmpathyMainWindow *window,
+			   TpAccount         *account)
 {
-	EmpathyMainWindow *window = user_data;
 	EmpathyMainWindowPriv *priv = GET_PRIV (window);
-	TpConnection *conn = TP_CONNECTION (source);
-	TpAccount *account = g_object_get_data (source, "account");
+	TpConnection *conn = tp_account_get_connection (account);
 	GtkAction *action;
-	GError *error = NULL;
 	const gchar *uri;
 
-	if (!tp_proxy_prepare_finish (conn, result, &error)) {
-		DEBUG ("Failed to prepare connection: %s", error->message);
-
-		g_error_free (error);
+	if (conn == NULL)
 		return;
-	}
+
+	/* need to prepare the connection:
+	 * store the account on the connection */
+	g_object_set_data (G_OBJECT (conn), "account", account);
 
 	if (!tp_proxy_is_prepared (conn, TP_CONNECTION_FEATURE_BALANCE))
 		return;
@@ -1110,23 +1106,7 @@ main_window_setup_balance_conn_ready (GObject      *source,
 
 	g_signal_connect (conn, "balance-changed",
 		G_CALLBACK (main_window_balance_changed_cb), action);
-}
-
-static void
-main_window_setup_balance (EmpathyMainWindow *window,
-			   TpAccount         *account)
-{
-	TpConnection *conn = tp_account_get_connection (account);
-	GQuark features[] = { TP_CONNECTION_FEATURE_BALANCE, 0 };
 
-	if (conn == NULL)
-		return;
-
-	/* need to prepare the connection:
-	 * store the account on the connection */
-	g_object_set_data (G_OBJECT (conn), "account", account);
-	tp_proxy_prepare_async (conn, features,
-		main_window_setup_balance_conn_ready, window);
 }
 
 static void



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