[gnome-maps] geoclue: Handle service not available



commit ad686e2635f5fa749865aa2577b714fbfb965314
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Mon Apr 21 22:53:55 2014 +0200

    geoclue: Handle service not available
    
    The dbus code can fail if geoclue is not present on the system. Move
    code that can fail to a try/catch block to handle geoclue not
    available. Also make sure that methods using Geoclue are aware that
    it might not be there.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=727706

 src/geoclue.js |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/geoclue.js b/src/geoclue.js
index 5f15a08..cde528d 100644
--- a/src/geoclue.js
+++ b/src/geoclue.js
@@ -81,7 +81,7 @@ const Geoclue = new Lang.Class({
     Name: 'Geoclue',
 
     overrideLocation: function(location) {
-        if (this._locationUpdatedId > 0) {
+        if (this._clientProxy && this._locationUpdatedId > 0) {
             this._clientProxy.disconnectSignal(this._locationUpdatedId);
             this._locationUpdatedId = 0;
             this._clientProxy.StopRemote(function(result, e) {
@@ -95,6 +95,9 @@ const Geoclue = new Lang.Class({
     },
 
     findLocation: function() {
+        if (!this._clientProxy)
+            return;
+
         this._locationUpdatedId =
             this._clientProxy.connectSignal("LocationUpdated",
                                             this._onLocationUpdated.bind(this));
@@ -118,11 +121,15 @@ const Geoclue = new Lang.Class({
             this.userSetLocation = Application.settings.get('last-location-user-set');
         }
 
-        this._managerProxy = new ManagerProxy(Gio.DBus.system,
-                                              "org.freedesktop.GeoClue2",
-                                              "/org/freedesktop/GeoClue2/Manager");
-
-        this._managerProxy.GetClientRemote(this._onGetClientReady.bind(this));
+        try {
+            this._managerProxy = new ManagerProxy(Gio.DBus.system,
+                                                  "org.freedesktop.GeoClue2",
+                                                  "/org/freedesktop/GeoClue2/Manager");
+            this._managerProxy.GetClientRemote(this._onGetClientReady.bind(this));
+        } catch (e) {
+            Utils.debug("Failed to connect to GeoClue2 service: " + e.message);
+            log('Connection with GeoClue failed, we are not able to find your location!');
+        }
     },
 
     _onGetClientReady: function(result, e) {


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