[evolution-data-server] Bug #691939 - Password prompt has "save password" always checked



commit dc69d82e0d63f5b1fdbcf43dd7bcef6c719f4522
Author: Milan Crha <mcrha redhat com>
Date:   Wed Apr 17 11:24:59 2013 +0200

    Bug #691939 - Password prompt has "save password" always checked

 libebackend/e-authentication-session.c | 11 +++++-
 libedataserver/e-source.c              | 70 ++++++++++++++++++++++++++++++++++
 libedataserver/e-source.h              |  3 ++
 3 files changed, 83 insertions(+), 1 deletion(-)
---
diff --git a/libebackend/e-authentication-session.c b/libebackend/e-authentication-session.c
index 8211f85..23a125e 100644
--- a/libebackend/e-authentication-session.c
+++ b/libebackend/e-authentication-session.c
@@ -412,6 +412,7 @@ authentication_session_execute_sync (EAuthenticationSession *session,
        const gchar *prompt_password;
        gchar *stored_password = NULL;
        gboolean success;
+       gboolean remember_password = TRUE;
        GError *local_error = NULL;
 
        /* XXX I moved the execute() operation into a class method thinking
@@ -491,6 +492,7 @@ authentication_session_execute_sync (EAuthenticationSession *session,
                allow_auth_prompt =
                        e_server_side_source_get_allow_auth_prompt (
                        E_SERVER_SIDE_SOURCE (source));
+               remember_password = e_source_get_remember_password (source);
                g_object_unref (source);
        } else {
                allow_auth_prompt = TRUE;
@@ -531,7 +533,7 @@ authentication_session_execute_sync (EAuthenticationSession *session,
 
        label = _("Add this password to your keyring");
        gcr_prompt_set_choice_label (prompt, label);
-       gcr_prompt_set_choice_chosen (prompt, TRUE);
+       gcr_prompt_set_choice_chosen (prompt, remember_password);
 
 try_again:
 
@@ -553,6 +555,13 @@ try_again:
                goto close_prompt;
        }
 
+       source = e_source_registry_server_ref_source (server, source_uid);
+       if (source != NULL) {
+               e_source_set_remember_password (source,
+                       gcr_prompt_get_choice_chosen (prompt));
+               g_object_unref (source);
+       }
+
        /* Attempt authentication with the provided password. */
 
        password_string = g_string_new (prompt_password);
diff --git a/libedataserver/e-source.c b/libedataserver/e-source.c
index 365974e..909c0bc 100644
--- a/libedataserver/e-source.c
+++ b/libedataserver/e-source.c
@@ -130,6 +130,7 @@ struct _ESourcePrivate {
 
        gboolean enabled;
        gboolean initialized;
+       gboolean remember_password;
 };
 
 struct _AsyncContext {
@@ -145,6 +146,7 @@ enum {
        PROP_ENABLED,
        PROP_MAIN_CONTEXT,
        PROP_PARENT,
+       PROP_REMEMBER_PASSWORD,
        PROP_REMOTE_CREATABLE,
        PROP_REMOTE_DELETABLE,
        PROP_REMOVABLE,
@@ -763,6 +765,12 @@ source_set_property (GObject *object,
                                g_value_get_string (value));
                        return;
 
+               case PROP_REMEMBER_PASSWORD:
+                       e_source_set_remember_password (
+                               E_SOURCE (object),
+                               g_value_get_boolean (value));
+                       return;
+
                case PROP_UID:
                        source_set_uid (
                                E_SOURCE (object),
@@ -810,6 +818,12 @@ source_get_property (GObject *object,
                                E_SOURCE (object)));
                        return;
 
+               case PROP_REMEMBER_PASSWORD:
+                       g_value_set_boolean (
+                               value, e_source_get_remember_password (
+                               E_SOURCE (object)));
+                       return;
+
                case PROP_REMOTE_CREATABLE:
                        g_value_set_boolean (
                                value, e_source_get_remote_creatable (
@@ -1597,6 +1611,19 @@ e_source_class_init (ESourceClass *class)
 
        g_object_class_install_property (
                object_class,
+               PROP_REMEMBER_PASSWORD,
+               g_param_spec_boolean (
+                       "remember-password",
+                       "Remember Password",
+                       "Whether to remember password - used in a password prompt",
+                       TRUE,
+                       G_PARAM_READWRITE |
+                       G_PARAM_CONSTRUCT |
+                       G_PARAM_STATIC_STRINGS |
+                       E_SOURCE_PARAM_SETTING));
+
+       g_object_class_install_property (
+               object_class,
                PROP_REMOTE_CREATABLE,
                g_param_spec_boolean (
                        "remote-creatable",
@@ -2075,6 +2102,49 @@ e_source_set_enabled (ESource *source,
 }
 
 /**
+ * e_source_get_remember_password:
+ * @source: an #ESource
+ *
+ * Returns whether @source should remember password. This influences
+ * "Add this password to your keyring" option in a password prompt.
+ *
+ * Returns: whether @source should remember password
+ *
+ * Since: 3.10
+ **/
+gboolean
+e_source_get_remember_password (ESource *source)
+{
+       g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
+
+       return source->priv->remember_password;
+}
+
+/**
+ * e_source_set_remember_password:
+ * @source: an #ESource
+ * @remember_password: whether to remember password
+ *
+ * The password prompt will have checked "Add this password to your keyring" option
+ * based on this value.
+ *
+ * Since: 3.10
+ **/
+void
+e_source_set_remember_password (ESource *source,
+                               gboolean remember_password)
+{
+       g_return_if_fail (E_IS_SOURCE (source));
+
+       if ((source->priv->remember_password ? 1 : 0) == (remember_password ? 1 : 0))
+               return;
+
+       source->priv->remember_password = remember_password;
+
+       g_object_notify (G_OBJECT (source), "remember-password");
+}
+
+/**
  * e_source_get_writable:
  * @source: an #ESource
  *
diff --git a/libedataserver/e-source.h b/libedataserver/e-source.h
index a473e99..c8b2e58 100644
--- a/libedataserver/e-source.h
+++ b/libedataserver/e-source.h
@@ -165,6 +165,9 @@ void                e_source_set_parent             (ESource *source,
 gboolean       e_source_get_enabled            (ESource *source);
 void           e_source_set_enabled            (ESource *source,
                                                 gboolean enabled);
+gboolean       e_source_get_remember_password  (ESource *source);
+void           e_source_set_remember_password  (ESource *source,
+                                                gboolean remember_password);
 gboolean       e_source_get_writable           (ESource *source);
 gboolean       e_source_get_removable          (ESource *source);
 gboolean       e_source_get_remote_creatable   (ESource *source);


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