Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/sb.c

    r6048744 rbd28e6a  
    3030#include "md5.h"
    3131
    32 static void msn_sb_callback( gpointer data, gint source, GaimInputCondition cond );
     32static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond );
    3333static int msn_sb_command( gpointer data, char **cmd, int num_parts );
    3434static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts );
     
    122122        if( sb->ready )
    123123        {
    124                 char cmd[1024], *buf;
     124                char *packet, *buf;
    125125                int i, j;
    126126               
     127                /* Build the message. Convert LF to CR-LF for normal messages. */
    127128                if( strcmp( text, TYPING_NOTIFICATION_MESSAGE ) != 0 )
    128129                {
     
    142143                {
    143144                        i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->gc->username );
    144                         buf = g_new0( char, strlen( MSN_TYPING_HEADERS ) + strlen( sb->gc->username ) );
     145                        buf = g_new0( char, i );
    145146                        i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->gc->username );
    146147                }
    147148               
    148                 g_snprintf( cmd, sizeof( cmd ), "MSG %d N %d\r\n", ++sb->trId, i );
    149                 if( msn_sb_write( sb, cmd, strlen( cmd ) ) && msn_sb_write( sb, buf, i ) )
    150                 {
    151                         g_free( buf );
     149                /* Build the final packet (MSG command + the message). */
     150                packet = g_strdup_printf( "MSG %d N %d\r\n%s", ++sb->trId, i, buf );
     151                g_free( buf );
     152                if( msn_sb_write( sb, packet, strlen( packet ) ) )
     153                {
     154                        g_free( packet );
    152155                        return( 1 );
    153156                }
    154157                else
    155158                {
    156                         g_free( buf );
     159                        g_free( packet );
    157160                        return( 0 );
    158161                }
     
    237240        }
    238241       
    239         if( sb->inp ) gaim_input_remove( sb->inp );
     242        if( sb->inp ) b_event_remove( sb->inp );
    240243        closesocket( sb->fd );
    241244       
     
    245248}
    246249
    247 void msn_sb_connected( gpointer data, gint source, GaimInputCondition cond )
     250gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond )
    248251{
    249252        struct msn_switchboard *sb = data;
     
    254257        /* Are we still alive? */
    255258        if( !g_slist_find( msn_switchboards, sb ) )
    256                 return;
     259                return FALSE;
    257260       
    258261        gc = sb->gc;
     
    263266                debug( "ERROR %d while connecting to switchboard server", 1 );
    264267                msn_sb_destroy( sb );
    265                 return;
     268                return FALSE;
    266269        }
    267270       
     
    280283       
    281284        if( msn_sb_write( sb, buf, strlen( buf ) ) )
    282                 sb->inp = gaim_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb );
     285                sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb );
    283286        else
    284287                debug( "ERROR %d while connecting to switchboard server", 2 );
    285 }
    286 
    287 static void msn_sb_callback( gpointer data, gint source, GaimInputCondition cond )
     288       
     289        return FALSE;
     290}
     291
     292static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond )
    288293{
    289294        struct msn_switchboard *sb = data;
     
    293298                debug( "ERROR: Switchboard died" );
    294299                msn_sb_destroy( sb );
    295         }
     300               
     301                return FALSE;
     302        }
     303        else
     304                return TRUE;
    296305}
    297306
Note: See TracChangeset for help on using the changeset viewer.