Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/presence.c

    r1baaef8 r1bf1ae6  
    3131        struct xt_node *c;
    3232        struct jabber_buddy *bud;
    33         int is_chat = 0, is_away = 0;
    3433        char *s;
    3534       
     
    3736                return XT_HANDLED;
    3837       
    39         if( ( s = strchr( from, '/' ) ) )
    40         {
    41                 *s = 0;
    42                 if( jabber_chat_by_name( ic, from ) )
    43                         is_chat = 1;
    44                 *s = '/';
    45         }
    46        
    4738        if( type == NULL )
    4839        {
     40                int is_away = 0;
     41               
    4942                if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )
    5043                {
     
    7972                        bud->priority = 0;
    8073               
    81                 if( is_chat )
    82                         jabber_chat_pkt_presence( ic, bud, node );
    83                 else if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) )
     74                if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) )
    8475                        imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
    8576                                           ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
     
    8879        else if( strcmp( type, "unavailable" ) == 0 )
    8980        {
    90                 if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) ) == NULL )
     81                if( jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) == NULL )
    9182                {
    9283                        if( set_getbool( &ic->irc->set, "debug" ) )
     
    9586                }
    9687               
    97                 /* Handle this before we delete the JID. */
    98                 if( is_chat )
    99                 {
    100                         jabber_chat_pkt_presence( ic, bud, node );
    101                 }
    102                
    10388                jabber_buddy_remove( ic, from );
    10489               
    105                 if( is_chat )
    106                 {
    107                         /* Nothing else to do for now? */
    108                 }
    109                 else if( ( s = strchr( from, '/' ) ) )
     90                if( ( s = strchr( from, '/' ) ) )
    11091                {
    11192                        *s = 0;
    11293               
    113                         /* If another resource is still available, send its presence
    114                            information. */
    115                         if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) )
    116                         {
    117                                 if( bud->away_state && ( *bud->away_state->code == 0 ||
    118                                     strcmp( bud->away_state->code, "chat" ) == 0 ) )
    119                                         is_away = OPT_AWAY;
    120                                
    121                                 imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
    122                                                    ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
    123                                                    bud->away_message );
    124                         }
    125                         else
    126                         {
    127                                 /* Otherwise, count him/her as offline now. */
     94                        /* Only count this as offline if there's no other resource
     95                           available anymore. */
     96                        if( jabber_buddy_by_jid( ic, from, 0 ) == NULL )
    12897                                imcb_buddy_status( ic, from, 0, NULL, NULL );
    129                         }
    13098                       
    13199                        *s = '/';
     
    158126        else if( strcmp( type, "error" ) == 0 )
    159127        {
    160                 struct jabber_error *err;
    161                
    162                 if( ( c = xt_find_node( node->children, "error" ) ) )
    163                 {
    164                         err = jabber_error_parse( c, XMLNS_STANZA_ERROR );
    165                         imcb_error( ic, "Stanza (%s) error: %s%s%s", node->name,
    166                                     err->code, err->text ? ": " : "",
    167                                     err->text ? err->text : "" );
    168                         jabber_error_free( err );
    169                 }
    170                 /* What else to do with it? */
    171         }
    172         else
    173         {
    174                 printf( "Received PRES from %s:\n", from );
    175                 xt_print( node );
     128                /* What to do with it? */
    176129        }
    177130       
     
    187140        char *show = jd->away_state->code;
    188141        char *status = jd->away_message;
    189         struct groupchat *c;
    190142        int st;
    191143       
     
    198150       
    199151        st = jabber_write_packet( ic, node );
    200        
    201         /* Have to send this update to all groupchats too, the server won't
    202            do this automatically. */
    203         for( c = ic->groupchats; c && st; c = c->next )
    204         {
    205                 struct jabber_chat *jc = c->data;
    206                
    207                 xt_add_attr( node, "to", jc->my_full_jid );
    208                 st = jabber_write_packet( ic, node );
    209         }
    210152       
    211153        xt_free_node( node );
Note: See TracChangeset for help on using the changeset viewer.