[evolution-ews/gnome-3-16] Differentiate between Unavailable and No response errors



commit c08281f634f2db364e75c8b9bfb96906d6d30680
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jun 25 14:35:03 2015 +0200

    Differentiate between Unavailable and No response errors
    
    That way the Camel provider can return proper error code when
    the destination server is unavailable.

 src/camel/camel-ews-store.c   |    5 +++++
 src/server/e-ews-connection.c |   10 ++++++++++
 src/server/ews-errors.h       |    1 +
 3 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/camel/camel-ews-store.c b/src/camel/camel-ews-store.c
index 640d3c6..dec7fa6 100644
--- a/src/camel/camel-ews-store.c
+++ b/src/camel/camel-ews-store.c
@@ -1759,6 +1759,11 @@ ews_authenticate_sync (CamelService *service,
        g_free (old_sync_state);
        old_sync_state = NULL;
 
+       if (g_error_matches (local_error, EWS_CONNECTION_ERROR, EWS_CONNECTION_ERROR_UNAVAILABLE)) {
+               local_error->domain = CAMEL_SERVICE_ERROR;
+               local_error->code = CAMEL_SERVICE_ERROR_UNAVAILABLE;
+       }
+
        if (!initial_setup && g_error_matches (local_error, EWS_CONNECTION_ERROR, 
EWS_CONNECTION_ERROR_INVALIDSYNCSTATEDATA)) {
                g_clear_error (&local_error);
                ews_store_forget_all_folders (ews_store);
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index 464d756..dd4e1e2 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -791,6 +791,16 @@ ews_response_cb (SoupSession *session,
                        EWS_CONNECTION_ERROR_AUTHENTICATION_FAILED,
                        _("Authentication failed"));
                goto exit;
+       } else if (msg->status_code == SOUP_STATUS_CANT_RESOLVE ||
+                  msg->status_code == SOUP_STATUS_CANT_RESOLVE_PROXY ||
+                  msg->status_code == SOUP_STATUS_CANT_CONNECT ||
+                  msg->status_code == SOUP_STATUS_CANT_CONNECT_PROXY) {
+               g_simple_async_result_set_error (
+                       enode->simple,
+                       EWS_CONNECTION_ERROR,
+                       EWS_CONNECTION_ERROR_UNAVAILABLE,
+                       "%s", msg->reason_phrase);
+               goto exit;
        }
 
        response = e_soap_message_parse_response ((ESoapMessage *) msg);
diff --git a/src/server/ews-errors.h b/src/server/ews-errors.h
index fc48ead..7868b67 100644
--- a/src/server/ews-errors.h
+++ b/src/server/ews-errors.h
@@ -300,6 +300,7 @@ enum {
        /* Below this point are no longer direct translations of EWS errors */
        EWS_CONNECTION_ERROR_NORESPONSE,
        EWS_CONNECTION_ERROR_AUTHENTICATION_FAILED,
+       EWS_CONNECTION_ERROR_UNAVAILABLE,
        EWS_CONNECTION_ERROR_UNKNOWN
 };
 


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