diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-09-04 16:54:52 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-09-04 16:54:52 +0100 | 
| commit | 4aa8a046968bff0a08dc5ae96e228861fa21fcbe (patch) | |
| tree | 99927daf2e094c7de4c60a7ed6298cf503b5882a /protocols | |
| parent | bae06178bbe3863b39ec307c34d2781a53472272 (diff) | |
This works (includes some token sabotage code to ease testing), but I just
realised there's probably no need for the additional temporary NS connection.
Diffstat (limited to 'protocols')
| -rw-r--r-- | protocols/msn/msn.c | 7 | ||||
| -rw-r--r-- | protocols/msn/msn.h | 4 | ||||
| -rw-r--r-- | protocols/msn/ns.c | 15 | ||||
| -rw-r--r-- | protocols/msn/soap.c | 40 | ||||
| -rw-r--r-- | protocols/msn/soap.h | 2 | 
5 files changed, 54 insertions, 14 deletions
| diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index c5c05087..1467f033 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -63,6 +63,7 @@ static void msn_login( account_t *acc )  	md->ic = ic;  	md->away_state = msn_away_state_list;  	md->domaintree = g_tree_new( msn_domaintree_cmp ); +	md->ns->fd = md->auth->fd = -1;  	msn_connections = g_slist_prepend( msn_connections, ic ); @@ -179,6 +180,8 @@ static void msn_set_away( struct im_connection *ic, char *state, char *message )  	char *uux;  	struct msn_data *md = ic->proto_data; +	strcpy( md->tokens[1], md->tokens[2] ); +	  	if( state == NULL )  		md->away_state = msn_away_state_list;  	else if( ( md->away_state = msn_away_state_by_name( state ) ) == NULL ) @@ -280,7 +283,7 @@ static void msn_add_permit( struct im_connection *ic, char *who )  static void msn_rem_permit( struct im_connection *ic, char *who )  { -	msn_buddy_list_remove( ic, MSN_BUDDY_AL, who, NULL ); +	//msn_buddy_list_remove( ic, MSN_BUDDY_AL, who, NULL );  }  static void msn_add_deny( struct im_connection *ic, char *who ) @@ -298,7 +301,7 @@ 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, MSN_BUDDY_BL, who, NULL ); +	//msn_buddy_list_remove( ic, MSN_BUDDY_BL, who, NULL );  }  static int msn_send_typing( struct im_connection *ic, char *who, int typing ) diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 5a195348..3def01a4 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -107,9 +107,9 @@ struct msn_data  	int trId;  	char *tokens[4]; -	char *lock_key; +	char *lock_key, *pp_policy; -	GSList *msgq, *grpq; +	GSList *msgq, *grpq, *soapq;  	GSList *switchboards;  	int sb_failures;  	time_t first_sb_failure; diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 6260e300..401461b2 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -110,7 +110,7 @@ static gboolean msn_ns_connected( gpointer data, gint source, b_input_condition  	handler->rxlen = 0;  	handler->rxq = g_new0( char, 1 ); -	if( msn_ns_write( ic, -1, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER ) ) +	if( msn_ns_write( ic, source, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER ) )  	{  		handler->inpa = b_input_add( handler->fd, B_EV_IO_READ, msn_ns_callback, handler );  		imcb_log( ic, "Connected to server, waiting for reply" ); @@ -172,13 +172,13 @@ static int msn_ns_command( struct msn_handler_data *handler, char **cmd, int num  			return( 0 );  		} -		return( msn_ns_write( ic, -1, "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s\r\n", +		return( msn_ns_write( ic, handler->fd, "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s\r\n",  		                      ++md->trId, ic->acc->user ) );  	}  	else if( strcmp( cmd[0], "CVR" ) == 0 )  	{  		/* We don't give a damn about the information we just received */ -		return msn_ns_write( ic, -1, "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user ); +		return msn_ns_write( ic, handler->fd, "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user );  	}  	else if( strcmp( cmd[0], "XFR" ) == 0 )  	{ @@ -271,7 +271,14 @@ static int msn_ns_command( struct msn_handler_data *handler, char **cmd, int num  		if( num_parts >= 6 && strcmp( cmd[2], "SSO" ) == 0 &&  		    strcmp( cmd[3], "S" ) == 0 )  		{ -			msn_soap_passport_sso_request( ic, cmd[4], cmd[5] ); +			g_free( md->pp_policy ); +			md->pp_policy = g_strdup( cmd[4] ); +			msn_soap_passport_sso_request( ic, cmd[5] ); +			if( handler == md->auth ) +			{ +				msn_ns_close( md->auth ); +				return 0; +			}  		}  		else if( strcmp( cmd[2], "OK" ) == 0 )  		{ diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 8d276108..592dbd4f 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -136,9 +136,24 @@ static void msn_soap_handle_response( struct http_request *http_req )  	if( http_req->body_size > 0 )  	{  		struct xt_parser *parser; +		struct xt_node *err;  		parser = xt_new( soap_req->xml_parser, soap_req );  		xt_feed( parser, http_req->reply_body, http_req->body_size ); +		if( http_req->status_code == 500 && +		    ( err = xt_find_path( parser->root, "soap:Body/soap:Fault/detail/errorcode" ) ) && +		    err->text_len > 0 && strcmp( err->text, "PassportAuthFail" ) == 0 ) +		{ +			struct msn_data *md = soap_req->ic->proto_data; +			 +			xt_free( parser ); +			if( md->auth->fd == -1 ) +				msn_ns_connect( soap_req->ic, md->auth, MSN_NS_HOST, MSN_NS_PORT ); +			md->soapq = g_slist_prepend( md->soapq, soap_req ); +			 +			return; +		} +		  		xt_handle( parser, NULL, -1 );  		xt_free( parser );  	} @@ -201,12 +216,24 @@ static void msn_soap_debug_print( const char *headers, const char *payload )  #endif  } +static int msn_soapq_empty( struct im_connection *ic ) +{ +	struct msn_data *md = ic->proto_data; +	 +	while( md->soapq ) +	{ +		msn_soap_send_request( (struct msn_soap_req_data*) md->soapq->data ); +		md->soapq = g_slist_remove( md->soapq, md->soapq->data ); +	} +	 +	return MSN_SOAP_OK; +} +  /* passport_sso: Authentication MSNP15+ */  struct msn_soap_passport_sso_data  { -	char *policy;  	char *nonce;  	char *secret;  	char *error; @@ -216,6 +243,7 @@ static int msn_soap_passport_sso_build_request( struct msn_soap_req_data *soap_r  {  	struct msn_soap_passport_sso_data *sd = soap_req->data;  	struct im_connection *ic = soap_req->ic; +	struct msn_data *md = ic->proto_data;  	if( g_str_has_suffix( ic->acc->user, "@msn.com" ) )  		soap_req->url = g_strdup( SOAP_PASSPORT_SSO_URL_MSN ); @@ -223,7 +251,7 @@ static int msn_soap_passport_sso_build_request( struct msn_soap_req_data *soap_r  		soap_req->url = g_strdup( SOAP_PASSPORT_SSO_URL );  	soap_req->payload = g_markup_printf_escaped( SOAP_PASSPORT_SSO_PAYLOAD, -		ic->acc->user, ic->acc->pass, sd->policy ); +		ic->acc->user, ic->acc->pass, md->pp_policy );  	return MSN_SOAP_OK;  } @@ -300,6 +328,7 @@ static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap  {  	struct msn_soap_passport_sso_data *sd = soap_req->data;  	struct im_connection *ic = soap_req->ic; +	struct msn_data *md = ic->proto_data;  	char *key1, *key2, *key3, *blurb64;  	int key1_len;  	unsigned char *padnonce, *des3res; @@ -325,6 +354,9 @@ static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap  		GUINT32_TO_LE( 72 ),  	}; +	if( md->soapq ) +		return msn_soapq_empty( ic ); +	  	if( sd->secret == NULL )  	{  		msn_auth_got_passport_token( ic, NULL, sd->error ); @@ -363,7 +395,6 @@ static int msn_soap_passport_sso_free_data( struct msn_soap_req_data *soap_req )  {  	struct msn_soap_passport_sso_data *sd = soap_req->data; -	g_free( sd->policy );  	g_free( sd->nonce );  	g_free( sd->secret );  	g_free( sd->error ); @@ -371,11 +402,10 @@ static int msn_soap_passport_sso_free_data( struct msn_soap_req_data *soap_req )  	return MSN_SOAP_OK;  } -int msn_soap_passport_sso_request( struct im_connection *ic, const char *policy, const char *nonce ) +int msn_soap_passport_sso_request( struct im_connection *ic, const char *nonce )  {  	struct msn_soap_passport_sso_data *sd = g_new0( struct msn_soap_passport_sso_data, 1 ); -	sd->policy = g_strdup( policy );  	sd->nonce = g_strdup( nonce );  	return msn_soap_start( ic, sd, msn_soap_passport_sso_build_request, diff --git a/protocols/msn/soap.h b/protocols/msn/soap.h index 9fba5366..3a46af46 100644 --- a/protocols/msn/soap.h +++ b/protocols/msn/soap.h @@ -138,7 +138,7 @@     "</Body>" \  "</Envelope>" -int msn_soap_passport_sso_request( struct im_connection *ic, const char *policy, const char *nonce ); +int msn_soap_passport_sso_request( struct im_connection *ic, const char *nonce );  #define SOAP_OIM_SEND_URL "https://ows.messenger.msn.com/OimWS/oim.asmx" | 
