]> git.0d.be Git - empathy.git/commitdiff
Remember password at least until session restart
authorXavier Claessens <xavier.claessens@collabora.co.uk>
Fri, 24 Aug 2012 08:14:43 +0000 (10:14 +0200)
committerXavier Claessens <xavier.claessens@collabora.co.uk>
Mon, 27 Aug 2012 13:47:21 +0000 (15:47 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=680776

libempathy-gtk/empathy-account-widget.c
libempathy/empathy-account-settings.c
libempathy/empathy-account-settings.h
libempathy/empathy-keyring.c
libempathy/empathy-keyring.h
libempathy/empathy-server-sasl-handler.c

index c71b24f7b8928a1e50a444f09968d4d2be0f3bb8..aea76cf9f9edb0a8299cda4a1579f7e0df027a2e 100644 (file)
@@ -1864,16 +1864,8 @@ static void
 remember_password_toggled_cb (GtkToggleButton *button,
     EmpathyAccountWidget *self)
 {
-  if (gtk_toggle_button_get_active (button))
-    {
-      gtk_widget_set_sensitive (self->priv->param_password_widget, TRUE);
-    }
-  else
-    {
-      gtk_widget_set_sensitive (self->priv->param_password_widget, FALSE);
-      gtk_entry_set_text (GTK_ENTRY (self->priv->param_password_widget), "");
-      empathy_account_settings_unset (self->priv->settings, "password");
-    }
+  empathy_account_settings_set_remember_password (self->priv->settings,
+      gtk_toggle_button_get_active (button));
 }
 
 static void
@@ -2015,6 +2007,8 @@ do_constructed (GObject *obj)
       && !empathy_account_settings_supports_sasl (self->priv->settings))
     {
       gtk_widget_set_visible (self->priv->remember_password_widget, FALSE);
+      empathy_account_settings_set_remember_password (self->priv->settings,
+          TRUE);
     }
 
   /* dup and init the account-manager */
index 12154eb7906fdb4bff2913e81988f20d03d57bae..ee0cb34604df687ee15bccaaa82d412cde6376de 100644 (file)
@@ -82,6 +82,7 @@ struct _EmpathyAccountSettingsPriv
 
   gboolean supports_sasl;
   gboolean password_changed;
+  gboolean remember_password;
 
   gchar *password;
   gchar *password_original;
@@ -1344,7 +1345,8 @@ empathy_account_settings_account_updated (GObject *source,
           /* 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
@@ -1399,7 +1401,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 +1729,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;
+}
index 7f17e33c85af1091d7adad8416bda2e868b38b79..c54065258d98121a3ccc3cf47f0fbaa2ec1bfd09 100644 (file)
@@ -197,6 +197,10 @@ void empathy_account_settings_set_storage_provider (
     EmpathyAccountSettings *self,
     const gchar *storage);
 
+void empathy_account_settings_set_remember_password (
+    EmpathyAccountSettings *self,
+    gboolean remember);
+
 G_END_DECLS
 
 #endif /* #ifndef __EMPATHY_ACCOUNT_SETTINGS_H__*/
index 5b69cc25cbd5af429311af9e30038d2061ee7263..f9ca47606d002bec609a02c046fb3a53089cd17a 100644 (file)
@@ -181,6 +181,7 @@ store_password_cb (GObject *source,
 void
 empathy_keyring_set_account_password_async (TpAccount *account,
     const gchar *password,
+    gboolean remember,
     GAsyncReadyCallback callback,
     gpointer user_data)
 {
@@ -202,7 +203,9 @@ empathy_keyring_set_account_password_async (TpAccount *account,
   name = g_strdup_printf (_("IM account password for %s (%s)"),
       tp_account_get_display_name (account), account_id);
 
-  secret_password_store (&account_keyring_schema, NULL, name, password,
+  secret_password_store (&account_keyring_schema,
+      remember ? NULL : SECRET_COLLECTION_SESSION,
+      name, password,
       NULL, store_password_cb, simple,
       "account-id", account_id,
       "param-name", "password",
index 92c8a6e9f51167caa0ae3ebe7e537ab6af882207..05c460e5d136b561b1514751cac12631f31b625b 100644 (file)
@@ -41,7 +41,7 @@ const gchar * empathy_keyring_get_room_password_finish (TpAccount *account,
     GAsyncResult *result, GError **error);
 
 void empathy_keyring_set_account_password_async (TpAccount *account,
-    const gchar *password, GAsyncReadyCallback callback,
+    const gchar *password, gboolean remember, GAsyncReadyCallback callback,
     gpointer user_data);
 
 gboolean empathy_keyring_set_account_password_finish (TpAccount *account,
index 1518f3374345595302c964d2baaaea27ef6c05b0..db7ba1be8f58f11d5dd28f6408d16668efe4de49 100644 (file)
@@ -115,14 +115,10 @@ sasl_status_changed_cb (TpChannel *channel,
 
   if (status == TP_SASL_STATUS_SERVER_SUCCEEDED)
     {
-      if (priv->save_password)
-        {
-          DEBUG ("Saving password in keyring");
-
-          empathy_keyring_set_account_password_async (priv->account,
-              priv->password, empathy_server_sasl_handler_set_password_cb,
-              NULL);
-        }
+      empathy_keyring_set_account_password_async (priv->account,
+          priv->password, priv->save_password,
+          empathy_server_sasl_handler_set_password_cb,
+          NULL);
 
       DEBUG ("Calling AcceptSASL");
       tp_cli_channel_interface_sasl_authentication_call_accept_sasl (