Mercurial > pidgin
comparison libpurple/protocols/mxit/login.c @ 31869:c80ac2d937b7
Change last remaining users of purple_connection_error to use
purple_connection_error_reason. The "reason" I used in this code
is probably not the most appropriate reason. My goal was to retain
the same behavior before and after this change.
It's not a bad idea for someone to look at each of these calls and
determine if a different reason should be used... but it hasn't seemed
to cause problems so far, so maybe it doesn't matter.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 21 Aug 2011 07:49:24 +0000 |
parents | 7c3b4002f46e |
children | a5b556ac1de5 |
comparison
equal
deleted
inserted
replaced
31868:c3ea1711c372 | 31869:c80ac2d937b7 |
---|---|
163 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_connect\n" ); | 163 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_connect\n" ); |
164 | 164 |
165 /* source is the file descriptor of the new connection */ | 165 /* source is the file descriptor of the new connection */ |
166 if ( source < 0 ) { | 166 if ( source < 0 ) { |
167 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_connect failed: %s\n", error_message ); | 167 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_connect failed: %s\n", error_message ); |
168 purple_connection_error( session->con, _( "Unable to connect to the MXit server. Please check your server settings." ) ); | 168 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Unable to connect to the MXit server. Please check your server settings." ) ); |
169 return; | 169 return; |
170 } | 170 } |
171 | 171 |
172 /* we now have an open and active TCP connection to the mxit server */ | 172 /* we now have an open and active TCP connection to the mxit server */ |
173 session->fd = source; | 173 session->fd = source; |
200 | 200 |
201 if ( !session->http ) { | 201 if ( !session->http ) { |
202 /* socket connection */ | 202 /* socket connection */ |
203 data = purple_proxy_connect( session->con, session->acc, session->server, session->port, mxit_cb_connect, session ); | 203 data = purple_proxy_connect( session->con, session->acc, session->server, session->port, mxit_cb_connect, session ); |
204 if ( !data ) { | 204 if ( !data ) { |
205 purple_connection_error( session->con, _( "Unable to connect to the MXit server. Please check your server settings." ) ); | 205 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Unable to connect to the MXit server. Please check your server settings." ) ); |
206 return; | 206 return; |
207 } | 207 } |
208 } | 208 } |
209 else { | 209 else { |
210 /* http connection */ | 210 /* http connection */ |
389 purple_debug_info( MXIT_PLUGIN_ID, "HTTP RESPONSE: '%s'\n", url_text ); | 389 purple_debug_info( MXIT_PLUGIN_ID, "HTTP RESPONSE: '%s'\n", url_text ); |
390 #endif | 390 #endif |
391 | 391 |
392 if ( !url_text ) { | 392 if ( !url_text ) { |
393 /* no reply from the WAP site */ | 393 /* no reply from the WAP site */ |
394 purple_connection_error( session->con, _( "Error contacting the MXit WAP site. Please try again later." ) ); | 394 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Error contacting the MXit WAP site. Please try again later." ) ); |
395 return; | 395 return; |
396 } | 396 } |
397 | 397 |
398 /* explode the response from the WAP site into an array */ | 398 /* explode the response from the WAP site into an array */ |
399 parts = g_strsplit( url_text, ";", 15 ); | 399 parts = g_strsplit( url_text, ";", 15 ); |
400 | 400 |
401 if ( !parts ) { | 401 if ( !parts ) { |
402 /* wapserver error */ | 402 /* wapserver error */ |
403 purple_connection_error( session->con, _( "MXit is currently unable to process the request. Please try again later." ) ); | 403 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "MXit is currently unable to process the request. Please try again later." ) ); |
404 return; | 404 return; |
405 } | 405 } |
406 | 406 |
407 /* check wapsite return code */ | 407 /* check wapsite return code */ |
408 switch ( parts[0][0] ) { | 408 switch ( parts[0][0] ) { |
409 case '0' : | 409 case '0' : |
410 /* valid reply! */ | 410 /* valid reply! */ |
411 break; | 411 break; |
412 case '1' : | 412 case '1' : |
413 purple_connection_error( session->con, _( "Wrong security code entered. Please try again later." ) ); | 413 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Wrong security code entered. Please try again later." ) ); |
414 return; | 414 return; |
415 case '2' : | 415 case '2' : |
416 purple_connection_error( session->con, _( "Your session has expired. Please try again later." ) ); | 416 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Your session has expired. Please try again later." ) ); |
417 return; | 417 return; |
418 case '5' : | 418 case '5' : |
419 purple_connection_error( session->con, _( "Invalid country selected. Please try again." ) ); | 419 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Invalid country selected. Please try again." ) ); |
420 return; | 420 return; |
421 case '6' : | 421 case '6' : |
422 purple_connection_error( session->con, _( "The MXit ID you entered is not registered. Please register first." ) ); | 422 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "The MXit ID you entered is not registered. Please register first." ) ); |
423 return; | 423 return; |
424 case '7' : | 424 case '7' : |
425 purple_connection_error( session->con, _( "The MXit ID you entered is already registered. Please choose another." ) ); | 425 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "The MXit ID you entered is already registered. Please choose another." ) ); |
426 /* this user's account already exists, so we need to change the registration login flag to be login */ | 426 /* this user's account already exists, so we need to change the registration login flag to be login */ |
427 purple_account_set_int( session->acc, MXIT_CONFIG_STATE, MXIT_STATE_LOGIN ); | 427 purple_account_set_int( session->acc, MXIT_CONFIG_STATE, MXIT_STATE_LOGIN ); |
428 return; | 428 return; |
429 case '3' : | 429 case '3' : |
430 case '4' : | 430 case '4' : |
431 default : | 431 default : |
432 purple_connection_error( session->con, _( "Internal error. Please try again later." ) ); | 432 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Internal error. Please try again later." ) ); |
433 return; | 433 return; |
434 } | 434 } |
435 | 435 |
436 /* now parse and split the distribution code and the client key */ | 436 /* now parse and split the distribution code and the client key */ |
437 g_strlcpy( session->distcode, &parts[1][2], 36 + 1 ); | 437 g_strlcpy( session->distcode, &parts[1][2], 36 + 1 ); |
609 purple_debug_info( MXIT_PLUGIN_ID, "RESPONSE: %s\n", url_text ); | 609 purple_debug_info( MXIT_PLUGIN_ID, "RESPONSE: %s\n", url_text ); |
610 #endif | 610 #endif |
611 | 611 |
612 if ( !url_text ) { | 612 if ( !url_text ) { |
613 /* no reply from the WAP site */ | 613 /* no reply from the WAP site */ |
614 purple_connection_error( session->con, _( "Error contacting the MXit WAP site. Please try again later." ) ); | 614 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Error contacting the MXit WAP site. Please try again later." ) ); |
615 return; | 615 return; |
616 } | 616 } |
617 | 617 |
618 /* explode the response from the WAP site into an array */ | 618 /* explode the response from the WAP site into an array */ |
619 parts = g_strsplit( url_text, ";", 15 ); | 619 parts = g_strsplit( url_text, ";", 15 ); |
620 | 620 |
621 if ( ( !parts ) || ( parts[0][0] != '0' ) ) { | 621 if ( ( !parts ) || ( parts[0][0] != '0' ) ) { |
622 /* server could not find the user */ | 622 /* server could not find the user */ |
623 purple_connection_error( session->con, _( "MXit is currently unable to process the request. Please try again later." ) ); | 623 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "MXit is currently unable to process the request. Please try again later." ) ); |
624 return; | 624 return; |
625 } | 625 } |
626 | 626 |
627 /* save received settings */ | 627 /* save received settings */ |
628 logindata = g_new0( struct login_data, 1 ); | 628 logindata = g_new0( struct login_data, 1 ); |