From db6fba9eea92111a486bc72a6cf2a220af6b3032 Mon Sep 17 00:00:00 2001 From: Colin Leroy Date: Thu, 10 Aug 2006 16:36:19 +0000 Subject: [PATCH 1/1] 2006-08-10 [colin] 2.4.0cvs39 * src/main.c Fix default font size setting after wizard run * src/imap.c * src/etpan/imap-thread.c * src/etpan/imap-thread.h Fix bug #999 (Timing out on TSL cert validation dialog makes ugly things happen). Also, STARTTLS unconditionnaly if initial capabilities contain LOGINDISABLED and STARTTLS. --- ChangeLog | 12 +++++++ PATCHSETS | 1 + configure.ac | 2 +- src/etpan/imap-thread.c | 7 ++-- src/etpan/imap-thread.h | 2 +- src/imap.c | 77 +++++++++++++++++++++++++++++------------ src/main.c | 1 + 7 files changed, 75 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8ef3bc290..ee86c2f83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-08-10 [colin] 2.4.0cvs39 + + * src/main.c + Fix default font size setting after wizard run + * src/imap.c + * src/etpan/imap-thread.c + * src/etpan/imap-thread.h + Fix bug #999 (Timing out on TSL cert validation + dialog makes ugly things happen). Also, STARTTLS + unconditionnaly if initial capabilities contain + LOGINDISABLED and STARTTLS. + 2006-08-09 [colin] 2.4.0cvs38 * src/mainwindow.c diff --git a/PATCHSETS b/PATCHSETS index 7d18aa804..53d183ddd 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -1730,3 +1730,4 @@ ( cvs diff -u -r 1.115.2.99 -r 1.115.2.100 src/main.c; cvs diff -u -r 1.7.2.3 -r 1.7.2.4 src/main.h; cvs diff -u -r 1.14.2.34 -r 1.14.2.35 src/plugins/trayicon/trayicon.c; ) > 2.4.0cvs36.patchset ( cvs diff -u -r 1.94.2.96 -r 1.94.2.97 src/messageview.c; cvs diff -u -r 1.60.2.38 -r 1.60.2.39 src/prefs_actions.c; cvs diff -u -r 1.59.2.39 -r 1.59.2.40 src/prefs_filtering.c; cvs diff -u -r 1.1.4.27 -r 1.1.4.28 src/prefs_filtering_action.c; cvs diff -u -r 1.43.2.42 -r 1.43.2.43 src/prefs_matcher.c; cvs diff -u -r 1.9.2.19 -r 1.9.2.20 src/plugins/clamav/clamav_plugin_gtk.c; ) > 2.4.0cvs37.patchset ( cvs diff -u -r 1.274.2.135 -r 1.274.2.136 src/mainwindow.c; cvs diff -u -r 1.39.2.18 -r 1.39.2.19 src/mainwindow.h; ) > 2.4.0cvs38.patchset +( cvs diff -u -r 1.179.2.127 -r 1.179.2.128 src/imap.c; cvs diff -u -r 1.115.2.100 -r 1.115.2.101 src/main.c; cvs diff -u -r 1.1.4.46 -r 1.1.4.47 src/etpan/imap-thread.c; cvs diff -u -r 1.1.4.10 -r 1.1.4.11 src/etpan/imap-thread.h; ) > 2.4.0cvs39.patchset diff --git a/configure.ac b/configure.ac index 03831ce3a..5ee4d0ad1 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=4 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=38 +EXTRA_VERSION=39 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/etpan/imap-thread.c b/src/etpan/imap-thread.c index 0ee012d50..263e0dcbe 100644 --- a/src/etpan/imap-thread.c +++ b/src/etpan/imap-thread.c @@ -470,7 +470,7 @@ static void capability_run(struct etpan_thread_op * op) } -struct mailimap_capability_data * imap_threaded_capability(Folder *folder) +struct mailimap_capability_data * imap_threaded_capability(Folder *folder, int *ok) { struct capa_param param; struct capa_result result; @@ -482,8 +482,11 @@ struct mailimap_capability_data * imap_threaded_capability(Folder *folder) threaded_run(folder, ¶m, &result, capability_run); - debug_print("capa ok\n"); + debug_print("capa %d\n", result.error); + if (ok) + *ok = result.error; + return result.caps; } diff --git a/src/etpan/imap-thread.h b/src/etpan/imap-thread.h index 882f1ec61..ee59d62a0 100644 --- a/src/etpan/imap-thread.h +++ b/src/etpan/imap-thread.h @@ -16,7 +16,7 @@ void imap_done(Folder * folder); int imap_threaded_connect(Folder * folder, const char * server, int port); int imap_threaded_connect_ssl(Folder * folder, const char * server, int port); -struct mailimap_capability_data * imap_threaded_capability(Folder *folder); +struct mailimap_capability_data * imap_threaded_capability(Folder *folder, int *ok); int imap_threaded_connect_cmd(Folder * folder, const char * command, const char * server, int port); diff --git a/src/imap.c b/src/imap.c index f74319668..1116b7a58 100644 --- a/src/imap.c +++ b/src/imap.c @@ -308,7 +308,6 @@ static gint imap_cmd_login (IMAPSession *session, const gchar *user, const gchar *pass, const gchar *type); -static gint imap_cmd_logout (IMAPSession *session); static gint imap_cmd_noop (IMAPSession *session); #if USE_OPENSSL static gint imap_cmd_starttls (IMAPSession *session); @@ -539,18 +538,24 @@ static void imap_reset_uid_lists(Folder *folder) g_node_traverse(folder->node, G_IN_ORDER, G_TRAVERSE_ALL, -1, imap_reset_uid_lists_func, NULL); } -void imap_get_capabilities(IMAPSession *session) +int imap_get_capabilities(IMAPSession *session) { struct mailimap_capability_data *capabilities = NULL; clistiter *cur; + int result = -1; if (session->capability != NULL) - return; + return MAILIMAP_NO_ERROR; - capabilities = imap_threaded_capability(session->folder); + capabilities = imap_threaded_capability(session->folder, &result); - if (capabilities == NULL) - return; + if (result != MAILIMAP_NO_ERROR) { + return MAILIMAP_ERROR_CAPABILITY; + } + + if (capabilities == NULL) { + return MAILIMAP_NO_ERROR; + } for(cur = clist_begin(capabilities->cap_list) ; cur != NULL ; cur = clist_next(cur)) { @@ -564,6 +569,7 @@ void imap_get_capabilities(IMAPSession *session) debug_print("got capa %s\n", cap->cap_data.cap_name); } mailimap_capability_data_free(capabilities); + return MAILIMAP_NO_ERROR; } gboolean imap_has_capability(IMAPSession *session, const gchar *cap) @@ -581,8 +587,10 @@ static gint imap_auth(IMAPSession *session, const gchar *user, const gchar *pass { gint ok = IMAP_ERROR; static time_t last_login_err = 0; + gchar *ext_info = ""; - imap_get_capabilities(session); + if (imap_get_capabilities(session) != MAILIMAP_NO_ERROR) + return IMAP_ERROR; switch(type) { case IMAP_AUTH_ANON: @@ -607,19 +615,16 @@ static gint imap_auth(IMAPSession *session, const gchar *user, const gchar *pass if (ok == IMAP_ERROR) /* we always try LOGIN before giving up */ ok = imap_cmd_login(session, user, pass, "LOGIN"); } + if (ok == IMAP_SUCCESS) session->authenticated = TRUE; else { - gchar *ext_info = NULL; - if (type == IMAP_AUTH_CRAM_MD5) { ext_info = _("\n\nCRAM-MD5 logins only work if libetpan has been " "compiled with SASL support and the " "CRAM-MD5 SASL plugin is installed."); - } else { - ext_info = ""; - } - + } + if (time(NULL) - last_login_err > 10) { if (!prefs_common.no_recv_err_panel) { alertpanel_error(_("Connection to %s failed: " @@ -717,6 +722,8 @@ static IMAPSession *imap_session_get(Folder *folder) imap_session_authenticate(IMAP_SESSION(session), folder->account); if (!IMAP_SESSION(session)->authenticated) { + imap_threaded_disconnect(session->folder); + SESSION(session)->state = SESSION_DISCONNECTED; session_destroy(SESSION(session)); rfolder->session = NULL; rfolder->last_failure = time(NULL); @@ -750,7 +757,7 @@ static IMAPSession *imap_session_new(Folder * folder, IMAPSession *session; gushort port; int r; - int authenticated; + int authenticated = FALSE; #ifdef USE_OPENSSL /* FIXME: IMAP over SSL only... */ @@ -889,8 +896,6 @@ try_again: failed = TRUE; goto try_again; } else { - imap_threaded_disconnect(session->folder); - imap_cmd_logout(session); alertpanel_error(_("Couldn't login to IMAP server %s."), account->recv_server); } @@ -899,6 +904,7 @@ try_again: statusbar_pop_all(); session->authenticated = TRUE; + return; } static void imap_session_destroy(Session *session) @@ -2475,6 +2481,37 @@ static gint imap_cmd_login(IMAPSession *session, int r; gint ok; + if (!strcmp(type, "LOGIN") && imap_has_capability(session, "LOGINDISABLED")) { + gint ok = IMAP_ERROR; + if (imap_has_capability(session, "STARTTLS")) { +#if USE_OPENSSL + log_warning(_("Server requires TLS to log in.\n")); + ok = imap_cmd_starttls(session); + if (ok != IMAP_SUCCESS) { + log_warning(_("Can't start TLS session.\n")); + return IMAP_ERROR; + } else { + /* refresh capas */ + imap_free_capabilities(session); + if (imap_get_capabilities(session) != MAILIMAP_NO_ERROR) { + log_warning(_("Can't refresh capabilities.\n")); + return IMAP_ERROR; + } + } +#else + log_error(_("Connection to %s failed: " + "server requires TLS, but Sylpheed-Claws " + "has been compiled without OpenSSL " + "support.\n"), + SESSION(session)->server); + return IMAP_ERROR; +#endif + } else { + log_error(_("Server logins are disabled.\n")); + return IMAP_ERROR; + } + } + log_print("IMAP4> Logging %s to %s using %s\n", user, SESSION(session)->server, @@ -2492,13 +2529,6 @@ static gint imap_cmd_login(IMAPSession *session, return ok; } -static gint imap_cmd_logout(IMAPSession *session) -{ - imap_threaded_disconnect(session->folder); - - return IMAP_SUCCESS; -} - static gint imap_cmd_noop(IMAPSession *session) { int r; @@ -4262,6 +4292,7 @@ void imap_disconnect_all(void) if (folder && folder->session) { IMAPSession *session = (IMAPSession *)folder->session; imap_threaded_disconnect(FOLDER(folder)); + SESSION(session)->state = SESSION_DISCONNECTED; session_destroy(SESSION(session)); folder->session = NULL; } diff --git a/src/main.c b/src/main.c index c8b07d656..fef7bb543 100644 --- a/src/main.c +++ b/src/main.c @@ -487,6 +487,7 @@ int main(int argc, char *argv[]) if (folder_read_list() < 0) { if (!run_wizard(mainwin, TRUE)) exit(1); + main_window_reflect_prefs_all_now(); folder_write_list(); } -- 2.25.1