[Telepathy-commits] [telepathy-glib/master] message-mixin test: print messages when we get MessageSent or MessageReceived

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Dec 18 10:41:25 PST 2008


20080414174953-53eee-a492128ef14335fa53085474af2e4ca1293b6534.gz
---
 tests/dbus/message-mixin.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/tests/dbus/message-mixin.c b/tests/dbus/message-mixin.c
index ebd07f9..bf1931b 100644
--- a/tests/dbus/message-mixin.c
+++ b/tests/dbus/message-mixin.c
@@ -80,6 +80,35 @@ on_received (TpChannel *chan,
   last_received_text = g_strdup (text);
 }
 
+static void
+on_message_received (TpChannel *chan,
+                     guint id,
+                     guint timestamp,
+                     guint sender,
+                     guint type,
+                     const GPtrArray *parts,
+                     gpointer data,
+                     GObject *object)
+{
+  TpHandleRepoIface *contact_repo = data;
+
+  g_message ("%p: MessageReceived #%u: time %u, sender %u '%s', type %u, "
+      "%u parts", chan, id, timestamp, sender,
+      tp_handle_inspect (contact_repo, sender), type, parts->len);
+}
+
+static void
+on_message_sent (TpChannel *chan,
+                 guint type,
+                 const GPtrArray *parts,
+                 const gchar *token,
+                 gpointer data,
+                 GObject *object)
+{
+  g_message ("%p: MessageSent with token '%s': type %u, %u parts",
+      chan, token, type, parts->len);
+}
+
 int
 main (int argc,
       char **argv)
@@ -152,6 +181,13 @@ main (int argc,
   MYASSERT (tp_cli_channel_type_text_connect_to_sent (chan, on_sent,
       NULL, NULL, NULL, NULL) != NULL, "");
 
+  MYASSERT (
+      tp_cli_channel_interface_message_parts_connect_to_message_received (chan,
+          on_message_received, g_object_ref (contact_repo), g_object_unref,
+          NULL, NULL) != NULL, "");
+  MYASSERT (tp_cli_channel_interface_message_parts_connect_to_message_sent (
+        chan, on_message_sent, NULL, NULL, NULL, NULL) != NULL, "");
+
   sent_count = 0;
   received_count = 0;
   tp_cli_channel_type_text_run_send (chan, -1,
-- 
1.5.6.5




More information about the Telepathy-commits mailing list