diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-07-05 13:59:48 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-07-05 13:59:48 +0200 |
commit | cd3d4fce75d731ac98037dc3c87b566ffd1998e0 (patch) | |
tree | b171885b0ca777c3679e7fde9f7511449cb1bce9 | |
parent | b1aeef1cc67f64ac5cfb8d961945ff401abaebf9 (diff) | |
download | telepathy-logger-cd3d4fce75d731ac98037dc3c87b566ffd1998e0.tar.gz |
Store TplChannel we are preparing into a hash table
-rw-r--r-- | telepathy-logger/observer.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/telepathy-logger/observer.c b/telepathy-logger/observer.c index 3cff7ac..2833a3e 100644 --- a/telepathy-logger/observer.c +++ b/telepathy-logger/observer.c @@ -92,6 +92,9 @@ struct _TplObserverPriv /* Registered channels * channel path borrowed from the TplChannel => reffed TplChannel */ GHashTable *channels; + /* Channels that we'll register once they are registered + * channel path borrowed from the TplChannel => reffed TplChannel */ + GHashTable *preparing_channels; TplLogManager *logmanager; gboolean dbus_registered; TplChannelFactory channel_factory; @@ -187,6 +190,11 @@ tpl_observer_observe_channels (TpBaseClient *client, } PATH_DEBUG (tpl_chan, "Starting preparation for TplChannel instance %p", tpl_chan); + + /* Pass the reference on the TplChannel to the hash table */ + g_hash_table_insert (self->priv->preparing_channels, + (gchar *) tp_proxy_get_object_path (tpl_chan), tpl_chan); + _tpl_channel_call_when_ready (tpl_chan, got_tpl_channel_text_ready_cb, observing_ctx); } @@ -245,8 +253,8 @@ got_tpl_channel_text_ready_cb (GObject *obj, PATH_DEBUG (obj, "failed to prepare"); } - /* drop our ref */ - g_object_unref (obj); + g_hash_table_remove (observing_ctx->self->priv->preparing_channels, + tp_proxy_get_object_path (obj)); observing_ctx->chan_n -= 1; if (observing_ctx->chan_n == 0) @@ -359,6 +367,10 @@ _tpl_observer_init (TplObserver *self) priv->channels = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); + + priv->preparing_channels = g_hash_table_new_full (g_str_hash, g_str_equal, + NULL, g_object_unref); + priv->logmanager = tpl_log_manager_dup_singleton (); /* Observe contact text channels */ @@ -389,6 +401,7 @@ tpl_observer_dispose (GObject *obj) TplObserverPriv *priv = TPL_OBSERVER (obj)->priv; tp_clear_pointer (&priv->channels, g_hash_table_unref); + tp_clear_pointer (&priv->preparing_channels, g_hash_table_unref); if (priv->logmanager != NULL) { |