diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2013-01-24 07:57:02 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2013-01-24 07:57:02 +0000 |
commit | 1bab6bdd955adcd88d9169ad808b47924443eacd (patch) | |
tree | 06953251c84f86f7f83656f036ca01eff6dc0889 | |
parent | ed5e41fbf46d5820d596c853378bdf45355e6efa (diff) |
do not disconnect immediately but send QUIT on normal POP3 errors.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3194 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | libsylph/pop.c | 37 | ||||
-rw-r--r-- | src/inc.c | 4 |
3 files changed, 34 insertions, 13 deletions
@@ -1,3 +1,9 @@ +2013-01-24 + + * libsylph/pop.c + src/inc.c: do not disconnect immediately but send QUIT on normal + POP3 errors. + 2013-01-22 * src/main.c diff --git a/libsylph/pop.c b/libsylph/pop.c index 4be646ba..c5b86b2e 100644 --- a/libsylph/pop.c +++ b/libsylph/pop.c @@ -116,7 +116,7 @@ gint pop3_stls_recv(Pop3Session *session) { if (session_start_tls(SESSION(session)) < 0) { session->error_val = PS_SOCKET; - return -1; + return PS_SOCKET; } return PS_SUCCESS; } @@ -156,13 +156,13 @@ gint pop3_getauth_apop_send(Pop3Session *session) log_warning(_("Required APOP timestamp not found " "in greeting\n")); session->error_val = PS_PROTOCOL; - return -1; + return PS_PROTOCOL; } if ((end = strchr(start, '>')) == NULL || end == start + 1) { log_warning(_("Timestamp syntax error in greeting\n")); session->error_val = PS_PROTOCOL; - return -1; + return PS_PROTOCOL; } *(end + 1) = '\0'; @@ -170,7 +170,7 @@ gint pop3_getauth_apop_send(Pop3Session *session) if (!is_ascii_str(start) || strchr(start, '@') == NULL) { log_warning(_("Invalid timestamp in greeting\n")); session->error_val = PS_PROTOCOL; - return -1; + return PS_PROTOCOL; } apop_str = g_strconcat(start, session->pass, NULL); @@ -198,7 +198,7 @@ gint pop3_getrange_stat_recv(Pop3Session *session, const gchar *msg) if (sscanf(msg, "%d %lld", &session->count, &session->total_bytes) != 2) { log_warning(_("POP3 protocol error\n")); session->error_val = PS_PROTOCOL; - return -1; + return PS_PROTOCOL; } else { if (session->count == 0) { session->uidl_is_valid = TRUE; @@ -225,7 +225,7 @@ gint pop3_getrange_last_recv(Pop3Session *session, const gchar *msg) if (sscanf(msg, "%d", &last) == 0) { log_warning(_("POP3 protocol error\n")); session->error_val = PS_PROTOCOL; - return -1; + return PS_PROTOCOL; } else { if (session->count > last) { session->new_msg_exist = TRUE; @@ -257,7 +257,7 @@ gint pop3_getrange_uidl_recv(Pop3Session *session, const gchar *data, guint len) while (p < lastp) { if ((newline = memchr(p, '\r', lastp - p)) == NULL) - return -1; + return PS_PROTOCOL; buf_len = MIN(newline - p, sizeof(buf) - 1); memcpy(buf, p, buf_len); buf[buf_len] = '\0'; @@ -309,7 +309,7 @@ gint pop3_getsize_list_recv(Pop3Session *session, const gchar *data, guint len) while (p < lastp) { if ((newline = memchr(p, '\r', lastp - p)) == NULL) - return -1; + return PS_PROTOCOL; buf_len = MIN(newline - p, sizeof(buf) - 1); memcpy(buf, p, buf_len); buf[buf_len] = '\0'; @@ -319,7 +319,7 @@ gint pop3_getsize_list_recv(Pop3Session *session, const gchar *data, guint len) if (sscanf(buf, "%u %u", &num, &size) != 2) { session->error_val = PS_PROTOCOL; - return -1; + return PS_PROTOCOL; } if (num > 0 && num <= session->count) @@ -347,7 +347,7 @@ gint pop3_retr_recv(Pop3Session *session, FILE *fp, guint len) if (pop3_write_msg_to_file(file, fp, len) < 0) { g_free(file); session->error_val = PS_IOERR; - return -1; + return PS_IOERR; } drop_ok = session->drop_message(session, file); @@ -355,7 +355,7 @@ gint pop3_retr_recv(Pop3Session *session, FILE *fp, guint len) g_free(file); if (drop_ok < 0) { session->error_val = PS_IOERR; - return -1; + return PS_IOERR; } session->cur_total_bytes += session->msg[session->cur_msg].size; @@ -723,7 +723,10 @@ Pop3ErrorValue pop3_ok(Pop3Session *session, const gchar *msg) } else ok = PS_PROTOCOL; - session->error_val = ok; + /* don't overwrite previous error on logout */ + if (session->state != POP3_LOGOUT) + session->error_val = ok; + return ok; } @@ -738,10 +741,18 @@ static gint pop3_session_recv_msg(Session *session, const gchar *msg) pop3_session->state != POP3_GETSIZE_LIST_RECV) { val = pop3_ok(pop3_session, msg); if (val != PS_SUCCESS) { - if (val != PS_NOTSUPPORTED) { + if (val == PS_SOCKET) { pop3_session->state = POP3_ERROR; return -1; } + if (val != PS_NOTSUPPORTED) { + if (pop3_session->state != POP3_LOGOUT) { + if (pop3_logout_send(pop3_session) == PS_SUCCESS) + return 0; + else + return -1; + } + } } if (*body == '+' || *body == '-') @@ -1038,6 +1038,10 @@ static IncState inc_pop3_session_do(IncSession *session) } log_window_flush(); + debug_print("inc_state: %d\n", session->inc_state); + debug_print("pop3_session.error_val: %d\n", pop3_session->error_val); + debug_print("pop3_session.error_msg: %s\n", pop3_session->error_msg ? pop3_session->error_msg : "(empty)"); + if (session->inc_state == INC_SUCCESS) { switch (pop3_session->error_val) { case PS_SUCCESS: |