diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2010-10-13 12:23:21 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2010-10-13 12:23:23 +0100 |
commit | 438c3bfb03a98c1bfde12640ef4023188c657272 (patch) | |
tree | 23fdf8299e7aed3651fabcb3cc256642196dbc6b | |
parent | 48eebc053edd754a5b601e1993b497ad1912438b (diff) | |
parent | 3b3b92fb7c369a0b23276d276ae91ad92b24c20a (diff) | |
download | telepathy-logger-438c3bfb03a98c1bfde12640ef4023188c657272.tar.gz |
Merge branch 'fd.o-30824'
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r-- | telepathy-logger/channel-text.c | 101 | ||||
-rw-r--r-- | telepathy-logger/observer.c | 40 |
2 files changed, 66 insertions, 75 deletions
diff --git a/telepathy-logger/channel-text.c b/telepathy-logger/channel-text.c index ddd52eb..930d849 100644 --- a/telepathy-logger/channel-text.c +++ b/telepathy-logger/channel-text.c @@ -68,8 +68,8 @@ static void call_when_ready_wrapper (TplChannel *tpl_chan, static void got_tpl_chan_ready_cb (GObject *obj, GAsyncResult *result, gpointer user_data); -static void on_closed_cb (TpChannel *proxy, gpointer user_data, - GObject *weak_object); +static void on_channel_invalidated_cb (TpProxy *proxy, guint domain, gint code, + gchar *message, gpointer user_data); static void on_lost_message_cb (TpChannel *proxy, gpointer user_data, GObject *weak_object); static void on_received_signal_cb (TpChannel *proxy, guint arg_ID, @@ -922,75 +922,42 @@ pendingproc_connect_message_signals (TplActionChain *ctx, gpointer user_data) { TplChannelText *tpl_text = _tpl_action_chain_get_object (ctx); - GError *error = NULL; - gboolean is_error = FALSE; TpChannel *channel = TP_CHANNEL (tpl_text); + GError *error = NULL; - tp_cli_channel_type_text_connect_to_received (channel, - on_received_signal_cb, NULL, NULL, NULL, &error); - if (error != NULL) - { - PATH_DEBUG (tpl_text, "'received' signal connect: %s", error->message); - g_clear_error (&error); - is_error = TRUE; - } + tp_g_signal_connect_object (channel, "invalidated", + G_CALLBACK (on_channel_invalidated_cb), tpl_text, 0); - tp_cli_channel_type_text_connect_to_sent (channel, - on_sent_signal_cb, tpl_text, NULL, NULL, &error); - if (error != NULL) - { - PATH_DEBUG (tpl_text, "'sent' signal connect: %s", error->message); - g_clear_error (&error); - is_error = TRUE; - } + if (tp_cli_channel_type_text_connect_to_received (channel, + on_received_signal_cb, NULL, NULL, NULL, &error) == NULL) + goto disaster; - tp_cli_channel_type_text_connect_to_send_error (channel, - on_send_error_cb, tpl_text, NULL, NULL, &error); - if (error != NULL) - { - PATH_DEBUG (tpl_text, "'send error' signal connect: %s", error->message); - g_clear_error (&error); - is_error = TRUE; - } + if (tp_cli_channel_type_text_connect_to_sent (channel, + on_sent_signal_cb, tpl_text, NULL, NULL, &error) == NULL) + goto disaster; - tp_cli_channel_type_text_connect_to_lost_message (channel, - on_lost_message_cb, tpl_text, NULL, NULL, &error); - if (error != NULL) - { - PATH_DEBUG (tpl_text, "'lost message' signal connect: %s", - error->message); - g_clear_error (&error); - is_error = TRUE; - } + if (tp_cli_channel_type_text_connect_to_send_error (channel, + on_send_error_cb, tpl_text, NULL, NULL, &error) == NULL) + goto disaster; - tp_cli_channel_connect_to_closed (channel, on_closed_cb, - tpl_text, NULL, NULL, &error); - if (error != NULL) - { - PATH_DEBUG (tpl_text, "'closed' signal connect: %s", error->message); - g_clear_error (&error); - is_error = TRUE; - } + if (tp_cli_channel_type_text_connect_to_lost_message (channel, + on_lost_message_cb, tpl_text, NULL, NULL, &error) == NULL) + goto disaster; if (tp_proxy_has_interface_by_id (tpl_text, - TP_IFACE_QUARK_CHANNEL_INTERFACE_MESSAGES)) - { + TP_IFACE_QUARK_CHANNEL_INTERFACE_MESSAGES) && tp_cli_channel_interface_messages_connect_to_pending_messages_removed ( channel, on_pending_messages_removed_cb, NULL, NULL, - G_OBJECT (tpl_text), &error); - if (error != NULL) - { - PATH_DEBUG (tpl_text, "'PendingMessagesRemoved' signal connect: %s", - error->message); - g_clear_error (&error); - is_error = TRUE; - } - } + G_OBJECT (tpl_text), &error) == NULL) + goto disaster; - if (is_error) - _tpl_action_chain_terminate (ctx); - else - _tpl_action_chain_continue (ctx); + _tpl_action_chain_continue (ctx); + return; + +disaster: + DEBUG ("couldn't connect to signals: %s", error->message); + g_clear_error (&error); + _tpl_action_chain_terminate (ctx); } @@ -1029,14 +996,18 @@ on_pending_messages_removed_cb (TpChannel *proxy, static void -on_closed_cb (TpChannel *proxy, - gpointer user_data, - GObject *weak_object) +on_channel_invalidated_cb (TpProxy *proxy, + guint domain, + gint code, + gchar *message, + gpointer user_data) { - TplChannelText *tpl_text = TPL_CHANNEL_TEXT (user_data); - TplChannel *tpl_chan = TPL_CHANNEL (tpl_text); + TplChannel *tpl_chan = TPL_CHANNEL (user_data); TplObserver *observer = _tpl_observer_new (); + PATH_DEBUG (tpl_chan, "%s #%d %s", + g_quark_to_string (domain), code, message); + if (!_tpl_observer_unregister_channel (observer, tpl_chan)) PATH_DEBUG (tpl_chan, "Channel couldn't be unregistered correctly (BUG?)"); diff --git a/telepathy-logger/observer.c b/telepathy-logger/observer.c index 3916a57..43095a7 100644 --- a/telepathy-logger/observer.c +++ b/telepathy-logger/observer.c @@ -106,6 +106,8 @@ typedef struct TpObserveChannelsContext *ctx; } ObservingContext; +static gboolean observing_context_try_to_return (ObservingContext *ctx); + static TplObserver *observer_singleton = NULL; enum @@ -154,7 +156,10 @@ tpl_observer_observe_channels (TpBaseClient *client, /* Ignore channel if we are already observing it */ if (g_hash_table_lookup (self->priv->channels, path) != NULL || g_hash_table_lookup (self->priv->preparing_channels, path) != NULL) - continue; + { + observing_ctx->chan_n--; + continue; + } /* d.bus.propertyName.str/gvalue hash */ prop_map = tp_channel_borrow_immutable_properties (channel); @@ -164,8 +169,9 @@ tpl_observer_observe_channels (TpBaseClient *client, &error); if (tpl_chan == NULL) { - DEBUG ("%s", error->message); + DEBUG ("%s: %s", path, error->message); g_clear_error (&error); + observing_ctx->chan_n--; continue; } PATH_DEBUG (tpl_chan, "Starting preparation for TplChannel instance %p", @@ -179,7 +185,27 @@ tpl_observer_observe_channels (TpBaseClient *client, observing_ctx); } - tp_observe_channels_context_delay (context); + /* Arguably we shouldn't claim to have accepted the channels if an error + * occurred above? */ + if (!observing_context_try_to_return (observing_ctx)) + tp_observe_channels_context_delay (context); +} + +static gboolean +observing_context_try_to_return (ObservingContext *observing_ctx) +{ + if (observing_ctx->chan_n == 0) + { + DEBUG ("Returning from observe channels"); + tp_observe_channels_context_accept (observing_ctx->ctx); + g_object_unref (observing_ctx->ctx); + g_slice_free (ObservingContext, observing_ctx); + return TRUE; + } + else + { + return FALSE; + } } static gboolean @@ -224,13 +250,7 @@ got_tpl_channel_text_ready_cb (GObject *obj, tp_proxy_get_object_path (obj)); observing_ctx->chan_n -= 1; - if (observing_ctx->chan_n == 0) - { - DEBUG ("Returning from observe channels"); - tp_observe_channels_context_accept (observing_ctx->ctx); - g_object_unref (observing_ctx->ctx); - g_slice_free (ObservingContext, observing_ctx); - } + observing_context_try_to_return (observing_ctx); } |