aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/imap/camel-imap-store.c10
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c58
2 files changed, 59 insertions, 9 deletions
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 26cfeb765f..ec65d499b3 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -404,9 +404,8 @@ imap_connect (CamelService *service, CamelException *ex)
if (service->url->authmech) {
if (!g_hash_table_lookup (store->authtypes, service->url->authmech)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- "IMAP server %s does not "
- "support requested "
- "authentication type %s",
+ _("IMAP server %s does not support requested "
+ "authentication type %s"),
service->url->host,
service->url->authmech);
camel_service_disconnect (service, TRUE, NULL);
@@ -416,8 +415,7 @@ imap_connect (CamelService *service, CamelException *ex)
authtype = camel_sasl_authtype (service->url->authmech);
if (!authtype) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
- "No support for "
- "authentication type %s",
+ _("No support for authentication type %s"),
service->url->authmech);
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
@@ -460,7 +458,7 @@ imap_connect (CamelService *service, CamelException *ex)
if (!service->url->passwd) {
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
- "You didn\'t enter a password.");
+ _("You didn't enter a password."));
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
}
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 90a9c5f377..0d2c75398c 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -280,7 +280,10 @@ smtp_connect (CamelService *service, CamelException *ex)
/* check to see if AUTH is required, if so...then AUTH ourselves */
if (service->url->authmech) {
+ CamelSession *session = camel_service_get_session (service);
CamelServiceAuthType *authtype;
+ gboolean authenticated = FALSE;
+ char *errbuf = NULL;
if (!transport->is_esmtp || !g_hash_table_lookup (transport->authtypes, service->url->authmech)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
@@ -300,9 +303,58 @@ smtp_connect (CamelService *service, CamelException *ex)
return FALSE;
}
- if (!smtp_auth (transport, authtype->authproto, ex)) {
- camel_service_disconnect (service, TRUE, NULL);
- return FALSE;
+ if (!authtype->need_password) {
+ /* authentication mechanism doesn't need a password,
+ so if it fails there's nothing we can do */
+ authenticated = smtp_auth (transport, authtype->authproto, ex);
+ if (!authenticated) {
+ camel_service_disconnect (service, TRUE, NULL);
+ return FALSE;
+ }
+ }
+
+ /* keep trying to login until either we succeed or the user cancels */
+ while (!authenticated) {
+ if (errbuf) {
+ /* We need to un-cache the password before prompting again */
+ camel_session_query_authenticator (
+ session, CAMEL_AUTHENTICATOR_TELL, NULL,
+ TRUE, service, "password", ex);
+ g_free (service->url->passwd);
+ service->url->passwd = NULL;
+ }
+
+ if (!service->url->passwd) {
+ char *prompt;
+
+ prompt = g_strdup_printf (_("%sPlease enter the SMTP password for %s@%s"),
+ errbuf ? errbuf : "", service->url->user,
+ service->url->host);
+
+ service->url->passwd =
+ camel_session_query_authenticator (
+ session, CAMEL_AUTHENTICATOR_ASK,
+ prompt, TRUE, service, "password", ex);
+
+ g_free (prompt);
+ g_free (errbuf);
+ errbuf = NULL;
+
+ if (!service->url->passwd) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
+ _("You didn't enter a password."));
+ camel_service_disconnect (service, TRUE, NULL);
+ return FALSE;
+ }
+ }
+
+ authenticated = smtp_auth (transport, authtype->authproto, ex);
+ if (!authenticated) {
+ errbuf = g_strdup_printf (_("Unable to authenticate "
+ "to IMAP server.\n%s\n\n"),
+ camel_exception_get_description (ex));
+ camel_exception_clear (ex);
+ }
}
/* we have to re-EHLO */