[gnome-maps] geoclue: Connect directly through GDBus
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] geoclue: Connect directly through GDBus
- Date: Fri, 23 Aug 2013 16:28:20 +0000 (UTC)
commit 06b151ef23003a5d38ea65089082020a51e49762
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Aug 23 19:21:19 2013 +0300
geoclue: Connect directly through GDBus
i-e Drop usage of client-side library as it will be dropped soon.
src/geoclue.js | 99 +++++++++++++++++++++++++++-----------------------------
1 files changed, 48 insertions(+), 51 deletions(-)
---
diff --git a/src/geoclue.js b/src/geoclue.js
index 622a3a9..bf9e521 100644
--- a/src/geoclue.js
+++ b/src/geoclue.js
@@ -24,7 +24,6 @@ const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gio = imports.gi.Gio;
const Geocode = imports.gi.GeocodeGlib;
-const GClue = imports.gi.Geoclue;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
@@ -35,6 +34,33 @@ const Path = imports.path;
const Signals = imports.signals;
const _ = imports.gettext.gettext;
+const ManagerInterface = <interface name="org.freedesktop.GeoClue2.Manager">
+ <method name="GetClient">
+ <arg name="client" type="o" direction="out"/>
+ </method>
+</interface>
+const ManagerProxy = Gio.DBusProxy.makeProxyWrapper(ManagerInterface);
+
+const ClientInterface = <interface name="org.freedesktop.GeoClue2.Client">
+ <property name="Location" type="o" access="read"/>
+ <property name="DistanceThreshold" type="u" access="readwrite"/>
+ <method name="Start"/>
+ <method name="Stop"/>
+ <signal name="LocationUpdated">
+ <arg name="old" type="o"/>
+ <arg name="new" type="o"/>
+ </signal>
+</interface>
+const ClientProxy = Gio.DBusProxy.makeProxyWrapper(ClientInterface);
+
+const LocationInterface = <interface name="org.freedesktop.GeoClue2.Location">
+ <property name="latitude" type="d" access="read"/>
+ <property name="longitude" type="d" access="read"/>
+ <property name="accuracy" type="d" access="read"/>
+ <property name="description" type="s" access="read"/>
+</interface>
+const LocationProxy = Gio.DBusProxy.makeProxyWrapper(LocationInterface);
+
const Geoclue = new Lang.Class({
Name: 'Geoclue',
@@ -56,70 +82,41 @@ const Geoclue = new Lang.Class({
},
_findLocation: function() {
- GClue.ManagerProxy.new_for_bus(Gio.BusType.SYSTEM,
- Gio.DBusProxyFlags.NONE,
- "org.freedesktop.GeoClue2",
- "/org/freedesktop/GeoClue2/Manager",
- null,
- this._onManagerProxyReady.bind(this));
- },
+ this._managerProxy = new ManagerProxy(Gio.DBus.system,
+ "org.freedesktop.GeoClue2",
+ "/org/freedesktop/GeoClue2/Manager");
- _onManagerProxyReady: function(sourceObject, res) {
- try {
- this._managerProxy = GClue.ManagerProxy.new_for_bus_finish(res);
+ this._managerProxy.GetClientRemote(this._onGetClientReady.bind(this));
+ },
- this._managerProxy.call_get_client(null, this._onGetClientReady.bind(this));
- } catch (e) {
+ _onGetClientReady: function(result, e) {
+ if (e) {
log ("Failed to connect to GeoClue2 service: " + e.message);
+ return;
}
- },
- _onGetClientReady: function(sourceObject, res) {
- try {
- let [ret, clientPath] = this._managerProxy.call_get_client_finish(res);
+ let [clientPath] = result;
- GClue.ClientProxy.new_for_bus(Gio.BusType.SYSTEM,
- Gio.DBusProxyFlags.NONE,
- "org.freedesktop.GeoClue2",
- clientPath,
- null,
- this._onClientProxyReady.bind(this));
- } catch (e) {
- log ("Failed to connect to GeoClue2 service: " + e.message);
- }
- },
+ this._clientProxy = new ClientProxy(Gio.DBus.system,
+ "org.freedesktop.GeoClue2",
+ clientPath);
+ this._clientProxy.connectSignal("LocationUpdated",
+ this._onLocationUpdated.bind(this));
- _onClientProxyReady: function(sourceObject, res) {
- try {
- this._clientProxy = GClue.ClientProxy.new_for_bus_finish(res);
-
- this._clientProxy.connect("location-updated", (function(client, oldPath, newPath) {
- GClue.LocationProxy.new_for_bus(Gio.BusType.SYSTEM,
- Gio.DBusProxyFlags.NONE,
- "org.freedesktop.GeoClue2",
- newPath,
- null,
- this._onLocationProxyReady.bind(this));
- }).bind(this));
-
- this._clientProxy.call_start(null, this._onStartReady.bind(this));
- } catch (e) {
- log ("Failed to connect to GeoClue2 service: " + e.message);
- }
+ this._clientProxy.StartRemote(this._onStartReady.bind(this));
},
- _onStartReady: function(sourceObject, res) {
- try {
- this._clientProxy.call_start_finish(res);
- } catch (e) {
+ _onStartReady: function(result, e) {
+ if (e) {
log ("Failed to connect to GeoClue2 service: " + e.message);
}
},
- _onLocationProxyReady: function(sourceObject, res) {
+ _onLocationUpdated: function(proxy, sender, [oldPath, newPath]) {
+ this.location = new LocationProxy(Gio.DBus.system,
+ "org.freedesktop.GeoClue2",
+ newPath);
try {
- this.location = GClue.LocationProxy.new_for_bus_finish(res);
-
let variant = GLib.Variant.new('ad', [this.location.latitude,
this.location.longitude,
this.location.accuracy]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]