Changeset 1444be5


Ignore:
Timestamp:
2012-10-17T07:23:00Z (11 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.

Location:
protocols/jabber
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    r13df515 r1444be5  
    128128                                                   XMLNS_MUC,
    129129                                                   XMLNS_PING,
     130                                                   XMLNS_RECEIPTS,
    130131                                                   XMLNS_SI,
    131132                                                   XMLNS_BYTESTREAMS,
  • protocols/jabber/jabber.h

    r13df515 r1444be5  
    227227#define XMLNS_TIME         "urn:xmpp:time"                                       /* XEP-0202 */
    228228#define XMLNS_PING         "urn:xmpp:ping"                                       /* XEP-0199 */
     229#define XMLNS_RECEIPTS     "urn:xmpp:receipts"                                   /* XEP-0184 */
    229230#define XMLNS_VCARD        "vcard-temp"                                          /* XEP-0054 */
    230231#define XMLNS_DELAY        "jabber:x:delay"                                      /* XEP-0091 */
  • 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.