[empathy] Queue location publish requests
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Subject: [empathy] Queue location publish requests
- Date: Mon, 1 Jun 2009 11:45:49 -0400 (EDT)
commit 9330381ac6f8b78ba737a21e42f9b60c1bcee6dd
Author: Pierre-Luc Beaudoin <pierre-luc beaudoin collabora co uk>
Date: Fri May 29 14:08:18 2009 -0400
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.
---
libempathy-gtk/empathy-location-manager.c | 30 ++++++++++++++++++++++------
1 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/libempathy-gtk/empathy-location-manager.c b/libempathy-gtk/empathy-location-manager.c
index 27eca75..5db00fd 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);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]