diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-03-06 15:44:46 +0000 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-03-06 15:44:46 +0000 | 
| commit | b051d39d99219852a1dc79f68ee301fc1fe16a5e (patch) | |
| tree | cc0c36f6124a565362e64e3e1ab66a45b68dc2e8 /protocols | |
| parent | 2bc8ac0680e6a04f8431003ab468bb6e419534ed (diff) | |
MSN module updated to deal with the new API. Not many changes since it
doesn't currently support away messages anyway. This is more a bit of a
cleanup.
Diffstat (limited to 'protocols')
| -rw-r--r-- | protocols/msn/msn.c | 18 | ||||
| -rw-r--r-- | protocols/msn/msn.h | 1 | ||||
| -rw-r--r-- | protocols/msn/ns.c | 14 | ||||
| -rw-r--r-- | protocols/msn/tables.c | 37 | 
4 files changed, 29 insertions, 41 deletions
| diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index 046b2772..e12fb3a9 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -138,8 +138,9 @@ static GList *msn_away_states( struct im_connection *ic )  	int i;  	if( l == NULL ) -		for( i = 0; msn_away_state_list[i].number > -1; i ++ ) -			l = g_list_append( l, (void*) msn_away_state_list[i].name ); +		for( i = 0; *msn_away_state_list[i].code; i ++ ) +			if( *msn_away_state_list[i].name ) +				l = g_list_append( l, (void*) msn_away_state_list[i].name );  	return l;  } @@ -148,17 +149,14 @@ static void msn_set_away( struct im_connection *ic, char *state, char *message )  {  	char buf[1024];  	struct msn_data *md = ic->proto_data; -	const struct msn_away_state *st; -	if( strcmp( state, GAIM_AWAY_CUSTOM ) == 0 ) -		st = msn_away_state_by_name( "Away" ); +	if( state ) +		md->away_state = msn_away_state_by_name( state ) ? : +		                 msn_away_state_list + 1;  	else -		st = msn_away_state_by_name( state ); +		md->away_state = msn_away_state_list; -	if( !st ) st = msn_away_state_list; -	md->away_state = st; -	 -	g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code ); +	g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, md->away_state->code );  	msn_write( ic, buf, strlen( buf ) );  } diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 7c849acf..333ae7f0 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -96,7 +96,6 @@ struct msn_switchboard  struct msn_away_state  { -	int number;  	char code[4];  	char name[16];  }; diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 30a35e4e..d05d8e0d 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -419,11 +419,12 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )  		if( !st )  		{  			/* FIXME: Warn/Bomb about unknown away state? */ -			st = msn_away_state_list; +			st = msn_away_state_list + 1;  		} -		imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | -		                   ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); +		imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN |  +		                   ( st != msn_away_state_list ? OPT_AWAY : 0 ), +		                   st->name, NULL );  	}  	else if( strcmp( cmd[0], "FLN" ) == 0 )  	{ @@ -448,11 +449,12 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )  		if( !st )  		{  			/* FIXME: Warn/Bomb about unknown away state? */ -			st = msn_away_state_list; +			st = msn_away_state_list + 1;  		} -		imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | -		                   ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); +		imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN |  +		                   ( st != msn_away_state_list ? OPT_AWAY : 0 ), +		                   st->name, NULL );  	}  	else if( strcmp( cmd[0], "RNG" ) == 0 )  	{ diff --git a/protocols/msn/tables.c b/protocols/msn/tables.c index 5ba9ea73..b01361bd 100644 --- a/protocols/msn/tables.c +++ b/protocols/msn/tables.c @@ -28,48 +28,37 @@  const struct msn_away_state msn_away_state_list[] =  { -	{  0, "NLN", "Available" }, -	{  1, "BSY", "Busy" }, -	{  3, "IDL", "Idle" }, -	{  5, "BRB", "Be Right Back" }, -	{  7, "AWY", "Away" }, -	{  9, "PHN", "On the Phone" }, -	{ 11, "LUN", "Out to Lunch" }, -	{ 13, "HDN", "Hidden" }, -	{ -1, "",    "" } +	{ "NLN", "" }, +	{ "BSY", "Busy" }, +	{ "IDL", "Idle" }, +	{ "BRB", "Be Right Back" }, +	{ "AWY", "Away" }, +	{ "PHN", "On the Phone" }, +	{ "LUN", "Out to Lunch" }, +	{ "HDN", "Hidden" }, +	{ "",    "" }  }; -const struct msn_away_state *msn_away_state_by_number( int number ) -{ -	int i; -	 -	for( i = 0; msn_away_state_list[i].number > -1; i ++ ) -		if( msn_away_state_list[i].number == number ) -			return( msn_away_state_list + i ); -	 -	return( NULL ); -} -  const struct msn_away_state *msn_away_state_by_code( char *code )  {  	int i; -	for( i = 0; msn_away_state_list[i].number > -1; i ++ ) +	for( i = 0; *msn_away_state_list[i].code; i ++ )  		if( g_strcasecmp( msn_away_state_list[i].code, code ) == 0 )  			return( msn_away_state_list + i ); -	return( NULL ); +	return NULL;  }  const struct msn_away_state *msn_away_state_by_name( char *name )  {  	int i; -	for( i = 0; msn_away_state_list[i].number > -1; i ++ ) +	for( i = 0; *msn_away_state_list[i].code; i ++ )  		if( g_strcasecmp( msn_away_state_list[i].name, name ) == 0 )  			return( msn_away_state_list + i ); -	return( NULL ); +	return NULL;  }  const struct msn_status_code msn_status_code_list[] = | 
