[gnome-shell/wip/loc-apps: 1/2] location: dconf-based



commit 614f37b116c9309b67b70a4814e11e3d32cfe843
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Feb 5 23:15:25 2016 +0000

    location: dconf-based

 js/ui/status/location.js |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/status/location.js b/js/ui/status/location.js
index 29f054e..1aae47a 100644
--- a/js/ui/status/location.js
+++ b/js/ui/status/location.js
@@ -12,6 +12,7 @@ const Shell = imports.gi.Shell;
 const LOCATION_SCHEMA = 'org.gnome.system.location';
 const MAX_ACCURACY_LEVEL = 'max-accuracy-level';
 const ENABLED = 'enabled';
+const APPS = 'applications';
 
 const GeoclueAccuracyLevel = {
     NONE: 0,
@@ -89,18 +90,27 @@ const Indicator = new Lang.Class({
         return this._getMaxAccuracyLevel();
     },
 
-    // We (and geoclue) have currently no way to reliably identifying apps so
-    // for now, lets just authorize all apps as long as they provide a valid
-    // desktop ID. We also ensure they don't get more accuracy than global max.
     AuthorizeApp: function(desktop_id, reqAccuracyLevel) {
-        var appSystem = Shell.AppSystem.get_default();
-        var app = appSystem.lookup_app(desktop_id + ".desktop");
-        if (app == null) {
-            return [false, 0];
+        let apps = this._settings.get_value(APPS);
+        let nApps = apps.n_children();
+
+        for (let i = 0; i < nApps; i++) {
+            let [app, levelStr] = apps.get_child_value(i).deep_unpack();
+            if (app != desktop_id)
+                continue;
+
+            level = GeoclueAccuracyLevel[levelStr.toUpperCase()] ||
+                    GeoclueAccuracyLevel.NONE;
+            if (level == GeoclueAccuracyLevel.NONE)
+                return [false, 0];
+
+            let allowedAccuracyLevel = clamp(reqAccuracyLevel, 0, level);
+            allowedAccuracyLevel = clamp(allowedAccuracyLevel, 0, this._getMaxAccuracyLevel());
+
+            return [true, allowedAccuracyLevel];
         }
 
-        let allowedAccuracyLevel = clamp(reqAccuracyLevel, 0, this._getMaxAccuracyLevel());
-        return [true, allowedAccuracyLevel];
+        return [false, 0];
     },
 
     _syncIndicator: function() {


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