aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-03-14 22:42:05 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-03-15 15:48:47 +0800
commit8eb401d562b29f195d68ca04e3dfbf8adc501846 (patch)
treecce66d12e01b655ae8e48d3a1d2a8d55a170b3cf
parent4bfb1d6bf59735b088e3daae5158203454fd23ba (diff)
downloadgsoc2013-empathy-8eb401d562b29f195d68ca04e3dfbf8adc501846.tar
gsoc2013-empathy-8eb401d562b29f195d68ca04e3dfbf8adc501846.tar.gz
gsoc2013-empathy-8eb401d562b29f195d68ca04e3dfbf8adc501846.tar.bz2
gsoc2013-empathy-8eb401d562b29f195d68ca04e3dfbf8adc501846.tar.lz
gsoc2013-empathy-8eb401d562b29f195d68ca04e3dfbf8adc501846.tar.xz
gsoc2013-empathy-8eb401d562b29f195d68ca04e3dfbf8adc501846.tar.zst
gsoc2013-empathy-8eb401d562b29f195d68ca04e3dfbf8adc501846.zip
location-manager: use geoclue_master_client_set_requirements_async()
https://bugzilla.gnome.org/show_bug.cgi?id=671994
-rw-r--r--libempathy-gtk/empathy-location-manager.c71
1 files changed, 44 insertions, 27 deletions
diff --git a/libempathy-gtk/empathy-location-manager.c b/libempathy-gtk/empathy-location-manager.c
index 53f25d6dc..ec7810f7d 100644
--- a/libempathy-gtk/empathy-location-manager.c
+++ b/libempathy-gtk/empathy-location-manager.c
@@ -433,21 +433,32 @@ initial_position_cb (GeocluePosition *position,
}
}
-static gboolean
-set_requirements (EmpathyLocationManager *self)
+static void
+set_requirements (EmpathyLocationManager *self,
+ GeoclueSetRequirementsCallback callback)
{
- GError *error = NULL;
+ geoclue_master_client_set_requirements_async (self->priv->gc_client,
+ GEOCLUE_ACCURACY_LEVEL_COUNTRY, 0, FALSE, self->priv->resources,
+ callback, self);
+}
+
+static void
+update_resources_set_requirements_cb (GeoclueMasterClient *client,
+ GError *error,
+ gpointer userdata)
+{
+ EmpathyLocationManager *self = userdata;
- if (!geoclue_master_client_set_requirements (self->priv->gc_client,
- GEOCLUE_ACCURACY_LEVEL_COUNTRY, 0, FALSE, self->priv->resources,
- &error))
+ if (error != NULL)
{
DEBUG ("set_requirements failed: %s", error->message);
- g_error_free (error);
- return FALSE;
+ return;
}
- return TRUE;
+ geoclue_address_get_address_async (self->priv->gc_address,
+ initial_address_cb, self);
+ geoclue_position_get_position_async (self->priv->gc_position,
+ initial_position_cb, self);
}
static void
@@ -461,19 +472,11 @@ update_resources (EmpathyLocationManager *self)
/* As per Geoclue bug #15126, using NONE results in no address
* being found as geoclue-manual report an empty address with
* accuracy = NONE */
- if (!set_requirements (self))
- return;
-
- geoclue_address_get_address_async (self->priv->gc_address,
- initial_address_cb, self);
- geoclue_position_get_position_async (self->priv->gc_position,
- initial_position_cb, self);
+ set_requirements (self, update_resources_set_requirements_cb);
}
static void
-create_client_cb (GeoclueMaster *master,
- GeoclueMasterClient *client,
- char *object_path,
+create_client_set_requirements_cb (GeoclueMasterClient *client,
GError *error,
gpointer userdata)
{
@@ -481,17 +484,10 @@ create_client_cb (GeoclueMaster *master,
if (error != NULL)
{
- DEBUG ("Failed to create GeoclueMasterClient: %s", error->message);
+ DEBUG ("set_requirements failed: %s", error->message);
return;
}
- /* @client seems be (transfer full) looking at the geoclue code; yeah for
- * undocumented API... */
- self->priv->gc_client = client;
-
- if (!set_requirements (self))
- return;
-
/* Get updated when the position is changes */
self->priv->gc_position = geoclue_master_client_create_position (
self->priv->gc_client, &error);
@@ -519,7 +515,28 @@ create_client_cb (GeoclueMaster *master,
G_CALLBACK (address_changed_cb), self);
self->priv->geoclue_is_setup = TRUE;
+}
+
+static void
+create_client_cb (GeoclueMaster *master,
+ GeoclueMasterClient *client,
+ char *object_path,
+ GError *error,
+ gpointer userdata)
+{
+ EmpathyLocationManager *self = userdata;
+
+ if (error != NULL)
+ {
+ DEBUG ("Failed to create GeoclueMasterClient: %s", error->message);
+ return;
+ }
+
+ /* @client seems be (transfer full) looking at the geoclue code; yeah for
+ * undocumented API... */
+ self->priv->gc_client = client;
+ set_requirements (self, create_client_set_requirements_cb);
}
static void