[evolution-ews] eds-I#286 - Skip collection account refresh when parts disabled



commit c13c911ac52276a32f01b86a4433fa9e36d08a5e
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jan 7 18:40:53 2021 +0100

    eds-I#286 - Skip collection account refresh when parts disabled
    
    It doesn't make sense to ask the server for existing sources, the less
    the user for credentials to login to the server, when all the related
    parts are disabled.
    
    Related to https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/286

 src/EWS/registry/e-ews-backend.c           | 25 +++++++++++++------------
 src/Microsoft365/registry/e-m365-backend.c | 21 +++++++++++----------
 2 files changed, 24 insertions(+), 22 deletions(-)
---
diff --git a/src/EWS/registry/e-ews-backend.c b/src/EWS/registry/e-ews-backend.c
index 9c06f919..26ce2e9f 100644
--- a/src/EWS/registry/e-ews-backend.c
+++ b/src/EWS/registry/e-ews-backend.c
@@ -594,7 +594,7 @@ static void
 ews_backend_source_changed_cb (ESource *source,
                                EEwsBackend *backend)
 {
-       if (!e_source_get_enabled (source)) {
+       if (!e_collection_backend_get_part_enabled (E_COLLECTION_BACKEND (backend), 
E_COLLECTION_BACKEND_PART_ANY)) {
                backend->priv->need_update_folders = TRUE;
                return;
        }
@@ -800,12 +800,13 @@ ews_backend_folders_synced_cb (GObject *source,
 }
 
 static void
-ews_backend_populate (ECollectionBackend *backend)
+ews_backend_populate (ECollectionBackend *collection_backend)
 {
        ESource *source;
-       EEwsBackend *ews_backend = E_EWS_BACKEND (backend);
+       EEwsBackend *ews_backend = E_EWS_BACKEND (collection_backend);
+       EBackend *backend = E_BACKEND (ews_backend);
 
-       source = e_backend_get_source (E_BACKEND (backend));
+       source = e_backend_get_source (backend);
 
        ews_backend->priv->need_update_folders = TRUE;
 
@@ -816,32 +817,32 @@ ews_backend_populate (ECollectionBackend *backend)
        }
 
        /* do not do anything, if account is disabled */
-       if (!e_source_get_enabled (source))
+       if (!e_collection_backend_get_part_enabled (collection_backend, E_COLLECTION_BACKEND_PART_ANY))
                return;
 
-       if (!e_collection_backend_freeze_populate (backend)) {
-               e_collection_backend_thaw_populate (backend);
+       if (!e_collection_backend_freeze_populate (collection_backend)) {
+               e_collection_backend_thaw_populate (collection_backend);
                return;
        }
 
        ews_backend_add_gal_source (ews_backend);
-       ews_backend_claim_old_resources (backend);
+       ews_backend_claim_old_resources (collection_backend);
 
-       if (e_backend_get_online (E_BACKEND (backend))) {
+       if (e_backend_get_online (backend)) {
                CamelEwsSettings *ews_settings;
 
                ews_settings = ews_backend_get_settings (ews_backend);
 
                if (e_ews_connection_utils_get_without_password (ews_settings)) {
-                       e_backend_schedule_authenticate (E_BACKEND (backend), NULL);
+                       e_backend_schedule_authenticate (backend, NULL);
                } else {
-                       e_backend_credentials_required_sync (E_BACKEND (backend),
+                       e_backend_credentials_required_sync (backend,
                                E_SOURCE_CREDENTIALS_REASON_REQUIRED, NULL, 0, NULL,
                                NULL, NULL);
                }
        }
 
-       e_collection_backend_thaw_populate (backend);
+       e_collection_backend_thaw_populate (collection_backend);
 }
 
 static gchar *
diff --git a/src/Microsoft365/registry/e-m365-backend.c b/src/Microsoft365/registry/e-m365-backend.c
index 1eef5f81..a19917b0 100644
--- a/src/Microsoft365/registry/e-m365-backend.c
+++ b/src/Microsoft365/registry/e-m365-backend.c
@@ -59,7 +59,7 @@ static void
 m365_backend_source_changed_cb (ESource *source,
                                EM365Backend *backend)
 {
-       if (!e_source_get_enabled (source)) {
+       if (!e_collection_backend_get_part_enabled (E_COLLECTION_BACKEND (backend), 
E_COLLECTION_BACKEND_PART_ANY)) {
                backend->priv->need_update_folders = TRUE;
                return;
        }
@@ -71,10 +71,11 @@ m365_backend_source_changed_cb (ESource *source,
 }
 
 static void
-m365_backend_populate (ECollectionBackend *backend)
+m365_backend_populate (ECollectionBackend *collection_backend)
 {
        ESource *source;
-       EM365Backend *m365_backend = E_M365_BACKEND (backend);
+       EM365Backend *m365_backend = E_M365_BACKEND (collection_backend);
+       EBackend *backend = E_BACKEND (m365_backend);
 
        source = e_backend_get_source (E_BACKEND (backend));
 
@@ -86,20 +87,20 @@ m365_backend_populate (ECollectionBackend *backend)
        }
 
        /* do not do anything, if account is disabled */
-       if (!e_source_get_enabled (source))
+       if (!e_collection_backend_get_part_enabled (collection_backend, E_COLLECTION_BACKEND_PART_ANY))
                return;
 
-       if (!e_collection_backend_freeze_populate (backend)) {
-               e_collection_backend_thaw_populate (backend);
+       if (!e_collection_backend_freeze_populate (collection_backend)) {
+               e_collection_backend_thaw_populate (collection_backend);
                return;
        }
 
-       m365_backend_claim_old_resources (backend);
+       m365_backend_claim_old_resources (collection_backend);
 
-       if (e_backend_get_online (E_BACKEND (backend)))
-               e_backend_schedule_authenticate (E_BACKEND (backend), NULL);
+       if (e_backend_get_online (backend))
+               e_backend_schedule_authenticate (backend, NULL);
 
-       e_collection_backend_thaw_populate (backend);
+       e_collection_backend_thaw_populate (collection_backend);
 }
 
 static void


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