Index: camel/providers/nntp/ChangeLog
===================================================================
--- camel/providers/nntp/ChangeLog	(revision 9593)
+++ camel/providers/nntp/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2008-09-23  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #553301
+
+	* camel-nntp-store.c: (camel_nntp_try_authenticate): Do not forget
+	password when server not available at the moment or user cancelled.
+	* camel-nntp-auth.c: (camel_nntp_auth_authenticate):
+	Use correct parameters.
+
 2008-08-06  Milan Crha  <mcrha@redhat.com>
 
 	** Part of fix for bug #546397
Index: camel/providers/nntp/camel-nntp-store.c
===================================================================
--- camel/providers/nntp/camel-nntp-store.c	(revision 9593)
+++ camel/providers/nntp/camel-nntp-store.c	(working copy)
@@ -1189,8 +1189,14 @@ camel_nntp_try_authenticate (CamelNNTPSt
 
 	if (ret != NNTP_AUTH_ACCEPTED) {
 		if (ret != -1) {
+			if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_USER_CANCEL ||
+			    camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_UNAVAILABLE)
+				return ret;
+
 			/* Need to forget the password here since we have no context on it */
 			camel_session_forget_password(session, service, NULL, "password", ex);
+			g_free (service->url->passwd);
+			service->url->passwd = NULL;
 			goto retry;
 		}
 		return -1;
Index: camel/providers/nntp/camel-nntp-auth.c
===================================================================
--- camel/providers/nntp/camel-nntp-auth.c	(revision 9593)
+++ camel/providers/nntp/camel-nntp-auth.c	(working copy)
@@ -47,7 +47,7 @@ camel_nntp_auth_authenticate (CamelNNTPS
 			"NNTP", service->url->user, service->url->host);
 
 		service->url->passwd = camel_session_get_password (
-			session, prompt, TRUE, service, "password", ex);
+			session, service, NULL, prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);
 
 		g_free (prompt);
 
Index: camel/providers/pop3/ChangeLog
===================================================================
--- camel/providers/pop3/ChangeLog	(revision 9593)
+++ camel/providers/pop3/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2008-09-23  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #553301
+
+	* camel-pop3-store.c: (pop3_try_authenticate):
+	Return 'int', not gboolean.
+	* camel-pop3-store.c: (pop3_connect):
+	Also forget password in a session before reprompting it.
+
 2008-09-08  Patrick Ohly  <patrick.ohly@gmx.de>
 
 	** Fixes memory leak created by patch for #514827
Index: camel/providers/pop3/camel-pop3-store.c
===================================================================
--- camel/providers/pop3/camel-pop3-store.c	(revision 9593)
+++ camel/providers/pop3/camel-pop3-store.c	(working copy)
@@ -489,7 +489,7 @@ pop3_try_authenticate (CamelService *ser
 		g_free (base_prompt);
 		g_free (full_prompt);
 		if (!service->url->passwd)
-			return FALSE;
+			return 0;
 	}
 
 	if (!service->url->authmech) {
@@ -509,7 +509,7 @@ pop3_try_authenticate (CamelService *ser
 						_("Unable to connect to POP server %s:	Invalid APOP ID received. Impersonation attack suspected. Please contact your admin."),
 						CAMEL_SERVICE (store)->url->host);
 
-				return FALSE;
+				return 0;
 			}
 			d++;
 		}
@@ -528,7 +528,7 @@ pop3_try_authenticate (CamelService *ser
 		while (l) {
 			auth = l->data;
 			if (strcmp(auth->authproto, service->url->authmech) == 0)
-				return try_sasl(store, service->url->authmech, ex) == -1;
+				return try_sasl (store, service->url->authmech, ex);
 			l = l->next;
 		}
 		
@@ -536,7 +536,7 @@ pop3_try_authenticate (CamelService *ser
 				      _("Unable to connect to POP server %s: "
 					"No support for requested authentication mechanism."),
 				      CAMEL_SERVICE (store)->url->host);
-		return FALSE;
+		return 0;
 	}
 	
 	while ((status = camel_pop3_engine_iterate(store->engine, pcp)) > 0)
@@ -610,10 +610,14 @@ pop3_connect (CamelService *service, Cam
 		/* we only re-prompt if we failed to authenticate, any other error and we just abort */
 		if (status == 0 && camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE) {
 			errbuf = g_markup_printf_escaped ("%s\n\n", camel_exception_get_description (ex));
+			camel_exception_clear (ex);
+
+			camel_session_forget_password (session, service, NULL, "password", ex);
+			camel_exception_clear (ex);
+
 			g_free (service->url->passwd);
 			service->url->passwd = NULL;
 			reprompt = TRUE;
-			camel_exception_clear (ex);
 		} else
 			break;
 	}
Index: camel/providers/smtp/ChangeLog
===================================================================
--- camel/providers/smtp/ChangeLog	(revision 9593)
+++ camel/providers/smtp/ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2008-09-23  Milan Crha  <mcrha@redhat.com>
+
+	** Part of fix for bug #553301
+
+	* camel-smtp-transport.c: (smtp_connect): Do not forget password
+	when server not available at the moment or user cancelled.
+	* camel-smtp-transport.c: (smtp_data): Compiler warning cleanup.
+
 2008-06-20  Jeffrey Stedfast  <fejj@novell.com>
 
 	* camel-smtp-transport.c (smtp_data): Setup progress reporting for
Index: camel/providers/smtp/camel-smtp-transport.c
===================================================================
--- camel/providers/smtp/camel-smtp-transport.c	(revision 9593)
+++ camel/providers/smtp/camel-smtp-transport.c	(working copy)
@@ -560,6 +560,10 @@ smtp_connect (CamelService *service, Cam
 
 			authenticated = smtp_auth (transport, authtype->authproto, ex);
 			if (!authenticated) {
+				if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_USER_CANCEL ||
+				    camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_UNAVAILABLE)
+					return FALSE;
+
 				errbuf = g_markup_printf_escaped (
 					_("Unable to authenticate "
 					  "to SMTP server.\n%s\n\n"),
@@ -1369,7 +1373,7 @@ smtp_data (CamelSmtpTransport *transport
 	}
 	
 	/* find out how large the message is... */
-	null = camel_stream_null_new ();
+	null = CAMEL_STREAM_NULL (camel_stream_null_new ());
 	camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (null));
 	
 	filtered_stream = camel_stream_filter_new_with_stream (transport->ostream);
