aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-04-21 00:44:00 +0800
committerMilan Crha <mcrha@redhat.com>2011-04-21 00:44:00 +0800
commit7bd0191f4f09cbaac08454674f4012b68e79a437 (patch)
treed78ec01a7be08a8e0066a1d55db827f676542ffc
parent36049edd4c86cd86eff25e2b60fa062072ce124b (diff)
downloadgsoc2013-evolution-7bd0191f4f09cbaac08454674f4012b68e79a437.tar
gsoc2013-evolution-7bd0191f4f09cbaac08454674f4012b68e79a437.tar.gz
gsoc2013-evolution-7bd0191f4f09cbaac08454674f4012b68e79a437.tar.bz2
gsoc2013-evolution-7bd0191f4f09cbaac08454674f4012b68e79a437.tar.lz
gsoc2013-evolution-7bd0191f4f09cbaac08454674f4012b68e79a437.tar.xz
gsoc2013-evolution-7bd0191f4f09cbaac08454674f4012b68e79a437.tar.zst
gsoc2013-evolution-7bd0191f4f09cbaac08454674f4012b68e79a437.zip
Bug #502188 - Store 'Remember password' for calendars
-rw-r--r--calendar/common/authentication.c42
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;
}