aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-05-30 02:08:18 +0800
committerPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-06-01 23:35:32 +0800
commit9330381ac6f8b78ba737a21e42f9b60c1bcee6dd (patch)
treef9db8fa0630890767ccd4564e54297f19f84a341 /libempathy-gtk
parent2556a450e8c1c1deb5330dacb00087e6c56d8f57 (diff)
downloadgsoc2013-empathy-9330381ac6f8b78ba737a21e42f9b60c1bcee6dd.tar
gsoc2013-empathy-9330381ac6f8b78ba737a21e42f9b60c1bcee6dd.tar.gz
gsoc2013-empathy-9330381ac6f8b78ba737a21e42f9b60c1bcee6dd.tar.bz2
gsoc2013-empathy-9330381ac6f8b78ba737a21e42f9b60c1bcee6dd.tar.lz
gsoc2013-empathy-9330381ac6f8b78ba737a21e42f9b60c1bcee6dd.tar.xz
gsoc2013-empathy-9330381ac6f8b78ba737a21e42f9b60c1bcee6dd.tar.zst
gsoc2013-empathy-9330381ac6f8b78ba737a21e42f9b60c1bcee6dd.zip
Queue location publish requests
Using an idle callback makes it less probable that the location will be updated twice in a very short time. This scenario is common is the address_cb and position_cb got a reply from geocluse almost at the sametime.
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-location-manager.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/libempathy-gtk/empathy-location-manager.c b/libempathy-gtk/empathy-location-manager.c
index 27eca756a..5db00fde3 100644
--- a/libempathy-gtk/empathy-location-manager.c
+++ b/libempathy-gtk/empathy-location-manager.c
@@ -60,6 +60,9 @@ typedef struct {
gboolean reduce_accuracy;
gdouble reduce_value;
EmpathyAccountManager *account_manager;
+
+ /* The idle id for publish_on_idle func */
+ guint idle_id;
} EmpathyLocationManagerPriv;
static void location_manager_finalize (GObject *object);
@@ -85,6 +88,9 @@ static void account_connection_changed_cb (EmpathyAccountManager *manager,
McAccount *account, TpConnectionStatusReason reason,
TpConnectionStatus current, TpConnectionStatus previous,
gpointer *location_manager);
+static void publish_to_all_accounts (EmpathyLocationManager *location_manager,
+ gboolean force_publication);
+static gboolean publish_on_idle (gpointer user_data);
G_DEFINE_TYPE (EmpathyLocationManager, empathy_location_manager, G_TYPE_OBJECT);
@@ -107,6 +113,17 @@ empathy_location_manager_class_init (EmpathyLocationManagerClass *class)
g_type_class_add_private (object_class, sizeof (EmpathyLocationManagerPriv));
}
+static gboolean
+publish_on_idle (gpointer user_data)
+{
+ EmpathyLocationManager *manager = EMPATHY_LOCATION_MANAGER (user_data);
+ EmpathyLocationManagerPriv *priv = GET_PRIV (manager);
+
+ priv->idle_id = 0;
+ publish_to_all_accounts (manager, TRUE);
+ return FALSE;
+}
+
static void
publish_location (EmpathyLocationManager *location_manager,
McAccount *account,
@@ -152,7 +169,7 @@ publish_location (EmpathyLocationManager *location_manager,
}
static void
-publish_location_to_all_accounts (EmpathyLocationManager *location_manager,
+publish_to_all_accounts (EmpathyLocationManager *location_manager,
gboolean force_publication)
{
GList *accounts = NULL, *l;
@@ -385,8 +402,8 @@ position_changed_cb (GeocluePosition *position,
}
update_timestamp (location_manager);
- publish_location_to_all_accounts (EMPATHY_LOCATION_MANAGER (location_manager),
- FALSE);
+ if (priv->idle_id == 0)
+ g_idle_add (publish_on_idle, location_manager);
}
@@ -451,8 +468,8 @@ address_changed_cb (GeoclueAddress *address,
g_hash_table_foreach (details, address_foreach_cb, (gpointer)location_manager);
update_timestamp (location_manager);
- publish_location_to_all_accounts (EMPATHY_LOCATION_MANAGER (location_manager),
- FALSE);
+ if (priv->idle_id == 0)
+ g_idle_add (publish_on_idle, location_manager);
}
@@ -557,7 +574,6 @@ publish_cb (EmpathyConf *conf,
initial_address_cb, manager);
geoclue_position_get_position_async (priv->gc_position,
initial_position_cb, manager);
- publish_location_to_all_accounts (manager, FALSE);
}
else
{
@@ -565,7 +581,7 @@ publish_cb (EmpathyConf *conf,
* location from the servers
*/
g_hash_table_remove_all (priv->location);
- publish_location_to_all_accounts (manager, TRUE);
+ publish_to_all_accounts (manager, TRUE);
}
}