Ignore:
Timestamp:
2006-10-09T18:19:05Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
a21a8ac
Parents:
861c199
Message:

The module now keeps track of all resources available for a buddy. This
means the buddy won't show up offline when one resource goes down (while
there are still others available). It also remembers away state
information for every separate resource. Later this system will be used
to keep track of client capability information (Typing notices, yay...)
and who knows what else.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/presence.c

    r861c199 r6a1128d  
    2929        char *from = xt_find_attr( node, "from" );
    3030        char *type = xt_find_attr( node, "type" );      /* NULL should mean the person is online. */
    31         char *s;
     31        struct xt_node *c;
    3232       
    3333        if( !from )
    3434                return XT_HANDLED;
    3535       
    36         s = strchr( from, '/' );
    37         if( s )
    38                 *s = 0;
    39        
    40         /* Will implement better parsing of away states/msgs when we
    41            finally do those API changes. Which will probably be after
    42            merging this module into the main tree. */
    4336        if( type == NULL )
    44                 serv_got_update( gc, from, 1, 0, 0, 0, 0, 0 );
     37        {
     38                struct jabber_buddy *bud;
     39               
     40                if( !( bud = jabber_buddy_by_jid( gc, from ) ) )
     41                {
     42                        bud = jabber_buddy_add( gc, from );
     43                }
     44               
     45                g_free( bud->away_message );
     46                if( ( c = xt_find_node( node->children, "status" ) ) && c->text_len > 0 )
     47                        bud->away_message = g_strdup( c->text );
     48                else
     49                        bud->away_message = NULL;
     50               
     51                if( ( c = xt_find_node( node->children, "show" ) ) && c->text_len > 0 )
     52                        bud->away_state = (void*) jabber_away_state_by_code( c->text );
     53                else
     54                        bud->away_state = NULL;
     55               
     56                if( ( c = xt_find_node( node->children, "priority" ) ) && c->text_len > 0 )
     57                        bud->priority = atoi( c->text );
     58                else
     59                        bud->priority = 0;
     60               
     61                serv_got_update( gc, bud->handle, 1, 0, 0, 0, 0, 0 );
     62        }
    4563        else if( strcmp( type, "unavailable" ) == 0 )
    46                 serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );
     64        {
     65                char *s;
     66               
     67                jabber_buddy_remove( gc, from );
     68               
     69                if( ( s = strchr( from, '/' ) ) )
     70                        *s = 0;
     71               
     72                /* Only count this as offline if there's no other resource
     73                   available anymore. */
     74                if( jabber_buddy_by_jid( gc, from ) == NULL )
     75                        serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );
     76               
     77                *s = '/';
     78        }
    4779        else if( strcmp( type, "subscribe" ) == 0 )
     80        {
    4881                jabber_buddy_ask( gc, from );
     82        }
    4983        else if( strcmp( type, "subscribed" ) == 0 )
     84        {
    5085                serv_got_crap( gc, "%s just accepted your authorization request", from );
     86        }
    5187        else if( strcmp( type, "unsubscribe" ) == 0 || strcmp( type, "unsubscribed" ) == 0 )
    5288        {
     
    69105                xt_print( node );
    70106        }
    71        
    72         if( s )
    73                 *s = '/';
    74107       
    75108        return XT_HANDLED;
Note: See TracChangeset for help on using the changeset viewer.