aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2009-02-04 06:21:03 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-02-04 06:21:03 +0800
commit81eded4872ccf758f1294bc4205bba884d7e00c2 (patch)
tree7050a4fd10c2cb9e6a231cde0c892d6ac028e92a
parentabca76cfb55b62c918f6c82bdd43ed97fa64d2c4 (diff)
downloadgsoc2013-empathy-81eded4872ccf758f1294bc4205bba884d7e00c2.tar
gsoc2013-empathy-81eded4872ccf758f1294bc4205bba884d7e00c2.tar.gz
gsoc2013-empathy-81eded4872ccf758f1294bc4205bba884d7e00c2.tar.bz2
gsoc2013-empathy-81eded4872ccf758f1294bc4205bba884d7e00c2.tar.lz
gsoc2013-empathy-81eded4872ccf758f1294bc4205bba884d7e00c2.tar.xz
gsoc2013-empathy-81eded4872ccf758f1294bc4205bba884d7e00c2.tar.zst
gsoc2013-empathy-81eded4872ccf758f1294bc4205bba884d7e00c2.zip
Ignore and acknowledge empty NonTextContent messages.
Delivery reports on the Messages interface show up as empty messages with the NonTextContent flag set in a Text.Received signal and in ListPendingMessages. Empathy can't do anything useful with them, so ack them and ignore them. Signed-off-by: Will Thompson <will.thompson@collabora.co.uk> svn path=/trunk/; revision=2422
-rw-r--r--libempathy/empathy-tp-chat.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index d552db8da..7915ff20b 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -92,6 +92,8 @@ G_DEFINE_TYPE_WITH_CODE (EmpathyTpChat, empathy_tp_chat, G_TYPE_OBJECT,
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,
@@ -432,6 +434,20 @@ tp_chat_received_cb (TpChannel *channel,
DEBUG ("Message received: %s", message_body);
+ 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 (EMPATHY_TP_CHAT (chat), ids);
+ g_array_free (ids, TRUE);
+
+ return;
+ }
+
message = tp_chat_build_message (EMPATHY_TP_CHAT (chat),
message_id,
message_type,
@@ -546,6 +562,7 @@ tp_chat_list_pending_messages_cb (TpChannel *channel,
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
guint i;
+ GArray *empty_non_text_content_ids = NULL;
priv->listing_pending_messages = FALSE;
@@ -578,6 +595,18 @@ tp_chat_list_pending_messages_cb (TpChannel *channel,
DEBUG ("Message pending: %s", message_body);
+ 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 (EMPATHY_TP_CHAT (chat),
message_id,
message_type,
@@ -588,6 +617,11 @@ tp_chat_list_pending_messages_cb (TpChannel *channel,
tp_chat_emit_or_queue_message (EMPATHY_TP_CHAT (chat), message);
g_object_unref (message);
}
+
+ if (empty_non_text_content_ids != NULL) {
+ acknowledge_messages (EMPATHY_TP_CHAT (chat), empty_non_text_content_ids);
+ g_array_free (empty_non_text_content_ids, TRUE);
+ }
}
static void