Ignore:
Timestamp:
2006-10-20T19:12:14Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
3b3cd693
Parents:
f920d9e
Message:

Now all IQ packets get an ID and cached packets get a "special" ID. This
makes it easier to find out if an event handler has to be called for a
reply packet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber_util.c

    rf920d9e rdfa41a4  
    2424#include "jabber.h"
    2525
    26 static int next_id = 1;
     26static unsigned int next_id = 1;
    2727
    2828char *set_eval_priority( set_t *set, char *value )
     
    8383                xt_add_attr( node, "to", to );
    8484       
     85        /* IQ packets should always have an ID, so let's generate one. It
     86           might get overwritten by jabber_cache_add() if this packet has
     87           to be saved until we receive a response. Cached packets get
     88           slightly different IDs so we can recognize them. */
     89        if( strcmp( name, "iq" ) == 0 )
     90        {
     91                char *id = g_strdup_printf( "%s%05x", JABBER_PACKET_ID, ( next_id++ ) & 0xfffff );
     92                xt_add_attr( node, "id", id );
     93                g_free( id );
     94        }
     95       
    8596        return node;
    8697}
     
    116127}
    117128
    118 /* Cache a node/epacket for later use. Mainly useful for IQ packets if you need
     129/* Cache a node/packet for later use. Mainly useful for IQ packets if you need
    119130   them when you receive the response. Use this BEFORE sending the packet so
    120    it'll get an id= tag, and do NOT free() the packet after writing it! */
     131   it'll get a new id= tag, and do NOT free() the packet after writing it! */
    121132void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func )
    122133{
    123134        struct jabber_data *jd = gc->proto_data;
    124         char *id = g_strdup_printf( "BeeX%04x", next_id++ );
     135        char *id = g_strdup_printf( "%s%05x", JABBER_CACHED_ID, ( next_id++ ) & 0xfffff );
    125136        struct jabber_cache_entry *entry = g_new0( struct jabber_cache_entry, 1 );
    126137       
Note: See TracChangeset for help on using the changeset viewer.