aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-04-15 22:41:25 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-04-21 10:35:59 +0800
commit78dae7e27ab6fb535a7fe5ada450403b1d91c7bb (patch)
treec4355627d0077100c7a8b193f9e6e37f4a6146b0 /libempathy-gtk
parent755d626b3b010d2b2aaecb968c8faf579df92790 (diff)
downloadgsoc2013-empathy-78dae7e27ab6fb535a7fe5ada450403b1d91c7bb.tar
gsoc2013-empathy-78dae7e27ab6fb535a7fe5ada450403b1d91c7bb.tar.gz
gsoc2013-empathy-78dae7e27ab6fb535a7fe5ada450403b1d91c7bb.tar.bz2
gsoc2013-empathy-78dae7e27ab6fb535a7fe5ada450403b1d91c7bb.tar.lz
gsoc2013-empathy-78dae7e27ab6fb535a7fe5ada450403b1d91c7bb.tar.xz
gsoc2013-empathy-78dae7e27ab6fb535a7fe5ada450403b1d91c7bb.tar.zst
gsoc2013-empathy-78dae7e27ab6fb535a7fe5ada450403b1d91c7bb.zip
use tp_text_channel_send_message_async()
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-chat.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 986f84594..ee18be657 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -815,10 +815,35 @@ chat_command_me (EmpathyChat *chat,
GStrv strv)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
- EmpathyMessage *message;
+ TpMessage *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 = tp_client_message_new_text (TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
+ tmp);
+ g_free (tmp);
+ }
+ else {
+ message = tp_client_message_new_text (TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION,
+ strv[1]);
+ }
- 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);
}
@@ -828,9 +853,10 @@ chat_command_say (EmpathyChat *chat,
GStrv strv)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
- EmpathyMessage *message;
+ TpMessage *message;
- message = empathy_message_new (strv[1]);
+ message = tp_client_message_new_text (TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
+ strv[1]);
empathy_tp_chat_send (priv->tp_chat, message);
g_object_unref (message);
}
@@ -979,7 +1005,7 @@ chat_send (EmpathyChat *chat,
const gchar *msg)
{
EmpathyChatPriv *priv;
- EmpathyMessage *message;
+ TpMessage *message;
guint i;
if (EMP_STR_EMPTY (msg)) {
@@ -1044,7 +1070,8 @@ chat_send (EmpathyChat *chat,
}
}
- message = empathy_message_new (msg);
+ message = tp_client_message_new_text (TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
+ msg);
empathy_tp_chat_send (priv->tp_chat, message);
g_object_unref (message);
}