Ignore:
Timestamp:
2006-11-12T23:06:08Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
16b5f86
Parents:
47d3ac4
Message:

Improved handling of JIDs: Bare JIDs are allowed (*sigh*) and case
insensitivity. Probably not complete yet...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/presence.c

    r47d3ac4 r0d3f30f  
    3838        if( type == NULL )
    3939        {
    40                 if( ( s = strchr( from, '/' ) ) == NULL )
     40                if( !( bud = jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )
    4141                {
    42                         char *s = xt_to_string( node );
    43                         serv_got_crap( gc, "WARNING: Ignoring presence tag with bare JID: %s", s );
    44                         g_free( s );
     42                        serv_got_crap( gc, "WARNING: Could not handle presence information from JID: %s", from );
    4543                        return XT_HANDLED;
    46                 }
    47                
    48                 if( !( bud = jabber_buddy_by_jid( gc, from ) ) )
    49                 {
    50                         /* FOR NOW, s still contains the location of the /.
    51                            Keep this in mind when changing things here. :-) */
    52                        
    53                         /* We check if the buddy is in the contact list,
    54                            because Jabber servers seem to like to send
    55                            presence information of buddies we removed
    56                            from our list sometimes, for example... */
    57                        
    58                         *s = 0;
    59                         if( find_buddy( gc, from ) == NULL )
    60                         {
    61                                 *s = '/';
    62                                 serv_got_crap( gc, "WARNING: Ignoring presence information from unknown JID: %s", from );
    63                                 return XT_HANDLED;
    64                         }
    65                         *s = '/';
    66                        
    67                         bud = jabber_buddy_add( gc, from );
    6844                }
    6945               
     
    8965                        bud->priority = 0;
    9066               
    91                 serv_got_update( gc, bud->handle, 1, 0, 0, 0,
     67                serv_got_update( gc, bud->bare_jid, 1, 0, 0, 0,
    9268                                 bud->away_state ? UC_UNAVAILABLE : 0, 0 );
    9369        }
    9470        else if( strcmp( type, "unavailable" ) == 0 )
    9571        {
    96                 char *s;
    97                
    98                 if( ( s = strchr( from, '/' ) ) == NULL )
    99                 {
    100                         char *s = xt_to_string( node );
    101                         serv_got_crap( gc, "WARNING: Ignoring presence tag with bare JID: %s\n", s );
    102                         g_free( s );
    103                         return XT_HANDLED;
    104                 }
    105                
    106                 if( jabber_buddy_by_jid( gc, from ) == NULL )
     72                if( jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT ) == NULL )
    10773                {
    10874                        serv_got_crap( gc, "WARNING: Received presence information from unknown JID: %s", from );
     
    11177               
    11278                jabber_buddy_remove( gc, from );
    113                 *s = 0;
    11479               
    115                 /* Only count this as offline if there's no other resource
    116                    available anymore. */
    117                 if( jabber_buddy_by_jid( gc, from ) == NULL )
     80                if( ( s = strchr( from, '/' ) ) )
     81                {
     82                        *s = 0;
     83               
     84                        /* Only count this as offline if there's no other resource
     85                           available anymore. */
     86                        if( jabber_buddy_by_jid( gc, from, 0 ) == NULL )
     87                                serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );
     88                       
     89                        *s = '/';
     90                }
     91                else
     92                {
    11893                        serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );
    119                
    120                 *s = '/';
     94                }
    12195        }
    12296        else if( strcmp( type, "subscribe" ) == 0 )
     
    126100        else if( strcmp( type, "subscribed" ) == 0 )
    127101        {
     102                /* Not sure about this one, actually... */
    128103                serv_got_crap( gc, "%s just accepted your authorization request", from );
    129104        }
Note: See TracChangeset for help on using the changeset viewer.