diff options
| -rw-r--r-- | protocols/msn/Makefile | 2 | ||||
| -rw-r--r-- | protocols/msn/msn.c | 2 | ||||
| -rw-r--r-- | protocols/msn/msn.h | 3 | ||||
| -rw-r--r-- | protocols/msn/ns.c | 2 | ||||
| -rw-r--r-- | protocols/msn/passport.c | 172 | ||||
| -rw-r--r-- | protocols/msn/passport.h | 113 | ||||
| -rw-r--r-- | protocols/msn/sb.c | 3 | ||||
| -rw-r--r-- | protocols/msn/soap.c | 60 | ||||
| -rw-r--r-- | protocols/msn/tables.c | 2 | 
9 files changed, 39 insertions, 320 deletions
| diff --git a/protocols/msn/Makefile b/protocols/msn/Makefile index 28fe81c9..a14225d1 100644 --- a/protocols/msn/Makefile +++ b/protocols/msn/Makefile @@ -12,7 +12,7 @@ SRCDIR := $(SRCDIR)protocols/msn/  endif  # [SH] Program variables -objects = msn.o msn_util.o ns.o passport.o sb.o soap.o tables.o +objects = msn.o msn_util.o ns.o sb.o soap.o tables.o  LFLAGS += -r diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index ef70fe0c..7b881c67 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -1,7 +1,7 @@    /********************************************************************\    * BitlBee -- An IRC to other IM-networks gateway                     *    *                                                                    * -  * Copyright 2002-2004 Wilmer van der Gaast and others                * +  * Copyright 2002-2010 Wilmer van der Gaast and others                *    \********************************************************************/  /* MSN module - Main file; functions to be called from BitlBee          */ diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index 8abe6875..5c7949c9 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -232,7 +232,4 @@ int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m );  void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial );  void msn_sb_stop_keepalives( struct msn_switchboard *sb ); -/* invitation.c */ -void msn_ftp_transfer_request( struct im_connection *ic, file_transfer_t *ft, char *who ); -  #endif //_MSN_H diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 4ae8693d..40f96b21 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -1,7 +1,7 @@    /********************************************************************\    * BitlBee -- An IRC to other IM-networks gateway                     *    *                                                                    * -  * Copyright 2002-2004 Wilmer van der Gaast and others                * +  * Copyright 2002-2010 Wilmer van der Gaast and others                *    \********************************************************************/  /* MSN module - Notification server callbacks                           */ diff --git a/protocols/msn/passport.c b/protocols/msn/passport.c deleted file mode 100644 index 7c896db1..00000000 --- a/protocols/msn/passport.c +++ /dev/null @@ -1,172 +0,0 @@ -/** passport.c - * - * Functions to login to Microsoft Passport service for Messenger - * Copyright (C) 2004-2008 Wilmer van der Gaast <wilmer@gaast.net> - * - * This program is free software; you can redistribute it and/or modify              - * it under the terms of the GNU General Public License version 2                    - * as published by the Free Software Foundation                                      - *                                                                                    - * This program is distributed in the hope that is will be useful,                   - * bit WITHOU ANY WARRANTY; without even the implied warranty of                    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                     - * GNU General Public License for more details.                                      - *                                                                                    - * You should have received a copy of the GNU General Public License                 - * along with this program; if not, write to the Free Software                       - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA           - * - */ - -#include "http_client.h" -#include "passport.h" -#include "msn.h" -#include "bitlbee.h" -#include "url.h" -#include "misc.h" -#include "xmltree.h" -#include <ctype.h> -#include <errno.h> - -static int passport_get_token_real( struct msn_auth_data *mad ); -static void passport_get_token_ready( struct http_request *req ); - -int passport_get_token( gpointer func, gpointer data, char *username, char *password, char *cookie ) -{ -	struct msn_auth_data *mad = g_new0( struct msn_auth_data, 1 ); -	int i; -	 -	mad->username = g_strdup( username ); -	mad->password = g_strdup( password ); -	mad->cookie = g_strdup( cookie ); -	 -	mad->callback = func; -	mad->data = data; -	 -	mad->url = g_strdup( SOAP_AUTHENTICATION_URL ); -	mad->ttl = 3; /* Max. # of redirects. */ -	 -	/* HTTP-escape stuff and s/,/&/ */ -	http_decode( mad->cookie ); -	for( i = 0; mad->cookie[i]; i ++ ) -		if( mad->cookie[i] == ',' ) -			mad->cookie[i] = '&'; -	 -	/* Microsoft doesn't allow password longer than 16 chars and silently -	   fails authentication if you give the "full version" of your passwd. */ -	if( strlen( mad->password ) > MAX_PASSPORT_PWLEN ) -		mad->password[MAX_PASSPORT_PWLEN] = 0; -	 -	return passport_get_token_real( mad ); -} - -static int passport_get_token_real( struct msn_auth_data *mad ) -{ -	char *post_payload, *post_request; -	struct http_request *req; -	url_t url; -	 -	url_set( &url, mad->url ); -	 -	post_payload = g_markup_printf_escaped( SOAP_AUTHENTICATION_PAYLOAD, -	                                        mad->username, -	                                        mad->password, -	                                        mad->cookie ); -	 -	post_request = g_strdup_printf( SOAP_AUTHENTICATION_REQUEST, -	                                url.file, url.host, -	                                (int) strlen( post_payload ), -	                                post_payload ); -	                                 -	req = http_dorequest( url.host, url.port, 1, post_request, -	                      passport_get_token_ready, mad ); -	 -	g_free( post_request ); -	g_free( post_payload ); -	 -	return req != NULL; -} - -static xt_status passport_xt_extract_token( struct xt_node *node, gpointer data ); -static xt_status passport_xt_handle_fault( struct xt_node *node, gpointer data ); - -static const struct xt_handler_entry passport_xt_handlers[] = { -	{ "wsse:BinarySecurityToken", "wst:RequestedSecurityToken", passport_xt_extract_token }, -	{ "S:Fault",                  "S:Envelope",                 passport_xt_handle_fault  }, -	{ NULL,                       NULL,                         NULL                      } -}; - -static void passport_get_token_ready( struct http_request *req ) -{ -	struct msn_auth_data *mad = req->data; -	struct xt_parser *parser; -	 -	g_free( mad->url ); -	g_free( mad->error ); -	mad->url = mad->error = NULL; -	 -	if( req->status_code == 200 ) -	{ -		parser = xt_new( passport_xt_handlers, mad ); -		xt_feed( parser, req->reply_body, req->body_size ); -		xt_handle( parser, NULL, -1 ); -		xt_free( parser ); -	} -	else -	{ -		mad->error = g_strdup_printf( "HTTP error %d (%s)", req->status_code, -		                              req->status_string ? req->status_string : "unknown" ); -	} -	 -	if( mad->error == NULL && mad->token == NULL ) -		mad->error = g_strdup( "Could not parse Passport server response" ); -	 -	if( mad->url && mad->token == NULL ) -	{ -		passport_get_token_real( mad ); -	} -	else -	{ -		mad->callback( mad ); -		 -		g_free( mad->url ); -		g_free( mad->username ); -		g_free( mad->password ); -		g_free( mad->cookie ); -		g_free( mad->token ); -		g_free( mad->error ); -		g_free( mad ); -	} -} - -static xt_status passport_xt_extract_token( struct xt_node *node, gpointer data ) -{ -	struct msn_auth_data *mad = data; -	char *s; -	 -	if( ( s = xt_find_attr( node, "Id" ) ) && -	    ( strncmp( s, "Compact", 7 ) == 0 || -	      strncmp( s, "PPToken", 7 ) == 0 ) ) -		mad->token = g_memdup( node->text, node->text_len + 1 ); -	 -	return XT_HANDLED; -} - -static xt_status passport_xt_handle_fault( struct xt_node *node, gpointer data ) -{ -	struct msn_auth_data *mad = data; -	struct xt_node *code = xt_find_node( node->children, "faultcode" ); -	struct xt_node *string = xt_find_node( node->children, "faultstring" ); -	struct xt_node *redirect = xt_find_node( node->children, "psf:redirectUrl" ); -	 -	if( redirect && redirect->text_len && mad->ttl-- > 0 ) -		mad->url = g_memdup( redirect->text, redirect->text_len + 1 ); -	 -	if( code == NULL || code->text_len == 0 ) -		mad->error = g_strdup( "Unknown error" ); -	else -		mad->error = g_strdup_printf( "%s (%s)", code->text, string && string->text_len ? -		                              string->text : "no description available" ); -	 -	return XT_HANDLED; -} diff --git a/protocols/msn/passport.h b/protocols/msn/passport.h deleted file mode 100644 index 517d2e91..00000000 --- a/protocols/msn/passport.h +++ /dev/null @@ -1,113 +0,0 @@ -/* passport.h - * - * Functions to login to Microsoft Passport service for Messenger - * Copyright (C) 2004-2008 Wilmer van der Gaast <wilmer@gaast.net> - * - * This program is free software; you can redistribute it and/or modify              - * it under the terms of the GNU General Public License version 2                    - * as published by the Free Software Foundation                                      - *                                                                                    - * This program is distributed in the hope that is will be useful,                   - * bit WITHOU ANY WARRANTY; without even the implied warranty of                    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                     - * GNU General Public License for more details.                                      - *                                                                                    - * You should have received a copy of the GNU General Public License                 - * along with this program; if not, write to the Free Software                       - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA           - */ - -/* Thanks to http://msnpiki.msnfanatic.com/index.php/MSNP13:SOAPTweener -   for the specs! */ - -#ifndef __PASSPORT_H__ -#define __PASSPORT_H__ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#ifndef _WIN32 -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <unistd.h> -#endif -#include "nogaim.h" - -#define MAX_PASSPORT_PWLEN 16 - -struct msn_auth_data -{ -	char *url; -	int ttl; -	 -	char *username; -	char *password; -	char *cookie; -	 -	/* The end result, the only thing we'll really be interested in -	   once finished. */ -	char *token; -	char *error; /* Yeah, or that... */ -	 -	void (*callback)( struct msn_auth_data *mad ); -	gpointer data; -}; - -#define SOAP_AUTHENTICATION_URL "https://loginnet.passport.com/RST.srf" - -#define SOAP_AUTHENTICATION_REQUEST \ -"POST %s HTTP/1.0\r\n" \ -"Accept: text/*\r\n" \ -"User-Agent: BitlBee " BITLBEE_VERSION "\r\n" \ -"Host: %s\r\n" \ -"Content-Length: %d\r\n" \ -"Cache-Control: no-cache\r\n" \ -"\r\n" \ -"%s" - -#define SOAP_AUTHENTICATION_PAYLOAD \ -"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" \ -"<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\" xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\" xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">" \ -  "<Header>" \ -    "<ps:AuthInfo xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"PPAuthInfo\">" \ -      "<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>" \ -      "<ps:BinaryVersion>4</ps:BinaryVersion>" \ -      "<ps:UIVersion>1</ps:UIVersion>" \ -      "<ps:Cookies></ps:Cookies>" \ -      "<ps:RequestParams>AQAAAAIAAABsYwQAAAAzMDg0</ps:RequestParams>" \ -    "</ps:AuthInfo>" \ -    "<wsse:Security>" \ -       "<wsse:UsernameToken Id=\"user\">" \ -         "<wsse:Username>%s</wsse:Username>" \ -         "<wsse:Password>%s</wsse:Password>" \ -       "</wsse:UsernameToken>" \ -    "</wsse:Security>" \ -  "</Header>" \ -  "<Body>" \ -    "<ps:RequestMultipleSecurityTokens xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"RSTS\">" \ -      "<wst:RequestSecurityToken Id=\"RST0\">" \ -        "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \ -        "<wsp:AppliesTo>" \ -          "<wsa:EndpointReference>" \ -            "<wsa:Address>http://Passport.NET/tb</wsa:Address>" \ -          "</wsa:EndpointReference>" \ -        "</wsp:AppliesTo>" \ -      "</wst:RequestSecurityToken>" \ -      "<wst:RequestSecurityToken Id=\"RST1\">" \ -       "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>" \ -        "<wsp:AppliesTo>" \ -          "<wsa:EndpointReference>" \ -            "<wsa:Address>messenger.msn.com</wsa:Address>" \ -          "</wsa:EndpointReference>" \ -        "</wsp:AppliesTo>" \ -        "<wsse:PolicyReference URI=\"?%s\"></wsse:PolicyReference>" \ -      "</wst:RequestSecurityToken>" \ -    "</ps:RequestMultipleSecurityTokens>" \ -  "</Body>" \ -"</Envelope>" - -int passport_get_token( gpointer func, gpointer data, char *username, char *password, char *cookie ); - -#endif /* __PASSPORT_H__ */ diff --git a/protocols/msn/sb.c b/protocols/msn/sb.c index b718d4e8..fdad2882 100644 --- a/protocols/msn/sb.c +++ b/protocols/msn/sb.c @@ -1,7 +1,7 @@    /********************************************************************\    * BitlBee -- An IRC to other IM-networks gateway                     *    *                                                                    * -  * Copyright 2002-2005 Wilmer van der Gaast and others                * +  * Copyright 2002-2010 Wilmer van der Gaast and others                *    \********************************************************************/  /* MSN module - Switchboard server callbacks and utilities              */ @@ -26,7 +26,6 @@  #include <ctype.h>  #include "nogaim.h"  #include "msn.h" -#include "passport.h"  #include "md5.h"  #include "soap.h"  #include "invitation.h" diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 0fb36bb4..621e213b 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -1,25 +1,30 @@ -/** soap.c - * - * SOAP-related functions. Some manager at Microsoft apparently thought - * MSNP wasn't XMLy enough so someone stepped up and changed that. This - * is the result. - * - * Copyright (C) 2010 Wilmer van der Gaast <wilmer@gaast.net> - * - * This program is free software; you can redistribute it and/or modify              - * it under the terms of the GNU General Public License version 2                    - * as published by the Free Software Foundation                                      - *                                                                                    - * This program is distributed in the hope that is will be useful,                   - * bit WITHOU ANY WARRANTY; without even the implied warranty of                    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                     - * GNU General Public License for more details.                                      - *                                                                                    - * You should have received a copy of the GNU General Public License                 - * along with this program; if not, write to the Free Software                       - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA           - * - */ +  /********************************************************************\ +  * BitlBee -- An IRC to other IM-networks gateway                     * +  *                                                                    * +  * Copyright 2002-2010 Wilmer van der Gaast and others                * +  \********************************************************************/ + +/* MSN module - All the SOAPy XML stuff. +   Some manager at Microsoft apparently thought MSNP wasn't XMLy enough so +   someone stepped up and changed that. This is the result. Kilobytes and +   more kilobytes of XML vomit to transfer tiny bits of informaiton. */ + +/* +  This program is free software; you can redistribute it and/or modify +  it under the terms of the GNU General Public License as published by +  the Free Software Foundation; either version 2 of the License, or +  (at your option) any later version. + +  This program is distributed in the hope that it will be useful, +  but WITHOUT ANY WARRANTY; without even the implied warranty of +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +  GNU General Public License for more details. + +  You should have received a copy of the GNU General Public License with +  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; +  if not, write to the Free Software Foundation, Inc., 59 Temple Place, +  Suite 330, Boston, MA  02111-1307  USA +*/  #include "http_client.h"  #include "soap.h" @@ -33,6 +38,11 @@  #include <ctype.h>  #include <errno.h> +/* This file tries to make SOAP stuff pretty simple to do by letting you just +   provide a function to build a request, a few functions to parse various +   parts of the response, and a function to run when the full response was +   received and parsed. See the various examples below. */ +  typedef enum  {  	MSN_SOAP_OK, @@ -40,10 +50,6 @@ typedef enum  	MSN_SOAP_ABORT,  } msn_soap_result_t; -struct msn_soap_req_data; - -typedef int (*msn_soap_func) ( struct msn_soap_req_data * ); -  struct msn_soap_req_data  {  	void *data; @@ -57,6 +63,8 @@ struct msn_soap_req_data  	msn_soap_func build_request, handle_response, free_data;  }; +typedef int (*msn_soap_func) ( struct msn_soap_req_data * ); +  static int msn_soap_send_request( struct msn_soap_req_data *req );  static int msn_soap_start( struct im_connection *ic, diff --git a/protocols/msn/tables.c b/protocols/msn/tables.c index 42b12aa9..fd7eca41 100644 --- a/protocols/msn/tables.c +++ b/protocols/msn/tables.c @@ -1,7 +1,7 @@    /********************************************************************\    * BitlBee -- An IRC to other IM-networks gateway                     *    *                                                                    * -  * Copyright 2002-2004 Wilmer van der Gaast and others                * +  * Copyright 2002-2010 Wilmer van der Gaast and others                *    \********************************************************************/  /* MSN module - Some tables with useful data                            */ | 
