Changeset e7f8838


Ignore:
Timestamp:
2008-01-11T13:17:11Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
e64de00
Parents:
e731120
Message:

Fixing bug #344, now away states should always be correct, even when people
do complicated things with multiple resources. (There were two bugs and
some duplicated code, so I moved things around a bit.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/presence.c

    re731120 re7f8838  
    3030        char *type = xt_find_attr( node, "type" );      /* NULL should mean the person is online. */
    3131        struct xt_node *c;
    32         struct jabber_buddy *bud;
    33         int is_chat = 0, is_away = 0;
     32        struct jabber_buddy *bud, *send_presence = NULL;
     33        int is_chat = 0;
    3434        char *s;
    3535       
     
    6363                {
    6464                        bud->away_state = (void*) jabber_away_state_by_code( c->text );
    65                         if( strcmp( c->text, "chat" ) != 0 )
    66                                 is_away = OPT_AWAY;
    6765                }
    6866                else
     
    8179                if( is_chat )
    8280                        jabber_chat_pkt_presence( ic, bud, node );
    83                 else if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) )
    84                         imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
    85                                            ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
    86                                            bud->away_message );
     81                else
     82                        send_presence = jabber_buddy_by_jid( ic, bud->bare_jid, 0 );
    8783        }
    8884        else if( strcmp( type, "unavailable" ) == 0 )
     
    119115                        /* If another resource is still available, send its presence
    120116                           information. */
    121                         if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) )
    122                         {
    123                                 if( bud->away_state && ( *bud->away_state->code == 0 ||
    124                                     strcmp( bud->away_state->code, "chat" ) == 0 ) )
    125                                         is_away = OPT_AWAY;
    126                                
    127                                 imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
    128                                                    ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
    129                                                    bud->away_message );
    130                         }
    131                         else
     117                        if( ( send_presence = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL )
    132118                        {
    133119                                /* Otherwise, count him/her as offline now. */
     
    176162                        jabber_error_free( err );
    177163                } */
     164        }
     165
     166        if( send_presence )
     167        {
     168                int is_away;
     169
     170                if( send_presence->away_state && !( *send_presence->away_state->code == 0 ||
     171                    strcmp( send_presence->away_state->code, "chat" ) == 0 ) )
     172                        is_away = OPT_AWAY;
     173
     174                imcb_buddy_status( ic, send_presence->bare_jid, OPT_LOGGED_IN | is_away,
     175                                   ( is_away && send_presence->away_state ) ?
     176                                   send_presence->away_state->full_name : NULL,
     177                                   send_presence->away_message );
    178178        }
    179179       
Note: See TracChangeset for help on using the changeset viewer.