[gnome-online-accounts] telepathy: Simplify the code by re-using the existing GoaClient



commit 3d42c529e759afa4f97c440e57d6a992dac2fe03
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Jun 3 17:36:42 2016 +0200

    telepathy: Simplify the code by re-using the existing GoaClient
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767299

 src/goabackend/goatelepathyprovider.c |   33 +++++----------------------------
 1 files changed, 5 insertions(+), 28 deletions(-)
---
diff --git a/src/goabackend/goatelepathyprovider.c b/src/goabackend/goatelepathyprovider.c
index 65fb353..19d2896 100644
--- a/src/goabackend/goatelepathyprovider.c
+++ b/src/goabackend/goatelepathyprovider.c
@@ -327,7 +327,7 @@ check_existing_goa_accounts (AddAccountData *data)
   GList *l = NULL;
   gboolean found = FALSE;
 
-  if (data->tp_account == NULL || data->goa_client == NULL)
+  if (data->tp_account == NULL)
     return FALSE;
 
   goa_accounts = goa_client_get_accounts (data->goa_client);
@@ -366,31 +366,6 @@ goa_account_added_cb (GoaClient *client,
 }
 
 static void
-goa_client_new_cb (GObject      *object,
-                   GAsyncResult *result,
-                   gpointer      user_data)
-{
-  AddAccountData *data = user_data;
-
-  data->goa_client = goa_client_new_finish (result, &data->error);
-  if (data->goa_client == NULL)
-    {
-      g_set_error (&data->error,
-                   GOA_ERROR,
-                   GOA_ERROR_FAILED,
-                   _("Failed to initialize a GOA client"));
-      g_main_loop_quit (data->loop);
-      return;
-    }
-
-  if (!check_existing_goa_accounts (data))
-    {
-      data->goa_account_added_id = g_signal_connect (data->goa_client,
-          "account-added", G_CALLBACK (goa_account_added_cb), data);
-    }
-}
-
-static void
 account_widget_close_cb (TpawAccountWidget *widget,
                          GtkResponseType    response,
                          AddAccountData    *data)
@@ -433,7 +408,10 @@ add_account (GoaProvider  *provider,
   data.dialog = dialog;
   data.vbox = vbox;
 
-  goa_client_new (data.cancellable, goa_client_new_cb, &data);
+  data.goa_client = client;
+  data.goa_account_added_id = g_signal_connect (data.goa_client,
+      "account-added", G_CALLBACK (goa_account_added_cb), &data);
+
   wait_for_account_settings_ready (settings, data.loop);
 
   account_widget = tpaw_account_widget_new_for_protocol (settings,
@@ -489,7 +467,6 @@ out:
     g_signal_handler_disconnect (data.goa_client, data.goa_account_added_id);
 
   g_clear_pointer (&data.loop, g_main_loop_unref);
-  g_clear_object (&data.goa_client);
   g_clear_object (&data.tp_account);
 
   return data.ret;


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