Changeset abbd8ed for protocols


Ignore:
Timestamp:
2006-10-28T20:54:40Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
47d3ac4
Parents:
62d0c14
Message:

Added handling of roster pushes. This means your local buddy list will
stay synchronized with other clients logged into your account at the same
time.

Location:
protocols/jabber
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    r62d0c14 rabbd8ed  
    2424#include "jabber.h"
    2525
     26static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
     27static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
     28
    2629xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
    2730{
     
    135138                if( strcmp( s, "jabber:iq:roster" ) == 0 )
    136139                {
    137                         /* This is a roster push packet, probably. Here we
    138                            should check if the packet is legitimate by
    139                            checking if it really comes from the user's JID
    140                            and, if so, process it. */
     140                        int bare_len = strlen( gc->acc->user );
     141                       
     142                        if( ( s = xt_find_attr( node, "from" ) ) == NULL ||
     143                            ( strncmp( s, gc->acc->user, bare_len ) == 0 &&
     144                              ( s[bare_len] == 0 || s[bare_len] == '/' ) ) )
     145                        {
     146                                jabber_parse_roster( gc, node, NULL );
     147                               
     148                                /* Should we generate a reply here? Don't think it's
     149                                   very important... */
     150                        }
     151                        else
     152                        {
     153                                serv_got_crap( gc, "WARNING: %s tried to fake a roster push!", s );
     154                               
     155                                xt_free_node( reply );
     156                                reply = jabber_make_error_packet( node, "not-allowed", "cancel" );
     157                                pack = 0;
     158                        }
    141159                }
    142160                else
     
    296314}
    297315
    298 static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
    299 
    300316int jabber_get_roster( struct gaim_connection *gc )
    301317{
     
    318334{
    319335        struct xt_node *query, *c;
     336        int initial = ( orig != NULL );
    320337       
    321338        query = xt_find_node( node->children, "query" );
     
    328345                char *sub = xt_find_attr( c, "subscription" );
    329346               
    330                 if( jid && sub && ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) )
    331                         add_buddy( gc, NULL, jid, name );
     347                if( !jid || !sub )
     348                {
     349                        /* Maybe warn. But how likely is this to happen in the first place? */
     350                }
     351                else if( initial )
     352                {
     353                        if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) )
     354                                add_buddy( gc, NULL, jid, name );
     355                }
     356                else
     357                {
     358                        /* This is a roster push item. Find out what changed exactly. */
     359                        if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) )
     360                        {
     361                                if( find_buddy( gc, jid ) == NULL )
     362                                        add_buddy( gc, NULL, jid, name );
     363                                else
     364                                        serv_buddy_rename( gc, jid, name );
     365                        }
     366                        else if( strcmp( sub, "remove" ) == 0 )
     367                        {
     368                                /* Don't have any API call for this yet! So let's
     369                                   just try to handle this as well as we can. */
     370                                jabber_buddy_remove_bare( gc, jid );
     371                                serv_got_update( gc, jid, 0, 0, 0, 0, 0, 0 );
     372                                /* FIXME! */
     373                        }
     374                }
    332375               
    333376                c = c->next;
    334377        }
    335378       
    336         account_online( gc );
     379        if( initial )
     380                account_online( gc );
    337381       
    338382        return XT_HANDLED;
    339383}
    340 
    341 static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );
    342384
    343385int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid )
  • protocols/jabber/jabber.c

    r62d0c14 rabbd8ed  
    230230                /* If the user likes typing notification and if we don't know
    231231                   (and didn't probe before) if this resource supports XEP85,
    232                    include a probe in this packet now. */
     232                   include a probe in this packet now. Also, if we know this
     233                   buddy does support XEP85, we have to send this <active/>
     234                   tag to tell that the user stopped typing (well, that's what
     235                   we guess when s/he pressed Enter...). */
    233236                act = xt_new_node( "active", NULL, NULL );
    234237                xt_add_attr( act, "xmlns", "http://jabber.org/protocol/chatstates" );
Note: See TracChangeset for help on using the changeset viewer.