diff options
author | Not Zed <NotZed@Ximian.com> | 2004-11-19 13:26:47 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-11-19 13:26:47 +0800 |
commit | ded1f87e4c9b206906ee0587c1ecc648e36b4ac3 (patch) | |
tree | d9b737895f8d4f62c6eedde6c14ee3c8ba62cc9f /camel/providers/nntp | |
parent | eccb379e0ca17bb136a05eaafccaa8186420028e (diff) | |
download | gsoc2013-evolution-ded1f87e4c9b206906ee0587c1ecc648e36b4ac3.tar.gz gsoc2013-evolution-ded1f87e4c9b206906ee0587c1ecc648e36b4ac3.tar.zst gsoc2013-evolution-ded1f87e4c9b206906ee0587c1ecc648e36b4ac3.zip |
Make debug run based on 'nntp' debug option.
2004-11-18 Not Zed <NotZed@Ximian.com>
* 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
Diffstat (limited to 'camel/providers/nntp')
-rw-r--r-- | camel/providers/nntp/camel-nntp-store.c | 39 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-stream.c | 8 | ||||
-rw-r--r-- | camel/providers/nntp/camel-nntp-summary.c | 4 |
3 files changed, 32 insertions, 19 deletions
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 <camel/camel-disco-store.h> #include <camel/camel-disco-diary.h> #include "camel/camel-private.h" +#include <camel/camel-debug.h> #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 <glib.h> #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) |