#include <telepathy-glib/util.h>
#include "empathy-tp-chat.h"
+#include "empathy-tp-group.h"
#include "empathy-contact-factory.h"
#include "empathy-contact-monitor.h"
#include "empathy-contact-list.h"
G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CONTACT_LIST,
tp_chat_iface_init));
+static void acknowledge_messages (EmpathyTpChat *chat, GArray *ids);
+
static void
tp_chat_invalidated_cb (TpProxy *proxy,
guint domain,
const gchar *message)
{
EmpathyTpChatPriv *priv = GET_PRIV (list);
+ TpHandle handle;
+ GArray handles = {(gchar *) &handle, 1};
g_return_if_fail (EMPATHY_IS_TP_CHAT (list));
g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- if (priv->group) {
- empathy_tp_group_add_member (priv->group, contact, message);
- }
+ handle = empathy_contact_get_handle (contact);
+ tp_cli_channel_interface_group_call_add_members (priv->channel, -1,
+ &handles, NULL,
+ NULL, NULL, NULL,
+ NULL);
}
static void
const gchar *message)
{
EmpathyTpChatPriv *priv = GET_PRIV (list);
+ TpHandle handle;
+ GArray handles = {(gchar *) &handle, 1};
g_return_if_fail (EMPATHY_IS_TP_CHAT (list));
g_return_if_fail (EMPATHY_IS_CONTACT (contact));
- if (priv->group) {
- empathy_tp_group_remove_member (priv->group, contact, message);
- }
+ handle = empathy_contact_get_handle (contact);
+ tp_cli_channel_interface_group_call_remove_members (priv->channel, -1,
+ &handles, NULL,
+ NULL, NULL, NULL,
+ NULL);
}
static GList *
guint message_flags,
const gchar *message_body,
gpointer user_data,
- GObject *chat)
+ GObject *chat_)
{
+ EmpathyTpChat *chat = EMPATHY_TP_CHAT (chat_);
EmpathyTpChatPriv *priv = GET_PRIV (chat);
EmpathyMessage *message;
DEBUG ("Message received: %s", message_body);
- message = tp_chat_build_message (EMPATHY_TP_CHAT (chat),
+ if (message_flags & TP_CHANNEL_TEXT_MESSAGE_FLAG_NON_TEXT_CONTENT &&
+ !tp_strdiff (message_body, "")) {
+ GArray *ids;
+
+ DEBUG ("Empty message with NonTextContent, ignoring and acking.");
+
+ ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);
+ g_array_append_val (ids, message_id);
+ acknowledge_messages (chat, ids);
+ g_array_free (ids, TRUE);
+
+ return;
+ }
+
+ message = tp_chat_build_message (chat,
message_id,
message_type,
timestamp,
from_handle,
message_body);
- tp_chat_emit_or_queue_message (EMPATHY_TP_CHAT (chat), message);
+ tp_chat_emit_or_queue_message (chat, message);
g_object_unref (message);
}
guint message_type,
const gchar *message_body,
gpointer user_data,
- GObject *chat)
+ GObject *chat_)
{
+ EmpathyTpChat *chat = EMPATHY_TP_CHAT (chat_);
EmpathyTpChatPriv *priv = GET_PRIV (chat);
EmpathyMessage *message;
DEBUG ("Message sent: %s", message_body);
- message = tp_chat_build_message (EMPATHY_TP_CHAT (chat),
+ message = tp_chat_build_message (chat,
0,
message_type,
timestamp,
0,
message_body);
- tp_chat_emit_or_queue_message (EMPATHY_TP_CHAT (chat), message);
+ tp_chat_emit_or_queue_message (chat, message);
g_object_unref (message);
}
const GPtrArray *messages_list,
const GError *error,
gpointer user_data,
- GObject *chat)
+ GObject *chat_)
{
+ EmpathyTpChat *chat = EMPATHY_TP_CHAT (chat_);
EmpathyTpChatPriv *priv = GET_PRIV (chat);
guint i;
+ GArray *empty_non_text_content_ids = NULL;
priv->listing_pending_messages = FALSE;
DEBUG ("Message pending: %s", message_body);
- message = tp_chat_build_message (EMPATHY_TP_CHAT (chat),
+ if (message_flags & TP_CHANNEL_TEXT_MESSAGE_FLAG_NON_TEXT_CONTENT &&
+ !tp_strdiff (message_body, "")) {
+ DEBUG ("Empty message with NonTextContent, ignoring and acking.");
+
+ if (empty_non_text_content_ids == NULL) {
+ empty_non_text_content_ids = g_array_new (FALSE, FALSE, sizeof (guint));
+ }
+
+ g_array_append_val (empty_non_text_content_ids, message_id);
+ continue;
+ }
+
+ message = tp_chat_build_message (chat,
message_id,
message_type,
timestamp,
from_handle,
message_body);
- tp_chat_emit_or_queue_message (EMPATHY_TP_CHAT (chat), message);
+ tp_chat_emit_or_queue_message (chat, message);
g_object_unref (message);
}
+
+ if (empty_non_text_content_ids != NULL) {
+ acknowledge_messages (chat, empty_non_text_content_ids);
+ g_array_free (empty_non_text_content_ids, TRUE);
+ }
}
static void