aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>2008-12-13 06:40:22 +0800
committerPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-06-01 23:35:29 +0800
commit42344f07956ad7d6eb2d327f87cdb63d08334487 (patch)
tree011be930192dec575b2e56c0c71bc434e82bf562
parent07061229f3328c3fa5300217004e27f6a12304f8 (diff)
downloadgsoc2013-empathy-42344f07956ad7d6eb2d327f87cdb63d08334487.tar
gsoc2013-empathy-42344f07956ad7d6eb2d327f87cdb63d08334487.tar.gz
gsoc2013-empathy-42344f07956ad7d6eb2d327f87cdb63d08334487.tar.bz2
gsoc2013-empathy-42344f07956ad7d6eb2d327f87cdb63d08334487.tar.lz
gsoc2013-empathy-42344f07956ad7d6eb2d327f87cdb63d08334487.tar.xz
gsoc2013-empathy-42344f07956ad7d6eb2d327f87cdb63d08334487.tar.zst
gsoc2013-empathy-42344f07956ad7d6eb2d327f87cdb63d08334487.zip
Initial position/address and ressource fix
-rw-r--r--libempathy-gtk/empathy-location-manager.c58
1 files changed, 48 insertions, 10 deletions
diff --git a/libempathy-gtk/empathy-location-manager.c b/libempathy-gtk/empathy-location-manager.c
index 9e7ce4597..0e103a0ea 100644
--- a/libempathy-gtk/empathy-location-manager.c
+++ b/libempathy-gtk/empathy-location-manager.c
@@ -252,6 +252,27 @@ empathy_location_manager_get_default (void)
#if HAVE_GEOCLUE
static void
+initial_position_cb (GeocluePosition *position,
+ GeocluePositionFields fields,
+ int timestamp,
+ double latitude,
+ double longitude,
+ double altitude,
+ GeoclueAccuracy *accuracy,
+ GError *error,
+ gpointer location_manager)
+{
+ if (error)
+ {
+ DEBUG ("Error: %s", error->message);
+ g_error_free (error);
+ }
+ else
+ position_changed_cb (position, fields, timestamp, latitude, longitude,
+ altitude, accuracy, location_manager);
+}
+
+static void
position_changed_cb (GeocluePosition *position,
GeocluePositionFields fields,
int timestamp,
@@ -264,9 +285,10 @@ position_changed_cb (GeocluePosition *position,
EmpathyLocationManagerPriv *priv;
priv = GET_PRIV (location_manager);
GeoclueAccuracyLevel level;
+ gdouble mean, horizontal, vertical;
GValue *new_value;
- geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
+ geoclue_accuracy_get_details (accuracy, &level, &horizontal, &vertical);
DEBUG ("New position (accuracy level %d)", level);
if (level == GEOCLUE_ACCURACY_LEVEL_NONE)
return;
@@ -295,11 +317,7 @@ position_changed_cb (GeocluePosition *position,
if (level == GEOCLUE_ACCURACY_LEVEL_DETAILED)
{
- gdouble mean, horizontal, vertical;
-
- geoclue_accuracy_get_details (accuracy, &level, &horizontal, &vertical);
mean = (horizontal + vertical) / 2.0;
-
new_value = tp_g_value_slice_new (G_TYPE_DOUBLE);
g_value_set_double (new_value, mean);
g_hash_table_insert (priv->location, EMPATHY_LOCATION_ACCURACY, new_value);
@@ -328,6 +346,22 @@ address_foreach_cb (gpointer key,
DEBUG ("\t - %s: %s", (char*) key, (char*) value);
}
+static void
+initial_address_cb (GeoclueAddress *address,
+ int timestamp,
+ GHashTable *details,
+ GeoclueAccuracy *accuracy,
+ GError *error,
+ gpointer location_manager)
+{
+ if (error)
+ {
+ DEBUG ("Error: %s", error->message);
+ g_error_free (error);
+ }
+ else
+ address_changed_cb (address, timestamp, details, accuracy, location_manager);
+}
static void
address_changed_cb (GeoclueAddress *address,
@@ -364,7 +398,7 @@ update_resources (EmpathyLocationManager *location_manager)
DEBUG ("Updating resources");
if (!geoclue_master_client_set_requirements (priv->gc_client,
- GEOCLUE_ACCURACY_LEVEL_COUNTRY, 0, TRUE, priv->resources,
+ GEOCLUE_ACCURACY_LEVEL_LOCALITY, 0, FALSE, priv->resources,
NULL))
g_printerr ("set_requirements failed");
}
@@ -398,6 +432,8 @@ setup_geoclue (EmpathyLocationManager *location_manager)
g_signal_connect (G_OBJECT (priv->gc_position), "position-changed",
G_CALLBACK (position_changed_cb), location_manager);
+ geoclue_position_get_position_async (priv->gc_position,
+ initial_position_cb, location_manager);
/* Get updated when the address changes */
priv->gc_address = geoclue_master_client_create_address (
@@ -410,6 +446,8 @@ setup_geoclue (EmpathyLocationManager *location_manager)
g_signal_connect (G_OBJECT (priv->gc_address), "address-changed",
G_CALLBACK (address_changed_cb), location_manager);
+ geoclue_address_get_address_async (priv->gc_address,
+ initial_address_cb, location_manager);
priv->is_setup = TRUE;
}
@@ -448,15 +486,15 @@ resource_cb (EmpathyConf *conf,
gboolean resource_enabled;
priv = GET_PRIV (manager);
- DEBUG ("A Resource Conf changed");
+ DEBUG ("%s changed", key);
if (empathy_conf_get_bool (conf, key, &resource_enabled))
{
- if (strcmp (key, EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK))
+ if (strcmp (key, EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK) == 0)
resource = GEOCLUE_RESOURCE_NETWORK;
- if (strcmp (key, EMPATHY_PREFS_LOCATION_RESOURCE_CELL))
+ if (strcmp (key, EMPATHY_PREFS_LOCATION_RESOURCE_CELL) == 0)
resource = GEOCLUE_RESOURCE_CELL;
- if (strcmp (key, EMPATHY_PREFS_LOCATION_RESOURCE_GPS))
+ if (strcmp (key, EMPATHY_PREFS_LOCATION_RESOURCE_GPS) == 0)
resource = GEOCLUE_RESOURCE_GPS;
}
if (resource_enabled)