From ee4f0a3bd856d58d1e6ab52448d8e0272a821e49 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 16 Dec 2010 14:33:47 +0100 Subject: make text-handler example more exemplary --- examples/client/text-handler.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'examples/client') diff --git a/examples/client/text-handler.c b/examples/client/text-handler.c index e71eda4f5..e67819d18 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); } -- cgit v1.2.3