[gnome-shell] location: Split out PermissionStore



commit 9cc1e6b85ce72bd4c999b559cec310886aa2fc88
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Mar 19 15:37:15 2017 +0100

    location: Split out PermissionStore
    
    It doesn't make sense to tie the proxy code for flatpak's permission
    store to the location indicator, just because that was the first
    component to use it, so split it into a separate module.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780252

 js/js-resources.gresource.xml |    1 +
 js/misc/permissionStore.js    |   30 ++++++++++++++++++++++++++++++
 js/ui/status/location.js      |   26 ++------------------------
 3 files changed, 33 insertions(+), 24 deletions(-)
---
diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
index b774299..a1a4196 100644
--- a/js/js-resources.gresource.xml
+++ b/js/js-resources.gresource.xml
@@ -23,6 +23,7 @@
     <file>misc/modemManager.js</file>
     <file>misc/objectManager.js</file>
     <file>misc/params.js</file>
+    <file>misc/permissionStore.js</file>
     <file>misc/smartcardManager.js</file>
     <file>misc/util.js</file>
     <file>misc/weather.js</file>
diff --git a/js/misc/permissionStore.js b/js/misc/permissionStore.js
new file mode 100644
index 0000000..b1dbe86
--- /dev/null
+++ b/js/misc/permissionStore.js
@@ -0,0 +1,30 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
+const Gio = imports.gi.Gio;
+
+const PermissionStoreIface = '<node> \
+  <interface name="org.freedesktop.impl.portal.PermissionStore"> \
+    <method name="Lookup"> \
+      <arg name="table" type="s" direction="in"/> \
+      <arg name="id" type="s" direction="in"/> \
+      <arg name="permissions" type="a{sas}" direction="out"/> \
+      <arg name="data" type="v" direction="out"/> \
+    </method> \
+    <method name="Set"> \
+      <arg name="table" type="s" direction="in"/> \
+      <arg name="create" type="b" direction="in"/> \
+      <arg name="id" type="s" direction="in"/> \
+      <arg name="app_permissions" type="a{sas}" direction="in"/> \
+      <arg name="data" type="v" direction="in"/> \
+    </method> \
+  </interface> \
+</node>';
+
+const PermissionStoreProxy = Gio.DBusProxy.makeProxyWrapper(PermissionStoreIface);
+
+function PermissionStore(initCallback, cancellable) {
+    return new PermissionStoreProxy(Gio.DBus.session,
+                                    'org.freedesktop.impl.portal.PermissionStore',
+                                    '/org/freedesktop/impl/portal/PermissionStore',
+                                    initCallback, cancellable);
+};
diff --git a/js/ui/status/location.js b/js/ui/status/location.js
index 668f93c..7988dd4 100644
--- a/js/ui/status/location.js
+++ b/js/ui/status/location.js
@@ -9,6 +9,7 @@ const Main = imports.ui.main;
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
 const ModalDialog = imports.ui.modalDialog;
+const PermissionStore = imports.misc.permissionStore;
 const Shell = imports.gi.Shell;
 const Signals = imports.signals;
 const St = imports.gi.St;
@@ -62,26 +63,6 @@ var AgentIface = '<node> \
   </interface> \
 </node>';
 
-var PermissionStoreIface = '<node> \
-  <interface name="org.freedesktop.impl.portal.PermissionStore"> \
-    <method name="Lookup"> \
-      <arg name="table" type="s" direction="in"/> \
-      <arg name="id" type="s" direction="in"/> \
-      <arg name="permissions" type="a{sas}" direction="out"/> \
-      <arg name="data" type="v" direction="out"/> \
-    </method> \
-    <method name="Set"> \
-      <arg name="table" type="s" direction="in"/> \
-      <arg name="create" type="b" direction="in"/> \
-      <arg name="id" type="s" direction="in"/> \
-      <arg name="app_permissions" type="a{sas}" direction="in"/> \
-      <arg name="data" type="v" direction="in"/> \
-    </method> \
-  </interface> \
-</node>';
-
-const PermissionStore = Gio.DBusProxy.makeProxyWrapper(PermissionStoreIface);
-
 const Indicator = new Lang.Class({
     Name: 'LocationIndicator',
     Extends: PanelMenu.SystemIndicator,
@@ -253,10 +234,7 @@ const Indicator = new Lang.Class({
 
     _connectToPermissionStore: function() {
         this._permStoreProxy = null;
-        new PermissionStore(Gio.DBus.session,
-                           'org.freedesktop.impl.portal.PermissionStore',
-                           '/org/freedesktop/impl/portal/PermissionStore',
-                           Lang.bind(this, this._onPermStoreProxyReady));
+        new PermissionStore.PermissionStore(Lang.bind(this, this._onPermStoreProxyReady), null);
     },
 
     _onPermStoreProxyReady: function(proxy, error) {


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