Ignore:
Timestamp:
2012-10-17T07:23:00Z (12 years ago)
Author:
Michael Stapelberg <michael@…>
Branches:
master
Children:
91ae87d
Parents:
13df515
Message:

Implement jabber message receipts (XEP-0184)

This change will make BitlBee acknowledge messages when requested.
It will not request message receipts from other clients, mainly because I am
not sure if this feature can be mapped to IRC cleanly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/message.c

    r13df515 r1444be5  
    2424#include "jabber.h"
    2525
     26static unsigned int next_receipt_id = 1;
     27
    2628xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
    2729{
    2830        struct im_connection *ic = data;
     31        struct jabber_data *jd = ic->proto_data;
    2932        char *from = xt_find_attr( node, "from" );
    3033        char *type = xt_find_attr( node, "type" );
     34        char *id = xt_find_attr( node, "id" );
    3135        struct xt_node *body = xt_find_node( node->children, "body" ), *c;
     36        struct xt_node *request = xt_find_node( node->children, "request" );
     37        struct xt_node *received, *receipt;
    3238        struct jabber_buddy *bud = NULL;
    3339        char *s, *room = NULL, *reason = NULL;
     
    3541        if( !from )
    3642                return XT_HANDLED; /* Consider this packet corrupted. */
     43
     44        if( request && id )
     45        {
     46                /* Send a message receipt (XEP-0184), looking like this:
     47                 * <message
     48                 *  from='kingrichard@royalty.england.lit/throne'
     49                 *  id='bi29sg183b4v'
     50                 *  to='northumberland@shakespeare.lit/westminster'>
     51                 *  <received xmlns='urn:xmpp:receipts' id='richard2-4.1.247'/>
     52                 * </message> */
     53                received = xt_new_node( "received", NULL, NULL );
     54                xt_add_attr( received, "xmlns", XMLNS_RECEIPTS );
     55                xt_add_attr( received, "id", id );
     56                receipt = jabber_make_packet( "message", NULL, from, received );
     57                xt_add_attr( receipt, "from", jd->me );
     58
     59                char *id = g_strdup_printf( "%sRCPT%05x", JABBER_PACKET_ID, ( next_receipt_id++ ) & 0xfffff );
     60                xt_add_attr( receipt, "id", id );
     61                g_free( id );
     62
     63                jabber_write_packet( ic, receipt );
     64                xt_free_node( receipt );
     65        }
    3766       
    3867        bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT );
Note: See TracChangeset for help on using the changeset viewer.