Skip to content
Snippets Groups Projects
Commit 5f2b217f authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

[Florob] improve geoloc usage. Fixes #5677

parent c115c031
No related branches found
No related tags found
No related merge requests found
......@@ -37,13 +37,9 @@ class LocationListener:
self._data = {}
def get_data(self):
self._get_address()
self._get_position()
def _get_address(self):
bus = dbus.SessionBus()
if 'org.freedesktop.Geoclue.Master' not in bus.list_names():
self._on_geoclue_address_changed()
self._on_geoclue_position_changed()
return
obj = bus.get_object('org.freedesktop.Geoclue.Master',
'/org/freedesktop/Geoclue/Master')
......@@ -51,29 +47,29 @@ class LocationListener:
path = obj.Create()
# get MasterClient
cli = bus.get_object('org.freedesktop.Geoclue.Master', path)
cli.SetRequirements(1, 0, True, 1023)
self._get_address(cli)
self._get_position(cli)
def _get_address(self, cli):
bus = dbus.SessionBus()
cli.AddressStart()
# Check that there is a provider
name, description, service, path = cli.GetAddressProvider()
if path:
timestamp, address, accuracy = cli.GetAddress()
provider = bus.get_object(service, path)
timestamp, address, accuracy = provider.GetAddress()
self._on_geoclue_address_changed(timestamp, address, accuracy)
def _get_position(self):
def _get_position(self, cli):
bus = dbus.SessionBus()
if 'org.freedesktop.Geoclue.Master' not in bus.list_names():
self._on_geoclue_position_changed()
return
obj = bus.get_object('org.freedesktop.Geoclue.Master',
'/org/freedesktop/Geoclue/Master')
# get MasterClient path
path = obj.Create()
# get MasterClient
cli = bus.get_object('org.freedesktop.Geoclue.Master', path)
cli.PositionStart()
# Check that there is a provider
name, description, service, path = cli.GetPositionProvider()
if path:
fields, timestamp, lat, lon, alt, accuray = cli.GetPosition()
provider = bus.get_object(service, path)
fields, timestamp, lat, lon, alt, accuray = provider.GetPosition()
self._on_geoclue_position_changed(fields, timestamp, lat, lon, alt,
accuracy)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment