Ignore:
Timestamp:
2006-10-15T20:24:01Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d74c644
Parents:
e617b35
Message:

Proper cleanup of jabber buddy structures when removing a buddy from the
list, proper checking (and handling) of events related to buddies that
aren't "hashed" yet, limit checks on priorityto setting, renamed JEP85
to XEP85, support for more XEP85 states.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber_util.c

    re617b35 r788a1af  
    2929{
    3030        account_t *acc = set->data;
    31         char *ret;
    32        
    33         ret = set_eval_int( set, value );
     31        int i;
     32       
     33        if( sscanf( value, "%d", &i ) == 1 )
     34        {
     35                /* Priority is a signed 8-bit integer, according to RFC 3921. */
     36                if( i < -128 || i > 127 )
     37                        return NULL;
     38        }
     39        else
     40                return NULL;
    3441       
    3542        /* Only run this stuff if the account is online ATM,
    3643           and if the setting seems to be acceptable. */
    37         if( acc->gc && ret )
     44        if( acc->gc )
    3845        {
    3946                /* Although set_eval functions usually are very nice and
     
    4754               
    4855                g_free( set->value );
    49                 set->value = g_strdup( ret );
     56                set->value = g_strdup( value );
    5057               
    5158                /* (Yes, sorry, I prefer the hack. :-P) */
     
    5461        }
    5562       
    56         return ret;
     63        return value;
    5764}
    5865
     
    283290}
    284291
     292/* Finds a buddy from our structures. Can find both full- and bare JIDs. When
     293   asked for a bare JID, it uses the "resource_select" setting to see which
     294   resource to pick. */
    285295struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid )
    286296{
     
    323333}
    324334
     335/* Remove one specific full JID from our list. Use this when a buddy goes
     336   off-line (because (s)he can still be online from a different location. */
    325337int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid )
    326338{
     
    381393        }
    382394}
     395
     396/* Remove a buddy completely; removes all resources that belong to the
     397   specified bare JID. Use this when removing someone from the contact
     398   list, for example. */
     399int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid )
     400{
     401        struct jabber_data *jd = gc->proto_data;
     402        struct jabber_buddy *bud, *next;
     403       
     404        if( strchr( bare_jid, '/' ) )
     405                return 0;
     406       
     407        if( ( bud = g_hash_table_lookup( jd->buddies, bare_jid ) ) )
     408        {
     409                /* Most important: Remove the hash reference. We don't know
     410                   this buddy anymore. */
     411                g_hash_table_remove( jd->buddies, bud->handle );
     412               
     413                /* Deallocate the linked list of resources. */
     414                while( bud )
     415                {
     416                        next = bud->next;
     417                        g_free( bud->full_jid );
     418                        g_free( bud->away_message );
     419                        g_free( bud );
     420                        bud = next;
     421                }
     422               
     423                return 1;
     424        }
     425        else
     426        {
     427                return 0;
     428        }
     429}
Note: See TracChangeset for help on using the changeset viewer.