aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-04-18 20:31:42 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-04-18 21:34:30 +0800
commitd12280ac153d2b16b2a6a7181ebc5fa4c9300408 (patch)
tree6034423cb499846f15db2287d0e16ccf70045399 /libempathy
parent1f28f03c2d9765928df41bd5309ac58cfca45229 (diff)
downloadgsoc2013-empathy-d12280ac153d2b16b2a6a7181ebc5fa4c9300408.tar
gsoc2013-empathy-d12280ac153d2b16b2a6a7181ebc5fa4c9300408.tar.gz
gsoc2013-empathy-d12280ac153d2b16b2a6a7181ebc5fa4c9300408.tar.bz2
gsoc2013-empathy-d12280ac153d2b16b2a6a7181ebc5fa4c9300408.tar.lz
gsoc2013-empathy-d12280ac153d2b16b2a6a7181ebc5fa4c9300408.tar.xz
gsoc2013-empathy-d12280ac153d2b16b2a6a7181ebc5fa4c9300408.tar.zst
gsoc2013-empathy-d12280ac153d2b16b2a6a7181ebc5fa4c9300408.zip
use delivery report instead of Text.SendError
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-tp-chat.c75
1 files changed, 50 insertions, 25 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 114ad47da..580112529 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -309,13 +309,61 @@ tp_chat_build_message (EmpathyTpChat *chat,
}
static void
+handle_delivery_report (EmpathyTpChat *self,
+ TpMessage *message)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (self);
+ TpDeliveryStatus delivery_status;
+ const GHashTable *header;
+ TpChannelTextSendError delivery_error;
+ gboolean valid;
+ GPtrArray *echo;
+ const gchar *message_body = NULL;
+
+ header = tp_message_peek (message, 0);
+ if (header == NULL)
+ goto out;
+
+ delivery_status = tp_asv_get_uint32 (header, "delivery-status", &valid);
+ if (!valid || delivery_status != TP_DELIVERY_STATUS_PERMANENTLY_FAILED)
+ goto out;
+
+ delivery_error = tp_asv_get_uint32 (header, "delivery-error", &valid);
+ if (!valid)
+ delivery_error = TP_CHANNEL_TEXT_SEND_ERROR_UNKNOWN;
+
+ /* TODO: ideally we should use tp-glib API giving us the echoed message as a
+ * TpMessage. (fdo #35884) */
+ echo = tp_asv_get_boxed (header, "delivery-echo",
+ TP_ARRAY_TYPE_MESSAGE_PART_LIST);
+ if (echo != NULL && echo->len >= 1) {
+ const GHashTable *echo_body;
+
+ echo_body = g_ptr_array_index (echo, 1);
+ if (echo_body != NULL)
+ message_body = tp_asv_get_string (echo_body, "content");
+ }
+
+ g_signal_emit (self, signals[SEND_ERROR], 0, message_body, delivery_error);
+
+out:
+ tp_text_channel_ack_message_async (TP_TEXT_CHANNEL (priv->channel),
+ message, NULL, NULL);
+}
+
+static void
handle_incoming_message (EmpathyTpChat *self,
- TpMessage *message,
- gboolean pending)
+ TpMessage *message,
+ gboolean pending)
{
EmpathyTpChatPriv *priv = GET_PRIV (self);
gchar *message_body;
+ if (tp_message_is_delivery_report (message)) {
+ handle_delivery_report (self, message);
+ return;
+ }
+
message_body = tp_message_to_text (message, NULL);
DEBUG ("Message %s (channel %s): %s",
@@ -361,25 +409,6 @@ message_sent_cb (TpTextChannel *channel,
g_free (message_body);
}
-static void
-tp_chat_send_error_cb (TpChannel *channel,
- guint error_code,
- guint timestamp,
- guint message_type,
- const gchar *message_body,
- gpointer user_data,
- GObject *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
- if (priv->channel == NULL)
- return;
-
- DEBUG ("Error sending '%s' (%d)", message_body, error_code);
-
- g_signal_emit (chat, signals[SEND_ERROR], 0, message_body, error_code);
-}
-
static TpChannelTextSendError
error_to_text_send_error (GError *error)
{
@@ -818,10 +847,6 @@ check_almost_ready (EmpathyTpChat *chat)
tp_g_signal_connect_object (priv->channel, "message-sent",
G_CALLBACK (message_sent_cb), chat, 0);
- tp_cli_channel_type_text_connect_to_send_error (priv->channel,
- tp_chat_send_error_cb,
- NULL, NULL,
- G_OBJECT (chat), NULL);
tp_cli_channel_interface_chat_state_connect_to_chat_state_changed (priv->channel,
tp_chat_state_changed_cb,
NULL, NULL,