[evolution/webkit] Bug #502188 - Store 'Remember password' for calendars



commit 5c7bfe3ef623707ab473b56e3ac1a1617972f8d2
Author: Milan Crha <mcrha redhat com>
Date:   Wed Apr 20 18:42:24 2011 +0200

    Bug #502188 - Store 'Remember password' for calendars

 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 ddcc0ff..7989107 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;
 }
 



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