]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-account-settings.c
Merge branch 'gnome-3-8'
[empathy.git] / libempathy / empathy-account-settings.c
index 12154eb7906fdb4bff2913e81988f20d03d57bae..064d4d21580e398900cb276955dcc84d0cf3b3f5 100644 (file)
  */
 
 #include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/interfaces.h>
-#include <telepathy-glib/gtypes.h>
-
 #include "empathy-account-settings.h"
+
 #include "empathy-connection-managers.h"
 #include "empathy-keyring.h"
-#include "empathy-utils.h"
 #include "empathy-presence-manager.h"
+#include "empathy-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
 
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountSettings)
 
@@ -81,7 +73,7 @@ struct _EmpathyAccountSettingsPriv
   gboolean ready;
 
   gboolean supports_sasl;
-  gboolean password_changed;
+  gboolean remember_password;
 
   gchar *password;
   gchar *password_original;
@@ -832,7 +824,6 @@ empathy_account_settings_unset (EmpathyAccountSettings *settings,
     {
       g_free (priv->password);
       priv->password = NULL;
-      priv->password_changed = TRUE;
       return;
     }
 
@@ -850,7 +841,6 @@ empathy_account_settings_discard_changes (EmpathyAccountSettings *settings)
   g_hash_table_remove_all (priv->parameters);
   empathy_account_settings_free_unset_parameters (settings);
 
-  priv->password_changed = FALSE;
   g_free (priv->password);
   priv->password = g_strdup (priv->password_original);
 
@@ -1072,7 +1062,6 @@ empathy_account_settings_set (EmpathyAccountSettings *settings,
     {
       g_free (priv->password);
       priv->password = g_variant_dup_string (v, NULL);
-      priv->password_changed = TRUE;
     }
   else
     {
@@ -1335,16 +1324,22 @@ empathy_account_settings_account_updated (GObject *source,
       goto out;
     }
 
-  /* Only set the password in the keyring if the CM supports SASL and
-   * it's changed. */
-  if (priv->supports_sasl && priv->password_changed)
+  update_account_uri_schemes (settings);
+  update_account_service (settings);
+
+  g_simple_async_result_set_op_res_gboolean (priv->apply_result,
+      g_strv_length (reconnect_required) > 0);
+
+  /* Only set the password in the keyring if the CM supports SASL. */
+  if (priv->supports_sasl)
     {
       if (priv->password != NULL)
         {
           /* FIXME: we shouldn't save the password if we
            * can't (MaySaveResponse=False) but we don't have API to check that
            * at this point (fdo #35382). */
-          empathy_keyring_set_account_password_async (priv->account, priv->password,
+          empathy_keyring_set_account_password_async (priv->account,
+              priv->password, priv->remember_password,
               empathy_account_settings_set_password_cb, settings);
         }
       else
@@ -1356,12 +1351,6 @@ empathy_account_settings_account_updated (GObject *source,
       return;
     }
 
-  update_account_uri_schemes (settings);
-  update_account_service (settings);
-
-  g_simple_async_result_set_op_res_gboolean (priv->apply_result,
-      g_strv_length (reconnect_required) > 0);
-
 out:
   empathy_account_settings_discard_changes (settings);
 
@@ -1399,7 +1388,8 @@ empathy_account_settings_created_cb (GObject *source,
            * can't (MaySaveResponse=False) but we don't have API to check that
            * at this point (fdo #35382). */
           empathy_keyring_set_account_password_async (priv->account,
-              priv->password, empathy_account_settings_set_password_cb,
+              priv->password, priv->remember_password,
+              empathy_account_settings_set_password_cb,
               settings);
           return;
         }
@@ -1726,3 +1716,12 @@ empathy_account_settings_set_storage_provider (EmpathyAccountSettings *self,
   g_free (priv->storage_provider);
   priv->storage_provider = g_strdup (storage);
 }
+
+void
+empathy_account_settings_set_remember_password (EmpathyAccountSettings *self,
+    gboolean remember)
+{
+  EmpathyAccountSettingsPriv *priv = GET_PRIV (self);
+
+  priv->remember_password = remember;
+}