[evolution-mapi/gnome-3-30] Unnecessarily asks for the credentials from book and calendars



commit 094cf2a293e02121ff78452e7362e8cc25a9c744
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jan 15 18:07:53 2019 +0100

    Unnecessarily asks for the credentials from book and calendars
    
    The backends had been always claiming that the provided credentials
    are incorrect, which results in a credentials prompt on the client
    side, even when there had been no credentials provided yet. This can
    happen with the first attempt to open the source of the backends.

 src/addressbook/e-book-backend-mapi.c | 8 +++++++-
 src/calendar/e-cal-backend-mapi.c     | 8 +++++++-
 src/collection/e-mapi-backend.c       | 9 +++++++--
 3 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index 22bdd32..e779224 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -345,7 +345,13 @@ ebb_mapi_connect_sync (EBookMetaBackend *meta_backend,
 
                g_clear_error (&mapi_error);
 
-               *out_auth_result = is_network_error ? E_SOURCE_AUTHENTICATION_ERROR : 
E_SOURCE_AUTHENTICATION_REJECTED;
+               if (is_network_error) {
+                       *out_auth_result = E_SOURCE_AUTHENTICATION_ERROR;
+               } else if ((!credentials || !e_named_parameters_count (credentials)) && 
!camel_mapi_settings_get_kerberos (settings)) {
+                       *out_auth_result = E_SOURCE_AUTHENTICATION_REQUIRED;
+               } else {
+                       *out_auth_result = E_SOURCE_AUTHENTICATION_REJECTED;
+               }
 
                return FALSE;
        }
diff --git a/src/calendar/e-cal-backend-mapi.c b/src/calendar/e-cal-backend-mapi.c
index 922705d..bfd46c0 100644
--- a/src/calendar/e-cal-backend-mapi.c
+++ b/src/calendar/e-cal-backend-mapi.c
@@ -726,7 +726,13 @@ ecb_mapi_connect_sync (ECalMetaBackend *meta_backend,
 
                g_clear_error (&mapi_error);
 
-               *out_auth_result = is_network_error ? E_SOURCE_AUTHENTICATION_ERROR : 
E_SOURCE_AUTHENTICATION_REJECTED;
+               if (is_network_error) {
+                       *out_auth_result = E_SOURCE_AUTHENTICATION_ERROR;
+               } else if ((!credentials || !e_named_parameters_count (credentials)) && 
!camel_mapi_settings_get_kerberos (settings)) {
+                       *out_auth_result = E_SOURCE_AUTHENTICATION_REQUIRED;
+               } else {
+                       *out_auth_result = E_SOURCE_AUTHENTICATION_REJECTED;
+               }
 
                return FALSE;
        }
diff --git a/src/collection/e-mapi-backend.c b/src/collection/e-mapi-backend.c
index f9c64f4..53d4c84 100644
--- a/src/collection/e-mapi-backend.c
+++ b/src/collection/e-mapi-backend.c
@@ -883,10 +883,15 @@ mapi_backend_authenticate_sync (EBackend *backend,
                mapi_backend->priv->need_update_folders = TRUE;
 
                if (g_error_matches (mapi_error, E_MAPI_ERROR, MAPI_E_PASSWORD_CHANGE_REQUIRED) ||
-                   g_error_matches (mapi_error, E_MAPI_ERROR, MAPI_E_PASSWORD_EXPIRED))
+                   g_error_matches (mapi_error, E_MAPI_ERROR, MAPI_E_PASSWORD_EXPIRED)) {
                        res = E_SOURCE_AUTHENTICATION_REJECTED;
+               } else if ((!mapi_error || mapi_error->domain == E_MAPI_ERROR) &&
+                          (!credentials || !e_named_parameters_count (credentials)) &&
+                          !camel_mapi_settings_get_kerberos (settings)) {
+                       res = E_SOURCE_AUTHENTICATION_REQUIRED;
+               }
 
-               if (res != E_SOURCE_AUTHENTICATION_REJECTED) {
+               if (res == E_SOURCE_AUTHENTICATION_ERROR) {
                        if (krb_error) {
                                GError *new_error = g_error_new (mapi_error->domain, mapi_error->code,
                                        /* Translators: the first '%s' is replaced with a generic error 
message,


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