aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-chat.c
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy-gtk/empathy-chat.c')
-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);
}