diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-01-11 23:59:36 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-01-12 00:04:47 +0800 |
commit | efa437ce79b0df44f5595c6006a355a209b3608f (patch) | |
tree | c9b6553c49eebfd2de90b21606eba4b7d1205572 /libempathy/empathy-dispatcher.c | |
parent | 5fc16e172814745c2f40dffb35bb04c3d4f75f2b (diff) | |
download | gsoc2013-empathy-efa437ce79b0df44f5595c6006a355a209b3608f.tar.gz gsoc2013-empathy-efa437ce79b0df44f5595c6006a355a209b3608f.tar.zst gsoc2013-empathy-efa437ce79b0df44f5595c6006a355a209b3608f.zip |
store status-changed sig handler in a hash table
Diffstat (limited to 'libempathy/empathy-dispatcher.c')
-rw-r--r-- | libempathy/empathy-dispatcher.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c index b0991c1ce..6337f5c50 100644 --- a/libempathy/empathy-dispatcher.c +++ b/libempathy/empathy-dispatcher.c @@ -76,6 +76,9 @@ typedef struct GList *handlers; GHashTable *request_channel_class_async_ids; + /* (TpAccount *) => gulong + * Signal handler ID of the "status-changed" signal */ + GHashTable *status_changed_handlers; } EmpathyDispatcherPriv; static GList * @@ -1013,6 +1016,7 @@ dispatcher_finalize (GObject *object) GHashTableIter iter; gpointer connection; GList *list; + gpointer account, id; if (priv->request_channel_class_async_ids != NULL) { @@ -1036,6 +1040,13 @@ dispatcher_finalize (GObject *object) g_list_free (list); } + g_hash_table_iter_init (&iter, priv->status_changed_handlers); + while (g_hash_table_iter_next (&iter, &account, &id)) + { + g_signal_handler_disconnect (account, GPOINTER_TO_UINT (id)); + } + g_hash_table_destroy (priv->status_changed_handlers); + g_object_unref (priv->account_manager); g_hash_table_destroy (priv->outstanding_classes_requests); @@ -1141,11 +1152,22 @@ connect_account (EmpathyDispatcher *self, { EmpathyDispatcherPriv *priv = GET_PRIV (self); TpConnection *conn = tp_account_get_connection (account); + gulong id; + + id = GPOINTER_TO_UINT (g_hash_table_lookup (priv->status_changed_handlers, + account)); + + if (id != 0) + return; + if (conn != NULL) dispatcher_status_changed_cb (account, 0, 0, 0, NULL, NULL, self); id = g_signal_connect (account, "status-changed", G_CALLBACK (dispatcher_status_changed_cb), self); + + g_hash_table_insert (priv->status_changed_handlers, account, + GUINT_TO_POINTER (id)); } static void @@ -1197,6 +1219,8 @@ empathy_dispatcher_init (EmpathyDispatcher *self) priv->request_channel_class_async_ids = g_hash_table_new (g_direct_hash, g_direct_equal); + priv->status_changed_handlers = g_hash_table_new (g_direct_hash, + g_direct_equal); } EmpathyDispatcher * |