[evolution-data-server/wip/jtojnar/libgweather4] M!93 - Port to libgweather4
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/wip/jtojnar/libgweather4] M!93 - Port to libgweather4
- Date: Thu, 17 Feb 2022 15:30:31 +0000 (UTC)
commit 7857e253b6fd5c589b01b7b6e82f3e8b414d2832
Author: Javier Jardón <jjardon gnome org>
Date: Sat Jan 8 15:30:52 2022 +0000
M!93 - Port to libgweather4
Co-Authored-By: Jan Tojnar <jtojnar gmail com>
Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/merge_requests/93
CMakeLists.txt | 30 ++++++++++++++++------
.../backends/weather/e-cal-backend-weather.c | 8 ++++++
src/calendar/backends/weather/e-weather-source.c | 15 ++++++++---
3 files changed, 42 insertions(+), 11 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 234f605be..20d06aefd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -119,6 +119,7 @@ set(sqlite_minimum_version 3.7.17)
# Optional Packages
set(goa_minimum_version 3.8)
set(gweather_minimum_version 3.10)
+set(gweather4_minimum_version 3.91.0)
set(libaccounts_glib_minimum_version 1.4)
set(libsignon_glib_minimum_version 1.8)
set(json_glib_minimum_version 1.0.4)
@@ -755,18 +756,31 @@ endif(NOT have_addrinfo)
add_printable_option(ENABLE_WEATHER "Build the weather calendar backend" ON)
if(ENABLE_WEATHER)
- pkg_check_modules_for_option(ENABLE_WEATHER "weather calendar backend" LIBGWEATHER
gweather-3.0>=${gweather_minimum_version})
+ add_printable_variable(WITH_GWEATHER4 "Use GWeather 4 instead of 3" OFF)
+
+ if(WITH_GWEATHER4)
+ pkg_check_modules_for_option(ENABLE_WEATHER "weather calendar backend" LIBGWEATHER
gweather4>=${gweather4_minimum_version})
+ else(WITH_GWEATHER4)
+ pkg_check_modules_for_option(ENABLE_WEATHER "weather calendar backend" LIBGWEATHER
gweather-3.0>=${gweather_minimum_version})
+ message(FATAL_ERROR "Only GWeather 3 and 4 ABI branches are supported but
“${GWEATHER_BRANCH}” was selected, use -DGWEATHER_BRANCH=4 to link against gweather4, or -DGWEATHER_BRANCH=3
to link against gweather-3.0.")
+ endif(WITH_GWEATHER4)
set(CMAKE_REQUIRED_INCLUDES ${LIBGWEATHER_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${LIBGWEATHER_LDFLAGS})
- CHECK_C_SOURCE_COMPILES("#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
- #include <libgweather/gweather.h>
- #undef GWEATHER_I_KNOW_THIS_IS_UNSTABLE
- int main(void) {
- gweather_info_new (NULL);
- return 0;
- }" HAVE_ONE_ARG_GWEATHER_INFO_NEW)
+ if(WITH_GWEATHER4)
+ set(HAVE_ONE_ARG_GWEATHER_INFO_NEW ON)
+ else(WITH_GWEATHER4)
+ CHECK_C_SOURCE_COMPILES("#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
+ #include <libgweather/gweather.h>
+ #undef GWEATHER_I_KNOW_THIS_IS_UNSTABLE
+
+ int main(void) {
+ gweather_info_new (NULL);
+ return 0;
+ }" HAVE_ONE_ARG_GWEATHER_INFO_NEW)
+ endif(WITH_GWEATHER4)
+
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
endif(ENABLE_WEATHER)
diff --git a/src/calendar/backends/weather/e-cal-backend-weather.c
b/src/calendar/backends/weather/e-cal-backend-weather.c
index 72faccd62..cc5ebe410 100644
--- a/src/calendar/backends/weather/e-cal-backend-weather.c
+++ b/src/calendar/backends/weather/e-cal-backend-weather.c
@@ -464,7 +464,11 @@ create_weather (ECalBackendWeather *cbw,
time_t update_time;
ICalTimezone *update_zone = NULL;
const GWeatherLocation *location;
+ #if GWEATHER_CHECK_VERSION(3, 91, 0)
+ GTimeZone *w_timezone;
+ #else
const GWeatherTimezone *w_timezone;
+ #endif
gdouble tmin = 0.0, tmax = 0.0, temp = 0.0;
g_return_val_if_fail (E_IS_CAL_BACKEND_WEATHER (cbw), NULL);
@@ -484,7 +488,11 @@ create_weather (ECalBackendWeather *cbw,
/* use timezone of the location to determine date for which this is set */
location = gweather_info_get_location (report);
if (location && (w_timezone = gweather_location_get_timezone ((GWeatherLocation *) location)))
+ #if GWEATHER_CHECK_VERSION(3, 91, 0)
+ update_zone = i_cal_timezone_get_builtin_timezone (g_time_zone_get_identifier (w_timezone));
+ #else
update_zone = i_cal_timezone_get_builtin_timezone (gweather_timezone_get_tzid
((GWeatherTimezone *) w_timezone));
+ #endif
if (!update_zone)
update_zone = i_cal_timezone_get_utc_timezone ();
diff --git a/src/calendar/backends/weather/e-weather-source.c
b/src/calendar/backends/weather/e-weather-source.c
index 3052d034c..2575edfa2 100644
--- a/src/calendar/backends/weather/e-weather-source.c
+++ b/src/calendar/backends/weather/e-weather-source.c
@@ -39,8 +39,11 @@ weather_source_dispose (GObject *object)
EWeatherSourcePrivate *priv;
priv = E_WEATHER_SOURCE (object)->priv;
+ #if GWEATHER_CHECK_VERSION(3, 91, 0)
+ g_clear_object (&priv->location);
+ #else
g_clear_pointer (&priv->location, gweather_location_unref);
-
+ #endif
g_clear_object (&priv->info);
/* Chain up to parent's dispose() method. */
@@ -85,7 +88,7 @@ weather_source_find_location_by_coords (GWeatherLocation *start,
gweather_location_get_coords (location, &lat, &lon);
if (lat == latitude && lon == longitude) {
- gweather_location_ref (location);
+ g_object_ref (location);
return location;
}
}
@@ -96,7 +99,11 @@ weather_source_find_location_by_coords (GWeatherLocation *start,
result = weather_source_find_location_by_coords (child, latitude, longitude);
if (result) {
+ #if GWEATHER_CHECK_VERSION(3, 91, 0)
+ g_object_unref (child);
+ #else
gweather_location_unref (child);
+ #endif
return result;
}
}
@@ -159,7 +166,9 @@ e_weather_source_new (const gchar *location)
}
}
-#if GWEATHER_CHECK_VERSION(3, 39, 0)
+#if GWEATHER_CHECK_VERSION(3, 91, 0)
+ g_object_unref (world);
+#elif GWEATHER_CHECK_VERSION(3, 39, 0)
gweather_location_unref (world);
#endif
g_strfreev (tokens);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]