[evolution-data-server/wip/jtojnar/libgweather4: 3/3] M!93 - Port to libgweather4




commit a3d2de8fb70e54581cb78cf02263ed6eb52fdff2
Author: Javier Jardón <jjardon gnome org>
Date:   Sat Jan 8 15:30:52 2022 +0000

    M!93 - Port to libgweather4
    
    Adds support for linking against gweather4 (pass -DWITH_GWEATHER4=ON).
    
    Co-Authored-By: Jan Tojnar <jtojnar gmail com>
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/merge_requests/93

 CMakeLists.txt                                        |  9 ++++++++-
 config.h.in                                           |  3 +++
 src/calendar/backends/weather/e-cal-backend-weather.c |  8 ++++++++
 src/calendar/backends/weather/e-weather-source.c      | 16 +++++++++++++++-
 4 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 234f605be..5182a4792 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,7 +756,13 @@ 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})
+       endif(WITH_GWEATHER4)
 
        set(CMAKE_REQUIRED_INCLUDES ${LIBGWEATHER_INCLUDE_DIRS})
        set(CMAKE_REQUIRED_LIBRARIES ${LIBGWEATHER_LDFLAGS})
diff --git a/config.h.in b/config.h.in
index 4e79549ab..c087d2b04 100644
--- a/config.h.in
+++ b/config.h.in
@@ -197,6 +197,9 @@
 /* gweather_info_new() has only one argument */
 #cmakedefine HAVE_ONE_ARG_GWEATHER_INFO_NEW 1
 
+/* Defined when linking against gweather4. Cannot just use GWEATHER_CHECK_VERSION because 40.0 made the 
versions non-monotonic. */
+#cmakedefine WITH_GWEATHER4 1
+
 /* evolution-alarm-notify - Define if using Canberra-GTK for sound */
 #cmakedefine HAVE_CANBERRA 1
 
diff --git a/src/calendar/backends/weather/e-cal-backend-weather.c 
b/src/calendar/backends/weather/e-cal-backend-weather.c
index 72faccd62..c4999671f 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;
+       #ifdef WITH_GWEATHER4
+       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)))
+               #ifdef WITH_GWEATHER4
+               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..7aff1f6ac 100644
--- a/src/calendar/backends/weather/e-weather-source.c
+++ b/src/calendar/backends/weather/e-weather-source.c
@@ -39,7 +39,11 @@ weather_source_dispose (GObject *object)
        EWeatherSourcePrivate *priv;
 
        priv = E_WEATHER_SOURCE (object)->priv;
+       #ifdef WITH_GWEATHER4
+       g_clear_object (&priv->location);
+       #else
        g_clear_pointer (&priv->location, gweather_location_unref);
+       #endif
 
        g_clear_object (&priv->info);
 
@@ -85,7 +89,11 @@ weather_source_find_location_by_coords (GWeatherLocation *start,
                gweather_location_get_coords (location, &lat, &lon);
 
                if (lat == latitude && lon == longitude) {
+                       #ifdef WITH_GWEATHER4
+                       g_object_ref (location);
+                       #else
                        gweather_location_ref (location);
+                       #endif
                        return location;
                }
        }
@@ -96,7 +104,11 @@ weather_source_find_location_by_coords (GWeatherLocation *start,
 
                result = weather_source_find_location_by_coords (child, latitude, longitude);
                if (result) {
+                       #ifdef WITH_GWEATHER4
+                       g_object_unref (child);
+                       #else
                        gweather_location_unref (child);
+                       #endif
                        return result;
                }
        }
@@ -159,7 +171,9 @@ e_weather_source_new (const gchar *location)
                }
        }
 
-#if GWEATHER_CHECK_VERSION(3, 39, 0)
+#ifdef WITH_GWEATHER4
+       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]