[Telepathy-commits] [telepathy-mission-control/master] Set request to failed on channel abort
Alberto Mardegan
alberto.mardegan at nokia.com
Thu Nov 6 00:59:26 PST 2008
If a channel aborts while it is in REQUEST or DISPATCHING phase, make sure that
the channel status is set to FAILED.
Add some g_debug()s in critical places.
---
src/mcd-channel.c | 26 ++++++++++++++++++++++++++
src/mcd-connection.c | 1 +
src/mcd-dispatcher.c | 2 +-
3 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/src/mcd-channel.c b/src/mcd-channel.c
index 1caf81f..8ec20ed 100644
--- a/src/mcd-channel.c
+++ b/src/mcd-channel.c
@@ -676,15 +676,40 @@ _mcd_channel_dispose (GObject * object)
}
static void
+mcd_channel_abort (McdMission *mission)
+{
+ McdChannel *channel = MCD_CHANNEL (mission);
+ McdChannelPrivate *priv = channel->priv;
+
+ g_debug ("%s: %p", G_STRFUNC, mission);
+ /* If this is still a channel request, signal the failure */
+ if (priv->status == MCD_CHANNEL_REQUEST ||
+ priv->status == MCD_CHANNEL_DISPATCHING)
+ {
+ /* this code-path can only happen if the connection is aborted, as in
+ * the other cases we handle the error in McdChannel; for this reason,
+ * we use the DISCONNECTED error code */
+ GError *error = g_error_new (TP_ERRORS, TP_ERROR_DISCONNECTED,
+ "Channel aborted");
+ _mcd_channel_set_error (channel, error);
+ }
+
+ /* chain up with the parent */
+ MCD_MISSION_CLASS (mcd_channel_parent_class)->abort (mission);
+}
+
+static void
mcd_channel_class_init (McdChannelClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ McdMissionClass *mission_class = MCD_MISSION_CLASS (klass);
g_type_class_add_private (object_class, sizeof (McdChannelPrivate));
object_class->finalize = _mcd_channel_finalize;
object_class->dispose = _mcd_channel_dispose;
object_class->set_property = _mcd_channel_set_property;
object_class->get_property = _mcd_channel_get_property;
+ mission_class->abort = mcd_channel_abort;
/* signals */
mcd_channel_signals[STATUS_CHANGED] =
@@ -927,6 +952,7 @@ mcd_channel_set_object_path (McdChannel *channel, TpConnection *connection,
void
mcd_channel_set_status (McdChannel *channel, McdChannelStatus status)
{
+ g_debug ("%s: %p, %u", G_STRFUNC, channel, status);
g_return_if_fail(MCD_IS_CHANNEL(channel));
g_object_ref (channel);
g_signal_emit_by_name (channel, "status-changed", status);
diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index a0ee2c0..24504ad 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -2233,6 +2233,7 @@ create_channel_cb (TpConnection *proxy, const gchar *channel_path,
mcd_mission_abort ((McdMission *)channel);
return;
}
+ g_debug ("%s: %p, object %s", G_STRFUNC, channel, channel_path);
_mcd_channel_set_immutable_properties (channel,
_mcd_deepcopy_asv (properties));
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 6797e44..412c60d 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -588,7 +588,7 @@ on_channel_abort_list (McdChannel *channel, McdDispatcher *dispatcher)
{
McdDispatcherPrivate *priv = dispatcher->priv;
- g_debug ("Abort Channel; Removing channel from list");
+ g_debug ("Abort Channel %p; Removing channel from list", channel);
priv->channels = g_list_remove (priv->channels, channel);
g_signal_emit_by_name (dispatcher, "channel-removed", channel);
g_object_unref (channel);
--
1.5.6.5
More information about the Telepathy-commits
mailing list