[empathy/gnome-2-34: 54/60] account-settings: move the migration code to another function



commit 7e595f80583090026e8263c188e67d205caaed3a
Author: Jonny Lamb <jonnylamb gnome org>
Date:   Wed Dec 22 11:56:20 2010 +0000

    account-settings: move the migration code to another function
    
    Signed-off-by: Jonny Lamb <jonnylamb gnome org>

 libempathy/empathy-account-settings.c |   99 ++++++++++++++++++---------------
 1 files changed, 54 insertions(+), 45 deletions(-)
---
diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c
index d6f2c7f..aa635f9 100644
--- a/libempathy/empathy-account-settings.c
+++ b/libempathy/empathy-account-settings.c
@@ -421,6 +421,59 @@ empathy_account_settings_get_password_cb (GObject *source,
 }
 
 static void
+empathy_account_settings_try_migrating_password (EmpathyAccountSettings *self)
+{
+  EmpathyAccountSettingsPriv *priv = GET_PRIV (self);
+  const GValue *v;
+  const gchar *account_id, *password;
+  const gchar *unset[] = { "password", NULL };
+  GHashTable *empty;
+
+  if (!priv->supports_sasl || empathy_account_settings_get (
+          self, "password") == NULL)
+    return;
+
+  /* mission-control still has our password, although the CM
+   * supports SASL. Let's try migrating it. */
+
+  account_id = tp_proxy_get_object_path (priv->account)
+    + strlen (TP_ACCOUNT_OBJECT_PATH_BASE);
+
+  DEBUG ("Trying to migrate password parameter from MC to the "
+      "keyring ourselves for account %s", account_id);
+
+  v = empathy_account_settings_get (self, "password");
+
+  /* I can't imagine why this would fail. */
+  if (!G_VALUE_HOLDS_STRING (v))
+    return;
+
+  password = g_value_get_string (v);
+
+  if (EMP_STR_EMPTY (password))
+    return;
+
+  empathy_keyring_set_password_async (priv->account, password,
+      NULL, NULL);
+
+  /* We don't want to request the password again, we
+   * already know it. */
+  priv->password_requested = TRUE;
+
+  priv->password = g_strdup (password);
+  priv->password_original = g_strdup (password);
+
+  /* Now clear the password MC has stored. */
+  empty = tp_asv_new (NULL, NULL);
+  tp_account_update_parameters_async (priv->account,
+      empty, unset, NULL, NULL);
+
+  g_hash_table_remove (priv->parameters, "password");
+
+  g_hash_table_unref (empty);
+}
+
+static void
 empathy_account_settings_check_readyness (EmpathyAccountSettings *self)
 {
   EmpathyAccountSettingsPriv *priv = GET_PRIV (self);
@@ -510,52 +563,8 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self)
         }
     }
 
-  if (priv->supports_sasl && empathy_account_settings_get (
-          self, "password") != NULL)
-    {
-      /* mission-control still has our password, although the CM
-       * supports SASL. Let's try migrating it. */
-      const GValue *v;
-      const gchar *account_id;
-
-      account_id = tp_proxy_get_object_path (priv->account)
-        + strlen (TP_ACCOUNT_OBJECT_PATH_BASE);
-
-      g_print ("Trying to migrate password parameter from MC to the "
-          "keyring ourselves for account %s", account_id);
-
-      v = empathy_account_settings_get (self, "password");
-
-      /* I can't imagine why this would fail. */
-      if (G_VALUE_HOLDS_STRING (v))
-        {
-          const gchar *password = g_value_get_string (v);
-          const gchar *unset[] = { "password", NULL };
-
-          if (!EMP_STR_EMPTY (password))
-            {
-              GHashTable *empty = tp_asv_new (NULL, NULL);
-
-              empathy_keyring_set_password_async (priv->account, password,
-                  NULL, NULL);
-
-              /* We don't want to request the password again, we
-               * already know it. */
-              priv->password_requested = TRUE;
-
-              priv->password = g_strdup (password);
-              priv->password_original = g_strdup (password);
 
-              /* Now clear the password MC has stored. */
-              tp_account_update_parameters_async (priv->account,
-                  empty, unset, NULL, NULL);
-
-              g_hash_table_remove (priv->parameters, "password");
-
-              g_hash_table_unref (empty);
-            }
-        }
-    }
+  empathy_account_settings_try_migrating_password (self);
 
   /* priv->account won't be a proper account if it's the account
    * assistant showing this widget. */



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