Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/ns.c

    rbb839e8 r7815a2b  
    3535
    3636static void msn_auth_got_passport_token( struct msn_auth_data *mad );
     37static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name );
    3738
    3839gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond )
     
    231232                else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 )
    232233                {
    233                         set_t *s;
    234                        
    235234                        if( num_parts == 7 )
    236                         {
    237                                 http_decode( cmd[4] );
    238                                
    239                                 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) );
    240                                 ic->displayname[sizeof(ic->displayname)-1] = 0;
    241                                
    242                                 if( ( s = set_find( &ic->acc->set, "display_name" ) ) )
    243                                 {
    244                                         g_free( s->value );
    245                                         s->value = g_strdup( cmd[4] );
    246                                 }
    247                         }
     235                                msn_ns_got_display_name( ic, cmd[4] );
    248236                        else
    249                         {
    250237                                imcb_log( ic, "Warning: Friendly name in server response was corrupted" );
    251                         }
    252238                       
    253239                        imcb_log( ic, "Authenticated, getting buddy list" );
     
    436422        else if( strcmp( cmd[0], "FLN" ) == 0 )
    437423        {
    438                 if( cmd[1] == NULL )
    439                         return 1;
    440                
    441                 imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
    442                
    443                 msn_sb_start_keepalives( msn_sb_by_handle( ic, cmd[1] ), TRUE );
     424                if( cmd[1] )
     425                        imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
    444426        }
    445427        else if( strcmp( cmd[0], "NLN" ) == 0 )
     
    467449                                   ( st != msn_away_state_list ? OPT_AWAY : 0 ),
    468450                                   st->name, NULL );
    469                
    470                 msn_sb_stop_keepalives( msn_sb_by_handle( ic, cmd[2] ) );
    471451        }
    472452        else if( strcmp( cmd[0], "RNG" ) == 0 )
     
    573553                return( 0 );
    574554        }
     555#if 0
     556        /* Discard this one completely for now since I don't care about the ack
     557           and since MSN servers can apparently screw up the formatting. */
    575558        else if( strcmp( cmd[0], "REA" ) == 0 )
    576559        {
     
    603586                }
    604587        }
     588#endif
    605589        else if( strcmp( cmd[0], "IPG" ) == 0 )
    606590        {
     
    752736        }
    753737}
     738
     739static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name )
     740{
     741        set_t *s;
     742       
     743        if( ( s = set_find( &ic->acc->set, "display_name" ) ) == NULL )
     744                return FALSE; /* Shouldn't happen.. */
     745       
     746        http_decode( name );
     747       
     748        if( s->value && strcmp( s->value, name ) == 0 )
     749        {
     750                return TRUE;
     751                /* The names match, nothing to worry about. */
     752        }
     753        else if( s->value != NULL &&
     754                 ( strcmp( name, ic->acc->user ) == 0 ||
     755                   set_getbool( &ic->acc->set, "local_display_name" ) ) )
     756        {
     757                /* The server thinks our display name is our e-mail address
     758                   which is probably wrong, or the user *wants* us to do this:
     759                   Always use the locally set display_name. */
     760                return msn_set_display_name( ic, s->value );
     761        }
     762        else
     763        {
     764                if( s->value && *s->value )
     765                        imcb_log( ic, "BitlBee thinks your display name is `%s' but "
     766                                      "the MSN server says it's `%s'. Using the MSN "
     767                                      "server's name. Set local_display_name to true "
     768                                      "to use the local name.", s->value, name );
     769               
     770                if( g_utf8_validate( name, -1, NULL ) )
     771                {
     772                        g_free( s->value );
     773                        s->value = g_strdup( name );
     774                }
     775                else
     776                {
     777                        imcb_log( ic, "Warning: Friendly name in server response was corrupted" );
     778                }
     779               
     780                return TRUE;
     781        }
     782}
Note: See TracChangeset for help on using the changeset viewer.