[Telepathy-commits] [telepathy-glib/master] Echo example CM: don't echo messages we don't understand
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Dec 18 10:41:42 PST 2008
20080521181346-53eee-9f295564366cd5bc6337512080aba96a5e260bf3.gz
---
examples/cm/echo-message-parts/chan.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/examples/cm/echo-message-parts/chan.c b/examples/cm/echo-message-parts/chan.c
index dbb9ef5..0c7dda1 100644
--- a/examples/cm/echo-message-parts/chan.c
+++ b/examples/cm/echo-message-parts/chan.c
@@ -88,9 +88,17 @@ send_message (GObject *object,
ExampleEcho2Channel *self = EXAMPLE_ECHO_2_CHANNEL (object);
time_t timestamp = time (NULL);
guint len = tp_message_count_parts (message);
- TpMessage *received = tp_message_new (self->priv->conn, 1, len);
+ TpMessage *received = NULL;
guint i;
+ if (tp_asv_get_string (tp_message_peek (message, 0), "interface") != NULL)
+ {
+ /* this message is interface-specific - let's not echo it */
+ goto finally;
+ }
+
+ received = tp_message_new (self->priv->conn, 1, len);
+
/* Copy/modify the headers for the "received" message */
{
TpChannelTextMessageType message_type;
@@ -162,13 +170,17 @@ send_message (GObject *object,
tp_message_set (received, j, "content", value);
}
+finally:
/* "OK, we've sent the message" (after calling this, message must not be
* dereferenced) */
tp_message_mixin_sent (object, message, "", NULL);
- /* Pretend the other user sent us back the same message. After this call,
- * the received message is owned by the mixin */
- tp_message_mixin_take_received (object, received);
+ if (received != NULL)
+ {
+ /* Pretend the other user sent us back the same message. After this call,
+ * the received message is owned by the mixin */
+ tp_message_mixin_take_received (object, received);
+ }
}
--
1.5.6.5
More information about the Telepathy-commits
mailing list