2006-08-10 [colin] 2.4.0cvs39
authorColin Leroy <colin@colino.net>
Thu, 10 Aug 2006 16:36:19 +0000 (16:36 +0000)
committerColin Leroy <colin@colino.net>
Thu, 10 Aug 2006 16:36:19 +0000 (16:36 +0000)
* 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
PATCHSETS
configure.ac
src/etpan/imap-thread.c
src/etpan/imap-thread.h
src/imap.c
src/main.c

index 8ef3bc2900773bf40b3885f82caa6ded17866f43..ee86c2f835e4fed9df0d4750f113b4e1071fb3ab 100644 (file)
--- 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
 2006-08-09 [colin]     2.4.0cvs38
 
        * src/mainwindow.c
index 7d18aa804539a64505ed42df3dd6fc5257816416..53d183ddddc15c35c5a98f010f7e98a9b8e6ba31 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( 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.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
index 03831ce3a32b2202d0e231a2ad0b2b01e4e4a22d..5ee4d0ad137b17f6d02469401597d4eae7b24f9a 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=4
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=38
+EXTRA_VERSION=39
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 0ee012d502bc0f607dc3294af8d1c4223c19792a..263e0dcbee70be25ead47a26aecc8c22bd63c6f9 100644 (file)
@@ -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;
 {
        struct capa_param param;
        struct capa_result result;
@@ -482,8 +482,11 @@ struct mailimap_capability_data * imap_threaded_capability(Folder *folder)
        
        threaded_run(folder, &param, &result, capability_run);
        
        
        threaded_run(folder, &param, &result, capability_run);
        
-       debug_print("capa ok\n");
+       debug_print("capa %d\n", result.error);
        
        
+       if (ok)
+               *ok = result.error;
+
        return result.caps;
        
 }
        return result.caps;
        
 }
index 882f1ec61c94a39dc4c816c429b245e7f904b5a7..ee59d62a0858c12409ba95070312b2eb1b0de7bd 100644 (file)
@@ -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);
 
 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);
 
 int imap_threaded_connect_cmd(Folder * folder, const char * command,
                              const char * server, int port);
 
index f74319668af341a31bc4d5a4fb921c815eb0bd8b..1116b7a588f855f74d9ab5c2f9c718e08e2dcc0a 100644 (file)
@@ -308,7 +308,6 @@ static gint imap_cmd_login  (IMAPSession    *session,
                                 const gchar    *user,
                                 const gchar    *pass,
                                 const gchar    *type);
                                 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);
 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); 
 }
 
        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;
 {
        struct mailimap_capability_data *capabilities = NULL;
        clistiter *cur;
+       int result = -1;
 
        if (session->capability != NULL)
 
        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)) {
 
        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);
                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) 
 }
 
 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;
 {
        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:
 
        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_ERROR) /* we always try LOGIN before giving up */
                        ok = imap_cmd_login(session, user, pass, "LOGIN");
        }
+
        if (ok == IMAP_SUCCESS)
                session->authenticated = TRUE;
        else {
        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.");
                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: "
                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_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);
                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;
        IMAPSession *session;
        gushort port;
        int r;
-       int authenticated;
+       int authenticated = FALSE;
        
 #ifdef USE_OPENSSL
        /* FIXME: IMAP over SSL only... */ 
        
 #ifdef USE_OPENSSL
        /* FIXME: IMAP over SSL only... */ 
@@ -889,8 +896,6 @@ try_again:
                        failed = TRUE;
                        goto try_again;
                } else {
                        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);
                }               
 
                        alertpanel_error(_("Couldn't login to IMAP server %s."), account->recv_server);
                }               
 
@@ -899,6 +904,7 @@ try_again:
 
        statusbar_pop_all();
        session->authenticated = TRUE;
 
        statusbar_pop_all();
        session->authenticated = TRUE;
+       return;
 }
 
 static void imap_session_destroy(Session *session)
 }
 
 static void imap_session_destroy(Session *session)
@@ -2475,6 +2481,37 @@ static gint imap_cmd_login(IMAPSession *session,
        int r;
        gint ok;
 
        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,
        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;
 }
 
        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;
 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));
                        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;
                        }
                                session_destroy(SESSION(session));
                                folder->session = NULL;
                        }
index c8b07d656ec80e29ff275d5168d1c0fc6ad4a893..fef7bb54307b4848b24c36b6606ef7090e92812c 100644 (file)
@@ -487,6 +487,7 @@ int main(int argc, char *argv[])
        if (folder_read_list() < 0) {
                if (!run_wizard(mainwin, TRUE))
                        exit(1);
        if (folder_read_list() < 0) {
                if (!run_wizard(mainwin, TRUE))
                        exit(1);
+               main_window_reflect_prefs_all_now();
                folder_write_list();
        }
 
                folder_write_list();
        }