[empathy] keep our reference on the global ctx until the account has been removed



commit a4d45d9997e9c55a75f147cab51184a500640ca1
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Tue Aug 28 10:56:11 2012 +0200

    keep our reference on the global ctx until the account has been removed
    
    This ensures that the proccess stays running until we are actually done.

 src/empathy-sanity-cleaning.c |   44 +++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 23 deletions(-)
---
diff --git a/src/empathy-sanity-cleaning.c b/src/empathy-sanity-cleaning.c
index b60d800..51015b4 100644
--- a/src/empathy-sanity-cleaning.c
+++ b/src/empathy-sanity-cleaning.c
@@ -282,10 +282,30 @@ uoa_migration_data_free (UoaMigrationData *data)
   g_slice_free (UoaMigrationData, data);
 }
 
+#define DATA_SANITY_CTX "data-sanity-ctx"
+
+static void
+uoa_account_remove_cb (GObject *source,
+    GAsyncResult *result,
+    gpointer user_data)
+{
+  TpAccount *account = TP_ACCOUNT (source);
+  GError *error = NULL;
+
+  if (!tp_account_remove_finish (account, result, &error))
+    {
+      DEBUG ("Failed to remove account '%s': %s",
+          tp_account_get_path_suffix (account), error->message);
+      g_error_free (error);
+    }
+
+  g_object_set_data (G_OBJECT (account), DATA_SANITY_CTX, NULL);
+}
+
 static void
 uoa_migration_done (UoaMigrationData *data)
 {
-  tp_account_remove_async (data->old_account, NULL, NULL);
+  tp_account_remove_async (data->old_account, uoa_account_remove_cb, NULL);
 
   if (data->new_account != NULL)
     tp_account_set_enabled_async (data->new_account, data->enabled, NULL, NULL);
@@ -368,8 +388,6 @@ uoa_account_created_cb (GObject *source,
     }
 }
 
-#define DATA_SANITY_CTX "data-sanity-ctx"
-
 static void
 migrate_account_to_uoa (TpAccountManager *am,
     TpAccount *account)
@@ -428,31 +446,11 @@ migrate_account_to_uoa (TpAccountManager *am,
   tp_account_request_create_account_async (ar, uoa_account_created_cb,
       data);
 
-  g_object_set_data (G_OBJECT (account), DATA_SANITY_CTX, NULL);
-
   g_variant_unref (params);
   g_object_unref (ar);
 }
 
 static void
-uoa_account_remove_cb (GObject *source,
-    GAsyncResult *result,
-    gpointer user_data)
-{
-  TpAccount *account = TP_ACCOUNT (source);
-  GError *error = NULL;
-
-  if (!tp_account_remove_finish (account, result, &error))
-    {
-      DEBUG ("Failed to remove account '%s': %s",
-          tp_account_get_path_suffix (account), error->message);
-      g_error_free (error);
-    }
-
-  g_object_set_data (G_OBJECT (account), DATA_SANITY_CTX, NULL);
-}
-
-static void
 uoa_plugin_install_cb (GObject *source,
     GAsyncResult *result,
     gpointer user_data)



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