diff options
Diffstat (limited to 'protocols/msn/sb.c')
| -rw-r--r-- | protocols/msn/sb.c | 85 | 
1 files changed, 35 insertions, 50 deletions
| diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index e2ee8570..e23acc09 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -28,6 +28,7 @@  #include "msn.h"  #include "passport.h"  #include "md5.h" +#include "invitation.h"  static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond );  static int msn_sb_command( gpointer data, char **cmd, int num_parts ); @@ -173,6 +174,11 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text )  			buf = g_new0( char, i );  			i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->acc->user );  		} +		else if( strncmp( text, MSN_INVITE_HEADERS, sizeof( MSN_INVITE_HEADERS ) - 1 ) == 0 )  +		{ +			buf = g_strdup( text ); +			i = strlen( buf ); +		}  		else if( strcmp( text, SB_KEEPALIVE_MESSAGE ) == 0 )  		{  			buf = g_strdup( SB_KEEPALIVE_HEADERS ); @@ -314,7 +320,7 @@ gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond )  		g_snprintf( buf, sizeof( buf ), "ANS %d %s %s %d\r\n", ++sb->trId, ic->acc->user, sb->key, sb->session );  	if( msn_sb_write( sb, buf, strlen( buf ) ) ) -		sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb ); +		sb->inp = b_input_add( sb->fd, B_EV_IO_READ, msn_sb_callback, sb );  	else  		debug( "Error %d while connecting to switchboard server", 2 ); @@ -698,62 +704,41 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int  		}  		else if( g_strncasecmp( ct, "text/x-msmsgsinvite", 19 ) == 0 )  		{ -			char *itype = msn_findheader( body, "Application-GUID:", blen ); -			char buf[1024]; +			char *command = msn_findheader( body, "Invitation-Command:", blen ); +			char *cookie = msn_findheader( body, "Invitation-Cookie:", blen ); +			unsigned int icookie;  			g_free( ct ); -			*buf = 0; -			 -			if( !itype ) -				return( 1 ); -			 -			/* File transfer. */ -			if( strcmp( itype, "{5D3E02AB-6190-11d3-BBBB-00C04F795683}" ) == 0 ) -			{ -				char *name = msn_findheader( body, "Application-File:", blen ); -				char *size = msn_findheader( body, "Application-FileSize:", blen ); -				 -				if( name && size ) -				{ -					g_snprintf( buf, sizeof( buf ), "<< \x02""BitlBee\x02"" - Filetransfer: `%s', %s bytes >>\n" -					            "Filetransfers are not supported by BitlBee for now...", name, size ); -				} -				else -				{ -					strcpy( buf, "<< \x02""BitlBee\x02"" - Corrupted MSN filetransfer invitation message >>" ); -				} -				 -				if( name ) g_free( name ); -				if( size ) g_free( size ); -			} -			else -			{ -				char *iname = msn_findheader( body, "Application-Name:", blen ); -				 -				g_snprintf( buf, sizeof( buf ), "<< \x02""BitlBee\x02"" - Unknown MSN invitation - %s (%s) >>", -				                                itype, iname ? iname : "no name" ); -				 -				if( iname ) g_free( iname ); +			/* Every invite should have both a Command and Cookie header */ +			if( !command || !cookie ) { +				g_free( command ); +				g_free( cookie ); +				imcb_log( ic, "Warning: No command or cookie from %s", sb->who ); +				return 1;  			} -			g_free( itype ); +			icookie = strtoul( cookie, NULL, 10 ); +			g_free( cookie ); -			if( !*buf ) -				return( 1 ); -			 -			if( sb->who ) -			{ -				imcb_buddy_msg( ic, cmd[1], buf, 0, 0 ); -			} -			else if( sb->chat ) -			{ -				imcb_chat_msg( sb->chat, cmd[1], buf, 0, 0 ); -			} -			else -			{ -				/* PANIC! */ +			if( g_strncasecmp( command, "INVITE", 6 ) == 0 ) { +				msn_invitation_invite( sb, cmd[1], icookie, body, blen ); +			} else if( g_strncasecmp( command, "ACCEPT", 6 ) == 0 ) { +				msn_invitation_accept( sb, cmd[1], icookie, body, blen ); +			} else if( g_strncasecmp( command, "CANCEL", 6 ) == 0 ) { +				msn_invitation_cancel( sb, cmd[1], icookie, body, blen ); +			} else { +				imcb_log( ic, "Warning: Received invalid invitation with " +						"command %s from %s", command, sb->who );  			} +			 +			g_free( command ); +		} +		else if( g_strncasecmp( ct, "application/x-msnmsgrp2p", 24 ) == 0 )  +		{ +			imcb_error( sb->ic, "Cannot receive file from %s: BitlBee does not " +					"support msnmsgrp2p yet.", sb->who ); +			g_free( ct );  		}  		else if( g_strncasecmp( ct, "text/x-msmsgscontrol", 20 ) == 0 )  		{ | 
