diff options
Diffstat (limited to 'protocols/msn/msn.c')
| -rw-r--r-- | protocols/msn/msn.c | 93 | 
1 files changed, 55 insertions, 38 deletions
| diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index 4d859346..6222e1b6 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -30,16 +30,14 @@ int msn_chat_id;  GSList *msn_connections;  GSList *msn_switchboards; -static char *msn_set_display_name( set_t *set, char *value ); +static char *set_eval_display_name( set_t *set, char *value );  static void msn_init( account_t *acc )  { -	set_t *s; -	 -	s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc ); -	s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; - -	s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); +	set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc ); +	set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc ); +	set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); +	set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc );  }  static void msn_login( account_t *acc ) @@ -80,6 +78,12 @@ static void msn_logout( struct im_connection *ic )  	if( md )  	{ +		/** Disabling MSN ft support for now. +		while( md->filetransfers ) { +			imcb_file_canceled( md->filetransfers->data, "Closing connection" ); +		} +		*/ +		  		if( md->fd >= 0 )  			closesocket( md->fd ); @@ -98,10 +102,18 @@ static void msn_logout( struct im_connection *ic )  		while( md->groupcount > 0 )  			g_free( md->grouplist[--md->groupcount] );  		g_free( md->grouplist ); -		  		g_free( md->passport_token );  		g_free( md->lock_key ); +		while( md->grpq ) +		{ +			struct msn_groupadd *ga = md->grpq->data; +			g_free( ga->group ); +			g_free( ga->who ); +			g_free( ga ); +			md->grpq = g_slist_remove( md->grpq, ga ); +		} +		  		g_free( md );  	} @@ -120,6 +132,14 @@ static int msn_buddy_msg( struct im_connection *ic, char *who, char *message, in  {  	struct msn_switchboard *sb; +#ifdef DEBUG +	if( strcmp( who, "raw" ) == 0 ) +	{ +		msn_write( ic, message, strlen( message ) ); +		msn_write( ic, "\r\n", 2 ); +	} +	else +#endif  	if( ( sb = msn_sb_by_handle( ic, who ) ) )  	{  		return( msn_sb_sendmessage( sb, message ) ); @@ -157,11 +177,10 @@ static void msn_set_away( struct im_connection *ic, char *state, char *message )  	char buf[1024];  	struct msn_data *md = ic->proto_data; -	if( state ) -		md->away_state = msn_away_state_by_name( state ) ? : -		                 msn_away_state_list + 1; -	else +	if( state == NULL )  		md->away_state = msn_away_state_list; +	else if( ( md->away_state = msn_away_state_by_name( state ) ) == NULL ) +		md->away_state = msn_away_state_list + 1;  	g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, md->away_state->code );  	msn_write( ic, buf, strlen( buf ) ); @@ -169,7 +188,7 @@ static void msn_set_away( struct im_connection *ic, char *state, char *message )  static void msn_set_my_name( struct im_connection *ic, char *info )  { -	msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info ); +	msn_set_display_name( ic, info );  }  static void msn_get_info(struct im_connection *ic, char *who)  @@ -180,12 +199,16 @@ static void msn_get_info(struct im_connection *ic, char *who)  static void msn_add_buddy( struct im_connection *ic, char *who, char *group )  { -	msn_buddy_list_add( ic, "FL", who, who ); +	struct bee_user *bu = bee_user_by_handle( ic->bee, ic, who ); +	 +	msn_buddy_list_add( ic, "FL", who, who, group ); +	if( bu && bu->group ) +		msn_buddy_list_remove( ic, "FL", who, bu->group->name );  }  static void msn_remove_buddy( struct im_connection *ic, char *who, char *group )  { -	msn_buddy_list_remove( ic, "FL", who ); +	msn_buddy_list_remove( ic, "FL", who, NULL );  }  static void msn_chat_msg( struct groupchat *c, char *message, int flags ) @@ -221,6 +244,7 @@ static void msn_chat_leave( struct groupchat *c )  static struct groupchat *msn_chat_with( struct im_connection *ic, char *who )  {  	struct msn_switchboard *sb; +	struct groupchat *c = imcb_chat_new( ic, who );  	if( ( sb = msn_sb_by_handle( ic, who ) ) )  	{ @@ -238,10 +262,8 @@ static struct groupchat *msn_chat_with( struct im_connection *ic, char *who )  		msn_sb_write_msg( ic, m ); -		return NULL; +		return c;  	} -	 -	return NULL;  }  static void msn_keepalive( struct im_connection *ic ) @@ -251,19 +273,19 @@ static void msn_keepalive( struct im_connection *ic )  static void msn_add_permit( struct im_connection *ic, char *who )  { -	msn_buddy_list_add( ic, "AL", who, who ); +	msn_buddy_list_add( ic, "AL", who, who, NULL );  }  static void msn_rem_permit( struct im_connection *ic, char *who )  { -	msn_buddy_list_remove( ic, "AL", who ); +	msn_buddy_list_remove( ic, "AL", who, NULL );  }  static void msn_add_deny( struct im_connection *ic, char *who )  {  	struct msn_switchboard *sb; -	msn_buddy_list_add( ic, "BL", who, who ); +	msn_buddy_list_add( ic, "BL", who, who, NULL );  	/* If there's still a conversation with this person, close it. */  	if( ( sb = msn_sb_by_handle( ic, who ) ) ) @@ -274,29 +296,29 @@ static void msn_add_deny( struct im_connection *ic, char *who )  static void msn_rem_deny( struct im_connection *ic, char *who )  { -	msn_buddy_list_remove( ic, "BL", who ); +	msn_buddy_list_remove( ic, "BL", who, NULL );  }  static int msn_send_typing( struct im_connection *ic, char *who, int typing )  { -	if( typing & OPT_TYPING ) +	struct bee_user *bu = bee_user_by_handle( ic->bee, ic, who ); +	 +	if( !( bu->flags & BEE_USER_ONLINE ) ) +		return 0; +	else if( typing & OPT_TYPING )  		return( msn_buddy_msg( ic, who, TYPING_NOTIFICATION_MESSAGE, 0 ) );  	else -		return( 1 ); +		return 1;  } -static char *msn_set_display_name( set_t *set, char *value ) +static char *set_eval_display_name( set_t *set, char *value )  {  	account_t *acc = set->data;  	struct im_connection *ic = acc->ic; -	struct msn_data *md; -	char buf[1024], *fn; -	/* Double-check. */ +	/* Allow any name if we're offline. */  	if( ic == NULL ) -		return NULL; -	 -	md = ic->proto_data; +		return value;  	if( strlen( value ) > 129 )  	{ @@ -304,16 +326,10 @@ static char *msn_set_display_name( set_t *set, char *value )  		return NULL;  	} -	fn = msn_http_encode( value ); -	 -	g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn ); -	msn_write( ic, buf, strlen( buf ) ); -	g_free( fn ); -	  	/* Returning NULL would be better, because the server still has to  	   confirm the name change. However, it looks a bit confusing to the  	   user. */ -	return value; +	return msn_set_display_name( ic, value ) ? value : NULL;  }  void msn_initmodule() @@ -342,6 +358,7 @@ void msn_initmodule()  	ret->rem_deny = msn_rem_deny;  	ret->send_typing = msn_send_typing;  	ret->handle_cmp = g_strcasecmp; +	//ret->transfer_request = msn_ftp_transfer_request;  	register_protocol(ret);  } | 
