Changeset a73e91a for protocols


Ignore:
Timestamp:
2008-02-16T17:38:30Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
2d88d25a, 31fc3970
Parents:
ca60550
Message:

Added callback on Jabber add-to-roster requests so buddies get added to the
internal buddy list a little bit earlier. This should deal better with
Jabber servers that send presence information of a new buddy before the
roster push.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    rca60550 ra73e91a  
    526526}
    527527
     528static xt_status jabber_add_to_roster_callback( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );
     529
    528530int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name )
    529531{
     
    541543        xt_add_attr( node, "xmlns", XMLNS_ROSTER );
    542544        node = jabber_make_packet( "iq", "set", NULL, node );
     545        jabber_cache_add( ic, node, jabber_add_to_roster_callback );
    543546       
    544547        st = jabber_write_packet( ic, node );
    545548       
    546         xt_free_node( node );
    547549        return st;
     550}
     551
     552static xt_status jabber_add_to_roster_callback( struct im_connection *ic, struct xt_node *node, struct xt_node *orig )
     553{
     554        char *s, *jid = NULL;
     555        struct xt_node *c;
     556       
     557        if( ( c = xt_find_node( orig->children, "query" ) ) &&
     558            ( c = xt_find_node( c->children, "item" ) ) &&
     559            ( jid = xt_find_attr( c, "jid" ) ) &&
     560            ( s = xt_find_attr( node, "type" ) ) &&
     561            strcmp( s, "result" ) == 0 )
     562        {
     563                if( imcb_find_buddy( ic, jid ) == NULL )
     564                        imcb_add_buddy( ic, jid, NULL );
     565        }
     566        else
     567        {
     568                imcb_log( ic, "Error while adding `%s' to your contact list.",
     569                          jid ? jid : "(unknown handle)" );
     570        }
     571       
     572        return XT_HANDLED;
    548573}
    549574
Note: See TracChangeset for help on using the changeset viewer.