From 1acd03710d50072259f91bae1a9e2395c6bdfac7 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 6 May 2002 22:35:47 +0000 Subject: If the pop3 command status is -1, then we probably have a TCP error (?) so 2002-05-06 Jeffrey Stedfast * providers/pop3/camel-pop3-store.c (pop3_try_authenticate): If the pop3 command status is -1, then we probably have a TCP error (?) so set a SYSTEM exception so our caller can distinguish between a "bad password" and a "tcp error". (pop3_connect): Only uncache the password on "bad password" errors. svn path=/trunk/; revision=16700 --- camel/providers/pop3/camel-pop3-engine.c | 1 - camel/providers/pop3/camel-pop3-store.c | 36 +++++++++++++++++++------------- 2 files changed, 22 insertions(+), 15 deletions(-) (limited to 'camel/providers') diff --git a/camel/providers/pop3/camel-pop3-engine.c b/camel/providers/pop3/camel-pop3-engine.c index 1783520b7c..a76df8f9bc 100644 --- a/camel/providers/pop3/camel-pop3-engine.c +++ b/camel/providers/pop3/camel-pop3-engine.c @@ -315,7 +315,6 @@ camel_pop3_engine_iterate(CamelPOP3Engine *pe, CamelPOP3Command *pcwait) e_dlist_remove((EDListNode *)pw); - pe->sentlen += strlen(pw->data); pw->state = CAMEL_POP3_COMMAND_DISPATCHED; diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index dcdeefb392..ebf55ccd10 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -439,9 +439,9 @@ pop3_try_authenticate (CamelService *service, const char *errmsg, CamelException *ex) { CamelPOP3Store *store = (CamelPOP3Store *)service; - int status; CamelPOP3Command *pcu = NULL, *pcp = NULL; - + int status; + /* override, testing only */ /*printf("Forcing authmech to 'login'\n"); service->url->authmech = g_strdup("LOGIN");*/ @@ -494,14 +494,19 @@ pop3_try_authenticate (CamelService *service, const char *errmsg, "authentication mechanism.")); return FALSE; } - - while (camel_pop3_engine_iterate(store->engine, pcp) > 0) + + while ((status = camel_pop3_engine_iterate(store->engine, pcp)) > 0) ; - status = pcp->state != CAMEL_POP3_COMMAND_OK; - if (status) { - camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, - _("Unable to connect to POP server.\nError sending password: %s"), - store->engine->line); + + if (status != CAMEL_POP3_COMMAND_OK) { + if (status == CAMEL_POP3_COMMAND_ERR) + camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, + _("Unable to connect to POP server.\nError sending password: %s"), + store->engine->line); + else + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Unable to connect to POP server.\nError sending password: %s"), + errno ? g_strerror (errno) : _("Unknown error")); } camel_pop3_engine_command_free(store->engine, pcp); @@ -542,11 +547,14 @@ pop3_connect (CamelService *service, CamelException *ex) errbuf = g_strdup_printf ("%s\n\n", camel_exception_get_description (ex)); camel_exception_clear (ex); - /* Uncache the password before prompting again. */ - camel_session_forget_password (camel_service_get_session (service), - service, "password", ex); - g_free (service->url->passwd); - service->url->passwd = NULL; + /* don't forget the password if we encountered an unknown error */ + if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE) { + /* Uncache the password before prompting again. */ + camel_session_forget_password (camel_service_get_session (service), + service, "password", ex); + g_free (service->url->passwd); + service->url->passwd = NULL; + } } tryagain = pop3_try_authenticate (service, errbuf, ex); -- cgit v1.2.3