Changeset 79bb7e4


Ignore:
Timestamp:
2012-09-16T17:40:44Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
e9caacd
Parents:
080c43a
Message:

Online status should be read properly now.

Location:
protocols/msn
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.h

    r080c43a r79bb7e4  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2010 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2012 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    253253struct msn_group *msn_group_by_id( struct im_connection *ic, const char *id );
    254254int msn_ns_set_display_name( struct im_connection *ic, const char *value );
     255const char *msn_normalize_handle( const char *handle );
    255256
    256257/* tables.c */
     
    263264int msn_sb_write( struct msn_switchboard *sb, const char *fmt, ... ) G_GNUC_PRINTF( 2, 3 );;
    264265struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session );
    265 struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle );
     266struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, const char *handle );
    266267struct msn_switchboard *msn_sb_by_chat( struct groupchat *c );
    267268struct msn_switchboard *msn_sb_spare( struct im_connection *ic );
  • protocols/msn/msn_util.c

    r080c43a r79bb7e4  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2010 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2012 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    537537        return msn_ns_write( ic, -1, "PRP %d MFN %s\r\n", ++md->trId, fn );
    538538}
     539
     540const char *msn_normalize_handle( const char *handle )
     541{
     542        if( strncmp( handle, "1:", 2 ) == 0 )
     543                return handle + 2;
     544        else
     545                return handle;
     546}
  • protocols/msn/ns.c

    r080c43a r79bb7e4  
    372372                return st;
    373373        }
    374         else if( strcmp( cmd[0], "ILN" ) == 0 )
     374        else if( strcmp( cmd[0], "ILN" ) == 0 || strcmp( cmd[0], "NLN" ) == 0 )
    375375        {
    376376                const struct msn_away_state *st;
     377                const char *handle;
     378                int cap = 0;
    377379               
    378380                if( num_parts < 6 )
     
    382384                        return( 0 );
    383385                }
    384                
    385                 http_decode( cmd[5] );
    386                 imcb_rename_buddy( ic, cmd[3], cmd[5] );
    387                
    388                 st = msn_away_state_by_code( cmd[2] );
     386                /* ILN and NLN are more or less the same, except ILN has a trId
     387                   at the start, and NLN has a capability field at the end.
     388                   Does ILN still exist BTW? */
     389                if( cmd[0][1] == 'I' )
     390                        cmd ++;
     391                else
     392                        cap = atoi( cmd[4] );
     393
     394                handle = msn_normalize_handle( cmd[2] );
     395                if( strcmp( handle, ic->acc->user ) == 0 )
     396                        return 1; /* That's me! */
     397               
     398                http_decode( cmd[3] );
     399                imcb_rename_buddy( ic, handle, cmd[3] );
     400               
     401                st = msn_away_state_by_code( cmd[1] );
    389402                if( !st )
    390403                {
     
    393406                }
    394407               
    395                 imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN |
    396                                    ( st != msn_away_state_list ? OPT_AWAY : 0 ),
    397                                    st->name, NULL );
    398         }
    399         else if( strcmp( cmd[0], "FLN" ) == 0 )
    400         {
    401                 if( cmd[1] == NULL )
    402                         return 1;
    403                
    404                 imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
    405                
    406                 msn_sb_start_keepalives( msn_sb_by_handle( ic, cmd[1] ), TRUE );
    407         }
    408         else if( strcmp( cmd[0], "NLN" ) == 0 )
    409         {
    410                 const struct msn_away_state *st;
    411                 int cap;
    412                
    413                 if( num_parts < 6 )
    414                 {
    415                         imcb_error( ic, "Syntax error" );
    416                         imc_logout( ic, TRUE );
    417                         return( 0 );
    418                 }
    419                
    420                 http_decode( cmd[4] );
    421                 cap = atoi( cmd[5] );
    422                 imcb_rename_buddy( ic, cmd[2], cmd[4] );
    423                
    424                 st = msn_away_state_by_code( cmd[1] );
    425                 if( !st )
    426                 {
    427                         /* FIXME: Warn/Bomb about unknown away state? */
    428                         st = msn_away_state_list + 1;
    429                 }
    430                
    431                 imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN |
     408                imcb_buddy_status( ic, handle, OPT_LOGGED_IN |
    432409                                   ( st != msn_away_state_list ? OPT_AWAY : 0 ) |
    433410                                   ( cap & 1 ? OPT_MOBILE : 0 ),
    434411                                   st->name, NULL );
    435412               
    436                 msn_sb_stop_keepalives( msn_sb_by_handle( ic, cmd[2] ) );
     413                msn_sb_stop_keepalives( msn_sb_by_handle( ic, handle ) );
     414        }
     415        else if( strcmp( cmd[0], "FLN" ) == 0 )
     416        {
     417                const char *handle;
     418               
     419                if( cmd[1] == NULL )
     420                        return 1;
     421               
     422                handle = msn_normalize_handle( cmd[1] );
     423                imcb_buddy_status( ic, handle, 0, NULL, NULL );
     424                msn_sb_start_keepalives( msn_sb_by_handle( ic, handle ), TRUE );
    437425        }
    438426        else if( strcmp( cmd[0], "RNG" ) == 0 )
     
    481469                else
    482470                {
    483                         sb->who = g_strdup( cmd[5] );
     471                        sb->who = g_strdup( msn_normalize_handle( cmd[5] ) );
    484472                }
    485473        }
     
    707695                        psm_text = psm->text;
    708696               
    709                 imcb_buddy_status_msg( ic, cmd[1], psm_text );
     697                imcb_buddy_status_msg( ic, msn_normalize_handle( cmd[1] ), psm_text );
    710698                xt_free_node( ubx );
    711699        }
  • protocols/msn/sb.c

    r080c43a r79bb7e4  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2010 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2012 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    122122}
    123123
    124 struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle )
     124struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, const char *handle )
    125125{
    126126        struct msn_data *md = ic->proto_data;
Note: See TracChangeset for help on using the changeset viewer.