aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-04-05 22:37:37 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-04-06 17:49:48 +0800
commitbd751c69ef2e0a9928b4853a8657e1cea376531e (patch)
tree927b69898ab9e7bd2275ea6a4810f122f3cd91d0
parentae37cca09e8af88c08d2ed16400c1860fd173f7c (diff)
downloadgsoc2013-empathy-bd751c69ef2e0a9928b4853a8657e1cea376531e.tar
gsoc2013-empathy-bd751c69ef2e0a9928b4853a8657e1cea376531e.tar.gz
gsoc2013-empathy-bd751c69ef2e0a9928b4853a8657e1cea376531e.tar.bz2
gsoc2013-empathy-bd751c69ef2e0a9928b4853a8657e1cea376531e.tar.lz
gsoc2013-empathy-bd751c69ef2e0a9928b4853a8657e1cea376531e.tar.xz
gsoc2013-empathy-bd751c69ef2e0a9928b4853a8657e1cea376531e.tar.zst
gsoc2013-empathy-bd751c69ef2e0a9928b4853a8657e1cea376531e.zip
emulate '/me' command if CM doesn't support Action messages (#622118)
-rw-r--r--libempathy-gtk/empathy-chat.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index dae0239c2..b7c5192a8 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -869,9 +869,33 @@ chat_command_me (EmpathyChat *chat,
{
EmpathyChatPriv *priv = GET_PRIV (chat);
EmpathyMessage *message;
+ TpChannel *channel;
+
+ channel = empathy_tp_chat_get_channel (priv->tp_chat);
+
+ /* Strictly speaking we don't depend yet on Messages so best to check that
+ * the channel is actually a TpTextChannel before casting it. */
+ if (TP_IS_TEXT_CHANNEL (channel) &&
+ !tp_text_channel_supports_message_type (TP_TEXT_CHANNEL (channel),
+ TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION)) {
+ /* Action message are not supported, 'simulate' the action */
+ EmpathyContact *self_contact;
+ gchar *tmp;
+
+ self_contact = empathy_tp_chat_get_self_contact (priv->tp_chat);
+ /* The TpChat can't be ready if it doesn't have the self contact */
+ g_assert (self_contact != NULL);
+
+ tmp = g_strdup_printf ("%s %s", empathy_contact_get_alias (self_contact),
+ strv[1]);
+ message = empathy_message_new (tmp);
+ g_free (tmp);
+ }
+ else {
+ message = empathy_message_new (strv[1]);
+ empathy_message_set_tptype (message, TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION);
+ }
- message = empathy_message_new (strv[1]);
- empathy_message_set_tptype (message, TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION);
empathy_tp_chat_send (priv->tp_chat, message);
g_object_unref (message);
}