diff options
Diffstat (limited to 'protocols/msn/sb.c')
| -rw-r--r-- | protocols/msn/sb.c | 89 | 
1 files changed, 45 insertions, 44 deletions
| diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index 7ec340bd..1693cb95 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -47,9 +47,9 @@ int msn_sb_write( struct msn_switchboard *sb, char *s, int len )  	return( 1 );  } -struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, int port, char *key, int session ) +struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session )  { -	struct msn_data *md = gc->proto_data; +	struct msn_data *md = ic->proto_data;  	struct msn_switchboard *sb = g_new0( struct msn_switchboard, 1 );  	sb->fd = proxy_connect( host, port, msn_sb_connected, sb ); @@ -59,7 +59,7 @@ struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, i  		return( NULL );  	} -	sb->gc = gc; +	sb->ic = ic;  	sb->key = g_strdup( key );  	sb->session = session; @@ -69,9 +69,9 @@ struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, i  	return( sb );  } -struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *handle ) +struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle )  { -	struct msn_data *md = gc->proto_data; +	struct msn_data *md = ic->proto_data;  	struct msn_switchboard *sb;  	GSList *l; @@ -85,25 +85,25 @@ struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *hand  	return( NULL );  } -struct msn_switchboard *msn_sb_by_id( struct gaim_connection *gc, int id ) +struct msn_switchboard *msn_sb_by_chat( struct groupchat *c )  { -	struct msn_data *md = gc->proto_data; +	struct msn_data *md = c->ic->proto_data;  	struct msn_switchboard *sb;  	GSList *l;  	for( l = md->switchboards; l; l = l->next )  	{  		sb = l->data; -		if( sb->chat && sb->chat->id == id ) +		if( sb->chat == c )  			return( sb );  	}  	return( NULL );  } -struct msn_switchboard *msn_sb_spare( struct gaim_connection *gc ) +struct msn_switchboard *msn_sb_spare( struct im_connection *ic )  { -	struct msn_data *md = gc->proto_data; +	struct msn_data *md = ic->proto_data;  	struct msn_switchboard *sb;  	GSList *l; @@ -141,9 +141,9 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text )  		}  		else  		{ -			i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->gc->username ); +			i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->ic->acc->user );  			buf = g_new0( char, i ); -			i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->gc->username ); +			i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->acc->user );  		}  		/* Build the final packet (MSG command + the message). */ @@ -176,18 +176,18 @@ int msn_sb_sendmessage( struct msn_switchboard *sb, char *text )  	}  } -void msn_sb_to_chat( struct msn_switchboard *sb ) +struct groupchat *msn_sb_to_chat( struct msn_switchboard *sb )  { -	struct gaim_connection *gc = sb->gc; +	struct im_connection *ic = sb->ic;  	char buf[1024];  	/* Create the groupchat structure. */  	g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); -	sb->chat = serv_got_joined_chat( gc, ++msn_chat_id, buf ); +	sb->chat = imcb_chat_new( ic, buf );  	/* Populate the channel. */ -	if( sb->who ) add_chat_buddy( sb->chat, sb->who ); -	add_chat_buddy( sb->chat, gc->username ); +	if( sb->who ) imcb_chat_add_buddy( sb->chat, sb->who ); +	imcb_chat_add_buddy( sb->chat, ic->acc->user );  	/* And make sure the switchboard doesn't look like a regular chat anymore. */  	if( sb->who ) @@ -195,12 +195,14 @@ void msn_sb_to_chat( struct msn_switchboard *sb )  		g_free( sb->who );  		sb->who = NULL;  	} +	 +	return sb->chat;  }  void msn_sb_destroy( struct msn_switchboard *sb )  { -	struct gaim_connection *gc = sb->gc; -	struct msn_data *md = gc->proto_data; +	struct im_connection *ic = sb->ic; +	struct msn_data *md = ic->proto_data;  	debug( "Destroying switchboard: %s", sb->who ? sb->who : sb->key ? sb->key : "" ); @@ -219,7 +221,7 @@ void msn_sb_destroy( struct msn_switchboard *sb )  		}  		g_slist_free( sb->msgq ); -		serv_got_crap( gc, "Warning: Closing down MSN switchboard connection with " +		imcb_log( ic, "Warning: Closing down MSN switchboard connection with "  		                   "unsent message to %s, you'll have to resend it.",  		                   sb->who ? sb->who : "(unknown)" );  	} @@ -229,7 +231,7 @@ void msn_sb_destroy( struct msn_switchboard *sb )  	if( sb->chat )  	{ -		serv_got_chat_left( gc, sb->chat->id ); +		imcb_chat_removed( sb->chat );  	}  	if( sb->handler ) @@ -250,7 +252,7 @@ void msn_sb_destroy( struct msn_switchboard *sb )  gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond )  {  	struct msn_switchboard *sb = data; -	struct gaim_connection *gc; +	struct im_connection *ic;  	struct msn_data *md;  	char buf[1024]; @@ -258,8 +260,8 @@ gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond )  	if( !g_slist_find( msn_switchboards, sb ) )  		return FALSE; -	gc = sb->gc; -	md = gc->proto_data; +	ic = sb->ic; +	md = ic->proto_data;  	if( source != sb->fd )  	{ @@ -277,9 +279,9 @@ gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond )  	sb->handler->exec_message = msn_sb_message;  	if( sb->session == MSN_SB_NEW ) -		g_snprintf( buf, sizeof( buf ), "USR %d %s %s\r\n", ++sb->trId, gc->username, sb->key ); +		g_snprintf( buf, sizeof( buf ), "USR %d %s %s\r\n", ++sb->trId, ic->acc->user, sb->key );  	else -		g_snprintf( buf, sizeof( buf ), "ANS %d %s %s %d\r\n", ++sb->trId, gc->username, sb->key, sb->session ); +		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 ); @@ -307,7 +309,7 @@ static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition c  static int msn_sb_command( gpointer data, char **cmd, int num_parts )  {  	struct msn_switchboard *sb = data; -	struct gaim_connection *gc = sb->gc; +	struct im_connection *ic = sb->ic;  	char buf[1024];  	if( !num_parts ) @@ -318,8 +320,8 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )  	if( strcmp( cmd[0], "XFR" ) == 0 )  	{ -		hide_login_progress_error( gc, "Received an XFR from a switchboard server, unable to comply! This is likely to be a bug, please report it!" ); -		signoff( gc ); +		imcb_error( ic, "Received an XFR from a switchboard server, unable to comply! This is likely to be a bug, please report it!" ); +		imc_logout( ic, TRUE );  		return( 0 );  	}  	else if( strcmp( cmd[0], "USR" ) == 0 ) @@ -371,17 +373,17 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )  			if( num == 1 )  			{  				g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); -				sb->chat = serv_got_joined_chat( gc, ++msn_chat_id, buf ); +				sb->chat = imcb_chat_new( ic, buf );  				g_free( sb->who );  				sb->who = NULL;  			} -			add_chat_buddy( sb->chat, cmd[4] ); +			imcb_chat_add_buddy( sb->chat, cmd[4] );  			if( num == tot )  			{ -				add_chat_buddy( sb->chat, gc->username ); +				imcb_chat_add_buddy( sb->chat, ic->acc->user );  			}  		}  	} @@ -459,11 +461,11 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )  			/* This SB is a one-to-one chat right now, but someone else is joining. */  			msn_sb_to_chat( sb ); -			add_chat_buddy( sb->chat, cmd[1] ); +			imcb_chat_add_buddy( sb->chat, cmd[1] );  		}  		else if( sb->chat )  		{ -			add_chat_buddy( sb->chat, cmd[1] ); +			imcb_chat_add_buddy( sb->chat, cmd[1] );  			sb->ready = 1;  		}  		else @@ -513,7 +515,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )  		}  		else if( sb->chat )  		{ -			remove_chat_buddy( sb->chat, cmd[1], "" ); +			imcb_chat_remove_buddy( sb->chat, cmd[1], "" );  		}  		else  		{ @@ -525,8 +527,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )  		int num = atoi( cmd[0] );  		const struct msn_status_code *err = msn_status_by_number( num ); -		g_snprintf( buf, sizeof( buf ), "Error reported by switchboard server: %s", err->text ); -		do_error_dialog( gc, buf, "MSN" ); +		imcb_error( ic, "Error reported by switchboard server: %s", err->text );  		if( err->flags & STATUS_SB_FATAL )  		{ @@ -535,7 +536,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )  		}  		else if( err->flags & STATUS_FATAL )  		{ -			signoff( gc ); +			imc_logout( ic, TRUE );  			return 0;  		}  		else if( err->flags & STATUS_SB_IM_SPARE ) @@ -576,7 +577,7 @@ static int msn_sb_command( gpointer data, char **cmd, int num_parts )  static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts )  {  	struct msn_switchboard *sb = data; -	struct gaim_connection *gc = sb->gc; +	struct im_connection *ic = sb->ic;  	char *body;  	int blen = 0; @@ -605,11 +606,11 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int  			if( sb->who )  			{ -				serv_got_im( gc, cmd[1], body, 0, 0, blen ); +				imcb_buddy_msg( ic, cmd[1], body, 0, 0 );  			}  			else if( sb->chat )  			{ -				serv_got_chat_in( gc, sb->chat->id, cmd[1], 0, body, 0 ); +				imcb_chat_msg( sb->chat, cmd[1], body, 0, 0 );  			}  			else  			{ @@ -664,11 +665,11 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int  			if( sb->who )  			{ -				serv_got_im( gc, cmd[1], buf, 0, 0, strlen( buf ) ); +				imcb_buddy_msg( ic, cmd[1], buf, 0, 0 );  			}  			else if( sb->chat )  			{ -				serv_got_chat_in( gc, sb->chat->id, cmd[1], 0, buf, 0 ); +				imcb_chat_msg( sb->chat, cmd[1], buf, 0, 0 );  			}  			else  			{ @@ -681,7 +682,7 @@ static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int  			if( who )  			{ -				serv_got_typing( gc, who, 5, 1 ); +				imcb_buddy_typing( ic, who, OPT_TYPING );  				g_free( who );  			} | 
