[evolution-ews] Synchronize authentication extensions before creating an ESource



commit cfeef2da487894ceb9c05f0ca3df244e41c54b2d
Author: Milan Crha <mcrha redhat com>
Date:   Fri Nov 10 11:55:12 2017 +0100

    Synchronize authentication extensions before creating an ESource
    
    When the values in the collection source and in the child sources
    of the authentication extension do not match, then the GUI part can
    ask for the password even when not needed. Even the collection-backend
    listens for child-added, it's too late to fix it there, because other
    processes can be notified about these new sources as well and use
    old values.

 src/collection/e-ews-backend.c          |   24 ++++++++++++++++++++++++
 src/configuration/e-ews-config-lookup.c |   10 ++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/src/collection/e-ews-backend.c b/src/collection/e-ews-backend.c
index 8eae4c8..f5f93cc 100644
--- a/src/collection/e-ews-backend.c
+++ b/src/collection/e-ews-backend.c
@@ -200,6 +200,28 @@ ews_backend_update_enabled (ESource *data_source,
        e_source_set_enabled (data_source, part_enabled);
 }
 
+static void
+ews_backend_sync_authentication (EEwsBackend *ews_backend,
+                                ESource *child_source)
+{
+       ESourceAuthentication *coll_authentication_extension, *child_authentication_extension;
+       ESource *collection_source;
+
+       g_return_if_fail (E_IS_EWS_BACKEND (ews_backend));
+       g_return_if_fail (E_IS_SOURCE (child_source));
+
+       collection_source = e_backend_get_source (E_BACKEND (ews_backend));
+
+       coll_authentication_extension = e_source_get_extension (collection_source, 
E_SOURCE_EXTENSION_AUTHENTICATION);
+       child_authentication_extension = e_source_get_extension (child_source, 
E_SOURCE_EXTENSION_AUTHENTICATION);
+
+       e_source_authentication_set_host (child_authentication_extension,
+               e_source_authentication_get_host (coll_authentication_extension));
+
+       e_source_authentication_set_user (child_authentication_extension,
+               e_source_authentication_get_user (coll_authentication_extension));
+}
+
 static ESource *
 ews_backend_new_child (EEwsBackend *backend,
                        EEwsFolder *folder)
@@ -241,6 +263,7 @@ ews_backend_new_child (EEwsBackend *backend,
        extension = e_source_get_extension (source, extension_name);
        e_source_backend_set_backend_name (
                E_SOURCE_BACKEND (extension), "ews");
+       ews_backend_sync_authentication (backend, source);
        ews_backend_update_enabled (source, e_backend_get_source (E_BACKEND (backend)));
 
        if (e_ews_folder_get_folder_type (folder) != E_EWS_FOLDER_TYPE_CONTACTS &&
@@ -473,6 +496,7 @@ ews_backend_add_gal_source (EEwsBackend *backend)
        source = e_collection_backend_new_child (
                collection_backend, oal_id);
        e_source_set_enabled (source, can_enable);
+       ews_backend_sync_authentication (backend, source);
 
        e_source_set_display_name (source, display_name);
 
diff --git a/src/configuration/e-ews-config-lookup.c b/src/configuration/e-ews-config-lookup.c
index ed7c8a6..3baf3df 100644
--- a/src/configuration/e-ews-config-lookup.c
+++ b/src/configuration/e-ews-config-lookup.c
@@ -265,6 +265,10 @@ ews_config_lookup_worker_result_from_settings (EConfigLookupWorker *lookup_worke
 
                if (user && *user) {
                        e_config_lookup_result_simple_add_string (lookup_result,
+                               E_SOURCE_EXTENSION_COLLECTION,
+                               "identity", user);
+
+                       e_config_lookup_result_simple_add_string (lookup_result,
                                E_SOURCE_EXTENSION_AUTHENTICATION,
                                "user", user);
                }
@@ -275,6 +279,12 @@ ews_config_lookup_worker_result_from_settings (EConfigLookupWorker *lookup_worke
                                "host", suri->host);
                }
 
+               if (suri && suri->port) {
+                       e_config_lookup_result_simple_add_uint (lookup_result,
+                               E_SOURCE_EXTENSION_AUTHENTICATION,
+                               "port", suri->port);
+               }
+
                e_config_lookup_add_result (config_lookup, lookup_result);
 
                g_string_free (description, TRUE);


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