Mercurial > hg
diff mcabber/mcabber/xmpp.c @ 2032:f740c4128f76
Fix receipts handling according to recent XEP updates
* add lm_get_uid() @xmpp_helper.h
* identify receipts by id attribute of 'received' subelement
instead of stanza id
author | Myhailo Danylenko <isbear@ukrpost.net> |
---|---|
date | Sun, 14 Oct 2012 17:39:11 +0200 |
parents | 107d39cd968b |
children | a37fbc3ac6aa |
line wrap: on
line diff
--- a/mcabber/mcabber/xmpp.c Sat Oct 13 19:53:12 2012 +0200 +++ b/mcabber/mcabber/xmpp.c Sun Oct 14 17:39:11 2012 +0200 @@ -295,15 +295,6 @@ g_slist_free(resources); } -static LmHandlerResult cb_xep184(LmMessageHandler *h, LmConnection *c, - LmMessage *m, gpointer user_data) -{ - char *from = jidtodisp(lm_message_get_from(m)); - scr_remove_receipt_flag(from, h); - g_free(from); - return LM_HANDLER_RESULT_REMOVE_MESSAGE; -} - // xmpp_send_msg(jid, text, type, subject, // otrinject, *encrypted, type_overwrite) // When encrypted is not NULL, the function set *encrypted to 1 if the @@ -429,10 +420,11 @@ if (sl_buddy && xep184 && caps_has_feature(buddy_resource_getcaps(sl_buddy->data, rname), NS_RECEIPTS, barejid)) { - lm_message_node_set_attribute - (lm_message_node_add_child(x->node, "request", NULL), - "xmlns", NS_RECEIPTS); - *xep184 = lm_message_handler_new(cb_xep184, NULL, NULL); + lm_message_node_set_attribute(lm_message_node_add_child(x->node, "request", + NULL), + "xmlns", NS_RECEIPTS); + *xep184 = lm_get_uid (); + lm_message_node_set_attribute (x->node, "id", (const gchar *)*xep184); } g_free(barejid); @@ -499,11 +491,7 @@ if (mystatus != invisible) #endif update_last_use(); - if (xep184 && *xep184) { - lm_connection_send_with_reply(lconnection, x, *xep184, NULL); - lm_message_handler_unref(*xep184); - } else - lm_connection_send(lconnection, x, NULL); + lm_connection_send(lconnection, x, NULL); lm_message_unref(x); } @@ -1305,6 +1293,16 @@ lm_message_unref(rcvd); } + { // xep184 receipt confirmation + LmMessageNode *received = lm_message_node_get_child(m->node, "received"); + if (received && !g_strcmp0(lm_message_node_get_attribute(received, "xmlns"), NS_RECEIPTS)) { + char *jid = jidtodisp(from); + const char *id = lm_message_node_get_attribute(received, "id"); + scr_remove_receipt_flag(jid, id); + g_free(jid); + } + } + if (from) { x = lm_message_node_find_xmlns(m->node, NS_MUC_USER); if (x && !strcmp(x->name, "x"))