diff options
author | Milan Crha <mcrha@redhat.com> | 2011-04-21 00:42:24 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:41:55 +0800 |
commit | 6504fef6f4f89bc0a1632135be0e0e11c954733c (patch) | |
tree | 05f00fff5621216d75cb9dcabc22d1819c0126ca /calendar | |
parent | 51c8d2ed98184853c6651d07ca489e8733c71c7f (diff) | |
download | gsoc2013-evolution-6504fef6f4f89bc0a1632135be0e0e11c954733c.tar.gz gsoc2013-evolution-6504fef6f4f89bc0a1632135be0e0e11c954733c.tar.zst gsoc2013-evolution-6504fef6f4f89bc0a1632135be0e0e11c954733c.zip |
Bug #502188 - Store 'Remember password' for calendars
Diffstat (limited to 'calendar')
-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; } |