Skip to content

Commit

Permalink
EWS calendar: Do not link against Evolution libraries
Browse files Browse the repository at this point in the history
Replace Evolution functions with newly added libecal functions
and copy/adapt the rest Evolution functions, to not link against
Evolution, thus to not load Evolution (and GUI) libraries into
the evolution-calendar-factory process.

The code duplication is not ideal, but it does worth it in this case.

This way the distribution packagers can split evolution-ews into packages
which require evolution (the configuration part) and which not, and let
the users install evolution-ews core parts without Evolution itself, thus
for example Exchange accounts configured in GNOME Online Accounts can
provide data to GNOME Calendar without a need to install Evolution itself.
  • Loading branch information
mcrha committed Aug 4, 2023
1 parent fd52086 commit d28287d
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 22 deletions.
6 changes: 0 additions & 6 deletions src/EWS/calendar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ target_compile_definitions(ews-m365 PRIVATE

target_compile_options(ews-m365 PUBLIC
${CAMEL_CFLAGS}
${EVOLUTION_CALENDAR_CFLAGS}
${LIBEBACKEND_CFLAGS}
${LIBECAL_CFLAGS}
${LIBEDATACAL_CFLAGS}
Expand All @@ -50,7 +49,6 @@ target_include_directories(ews-m365 PUBLIC
${CMAKE_SOURCE_DIR}/src/Microsoft365
${CMAKE_CURRENT_BINARY_DIR}
${CAMEL_INCLUDE_DIRS}
${EVOLUTION_CALENDAR_INCLUDE_DIRS}
${LIBEBACKEND_INCLUDE_DIRS}
${LIBECAL_INCLUDE_DIRS}
${LIBEDATACAL_INCLUDE_DIRS}
Expand All @@ -60,7 +58,6 @@ target_include_directories(ews-m365 PUBLIC
target_link_libraries(ews-m365
${DEPENDENCIES}
${CAMEL_LDFLAGS}
${EVOLUTION_CALENDAR_LDFLAGS}
${LIBEBACKEND_LDFLAGS}
${LIBECAL_LDFLAGS}
${LIBEDATACAL_LDFLAGS}
Expand Down Expand Up @@ -104,7 +101,6 @@ target_compile_definitions(ecalbackendews PRIVATE

target_compile_options(ecalbackendews PUBLIC
${CAMEL_CFLAGS}
${EVOLUTION_CALENDAR_CFLAGS}
${LIBEBACKEND_CFLAGS}
${LIBECAL_CFLAGS}
${LIBEDATACAL_CFLAGS}
Expand All @@ -118,7 +114,6 @@ target_include_directories(ecalbackendews PUBLIC
${CMAKE_SOURCE_DIR}/src/EWS
${CMAKE_CURRENT_BINARY_DIR}
${CAMEL_INCLUDE_DIRS}
${EVOLUTION_CALENDAR_INCLUDE_DIRS}
${LIBEBACKEND_INCLUDE_DIRS}
${LIBECAL_INCLUDE_DIRS}
${LIBEDATACAL_INCLUDE_DIRS}
Expand All @@ -128,7 +123,6 @@ target_include_directories(ecalbackendews PUBLIC
target_link_libraries(ecalbackendews
${DEPENDENCIES}
${CAMEL_LDFLAGS}
${EVOLUTION_CALENDAR_LDFLAGS}
${LIBEBACKEND_LDFLAGS}
${LIBECAL_LDFLAGS}
${LIBEDATACAL_LDFLAGS}
Expand Down
41 changes: 41 additions & 0 deletions src/EWS/calendar/e-cal-backend-ews-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2388,3 +2388,44 @@ e_cal_backend_ews_get_datetime_with_zone (ETimezoneCache *timezone_cache,

return dt;
}

/* This is adapted copy of calendar_config_get_icaltimezone(), to avoid dependency
on the evolution code in the backend. */
ICalTimezone *
e_cal_backend_ews_get_configured_evolution_icaltimezone (void)
{
GSettingsSchemaSource *schema_source;
ICalTimezone *zone = NULL;
gchar *location = NULL;

schema_source = g_settings_schema_source_get_default ();
if (schema_source) {
GSettingsSchema *schema;

schema = g_settings_schema_source_lookup (schema_source, "org.gnome.evolution.calendar", TRUE);
if (schema) {
GSettings *settings;

settings = g_settings_new ("org.gnome.evolution.calendar");

if (g_settings_get_boolean (settings, "use-system-timezone"))
location = e_cal_util_get_system_timezone_location ();
else
location = g_settings_get_string (settings, "timezone");

g_clear_object (&settings);
g_settings_schema_unref (schema);
}
}

if (!location)
location = e_cal_util_get_system_timezone_location ();

if (location) {
zone = i_cal_timezone_get_builtin_timezone (location);

g_free (location);
}

return zone;
}
2 changes: 2 additions & 0 deletions src/EWS/calendar/e-cal-backend-ews-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ ICalTime * e_cal_backend_ews_get_datetime_with_zone (ETimezoneCache *timezone_ca
ICalComponent *comp,
ICalPropertyKind prop_kind,
ICalTime * (* get_func) (ICalProperty *prop));
ICalTimezone * e_cal_backend_ews_get_configured_evolution_icaltimezone
(void);

G_END_DECLS

Expand Down
Loading

0 comments on commit d28287d

Please sign in to comment.