Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    ra830512 re3413cc  
    2727#include "msn.h"
    2828
    29 static char *msn_set_display_name( set_t *set, char *value );
     29int msn_chat_id;
     30GSList *msn_connections;
     31GSList *msn_switchboards;
     32
     33static char *set_eval_display_name( set_t *set, char *value );
    3034
    3135static void msn_init( account_t *acc )
    3236{
    33         set_t *s;
    34        
    35         s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc );
    36         s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
    37 
    38         s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
     37        set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc );
     38        set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc );
     39        set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
    3940}
    4041
     
    139140       
    140141        if( l == NULL )
    141                 for( i = 0; msn_away_state_list[i].number > -1; i ++ )
    142                         l = g_list_append( l, (void*) msn_away_state_list[i].name );
     142                for( i = 0; *msn_away_state_list[i].code; i ++ )
     143                        if( *msn_away_state_list[i].name )
     144                                l = g_list_append( l, (void*) msn_away_state_list[i].name );
    143145       
    144146        return l;
     
    149151        char buf[1024];
    150152        struct msn_data *md = ic->proto_data;
    151         const struct msn_away_state *st;
    152        
    153         if( strcmp( state, GAIM_AWAY_CUSTOM ) == 0 )
    154                 st = msn_away_state_by_name( "Away" );
     153       
     154        if( state )
     155                md->away_state = msn_away_state_by_name( state ) ? :
     156                                 msn_away_state_list + 1;
    155157        else
    156                 st = msn_away_state_by_name( state );
    157        
    158         if( !st ) st = msn_away_state_list;
    159         md->away_state = st;
    160        
    161         g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code );
     158                md->away_state = msn_away_state_list;
     159       
     160        g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, md->away_state->code );
    162161        msn_write( ic, buf, strlen( buf ) );
    163162}
     
    165164static void msn_set_my_name( struct im_connection *ic, char *info )
    166165{
    167         msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info );
     166        msn_set_display_name( ic, info );
    168167}
    169168
     
    281280}
    282281
    283 static char *msn_set_display_name( set_t *set, char *value )
     282static char *set_eval_display_name( set_t *set, char *value )
    284283{
    285284        account_t *acc = set->data;
    286285        struct im_connection *ic = acc->ic;
    287         struct msn_data *md;
    288         char buf[1024], *fn;
    289        
    290         /* Double-check. */
     286       
     287        /* Allow any name if we're offline. */
    291288        if( ic == NULL )
    292                 return NULL;
    293        
    294         md = ic->proto_data;
     289                return value;
    295290       
    296291        if( strlen( value ) > 129 )
     
    299294                return NULL;
    300295        }
    301        
    302         fn = msn_http_encode( value );
    303        
    304         g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );
    305         msn_write( ic, buf, strlen( buf ) );
    306         g_free( fn );
    307296       
    308297        /* Returning NULL would be better, because the server still has to
    309298           confirm the name change. However, it looks a bit confusing to the
    310299           user. */
    311         return value;
     300        return msn_set_display_name( ic, value ) ? value : NULL;
    312301}
    313302
Note: See TracChangeset for help on using the changeset viewer.