[next] telepathy-glib: base-call-channel: include the expected and current state in Accept error message

Simon McVittie smcv at kemper.freedesktop.org
Mon Oct 8 08:23:16 PDT 2012


Module: telepathy-glib
Branch: next
Commit: 6d3c8df3cd918cf76abae7d5c43f84bfca6ed59d
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=6d3c8df3cd918cf76abae7d5c43f84bfca6ed59d

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Thu Sep 20 13:44:01 2012 +0200

base-call-channel: include the expected and current state in Accept error message

I'm debugging an Empathy call issue and this kind of info can be useful.

---

 telepathy-glib/base-call-channel.c |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/telepathy-glib/base-call-channel.c b/telepathy-glib/base-call-channel.c
index 067c22f..af82ba1 100644
--- a/telepathy-glib/base-call-channel.c
+++ b/telepathy-glib/base-call-channel.c
@@ -1341,6 +1341,22 @@ tp_base_call_channel_set_queued (TpSvcChannelTypeCall *iface,
 }
 
 static void
+raise_accept_state_error (TpBaseCallChannel *self,
+    TpCallState expected,
+    DBusGMethodInvocation *context)
+{
+  GError *e = NULL;
+
+  e = g_error_new (TP_ERROR, TP_ERROR_NOT_AVAILABLE,
+      "Invalid state for Accept (expected: %s, current: %s)",
+      call_state_to_string (expected),
+      call_state_to_string (self->priv->state));
+
+  dbus_g_method_return_error (context, e);
+  g_error_free (e);
+}
+
+static void
 tp_base_call_channel_accept (TpSvcChannelTypeCall *iface,
     DBusGMethodInvocation *context)
 {
@@ -1364,9 +1380,8 @@ tp_base_call_channel_accept (TpSvcChannelTypeCall *iface,
         }
       else
         {
-          GError e = { TP_ERROR, TP_ERROR_NOT_AVAILABLE,
-              "Invalid state for Accept" };
-          dbus_g_method_return_error (context, &e);
+          raise_accept_state_error (self, TP_CALL_STATE_PENDING_INITIATOR,
+              context);
           return;
         }
     }
@@ -1382,9 +1397,8 @@ tp_base_call_channel_accept (TpSvcChannelTypeCall *iface,
         }
       else
         {
-          GError e = { TP_ERROR, TP_ERROR_NOT_AVAILABLE,
-              "Invalid state for Accept" };
-          dbus_g_method_return_error (context, &e);
+          raise_accept_state_error (self, TP_CALL_STATE_INITIALISED,
+              context);
           return;
         }
       self->priv->accepted = TRUE;



More information about the telepathy-commits mailing list