From: Jonny Lamb Date: Sat, 24 Oct 2009 17:52:02 +0000 (+0100) Subject: idle: use the TpAccount pointer as key to the hash table, and remove values on disconnect X-Git-Url: https://git.0d.be/?p=empathy.git;a=commitdiff_plain;h=c4fdd8511467729baed7df2db9b40d8eea16a38a idle: use the TpAccount pointer as key to the hash table, and remove values on disconnect https://bugzilla.gnome.org/show_bug.cgi?id=599169#c2 Signed-off-by: Jonny Lamb --- diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c index 7f68b794..2d202105 100644 --- a/libempathy/empathy-idle.c +++ b/libempathy/empathy-idle.c @@ -454,15 +454,13 @@ account_status_changed_cb (TpAccount *account, EmpathyIdlePriv *priv = GET_PRIV (idle); GTimeVal val; - if (new_status != TP_CONNECTION_STATUS_CONNECTED) { - return; + if (new_status == TP_CONNECTION_STATUS_CONNECTED) { + g_get_current_time (&val); + g_hash_table_insert (priv->connect_times, account, + GINT_TO_POINTER (val.tv_sec)); + } else if (new_status == TP_CONNECTION_STATUS_DISCONNECTED) { + g_hash_table_remove (priv->connect_times, account); } - - g_get_current_time (&val); - - g_hash_table_insert (priv->connect_times, - g_strdup (tp_proxy_get_object_path (account)), - GINT_TO_POINTER (val.tv_sec)); } static void @@ -534,8 +532,7 @@ empathy_idle_init (EmpathyIdle *idle) priv->state_change_signal_id = g_signal_connect (priv->connectivity, "state-change", G_CALLBACK (idle_state_change_cb), idle); - priv->connect_times = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, NULL); + priv->connect_times = g_hash_table_new (g_direct_hash, g_direct_equal); } EmpathyIdle * @@ -729,8 +726,7 @@ empathy_idle_account_is_just_connected (EmpathyIdle *idle, return FALSE; } - ptr = g_hash_table_lookup (priv->connect_times, - tp_proxy_get_object_path (account)); + ptr = g_hash_table_lookup (priv->connect_times, account); if (ptr == NULL) { return FALSE;