[evolution-data-server/email-factory] Add a handler for NEED_PASSWORD and let the backends return it when the password isn't available for



commit afeaeff3262f17dd87ad4e564bd4c493cc1a2cd9
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Tue Apr 19 19:01:58 2011 +0530

    Add a handler for NEED_PASSWORD and let the backends return it when the
    password isn't available for the backend.

 camel/camel-gpg-context.c                         |    6 +++---
 camel/camel-service.h                             |    3 ++-
 camel/providers/groupwise/camel-groupwise-store.c |    6 +++---
 camel/providers/imap/camel-imap-store.c           |    6 +++---
 camel/providers/imapx/camel-imapx-server.c        |    6 +++---
 camel/providers/nntp/camel-nntp-store.c           |    7 ++++++-
 camel/providers/pop3/camel-pop3-store.c           |    7 ++++++-
 camel/providers/smtp/camel-smtp-transport.c       |    4 ++++
 8 files changed, 30 insertions(+), 15 deletions(-)
---
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index 538306e..825fc36 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -882,9 +882,9 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg,
 		} else {
 			if (local_error == NULL)
 				g_set_error (
-					error, G_IO_ERROR,
-					G_IO_ERROR_CANCELLED,
-					_("Cancelled"));
+					error, CAMEL_SERVICE_ERROR,
+					CAMEL_SERVICE_ERROR_NEED_PASSWORD,
+					_("Need password for authentication"));
 			g_propagate_error (error, local_error);
 
 			return -1;
diff --git a/camel/camel-service.h b/camel/camel-service.h
index d1efa89..250d52e 100644
--- a/camel/camel-service.h
+++ b/camel/camel-service.h
@@ -79,7 +79,8 @@ typedef enum {
 	CAMEL_SERVICE_ERROR_URL_INVALID,
 	CAMEL_SERVICE_ERROR_UNAVAILABLE,
 	CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
-	CAMEL_SERVICE_ERROR_NOT_CONNECTED
+	CAMEL_SERVICE_ERROR_NOT_CONNECTED,
+	CAMEL_SERVICE_ERROR_NEED_PASSWORD
 } CamelServiceError;
 
 typedef enum {
diff --git a/camel/providers/groupwise/camel-groupwise-store.c b/camel/providers/groupwise/camel-groupwise-store.c
index 563117a..f1a30d0 100644
--- a/camel/providers/groupwise/camel-groupwise-store.c
+++ b/camel/providers/groupwise/camel-groupwise-store.c
@@ -202,9 +202,9 @@ groupwise_auth_loop (CamelService *service, GError **error)
 
 			if (!service->url->passwd) {
 				g_set_error (
-					error, G_IO_ERROR,
-					G_IO_ERROR_CANCELLED,
-					_("You did not enter a password."));
+					error, CAMEL_SERVICE_ERROR,
+					CAMEL_SERVICE_ERROR_NEED_PASSWORD,
+					_("Need password for authentication"));
 				return FALSE;
 			}
 		}
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index d241ee5..f3c8dad 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -1183,9 +1183,9 @@ imap_auth_loop (CamelService *service, GError **error)
 
 			if (!service->url->passwd) {
 				g_set_error (
-					error, G_IO_ERROR,
-					G_IO_ERROR_CANCELLED,
-					_("You did not enter a password."));
+					error, CAMEL_SERVICE_ERROR,
+					CAMEL_SERVICE_ERROR_NEED_PASSWORD,
+					_("Need password for authentication"));
 				return FALSE;
 			}
 		}
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 179252d..1f4ebb4 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -3030,9 +3030,9 @@ imapx_reconnect (CamelIMAPXServer *is, GError **error)
 
 			if (!service->url->passwd) {
 				g_set_error (
-					error, G_IO_ERROR,
-					G_IO_ERROR_CANCELLED,
-					_("You did not enter a password."));
+					error, CAMEL_SERVICE_ERROR,
+					CAMEL_SERVICE_ERROR_NEED_PASSWORD,
+					_("Need password for authentication"));
 				goto exception;
 			}
 		}
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 943368d..6a8e220 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -1281,8 +1281,13 @@ camel_nntp_try_authenticate (CamelNNTPStore *store, GError **error)
 		g_free(prompt);
 		g_free(base);
 
-		if (!service->url->passwd)
+		if (!service->url->passwd) {
+			g_set_error (
+				error, CAMEL_SERVICE_ERROR,
+				CAMEL_SERVICE_ERROR_NEED_PASSWORD,
+				_("Need password for authentication"));
 			return -1;
+		}
 
 		store->password_reprompt = FALSE;
 	}
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index d55dc5d..dda306e 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -398,8 +398,13 @@ pop3_try_authenticate (CamelService *service,
 
 		g_free (base_prompt);
 		g_free (full_prompt);
-		if (!service->url->passwd)
+		if (!service->url->passwd) {
+			g_set_error (
+				error, CAMEL_SERVICE_ERROR,
+				CAMEL_SERVICE_ERROR_NEED_PASSWORD,
+				_("Need password for authentication"));
 			return -1;
+		}
 	}
 
 	if (!service->url->authmech) {
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 9f927ee..272e444 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -510,6 +510,10 @@ smtp_connect (CamelService *service, GError **error)
 				errbuf = NULL;
 
 				if (!service->url->passwd) {
+					g_set_error (
+						error, CAMEL_SERVICE_ERROR,
+						CAMEL_SERVICE_ERROR_NEED_PASSWORD,
+						_("Need password for authentication"));	
 					camel_service_disconnect (service, TRUE, NULL);
 					return FALSE;
 				}



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