[evolution-data-server] I#374 - LDAP: Let open when server is offline and marked for offline work



commit 1171a13298ec0932ce657ae5c85fa96b878c4e6d
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jan 21 11:13:25 2022 +0100

    I#374 - LDAP: Let open when server is offline and marked for offline work
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/374

 src/addressbook/backends/ldap/e-book-backend-ldap.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/addressbook/backends/ldap/e-book-backend-ldap.c 
b/src/addressbook/backends/ldap/e-book-backend-ldap.c
index 92455bb25..47383b315 100644
--- a/src/addressbook/backends/ldap/e-book-backend-ldap.c
+++ b/src/addressbook/backends/ldap/e-book-backend-ldap.c
@@ -844,11 +844,16 @@ e_book_backend_ldap_connect (EBookBackendLDAP *bl,
                        ldap_error = ldap_start_tls_s (blpriv->ldap, NULL, NULL);
 #endif
                        if (ldap_error != LDAP_SUCCESS) {
-                               g_message ("TLS not available (fatal version), (ldap_error 0x%02x)", 
ldap_error);
+                               if (ldap_error == LDAP_SERVER_DOWN) {
+                                       g_message ("TLS failed due to server being down");
+                                       g_propagate_error (error, EC_ERROR 
(E_CLIENT_ERROR_REPOSITORY_OFFLINE));
+                               } else {
+                                       g_message ("TLS not available (fatal version), (ldap_error 0x%02x)", 
ldap_error);
+                                       g_propagate_error (error, EC_ERROR 
(E_CLIENT_ERROR_TLS_NOT_AVAILABLE));
+                               }
                                ldap_unbind (blpriv->ldap);
                                blpriv->ldap = NULL;
                                g_rec_mutex_unlock (&eds_ldap_handler_lock);
-                               g_propagate_error (error, EC_ERROR (E_CLIENT_ERROR_TLS_NOT_AVAILABLE));
                                return FALSE;
                        } else if (enable_debug)
                                g_message ("TLS active");
@@ -5414,9 +5419,12 @@ book_backend_ldap_open (EBookBackend *backend,
        }
 
        if (error != NULL && enable_debug)
-               printf ("%s ... failed to connect to server \n", G_STRFUNC);
+               printf ("%s ... failed to connect to server: %s\n", G_STRFUNC, error->message);
 
-       if (error == NULL && bl->priv->marked_for_offline)
+       /* Ignore 'Repository Offline' error when being marked for offline work */
+       if (bl->priv->marked_for_offline && g_error_matches (error, E_CLIENT_ERROR, 
E_CLIENT_ERROR_REPOSITORY_OFFLINE))
+               g_clear_error (&error);
+       else if (!error && bl->priv->marked_for_offline)
                generate_cache (bl);
 
        g_signal_connect_object (source, "changed",


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