[Telepathy-commits] [telepathy-glib/master] ExampleCallableMediaChannel: if the contact ID contains "(terminate)" simulate them answering, but then hanging up a moment later

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Mar 18 12:24:09 PDT 2009


---
 examples/cm/callable/media-channel.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/examples/cm/callable/media-channel.c b/examples/cm/callable/media-channel.c
index b60967e..d6d693d 100644
--- a/examples/cm/callable/media-channel.c
+++ b/examples/cm/callable/media-channel.c
@@ -917,12 +917,32 @@ stream_state_changed_cb (ExampleCallableMediaStream *stream,
 }
 
 static gboolean
+simulate_contact_ended_cb (gpointer p)
+{
+  ExampleCallableMediaChannel *self = p;
+
+  /* if the call has been cancelled while we were waiting for the
+   * contact to do so, do nothing! */
+  if (self->priv->progress == PROGRESS_ENDED)
+    return FALSE;
+
+  g_message ("SIGNALLING: receive: call terminated: <call-terminated/>");
+
+  example_callable_media_channel_close (self, self->priv->handle,
+      TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+
+  return FALSE;
+}
+
+static gboolean
 simulate_contact_answered_cb (gpointer p)
 {
   ExampleCallableMediaChannel *self = p;
   TpIntSet *peer_set;
   GHashTableIter iter;
   gpointer v;
+  TpHandleRepoIface *contact_repo;
+  const gchar *peer;
 
   /* if the call has been cancelled while we were waiting for the
    * contact to answer, do nothing */
@@ -957,6 +977,20 @@ simulate_contact_answered_cb (gpointer p)
       example_callable_media_stream_connect (v);
     }
 
+  contact_repo = tp_base_connection_get_handles
+      (self->priv->conn, TP_HANDLE_TYPE_CONTACT);
+  peer = tp_handle_inspect (contact_repo, self->priv->handle);
+
+  /* If the contact's ID contains the magic string "(terminate)", simulate
+   * them hanging up after a moment. */
+  if (strstr (peer, "(terminate)") != NULL)
+    {
+      g_timeout_add_full (G_PRIORITY_DEFAULT,
+          self->priv->simulation_delay,
+          simulate_contact_ended_cb, g_object_ref (self),
+          g_object_unref);
+    }
+
   return FALSE;
 }
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list