diff options
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/empathy-import-mc4-accounts.c | 47 |
2 files changed, 44 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index 7576c8e9d..080fdffd4 100644 --- a/configure.ac +++ b/configure.ac @@ -39,6 +39,7 @@ LIBCHAMPLAIN_GTK_REQUIRED=0.3.6 CLUTTER_GTK_REQUIRED=0.10 GEOCLUE_REQUIRED=0.11 WEBKIT_REQUIRED=1.1.7 +KEYRING_REQUIRED=2.22 NETWORK_MANAGER_REQUIRED=0.7.0 # Use --enable-maintainer-mode to disabled deprecated symbols @@ -127,6 +128,7 @@ PKG_CHECK_MODULES(EMPATHY, telepathy-farsight gstreamer-0.10 unique-1.0 + gnome-keyring-1 >= $KEYRING_REQUIRED ]) PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= $LIBNOTIFY_REQUIRED) diff --git a/src/empathy-import-mc4-accounts.c b/src/empathy-import-mc4-accounts.c index eea3b7f18..614c5cbe3 100644 --- a/src/empathy-import-mc4-accounts.c +++ b/src/empathy-import-mc4-accounts.c @@ -26,6 +26,7 @@ #include <gconf/gconf-client.h> #include <telepathy-glib/util.h> #include <dbus/dbus-protocol.h> +#include <gnome-keyring.h> #include <libempathy/empathy-account-manager.h> #include <libempathy/empathy-account-settings.h> #include <libempathy/empathy-connection-managers.h> @@ -172,7 +173,35 @@ _get_protocol_from_profile (const gchar *profile) } static void -_handle_entry (EmpathyAccountSettings *settings, +_set_password_from_keyring (EmpathyAccountSettings *settings, + const gchar *account_name, const gchar *key) +{ + GnomeKeyringResult res; + gchar *password; + GnomeKeyringPasswordSchema keyring_schema = { + GNOME_KEYRING_ITEM_GENERIC_SECRET, + { + { "account", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, + { "param", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, + { NULL, 0 } + } + }; + + res = gnome_keyring_find_password_sync (&keyring_schema, + &password, + "account", account_name, + "param", key, + NULL); + + if (res == GNOME_KEYRING_RESULT_OK) + { + empathy_account_settings_set_string (settings, key, password); + gnome_keyring_free_password (password); + } +} + +static void +_handle_entry (EmpathyAccountSettings *settings, const gchar *account_name, const gchar *key, GConfEntry *entry) { @@ -206,7 +235,13 @@ _handle_entry (EmpathyAccountSettings *settings, const gchar *v = gconf_value_get_string ( gconf_entry_get_value (entry)); - empathy_account_settings_set_string (settings, key, v); + /* MC 4 would put password in the keyring and leave the password in + * gconf keyring */ + + if (!tp_strdiff (key, "password") && !tp_strdiff (v, "keyring")) + _set_password_from_keyring (settings, account_name, key); + else + empathy_account_settings_set_string (settings, key, v); break; } case DBUS_TYPE_BOOLEAN: @@ -223,7 +258,8 @@ _handle_entry (EmpathyAccountSettings *settings, } static void -_recurse_account (GSList *entries, EmpathyAccountSettings *settings) +_recurse_account (GSList *entries, EmpathyAccountSettings *settings, + const gchar *account_name) { GSList *tmp; @@ -238,7 +274,8 @@ _recurse_account (GSList *entries, EmpathyAccountSettings *settings) if (g_str_has_prefix (param, "param-")) { - _handle_entry (settings, param + strlen ("param-"), entry); + _handle_entry (settings, account_name, param + strlen ("param-"), + entry); } g_free (param); @@ -306,7 +343,7 @@ import_one_account (const char *path, goto failed; } - _recurse_account (entries, settings); + _recurse_account (entries, settings, account_name); key = g_strdup_printf ("%s/enabled", path); enabled = gconf_client_get_bool (client, key, NULL); |