[evolution-mapi] build: Limit which parts link to the evolution libraries (and gtk+)



commit 92c40dd1e1b164d5881859c7e9467d5d4ec450ca
Author: Milan Crha <mcrha redhat com>
Date:   Fri Apr 29 10:29:01 2022 +0200

    build: Limit which parts link to the evolution libraries (and gtk+)
    
    Due to linking with Evolution in libraries not being used only in Evolution,
    the code could bring the GUI libraries into processes unexpectedly,
    especially gtk3 into a gtk4 application, which cannot be done.
    
    This change limits the linkage to the Evolution to necessary minimum,
    for a price of a small code duplication.
    
    Related to https://gitlab.gnome.org/GNOME/gnome-contacts/-/issues/222

 src/camel/CMakeLists.txt     |  3 ---
 src/camel/camel-mapi-store.c | 11 ++++++-----
 2 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/src/camel/CMakeLists.txt b/src/camel/CMakeLists.txt
index d360d88..0b99b03 100644
--- a/src/camel/CMakeLists.txt
+++ b/src/camel/CMakeLists.txt
@@ -42,7 +42,6 @@ target_compile_definitions(camelmapi-priv PRIVATE
 
 target_compile_options(camelmapi-priv PUBLIC
        ${CAMEL_CFLAGS}
-       ${EVOLUTION_MAIL_CFLAGS}
        ${LIBEDATASERVER_CFLAGS}
        ${LIBECAL_CFLAGS}
        ${LIBMAPI_CFLAGS}
@@ -55,7 +54,6 @@ target_include_directories(camelmapi-priv PUBLIC
        ${CMAKE_SOURCE_DIR}/src
        ${CMAKE_CURRENT_BINARY_DIR}
        ${CAMEL_INCLUDE_DIRS}
-       ${EVOLUTION_MAIL_INCLUDE_DIRS}
        ${LIBEDATASERVER_INCLUDE_DIRS}
        ${LIBECAL_INCLUDE_DIRS}
        ${LIBMAPI_INCLUDE_DIRS}
@@ -64,7 +62,6 @@ target_include_directories(camelmapi-priv PUBLIC
 target_link_libraries(camelmapi-priv
        ${DEPENDENCIES}
        ${CAMEL_LDFLAGS}
-       ${EVOLUTION_MAIL_LDFLAGS}
        ${LIBEDATASERVER_LDFLAGS}
        ${LIBECAL_LDFLAGS}
        ${LIBMAPI_LDFLAGS}
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index fa4639c..31cfc4e 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -33,7 +33,6 @@
 #include <errno.h>
 
 #include <libmapi/libmapi.h>
-#include <libemail-engine/libemail-engine.h>
 
 #include <glib/gi18n-lib.h>
 #include <glib/gstdio.h>
@@ -766,12 +765,13 @@ mapi_get_folder_info_offline (CamelStore *store,
                        ESourceRegistry *registry;
                        GList *all_sources;
 
-                       registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+                       registry = e_source_registry_new_sync (NULL, NULL);
                        all_sources = e_source_registry_list_sources (registry, NULL);
 
                        my_sources = e_mapi_utils_filter_sources_for_profile (all_sources, profile);
 
                        g_list_free_full (all_sources, g_object_unref);
+                       g_clear_object (&registry);
                }
        }
 
@@ -2976,6 +2976,7 @@ mapi_authenticate_sync (CamelService *service,
        CamelSettings *settings;
        CamelMapiSettings *mapi_settings;
        CamelNetworkSettings *network_settings;
+       ESourceRegistry *registry;
        EMapiProfileData empd = { 0 };
        const gchar *profile;
        const gchar *password;
@@ -3012,10 +3013,10 @@ mapi_authenticate_sync (CamelService *service,
        e_named_parameters_set (credentials, E_SOURCE_CREDENTIAL_PASSWORD, password);
        g_rec_mutex_lock (&store->priv->connection_lock);
        session = camel_service_ref_session (service);
-       store->priv->connection = e_mapi_connection_new (
-               e_mail_session_get_registry (E_MAIL_SESSION (session)),
-               profile, credentials, cancellable, &mapi_error);
+       registry = e_source_registry_new_sync (NULL, NULL);
+       store->priv->connection = e_mapi_connection_new (registry, profile, credentials, cancellable, 
&mapi_error);
        e_named_parameters_free (credentials);
+       g_clear_object (&registry);
        if (store->priv->connection && e_mapi_connection_connected (store->priv->connection)) {
                GPtrArray *array;
                guint ii;


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