[gnome-calendar/bilelmoussaoui/location-portal: 2/2] location service: adapt to make use of the portal




commit b43d9497c3048beb9a43eb48b1676961544a6dd1
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Wed Jan 12 11:28:00 2022 +0100

    location service: adapt to make use of the portal
    
    GClue automatically calls the portal for us when sandboxed and in such case
    a NULL is returned for the client porxy because the calls goes through the portal.
    
    Part of https://gitlab.gnome.org/GNOME/Initiatives/-/issues/30

 build-aux/flatpak/org.gnome.Calendar.json | 17 ++++++++++++++++-
 src/weather/gcal-weather-service.c        | 29 +++++++++++++++++------------
 2 files changed, 33 insertions(+), 13 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Calendar.json b/build-aux/flatpak/org.gnome.Calendar.json
index af65be2c..e8cbf74c 100644
--- a/build-aux/flatpak/org.gnome.Calendar.json
+++ b/build-aux/flatpak/org.gnome.Calendar.json
@@ -14,7 +14,6 @@
         "--socket=wayland",
         "--system-talk-name=org.freedesktop.login1",
         "--system-talk-name=org.freedesktop.timedate1",
-        "--system-talk-name=org.freedesktop.GeoClue2",
         "--talk-name=org.gnome.ControlCenter",
         "--talk-name=org.gnome.evolution.dataserver.AddressBook9",
         "--talk-name=org.gnome.evolution.dataserver.Calendar8",
@@ -38,6 +37,22 @@
         "*.a"
     ],
     "modules" : [
+        {
+            "name": "libgeoclue",
+            "buildsystem": "meson",
+            "config-opts" : [
+                "-Denable-backend=false",
+                "-Dlibgeoclue=true",
+                "-Dintrospection=true",
+                "-Dgtk-doc=false"
+            ],
+            "sources": [
+                {
+                    "type" : "git",
+                    "url": "https://gitlab.freedesktop.org/geoclue/geoclue.git";
+                }
+            ]
+        },
         {
             "name" : "geocode-glib",
             "buildsystem" : "meson",
diff --git a/src/weather/gcal-weather-service.c b/src/weather/gcal-weather-service.c
index 9fbedb51..6892971f 100644
--- a/src/weather/gcal-weather-service.c
+++ b/src/weather/gcal-weather-service.c
@@ -764,13 +764,14 @@ on_gclue_simple_creation_cb (GClueSimple        *_source,
                                self,
                                0);
     }
-
-  g_signal_connect_object (client,
-                           "notify::active",
-                           G_CALLBACK (on_gclue_client_activity_changed_cb),
-                           self,
-                           0);
-
+  if (client)
+    {
+      g_signal_connect_object (client,
+                               "notify::active",
+                               G_CALLBACK (on_gclue_client_activity_changed_cb),
+                               self,
+                               0);
+    }
   GCAL_EXIT;
 }
 
@@ -1143,6 +1144,7 @@ void
 gcal_weather_service_stop (GcalWeatherService *self)
 {
   GCAL_ENTRY;
+  GClueClient *client;
 
   g_return_if_fail (GCAL_IS_WEATHER_SERVICE (self));
 
@@ -1164,11 +1166,14 @@ gcal_weather_service_stop (GcalWeatherService *self)
     }
   else
     {
-      gclue_client_call_stop (gclue_simple_get_client (self->location_service),
-                              self->location_cancellable,
-                              (GAsyncReadyCallback) on_gclue_client_stopped_cb,
-                              self->location_service);
-
+      client = gclue_simple_get_client (self->location_service);
+      if (client)
+        {
+          gclue_client_call_stop (client,
+                                  self->location_cancellable,
+                                  (GAsyncReadyCallback) on_gclue_client_stopped_cb,
+                                  self->location_service);
+        }
       self->location_service = NULL;
     }
 


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