]> git.0d.be Git - empathy.git/blobdiff - src/empathy-sanity-cleaning.c
Use double quotes for all internal headers
[empathy.git] / src / empathy-sanity-cleaning.c
index 326b6467139a45c27fd2a13e8eded0d5464f0249..8e2234fe1cf7783d0518b7f03d4f4f6144cd0f0b 100644 (file)
 
 #include "empathy-sanity-cleaning.h"
 
-#include <telepathy-glib/telepathy-glib.h>
+#include "libempathy/empathy-gsettings.h"
 
-#include <libempathy/empathy-account-settings.h>
-#include <libempathy/empathy-gsettings.h>
-
-#include <libempathy-gtk/empathy-theme-manager.h>
+#include "libempathy-gtk/empathy-theme-manager.h"
 
 #ifdef HAVE_UOA
-#include <libempathy/empathy-pkg-kit.h>
-#include <libempathy/empathy-uoa-utils.h>
+#include "libempathy/empathy-pkg-kit.h"
+#include "libempathy/empathy-uoa-utils.h"
 
 #include <libaccounts-glib/ag-account-service.h>
 #include <libaccounts-glib/ag-manager.h>
@@ -42,8 +39,7 @@
 #endif
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
-#include <libempathy/empathy-keyring.h>
+#include "libempathy/empathy-debug.h"
 
 /*
  * This number has to be increased each time a new task is added or modified.
@@ -74,6 +70,7 @@ sanity_ctx_new (TpAccountManager *am,
   return ctx;
 }
 
+#ifdef HAVE_UOA
 static SanityCtx *
 sanity_ctx_ref (SanityCtx *ctx)
 {
@@ -81,6 +78,7 @@ sanity_ctx_ref (SanityCtx *ctx)
 
   return ctx;
 }
+#endif
 
 static void
 sanity_ctx_unref (SanityCtx *ctx)
@@ -124,7 +122,7 @@ fix_xmpp_account_priority (TpAccountManager *am)
 {
   GList *accounts, *l;
 
-  accounts = tp_account_manager_get_valid_accounts (am);
+  accounts = tp_account_manager_dup_valid_accounts (am);
   for (l = accounts; l != NULL; l = g_list_next (l))
     {
       TpAccount *account = l->data;
@@ -155,7 +153,7 @@ fix_xmpp_account_priority (TpAccountManager *am)
       g_hash_table_unref (params);
     }
 
-  g_list_free (accounts);
+  g_list_free_full (accounts, g_object_unref);
 }
 
 static void
@@ -163,7 +161,7 @@ set_facebook_account_fallback_server (TpAccountManager *am)
 {
   GList *accounts, *l;
 
-  accounts = tp_account_manager_get_valid_accounts (am);
+  accounts = tp_account_manager_dup_valid_accounts (am);
   for (l = accounts; l != NULL; l = g_list_next (l))
     {
       TpAccount *account = l->data;
@@ -195,7 +193,7 @@ set_facebook_account_fallback_server (TpAccountManager *am)
       g_hash_table_unref (params);
     }
 
-  g_list_free (accounts);
+  g_list_free_full (accounts, g_object_unref);
 }
 
 static void
@@ -282,11 +280,35 @@ 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_set_enabled_async (data->new_account, data->enabled, 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);
+
+  uoa_migration_data_free (data);
 }
 
 static void
@@ -350,7 +372,7 @@ uoa_account_created_cb (GObject *source,
           tp_account_get_path_suffix (data->old_account), error->message);
       g_clear_error (&error);
 
-      uoa_migration_data_free (data);
+      uoa_migration_done (data);
     }
   else
     {
@@ -364,8 +386,6 @@ uoa_account_created_cb (GObject *source,
     }
 }
 
-#define DATA_SANITY_CTX "data-sanity-ctx"
-
 static void
 migrate_account_to_uoa (TpAccountManager *am,
     TpAccount *account)
@@ -375,6 +395,7 @@ migrate_account_to_uoa (TpAccountManager *am,
   GVariant *param;
   GVariantIter iter;
   const gchar * const *supersedes;
+  guint i;
   UoaMigrationData *data;
 
   DEBUG ("Migrating account %s to UOA storage\n",
@@ -396,8 +417,10 @@ migrate_account_to_uoa (TpAccountManager *am,
   tp_account_request_set_enabled (ar, FALSE);
 
   supersedes = tp_account_get_supersedes (account);
-  while (*supersedes != NULL)
-    tp_account_request_add_supersedes (ar, *supersedes);
+
+  for (i = 0; supersedes[i] != NULL; i++)
+    tp_account_request_add_supersedes (ar, supersedes[i]);
+
   tp_account_request_add_supersedes (ar,
       tp_proxy_get_object_path (account));
 
@@ -424,30 +447,10 @@ 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,
@@ -536,7 +539,7 @@ migrate_accounts_to_uoa (SanityCtx *ctx)
 
   manager = empathy_uoa_manager_dup ();
 
-  accounts = tp_account_manager_get_valid_accounts (ctx->am);
+  accounts = tp_account_manager_dup_valid_accounts (ctx->am);
   for (l = accounts; l != NULL; l = g_list_next (l))
     {
       TpAccount *account = l->data;
@@ -558,6 +561,8 @@ migrate_accounts_to_uoa (SanityCtx *ctx)
       migrate_account_to_uoa (ctx->am, account);
     }
 
+  g_list_free_full (accounts, g_object_unref);
+
   g_object_unref (manager);
 }
 #endif