From ded1f87e4c9b206906ee0587c1ecc648e36b4ac3 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Fri, 19 Nov 2004 05:26:47 +0000 Subject: Make debug run based on 'nntp' debug option. 2004-11-18 Not Zed * providers/nntp/camel-nntp-stream.c: * providers/nntp/camel-nntp-store.c: * providers/nntp/camel-nntp-summary.c: Make debug run based on 'nntp' debug option. * providers/nntp/camel-nntp-stream.c (stream_fill): if we get a 0 read, return ECONNRESET. This should really have been put on the stream for that imap hack fix. * providers/nntp/camel-nntp-store.c (camel_nntp_try_authenticate): retry if the password attempt failed. ** See bug #68556. * providers/nntp/camel-nntp-store.c (xover_setup): don't overwrite exception if we get a failure. (camel_nntp_command): if we continue, then set the return code to -1, so we re-loop rather than abort. svn path=/trunk/; revision=27946 --- camel/ChangeLog | 21 +++++++++++++++++ camel/providers/nntp/camel-nntp-store.c | 39 ++++++++++++++++++++----------- camel/providers/nntp/camel-nntp-stream.c | 8 ++++--- camel/providers/nntp/camel-nntp-summary.c | 4 ++-- 4 files changed, 53 insertions(+), 19 deletions(-) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index e90ca8c61c..ed476ad02f 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,24 @@ +2004-11-18 Not Zed + + * providers/nntp/camel-nntp-stream.c: + * providers/nntp/camel-nntp-store.c: + * providers/nntp/camel-nntp-summary.c: Make debug run based on + 'nntp' debug option. + + * providers/nntp/camel-nntp-stream.c (stream_fill): if we get a 0 + read, return ECONNRESET. This should really have been put on the + stream for that imap hack fix. + + * providers/nntp/camel-nntp-store.c (camel_nntp_try_authenticate): + retry if the password attempt failed. + + ** See bug #68556. + + * providers/nntp/camel-nntp-store.c (xover_setup): don't overwrite + exception if we get a failure. + (camel_nntp_command): if we continue, then set the return code to + -1, so we re-loop rather than abort. + 2004-11-15 Jeffrey Stedfast * providers/pop3/camel-pop3-store.c (connect_to_server_wrapper): diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c index 67ca1829a1..2427d9577a 100644 --- a/camel/providers/nntp/camel-nntp-store.c +++ b/camel/providers/nntp/camel-nntp-store.c @@ -45,6 +45,7 @@ #include #include #include "camel/camel-private.h" +#include #include "camel-nntp-summary.h" #include "camel-nntp-store.h" @@ -55,8 +56,7 @@ #include "camel-i18n.h" #define w(x) -extern int camel_verbose_debug; -#define dd(x) (camel_verbose_debug?(x):0) +#define dd(x) (camel_debug("nntp")?(x):0) #define NNTP_PORT "119" #define NNTPS_PORT "563" @@ -111,8 +111,6 @@ xover_setup(CamelNNTPStore *store, CamelException *ex) ret = camel_nntp_raw_command_auth(store, ex, &line, "list overview.fmt"); if (ret == -1) { - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, - _("NNTP Command failed: %s"), g_strerror(errno)); return -1; } else if (ret != 215) /* unsupported command? ignore */ @@ -1130,25 +1128,36 @@ camel_nntp_try_authenticate (CamelNNTPStore *store, CamelException *ex) CamelService *service = (CamelService *) store; CamelSession *session = camel_service_get_session (service); int ret; - char *line; + char *line = NULL; if (!service->url->user) { camel_exception_setv(ex, CAMEL_EXCEPTION_INVALID_PARAM, _("Authentication requested but no username provided")); return -1; } - + /* if nessecary, prompt for the password */ if (!service->url->passwd) { - char *prompt; - - prompt = g_strdup_printf (_("Please enter the NNTP password for %s@%s"), - service->url->user, - service->url->host); + char *prompt, *base; + retry: + base = g_strdup_printf (_("Please enter the NNTP password for %s@%s"), + service->url->user, + service->url->host); + if (line) { + char *top = g_strdup_printf(_("Cannot authenticate to server: %s"), line); + + prompt = g_strdup_printf("%s\n\n%s", top, base); + g_free(top); + } else { + prompt = base; + base = NULL; + } + service->url->passwd = camel_session_get_password (session, service, NULL, prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex); - g_free (prompt); + g_free(prompt); + g_free(base); if (!service->url->passwd) return -1; @@ -1163,8 +1172,7 @@ camel_nntp_try_authenticate (CamelNNTPStore *store, CamelException *ex) if (ret != -1) { /* Need to forget the password here since we have no context on it */ camel_session_forget_password(session, service, NULL, "password", ex); - camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE, - _("Cannot authenticate to server: %s"), line); + goto retry; } return -1; } @@ -1356,6 +1364,8 @@ camel_nntp_command (CamelNNTPStore *store, CamelException *ex, CamelNNTPFolder * case NNTP_AUTH_REQUIRED: if (camel_nntp_try_authenticate(store, ex) != NNTP_AUTH_ACCEPTED) return -1; + retry--; + ret = -1; continue; case 411: /* no such group */ camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID, @@ -1365,6 +1375,7 @@ camel_nntp_command (CamelNNTPStore *store, CamelException *ex, CamelNNTPFolder * case 401: /* wrong client state - this should quit but this is what the old code did */ case 503: /* information not available - this should quit but this is what the old code did (?) */ camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); + ret = -1; continue; case -1: /* i/o error */ camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL); diff --git a/camel/providers/nntp/camel-nntp-stream.c b/camel/providers/nntp/camel-nntp-stream.c index 1e2dcb23f9..bc62c0a0c2 100644 --- a/camel/providers/nntp/camel-nntp-stream.c +++ b/camel/providers/nntp/camel-nntp-stream.c @@ -32,9 +32,9 @@ #include #include "camel-nntp-stream.h" +#include "camel-debug.h" -extern int camel_verbose_debug; -#define dd(x) (camel_verbose_debug?(x):0) +#define dd(x) (camel_debug("nntp:stream")?(x):0) static CamelObjectClass *parent_class = NULL; @@ -60,7 +60,9 @@ stream_fill(CamelNNTPStream *is) is->end[0] = '\n'; return is->end - is->ptr; } else { - dd(printf("NNTP_STREAM_FILL(ERROR): '%s'\n", strerror(errno))); + if (left == 0) + errno = ECONNRESET; + dd(printf("NNTP_STREAM_FILL(ERROR): %d - '%s'\n", left, strerror(errno))); return -1; } } diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c index 213c6f9045..e6c02b95af 100644 --- a/camel/providers/nntp/camel-nntp-summary.c +++ b/camel/providers/nntp/camel-nntp-summary.c @@ -37,6 +37,7 @@ #include "camel/camel-operation.h" #include "camel/camel-data-cache.h" #include "camel/camel-i18n.h" +#include "camel/camel-debug.h" #include "camel-nntp-summary.h" #include "camel-nntp-folder.h" @@ -46,8 +47,7 @@ #define w(x) #define io(x) #define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/ -extern int camel_verbose_debug; -#define dd(x) (camel_verbose_debug?(x):0) +#define dd(x) (camel_debug("nntp")?(x):0) #define CAMEL_NNTP_SUMMARY_VERSION (1) -- cgit