aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-10-24 12:40:28 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-10-24 12:40:28 +0200
commitbd28e6a2eec0333a866ef2e380d32b1e6ad0c80b (patch)
treeefbd4eb81c513f8e4622ffd8598c710a86d4a347
parent6237ded20b3f3058f1ada9b6afeaa07fcba535eb (diff)
MSN message packets are now sent at once instead of separately. Probably
the MSN servers don't care, but it looks a bit prettier in wireshark. ;-)
-rw-r--r--protocols/msn/sb.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c
index 63744cd0..7ec340bd 100644
--- a/protocols/msn/sb.c
+++ b/protocols/msn/sb.c
@@ -121,9 +121,10 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text )
{
if( sb->ready )
{
- char cmd[1024], *buf;
+ char *packet, *buf;
int i, j;
+ /* Build the message. Convert LF to CR-LF for normal messages. */
if( strcmp( text, TYPING_NOTIFICATION_MESSAGE ) != 0 )
{
buf = g_new0( char, sizeof( MSN_MESSAGE_HEADERS ) + strlen( text ) * 2 );
@@ -141,19 +142,21 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text )
else
{
i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->gc->username );
- buf = g_new0( char, strlen( MSN_TYPING_HEADERS ) + strlen( sb->gc->username ) );
+ buf = g_new0( char, i );
i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->gc->username );
}
- g_snprintf( cmd, sizeof( cmd ), "MSG %d N %d\r\n", ++sb->trId, i );
- if( msn_sb_write( sb, cmd, strlen( cmd ) ) && msn_sb_write( sb, buf, i ) )
+ /* Build the final packet (MSG command + the message). */
+ packet = g_strdup_printf( "MSG %d N %d\r\n%s", ++sb->trId, i, buf );
+ g_free( buf );
+ if( msn_sb_write( sb, packet, strlen( packet ) ) )
{
- g_free( buf );
+ g_free( packet );
return( 1 );
}
else
{
- g_free( buf );
+ g_free( packet );
return( 0 );
}
}