aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-08-27 20:22:37 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-08-28 15:08:47 +0800
commit79ea3b4ad24160ad2d0a32b24adcd4fb526f9eca (patch)
tree65a6df8d6bea1f509ae6f1f8c7cf76f7ccf36abe /src
parent7c6cb4b3b6cf3cfe6379b9d3a0f4a8e80fbebdd9 (diff)
downloadgsoc2013-empathy-79ea3b4ad24160ad2d0a32b24adcd4fb526f9eca.tar
gsoc2013-empathy-79ea3b4ad24160ad2d0a32b24adcd4fb526f9eca.tar.gz
gsoc2013-empathy-79ea3b4ad24160ad2d0a32b24adcd4fb526f9eca.tar.bz2
gsoc2013-empathy-79ea3b4ad24160ad2d0a32b24adcd4fb526f9eca.tar.lz
gsoc2013-empathy-79ea3b4ad24160ad2d0a32b24adcd4fb526f9eca.tar.xz
gsoc2013-empathy-79ea3b4ad24160ad2d0a32b24adcd4fb526f9eca.tar.zst
gsoc2013-empathy-79ea3b4ad24160ad2d0a32b24adcd4fb526f9eca.zip
try installing missing account-plugin-*
https://bugzilla.gnome.org/show_bug.cgi?id=682802
Diffstat (limited to 'src')
-rw-r--r--src/empathy-sanity-cleaning.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/empathy-sanity-cleaning.c b/src/empathy-sanity-cleaning.c
index 12fdb2413..03ceb8ef2 100644
--- a/src/empathy-sanity-cleaning.c
+++ b/src/empathy-sanity-cleaning.c
@@ -32,6 +32,15 @@
#include <libempathy-gtk/empathy-theme-manager.h>
+#ifdef HAVE_UOA
+#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>
+#include <libaccounts-glib/ag-service.h>
+#endif
+
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
#include <libempathy/empathy-keyring.h>
@@ -373,12 +382,89 @@ migrate_account_to_uoa (TpAccountManager *am,
}
static void
+uoa_plugin_install_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ TpAccount *account = user_data;
+ GError *error = NULL;
+ TpAccountManager *am;
+
+ if (!empathy_pkg_kit_install_packages_finish (result, &error))
+ {
+ DEBUG ("Failed to install plugin: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ DEBUG ("Plugin for account '%s' has been installed; migrate account",
+ tp_account_get_path_suffix (account));
+
+ am = tp_account_manager_dup ();
+ migrate_account_to_uoa (am, account);
+ g_object_unref (am);
+
+out:
+ g_object_unref (account);
+}
+
+static gchar *
+dup_plugin_name_for_protocol (const gchar *protocol)
+{
+ if (!tp_strdiff (protocol, "local-xmpp"))
+ return g_strdup ("account-plugin-salut");
+
+ return g_strdup_printf ("account-plugin-%s", protocol);
+}
+
+static gboolean
+uoa_plugin_installed (AgManager *manager,
+ TpAccount *account)
+{
+ AgAccount *ag_account;
+ const gchar *protocol;
+ GList *l;
+
+ protocol = tp_account_get_protocol_name (account);
+ ag_account = ag_manager_create_account (manager, protocol);
+
+ l = ag_account_list_services_by_type (ag_account, EMPATHY_UOA_SERVICE_TYPE);
+ if (l == NULL)
+ {
+ const gchar *packages[2];
+ gchar *pkg;
+
+ pkg = dup_plugin_name_for_protocol (protocol);
+
+ DEBUG ("%s is not installed; try to install it", pkg);
+
+ packages[0] = pkg;
+ packages[1] = NULL;
+
+ empathy_pkg_kit_install_packages_async (0, packages, NULL,
+ NULL, uoa_plugin_install_cb, g_object_ref (account));
+
+ g_free (pkg);
+ g_object_unref (ag_account);
+ return FALSE;
+ }
+
+ ag_service_list_free (l);
+
+ g_object_unref (ag_account);
+ return TRUE;
+}
+
+static void
migrate_accounts_to_uoa (TpAccountManager *am)
{
GList *accounts, *l;
+ AgManager *manager;
DEBUG ("Start migrating accounts to UOA");
+ manager = empathy_uoa_manager_dup ();
+
accounts = tp_account_manager_get_valid_accounts (am);
for (l = accounts; l != NULL; l = g_list_next (l))
{
@@ -391,8 +477,13 @@ migrate_accounts_to_uoa (TpAccountManager *am)
if (!tp_str_empty (tp_account_get_storage_provider (account)))
continue;
+ if (!uoa_plugin_installed (manager, account))
+ continue;
+
migrate_account_to_uoa (am, account);
}
+
+ g_object_unref (manager);
}
#endif