Changeset b051d39 for protocols/msn


Ignore:
Timestamp:
2010-03-06T15:44:46Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
17f9522
Parents:
2bc8ac0
Message:

MSN module updated to deal with the new API. Not many changes since it
doesn't currently support away messages anyway. This is more a bit of a
cleanup.

Location:
protocols/msn
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    r2bc8ac0 rb051d39  
    139139       
    140140        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 );
     141                for( i = 0; *msn_away_state_list[i].code; i ++ )
     142                        if( *msn_away_state_list[i].name )
     143                                l = g_list_append( l, (void*) msn_away_state_list[i].name );
    143144       
    144145        return l;
     
    149150        char buf[1024];
    150151        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" );
     152       
     153        if( state )
     154                md->away_state = msn_away_state_by_name( state ) ? :
     155                                 msn_away_state_list + 1;
    155156        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 );
     157                md->away_state = msn_away_state_list;
     158       
     159        g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, md->away_state->code );
    162160        msn_write( ic, buf, strlen( buf ) );
    163161}
  • protocols/msn/msn.h

    r2bc8ac0 rb051d39  
    9797struct msn_away_state
    9898{
    99         int number;
    10099        char code[4];
    101100        char name[16];
  • protocols/msn/ns.c

    r2bc8ac0 rb051d39  
    420420                {
    421421                        /* FIXME: Warn/Bomb about unknown away state? */
    422                         st = msn_away_state_list;
    423                 }
    424                
    425                 imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN |
    426                                    ( st->number ? OPT_AWAY : 0 ), st->name, NULL );
     422                        st = msn_away_state_list + 1;
     423                }
     424               
     425                imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN |
     426                                   ( st != msn_away_state_list ? OPT_AWAY : 0 ),
     427                                   st->name, NULL );
    427428        }
    428429        else if( strcmp( cmd[0], "FLN" ) == 0 )
     
    449450                {
    450451                        /* FIXME: Warn/Bomb about unknown away state? */
    451                         st = msn_away_state_list;
    452                 }
    453                
    454                 imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN |
    455                                    ( st->number ? OPT_AWAY : 0 ), st->name, NULL );
     452                        st = msn_away_state_list + 1;
     453                }
     454               
     455                imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN |
     456                                   ( st != msn_away_state_list ? OPT_AWAY : 0 ),
     457                                   st->name, NULL );
    456458        }
    457459        else if( strcmp( cmd[0], "RNG" ) == 0 )
  • protocols/msn/tables.c

    r2bc8ac0 rb051d39  
    2929const struct msn_away_state msn_away_state_list[] =
    3030{
    31         {  0, "NLN", "Available" },
    32         {  1, "BSY", "Busy" },
    33         {  3, "IDL", "Idle" },
    34         {  5, "BRB", "Be Right Back" },
    35         {  7, "AWY", "Away" },
    36         {  9, "PHN", "On the Phone" },
    37         { 11, "LUN", "Out to Lunch" },
    38         { 13, "HDN", "Hidden" },
    39         { -1, "",    "" }
     31        { "NLN", "" },
     32        { "BSY", "Busy" },
     33        { "IDL", "Idle" },
     34        { "BRB", "Be Right Back" },
     35        { "AWY", "Away" },
     36        { "PHN", "On the Phone" },
     37        { "LUN", "Out to Lunch" },
     38        { "HDN", "Hidden" },
     39        { "",    "" }
    4040};
    41 
    42 const struct msn_away_state *msn_away_state_by_number( int number )
    43 {
    44         int i;
    45        
    46         for( i = 0; msn_away_state_list[i].number > -1; i ++ )
    47                 if( msn_away_state_list[i].number == number )
    48                         return( msn_away_state_list + i );
    49        
    50         return( NULL );
    51 }
    5241
    5342const struct msn_away_state *msn_away_state_by_code( char *code )
     
    5544        int i;
    5645       
    57         for( i = 0; msn_away_state_list[i].number > -1; i ++ )
     46        for( i = 0; *msn_away_state_list[i].code; i ++ )
    5847                if( g_strcasecmp( msn_away_state_list[i].code, code ) == 0 )
    5948                        return( msn_away_state_list + i );
    6049       
    61         return( NULL );
     50        return NULL;
    6251}
    6352
     
    6655        int i;
    6756       
    68         for( i = 0; msn_away_state_list[i].number > -1; i ++ )
     57        for( i = 0; *msn_away_state_list[i].code; i ++ )
    6958                if( g_strcasecmp( msn_away_state_list[i].name, name ) == 0 )
    7059                        return( msn_away_state_list + i );
    7160       
    72         return( NULL );
     61        return NULL;
    7362}
    7463
Note: See TracChangeset for help on using the changeset viewer.