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




commit 66a3661e601b43fca41c7f0baa9a828631e70268
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 87558499..7696e399 100644
--- a/build-aux/flatpak/org.gnome.Calendar.json
+++ b/build-aux/flatpak/org.gnome.Calendar.json
@@ -15,7 +15,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",
@@ -39,6 +38,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 71ba8250..f8f45e33 100644
--- a/src/weather/gcal-weather-service.c
+++ b/src/weather/gcal-weather-service.c
@@ -762,13 +762,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;
 }
 
@@ -1141,6 +1142,7 @@ void
 gcal_weather_service_stop (GcalWeatherService *self)
 {
   GCAL_ENTRY;
+  GClueClient *client;
 
   g_return_if_fail (GCAL_IS_WEATHER_SERVICE (self));
 
@@ -1162,11 +1164,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]