aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-05-27 00:44:48 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-05-27 00:44:48 +0200
commita2582c84bda1ed8940c75bd842f9296cef3f50d4 (patch)
tree1313b5221c668add566d2dd0ef661af9bb84bb16
parentfe237200e4b3921e190d13693402e14d63fe2fa4 (diff)
Added error_string variable to Passport client.
-rw-r--r--protocols/msn/ns.c9
-rw-r--r--protocols/msn/passport.c29
-rw-r--r--protocols/msn/passport.h1
3 files changed, 33 insertions, 6 deletions
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index 90d525ef..523de0ae 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -649,8 +649,15 @@ static void msn_auth_got_passport_id( struct passport_reply *rep )
if( key == NULL )
{
- hide_login_progress( gc, "Error during Passport authentication" );
+ char *err;
+
+ err = g_strdup_printf( "Error during Passport authentication (%s)",
+ rep->error_string ? rep->error_string : "Unknown error" );
+
+ hide_login_progress( gc, err );
signoff( gc );
+
+ g_free( err );
}
else
{
diff --git a/protocols/msn/passport.c b/protocols/msn/passport.c
index 34703432..5ef4fa18 100644
--- a/protocols/msn/passport.c
+++ b/protocols/msn/passport.c
@@ -68,8 +68,7 @@ static int passport_get_id_real( gpointer func, gpointer data, char *header )
return( 0 );
}
- reqs = g_malloc( strlen( header ) + strlen( dummy ) + 128 );
- sprintf( reqs, "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header );
+ reqs = g_strdup_printf( "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header );
*dummy = 0;
req = http_dorequest( server, 443, 1, reqs, passport_get_id_ready, rep );
@@ -87,13 +86,13 @@ static void passport_get_id_ready( struct http_request *req )
{
struct passport_reply *rep = req->data;
- if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers )
+ if( !g_slist_find( msn_connections, rep->data ) )
{
destroy_reply( rep );
return;
}
- if( req->status_code == 200 )
+ if( req->finished && req->reply_headers && req->status_code == 200 )
{
char *dummy;
@@ -108,6 +107,15 @@ static void passport_get_id_ready( struct http_request *req )
rep->result = g_strdup( dummy );
}
+ else
+ {
+ rep->error_string = g_strdup( "Could not parse Passport server response" );
+ }
+ }
+ else
+ {
+ rep->error_string = g_strdup_printf( "HTTP error: %s",
+ req->status_string ? req->status_string : "Unknown error" );
}
rep->func( rep );
@@ -168,16 +176,26 @@ static void passport_retrieve_dalogin_ready( struct http_request *req )
char *dalogin;
char *urlend;
- if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers )
+ if( !g_slist_find( msn_connections, rep->data ) )
{
destroy_reply( rep );
return;
}
+ if( !req->finished || !req->reply_headers || req->status_code != 200 )
+ {
+ rep->error_string = g_strdup_printf( "HTTP error while fetching DALogin (%s)",
+ req->status_string ? req->status_string : "Unknown error" );
+ goto failure;
+ }
+
dalogin = strstr( req->reply_headers, "DALogin=" );
if( !dalogin )
+ {
+ rep->error_string = g_strdup( "Parse error while fetching DALogin" );
goto failure;
+ }
dalogin += strlen( "DALogin=" );
urlend = strchr( dalogin, ',' );
@@ -207,5 +225,6 @@ static void destroy_reply( struct passport_reply *rep )
{
g_free( rep->result );
g_free( rep->header );
+ g_free( rep->error_string );
g_free( rep );
}
diff --git a/protocols/msn/passport.h b/protocols/msn/passport.h
index f7e6ebb6..9fd81a82 100644
--- a/protocols/msn/passport.h
+++ b/protocols/msn/passport.h
@@ -38,6 +38,7 @@ struct passport_reply
void *data;
char *result;
char *header;
+ char *error_string;
};
int passport_get_id( gpointer func, gpointer data, char *username, char *password, char *cookie );