Changeset 5f8ab6a9 for protocols/msn


Ignore:
Timestamp:
2010-06-03T10:41:03Z (14 years ago)
Author:
Sven Moritz Hallberg <pesco@…>
Branches:
master
Children:
814aa52
Parents:
3f81999 (diff), f9928cb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge in bitlbee 1.2.5

Location:
protocols/msn
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    r3f81999 r5f8ab6a9  
    2626#include "nogaim.h"
    2727#include "msn.h"
     28
     29int msn_chat_id;
     30GSList *msn_connections;
     31GSList *msn_switchboards;
    2832
    2933static char *msn_set_display_name( set_t *set, char *value );
     
    139143       
    140144        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 );
     145                for( i = 0; *msn_away_state_list[i].code; i ++ )
     146                        if( *msn_away_state_list[i].name )
     147                                l = g_list_append( l, (void*) msn_away_state_list[i].name );
    143148       
    144149        return l;
     
    149154        char buf[1024];
    150155        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" );
     156       
     157        if( state )
     158                md->away_state = msn_away_state_by_name( state ) ? :
     159                                 msn_away_state_list + 1;
    155160        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 );
     161                md->away_state = msn_away_state_list;
     162       
     163        g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, md->away_state->code );
    162164        msn_write( ic, buf, strlen( buf ) );
    163165}
  • protocols/msn/msn.h

    r3f81999 r5f8ab6a9  
    9797struct msn_away_state
    9898{
    99         int number;
    10099        char code[4];
    101100        char name[16];
     
    136135#define STATUS_SB_CHAT_SPARE    8       /* Same, but also for groupchats (not used yet). */
    137136
    138 int msn_chat_id;
     137extern int msn_chat_id;
    139138extern const struct msn_away_state msn_away_state_list[];
    140139extern const struct msn_status_code msn_status_code_list[];
     
    145144   connection), the callback should check whether it's still listed here
    146145   before doing *anything* else. */
    147 GSList *msn_connections;
    148 GSList *msn_switchboards;
     146extern GSList *msn_connections;
     147extern GSList *msn_switchboards;
    149148
    150149/* ns.c */
  • protocols/msn/msn_util.c

    r3f81999 r5f8ab6a9  
    171171               
    172172                /* End of headers? */
    173                 if( strncmp( text + i - 2, "\n\n", 2 ) == 0 ||
    174                     strncmp( text + i - 4, "\r\n\r\n", 4 ) == 0 ||
    175                     strncmp( text + i - 2, "\r\r", 2 ) == 0 )
     173                if( ( i >= 4 && strncmp( text + i - 4, "\r\n\r\n", 4 ) == 0 ) ||
     174                    ( i >= 2 && ( strncmp( text + i - 2, "\n\n", 2 ) == 0 ||   
     175                                  strncmp( text + i - 2, "\r\r", 2 ) == 0 ) ) )
    176176                {
    177177                        break;
     
    374374        *list = NULL;
    375375       
    376         imcb_log( ic, ret->str );
     376        imcb_log( ic, "%s", ret->str );
    377377        g_string_free( ret, TRUE );
    378378}
  • protocols/msn/ns.c

    r3f81999 r5f8ab6a9  
    229229                        }
    230230                }
    231                 else if( num_parts == 7 && strcmp( cmd[2], "OK" ) == 0 )
     231                else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 )
    232232                {
    233233                        set_t *s;
    234234                       
    235                         http_decode( cmd[4] );
    236                        
    237                         strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) );
    238                         ic->displayname[sizeof(ic->displayname)-1] = 0;
    239                        
    240                         if( ( s = set_find( &ic->acc->set, "display_name" ) ) )
    241                         {
    242                                 g_free( s->value );
    243                                 s->value = g_strdup( cmd[4] );
     235                        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                        }
     248                        else
     249                        {
     250                                imcb_log( ic, "Warning: Friendly name in server response was corrupted" );
    244251                        }
    245252                       
     
    406413                {
    407414                        /* FIXME: Warn/Bomb about unknown away state? */
    408                         st = msn_away_state_list;
    409                 }
    410                
    411                 imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN |
    412                                    ( st->number ? OPT_AWAY : 0 ), st->name, NULL );
     415                        st = msn_away_state_list + 1;
     416                }
     417               
     418                imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN |
     419                                   ( st != msn_away_state_list ? OPT_AWAY : 0 ),
     420                                   st->name, NULL );
    413421        }
    414422        else if( strcmp( cmd[0], "FLN" ) == 0 )
     
    435443                {
    436444                        /* FIXME: Warn/Bomb about unknown away state? */
    437                         st = msn_away_state_list;
    438                 }
    439                
    440                 imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN |
    441                                    ( st->number ? OPT_AWAY : 0 ), st->name, NULL );
     445                        st = msn_away_state_list + 1;
     446                }
     447               
     448                imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN |
     449                                   ( st != msn_away_state_list ? OPT_AWAY : 0 ),
     450                                   st->name, NULL );
    442451        }
    443452        else if( strcmp( cmd[0], "RNG" ) == 0 )
     
    649658                                }
    650659                               
    651                                 if( arg1 ) g_free( arg1 );
    652                                 if( mtype ) g_free( mtype );
     660                                g_free( arg1 );
     661                                g_free( mtype );
    653662                        }
    654663                        else if( g_strncasecmp( ct, "text/x-msmsgsprofile", 20 ) == 0 )
     
    658667                        else if( g_strncasecmp( ct, "text/x-msmsgsinitialemailnotification", 37 ) == 0 )
    659668                        {
    660                                 char *inbox = msn_findheader( body, "Inbox-Unread:", blen );
    661                                 char *folders = msn_findheader( body, "Folders-Unread:", blen );
    662                                
    663                                 if( inbox && folders && set_getbool( &ic->acc->set, "mail_notifications" ) )
     669                                if( set_getbool( &ic->acc->set, "mail_notifications" ) )
    664670                                {
    665                                         imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );
     671                                        char *inbox = msn_findheader( body, "Inbox-Unread:", blen );
     672                                        char *folders = msn_findheader( body, "Folders-Unread:", blen );
     673
     674                                        if( inbox && folders )
     675                                                imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );
     676                                       
     677                                        g_free( inbox );
     678                                        g_free( folders );
    666679                                }
    667680                        }
    668681                        else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 )
    669682                        {
    670                                 char *from = msn_findheader( body, "From-Addr:", blen );
    671                                 char *fromname = msn_findheader( body, "From:", blen );
    672                                
    673                                 if( from && fromname && set_getbool( &ic->acc->set, "mail_notifications" ) )
     683                                if( set_getbool( &ic->acc->set, "mail_notifications" ) )
    674684                                {
    675                                         imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from );
     685                                        char *from = msn_findheader( body, "From-Addr:", blen );
     686                                        char *fromname = msn_findheader( body, "From:", blen );
     687                                       
     688                                        if( from && fromname )
     689                                                imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from );
     690
     691                                        g_free( from );
     692                                        g_free( fromname );
    676693                                }
    677694                        }
  • protocols/msn/tables.c

    r3f81999 r5f8ab6a9  
    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        { "AWY", "Away" },
     33        { "BSY", "Busy" },
     34        { "IDL", "Idle" },
     35        { "BRB", "Be Right Back" },
     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.