[evolution] e_mail_session_send_to(): Don't silently ignore if we can't send.



commit 13089f0d5088cf138697121a0839bd7d3ed85e42
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed May 29 16:50:27 2013 -0400

    e_mail_session_send_to(): Don't silently ignore if we can't send.
    
    If sending fails for any reason, return a suitable GError.  Don't just
    return silently.  Also check for a wider range of errors indicating the
    service is unavailable in composer_send_completed().  This will trigger
    the "save-to-outbox" info alert.

 libemail-engine/e-mail-session-utils.c |    9 ++-------
 mail/em-composer-utils.c               |   28 ++++++++++++++++++----------
 2 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/libemail-engine/e-mail-session-utils.c b/libemail-engine/e-mail-session-utils.c
index fb1ce9d..0938cae 100644
--- a/libemail-engine/e-mail-session-utils.c
+++ b/libemail-engine/e-mail-session-utils.c
@@ -541,13 +541,6 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple,
                return;
        }
 
-       provider = camel_service_get_provider (context->transport);
-       if ((provider->flags & CAMEL_PROVIDER_IS_REMOTE) != 0 &&
-           !camel_session_get_online (CAMEL_SESSION (session))) {
-               /* silently ignore */
-               return;
-       }
-
        status = camel_service_get_connection_status (context->transport);
        if (status != CAMEL_SERVICE_CONNECTED) {
                did_connect = TRUE;
@@ -561,6 +554,8 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple,
                }
        }
 
+       provider = camel_service_get_provider (context->transport);
+
        if (provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER)
                copy_to_sent = FALSE;
 
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 0f801b4..a8815f6 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -516,6 +516,7 @@ composer_send_completed (EMailSession *session,
                          AsyncContext *context)
 {
        GError *error = NULL;
+       gboolean service_unavailable;
        gboolean set_changed = FALSE;
 
        e_mail_session_send_to_finish (session, result, &error);
@@ -525,6 +526,23 @@ composer_send_completed (EMailSession *session,
                goto exit;
        }
 
+       /* Check for error codes which may indicate we're offline
+        * or name resolution failed or connection attempt failed. */
+       service_unavailable =
+               g_error_matches (
+                       error, CAMEL_SERVICE_ERROR,
+                       CAMEL_SERVICE_ERROR_UNAVAILABLE) ||
+               /* XXX camel_getaddrinfo() sets this, unfortunately. */
+               g_error_matches (error, CAMEL_ERROR, CAMEL_ERROR_GENERIC);
+       if (service_unavailable) {
+               /* Inform the user. */
+               e_alert_run_dialog_for_args (
+                       GTK_WINDOW (context->composer),
+                       "mail-composer:saving-to-outbox", NULL);
+               e_msg_composer_save_to_outbox (context->composer);
+               goto exit;
+       }
+
        /* Post-processing errors are shown in the shell window. */
        if (g_error_matches (error, E_MAIL_ERROR, E_MAIL_ERROR_POST_PROCESSING)) {
                EAlert *alert;
@@ -538,16 +556,6 @@ composer_send_completed (EMailSession *session,
                e_shell_submit_alert (shell, alert);
                g_object_unref (alert);
 
-       /* The destination store is offline => save to Outbox and try again later */
-       } else if (g_error_matches (error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE)) {
-               /* Inform the user. */
-               e_alert_run_dialog_for_args (
-                       GTK_WINDOW (context->composer),
-                       "mail-composer:saving-to-outbox", NULL);
-               e_msg_composer_save_to_outbox (context->composer);
-
-               goto exit;
-
        /* All other errors are shown in the composer window. */
        } else if (error != NULL) {
                gint response;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]