summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-12-16 14:33:47 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-12-16 16:18:59 +0100
commitee4f0a3bd856d58d1e6ab52448d8e0272a821e49 (patch)
tree77269e00abdc39e33748d8411efbd79e9c580508 /examples
parentd9782472a57473de24f1a0e5de59fb2aaf6e58da (diff)
make text-handler example more exemplary
Diffstat (limited to 'examples')
-rw-r--r--examples/client/text-handler.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/examples/client/text-handler.c b/examples/client/text-handler.c
index e71eda4f..e67819d1 100644
--- a/examples/client/text-handler.c
+++ b/examples/client/text-handler.c
@@ -22,15 +22,20 @@ echo_message (TpTextChannel *channel,
gchar *text;
gchar *up;
TpMessage *reply;
+ TpChannelTextMessageFlags flags;
+ const gchar *comment = "";
- text = tp_message_to_text (message, NULL);
- if (text == NULL)
- return;
+ text = tp_message_to_text (message, &flags);
+
+ if (flags & TP_CHANNEL_TEXT_MESSAGE_FLAG_NON_TEXT_CONTENT)
+ {
+ comment = " (and some non-text content we don't understand)";
+ }
if (pending)
- g_print ("pending: %s\n", text);
+ g_print ("pending: '%s' %s\n", text, comment);
else
- g_print ("received: %s\n", text);
+ g_print ("received: '%s' %s\n", text, comment);
up = g_ascii_strup (text, -1);
g_print ("send: %s\n", up);
@@ -65,7 +70,6 @@ display_pending_messages (TpTextChannel *channel)
{
TpMessage *msg = l->data;
-
echo_message (channel, msg, TRUE);
}
@@ -100,6 +104,9 @@ handle_channels_cb (TpSimpleHandler *self,
g_signal_connect (channel, "message-received",
G_CALLBACK (message_received_cb), NULL);
+ /* The default channel factory used by the TpSimpleHandler has
+ * already prepared TP_TEXT_CHANNEL_FEATURE_PENDING_MESSAGES,
+ * if possible. */
display_pending_messages (text_chan);
}