Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/ns.c

    r8ff0a61 r1145964  
    3434static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts );
    3535
    36 static void msn_auth_got_passport_id( struct passport_reply *rep );
     36static void msn_auth_got_passport_token( struct msn_auth_data *mad );
    3737
    3838gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond )
     
    178178                       
    179179                        debug( "Connecting to a new switchboard with key %s", cmd[5] );
    180                         sb = msn_sb_create( ic, server, port, cmd[5], MSN_SB_NEW );
     180
     181                        if( ( sb = msn_sb_create( ic, server, port, cmd[5], MSN_SB_NEW ) ) == NULL )
     182                        {
     183                                /* Although this isn't strictly fatal for the NS connection, it's
     184                                   definitely something serious (we ran out of file descriptors?). */
     185                                imcb_error( ic, "Could not create new switchboard" );
     186                                imc_logout( ic, TRUE );
     187                                return( 0 );
     188                        }
    181189                       
    182190                        if( md->msgq )
     
    214222                {
    215223                        /* Time for some Passport black magic... */
    216                         if( !passport_get_id( msn_auth_got_passport_id, ic, ic->acc->user, ic->acc->pass, cmd[4] ) )
     224                        if( !passport_get_token( msn_auth_got_passport_token, ic, ic->acc->user, ic->acc->pass, cmd[4] ) )
    217225                        {
    218226                                imcb_error( ic, "Error while contacting Passport server" );
     
    270278                if( num_parts == 5 )
    271279                {
     280                        int i, groupcount;
     281                       
     282                        groupcount = atoi( cmd[4] );
     283                        if( groupcount > 0 )
     284                        {
     285                                /* valgrind says this is leaking memory, I'm guessing
     286                                   that this happens during server redirects. */
     287                                if( md->grouplist )
     288                                {
     289                                        for( i = 0; i < md->groupcount; i ++ )
     290                                                g_free( md->grouplist[i] );
     291                                        g_free( md->grouplist );
     292                                }
     293                               
     294                                md->groupcount = groupcount;
     295                                md->grouplist = g_new0( char *, md->groupcount );
     296                        }
     297                       
    272298                        md->buddycount = atoi( cmd[3] );
    273                         md->groupcount = atoi( cmd[4] );
    274                         if( md->groupcount > 0 )
    275                                 md->grouplist = g_new0( char *, md->groupcount );
    276                        
    277299                        if( !*cmd[3] || md->buddycount == 0 )
    278300                                msn_logged_in( ic );
     
    468490                debug( "Got a call from %s (session %d). Key = %s", cmd[5], session, cmd[4] );
    469491               
    470                 sb = msn_sb_create( ic, server, port, cmd[4], session );
    471                 sb->who = g_strdup( cmd[5] );
     492                if( ( sb = msn_sb_create( ic, server, port, cmd[4], session ) ) == NULL )
     493                {
     494                        /* Although this isn't strictly fatal for the NS connection, it's
     495                           definitely something serious (we ran out of file descriptors?). */
     496                        imcb_error( ic, "Could not create new switchboard" );
     497                        imc_logout( ic, TRUE );
     498                        return( 0 );
     499                }
     500                else
     501                {
     502                        sb->who = g_strdup( cmd[5] );
     503                }
    472504        }
    473505        else if( strcmp( cmd[0], "ADD" ) == 0 )
     
    647679                                        imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );
    648680                                }
     681                               
     682                                g_free( inbox );
     683                                g_free( folders );
    649684                        }
    650685                        else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 )
     
    674709}
    675710
    676 static void msn_auth_got_passport_id( struct passport_reply *rep )
     711static void msn_auth_got_passport_token( struct msn_auth_data *mad )
    677712{
    678         struct im_connection *ic = rep->data;
    679         struct msn_data *md = ic->proto_data;
    680         char *key = rep->result;
    681         char buf[1024];
    682        
    683         if( key == NULL )
    684         {
    685                 imcb_error( ic, "Error during Passport authentication (%s)",
    686                                rep->error_string ? rep->error_string : "Unknown error" );
     713        struct im_connection *ic = mad->data;
     714        struct msn_data *md;
     715       
     716        /* Dead connection? */
     717        if( g_slist_find( msn_connections, ic ) == NULL )
     718                return;
     719       
     720        md = ic->proto_data;
     721        if( mad->token )
     722        {
     723                char buf[1024];
     724               
     725                g_snprintf( buf, sizeof( buf ), "USR %d TWN S %s\r\n", ++md->trId, mad->token );
     726                msn_write( ic, buf, strlen( buf ) );
     727        }
     728        else
     729        {
     730                imcb_error( ic, "Error during Passport authentication: %s", mad->error );
    687731                imc_logout( ic, TRUE );
    688732        }
    689         else
    690         {
    691                 g_snprintf( buf, sizeof( buf ), "USR %d TWN S %s\r\n", ++md->trId, key );
    692                 msn_write( ic, buf, strlen( buf ) );
    693         }
    694733}
Note: See TracChangeset for help on using the changeset viewer.