[evolution-groupwise] CamelGroupwiseStore: Use camel_service_set_password().



commit bf0da280b372f0351a7e820fc37c618a87596505
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Sep 25 20:06:49 2011 -0400

    CamelGroupwiseStore: Use camel_service_set_password().
    
    Instead of stashing the password in its CamelURL.

 src/camel/camel-groupwise-store.c |   31 +++++++++++++++++++++----------
 src/plugins/share-folder-common.c |    4 +++-
 2 files changed, 24 insertions(+), 11 deletions(-)
---
diff --git a/src/camel/camel-groupwise-store.c b/src/camel/camel-groupwise-store.c
index c4aec51..b50a0a8 100644
--- a/src/camel/camel-groupwise-store.c
+++ b/src/camel/camel-groupwise-store.c
@@ -114,6 +114,7 @@ groupwise_auth_loop (CamelService *service,
 	gchar *uri;
 	guint32 prompt_flags = CAMEL_SESSION_PASSWORD_SECRET;
 	const gchar *scheme;
+	const gchar *password;
 	EGwConnectionErrors errors = {E_GW_CONNECTION_STATUS_INVALID_OBJECT, NULL};
 	guint16 soap_port;
 
@@ -134,22 +135,32 @@ groupwise_auth_loop (CamelService *service,
 	uri = g_strdup_printf (
 		"%s://%s:%u/soap", scheme, priv->server_name, soap_port);
 
-	url->passwd = NULL;
+	camel_service_set_password (service, NULL);
+	password = camel_service_get_password (service);
 
 	while (!authenticated) {
 
-		if (!url->passwd && !(store->flags & CAMEL_STORE_PROXY)) {
+		if (password == NULL && !(store->flags & CAMEL_STORE_PROXY)) {
 			gchar *prompt;
+			gchar *new_passwd;
 
 			prompt = camel_session_build_password_prompt (
 				"GroupWise", url->user, url->host);
-			url->passwd =
-				camel_session_get_password (
-					session, service, prompt,
-					"password", prompt_flags, error);
+
+			/* XXX This is a tad awkward.  Maybe define a
+			 *     camel_service_ask_password() that calls
+			 *     camel_session_get_password() and caches
+			 *     the password itself? */
+			new_passwd = camel_session_get_password (
+				session, service, prompt,
+				"password", prompt_flags, error);
+			camel_service_set_password (service, new_passwd);
+			password = camel_service_get_password (service);
+			g_free (new_passwd);
+
 			g_free (prompt);
 
-			if (!url->passwd) {
+			if (password == NULL) {
 				g_set_error (
 					error, G_IO_ERROR,
 					G_IO_ERROR_CANCELLED,
@@ -158,14 +169,14 @@ groupwise_auth_loop (CamelService *service,
 			}
 		}
 
-		priv->cnc = e_gw_connection_new_with_error_handler (uri, priv->user, url->passwd, &errors);
+		priv->cnc = e_gw_connection_new_with_error_handler (uri, priv->user, password, &errors);
 
 		if (!E_IS_GW_CONNECTION (priv->cnc)) {
 			if (errors.status == E_GW_CONNECTION_STATUS_INVALID_PASSWORD) {
 				/* We need to un-cache the password before prompting again */
 				prompt_flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
-				g_free (url->passwd);
-				url->passwd = NULL;
+				camel_service_set_password (service, NULL);
+				password = camel_service_get_password (service);
 			} else {
 				g_set_error (
 					error, CAMEL_SERVICE_ERROR,
diff --git a/src/plugins/share-folder-common.c b/src/plugins/share-folder-common.c
index 23ab3ef..90ea304 100644
--- a/src/plugins/share-folder-common.c
+++ b/src/plugins/share-folder-common.c
@@ -441,6 +441,7 @@ get_cnc (CamelStore *store)
 	CamelURL *url;
 	CamelNetworkSecurityMethod security_method;
 	const gchar *scheme;
+	const gchar *password;
 	guint16 soap_port;
 
 	if (!store)
@@ -448,6 +449,7 @@ get_cnc (CamelStore *store)
 
 	service = CAMEL_SERVICE (store);
 	url = camel_service_get_camel_url (service);
+	password = camel_service_get_password (service);
 	settings = camel_service_get_settings (service);
 	server_name = g_strdup (url->host);
 	user = g_strdup (url->user);
@@ -466,7 +468,7 @@ get_cnc (CamelStore *store)
 	uri = g_strdup_printf (
 		"%s://%s:%u/soap", scheme, server_name, soap_port);
 
-	return e_gw_connection_new (uri, user, url->passwd);
+	return e_gw_connection_new (uri, user, password);
 }
 
 gchar *



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