diff options
author | Milan Crha <mcrha@redhat.com> | 2011-04-21 00:42:24 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2011-04-21 00:42:24 +0800 |
commit | 644279aeed67b634f3adcc8b2a367f06cae14226 (patch) | |
tree | cd53d14b3e02b9bbe13799fae02ce7927ecc979f | |
parent | 387d6e01e3ca74b50b17e5597847d2acb6322a91 (diff) | |
download | gsoc2013-evolution-644279aeed67b634f3adcc8b2a367f06cae14226.tar.gz gsoc2013-evolution-644279aeed67b634f3adcc8b2a367f06cae14226.tar.zst gsoc2013-evolution-644279aeed67b634f3adcc8b2a367f06cae14226.zip |
Bug #502188 - Store 'Remember password' for calendars
-rw-r--r-- | calendar/common/authentication.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/calendar/common/authentication.c b/calendar/common/authentication.c index ddcc0ffbd6..7989107e64 100644 --- a/calendar/common/authentication.c +++ b/calendar/common/authentication.c @@ -32,13 +32,31 @@ #include "authentication.h" #include <libedataserver/e-url.h> +static gboolean +get_remember_password (ESource *source) +{ + const gchar *value; + + value = e_source_get_property (source, "remember_password"); + if (value && !g_ascii_strcasecmp (value, "true")) + return TRUE; + + return FALSE; +} + +static void +set_remember_password (ESource *source, gboolean value) +{ + e_source_set_property (source, "remember_password", + value ? "true" : "false"); +} + static gchar * auth_func_cb (ECal *ecal, const gchar *prompt, const gchar *key, gpointer user_data) { - gboolean remember; gchar *password, *auth_domain; ESource *source; const gchar *component_name; @@ -48,7 +66,11 @@ auth_func_cb (ECal *ecal, component_name = auth_domain ? auth_domain : "Calendar"; password = e_passwords_get_password (component_name, key); - if (!password) + if (!password) { + gboolean remember; + + remember = get_remember_password (source); + password = e_passwords_ask_password ( _("Enter password"), component_name, key, prompt, @@ -57,6 +79,10 @@ auth_func_cb (ECal *ecal, E_PASSWORDS_ONLINE, &remember, NULL); + if (password) + set_remember_password (source, remember); + } + g_free (auth_domain); return password; @@ -179,7 +205,6 @@ load_cal_source_authenticate (ECal *cal, { const gchar *auth_component; const gchar *title; - gboolean remember; /* not used */ GtkWindow *parent; gchar *password; @@ -202,13 +227,22 @@ load_cal_source_authenticate (ECal *cal, password = e_passwords_get_password (auth_component, uri); - if (password == NULL) + if (password == NULL) { + gboolean remember; + ESource *source = e_cal_get_source (cal); + + remember = get_remember_password (source); + password = e_passwords_ask_password ( title, auth_component, uri, prompt, E_PASSWORDS_REMEMBER_FOREVER | E_PASSWORDS_SECRET | E_PASSWORDS_ONLINE, &remember, parent); + if (password) + set_remember_password (source, remember); + } + return password; } |