Mercurial > pidgin
comparison libpurple/protocols/oscar/clientlogin.c @ 32819:2c6510167895 default tip
propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24)
to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 02 Jun 2012 02:30:49 +0000 |
parents | 904686722499 |
children |
comparison
equal
deleted
inserted
replaced
32818:01ff09d4a463 | 32819:2c6510167895 |
---|---|
180 purple_debug_error("oscar", "startOSCARSession could not parse " | 180 purple_debug_error("oscar", "startOSCARSession could not parse " |
181 "response as XML: %s\n", response); | 181 "response as XML: %s\n", response); |
182 /* Note to translators: %s in this string is a URL */ | 182 /* Note to translators: %s in this string is a URL */ |
183 msg = generate_error_message(response_node, | 183 msg = generate_error_message(response_node, |
184 get_start_oscar_session_url(od)); | 184 get_start_oscar_session_url(od)); |
185 purple_connection_error_reason(gc, | 185 purple_connection_error(gc, |
186 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | 186 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
187 g_free(msg); | 187 g_free(msg); |
188 return FALSE; | 188 return FALSE; |
189 } | 189 } |
190 | 190 |
202 char *msg; | 202 char *msg; |
203 purple_debug_error("oscar", "startOSCARSession response was " | 203 purple_debug_error("oscar", "startOSCARSession response was " |
204 "missing statusCode: %s\n", response); | 204 "missing statusCode: %s\n", response); |
205 msg = generate_error_message(response_node, | 205 msg = generate_error_message(response_node, |
206 get_start_oscar_session_url(od)); | 206 get_start_oscar_session_url(od)); |
207 purple_connection_error_reason(gc, | 207 purple_connection_error(gc, |
208 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | 208 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
209 g_free(msg); | 209 g_free(msg); |
210 xmlnode_free(response_node); | 210 xmlnode_free(response_node); |
211 return FALSE; | 211 return FALSE; |
212 } | 212 } |
230 | 230 |
231 purple_debug_error("oscar", "startOSCARSession response statusCode " | 231 purple_debug_error("oscar", "startOSCARSession response statusCode " |
232 "was %s: %s\n", tmp, response); | 232 "was %s: %s\n", tmp, response); |
233 | 233 |
234 if ((code == 401 && status_detail != 1014) || code == 607) | 234 if ((code == 401 && status_detail != 1014) || code == 607) |
235 purple_connection_error_reason(gc, | 235 purple_connection_error(gc, |
236 PURPLE_CONNECTION_ERROR_OTHER_ERROR, | 236 PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
237 _("You have been connecting and disconnecting too " | 237 _("You have been connecting and disconnecting too " |
238 "frequently. Wait ten minutes and try again. If " | 238 "frequently. Wait ten minutes and try again. If " |
239 "you continue to try, you will need to wait even " | 239 "you continue to try, you will need to wait even " |
240 "longer.")); | 240 "longer.")); |
241 else { | 241 else { |
242 char *msg; | 242 char *msg; |
243 msg = generate_error_message(response_node, | 243 msg = generate_error_message(response_node, |
244 get_start_oscar_session_url(od)); | 244 get_start_oscar_session_url(od)); |
245 purple_connection_error_reason(gc, | 245 purple_connection_error(gc, |
246 PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg); | 246 PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg); |
247 g_free(msg); | 247 g_free(msg); |
248 } | 248 } |
249 | 249 |
250 g_free(tmp); | 250 g_free(tmp); |
259 char *msg; | 259 char *msg; |
260 purple_debug_error("oscar", "startOSCARSession response was missing " | 260 purple_debug_error("oscar", "startOSCARSession response was missing " |
261 "something: %s\n", response); | 261 "something: %s\n", response); |
262 msg = generate_error_message(response_node, | 262 msg = generate_error_message(response_node, |
263 get_start_oscar_session_url(od)); | 263 get_start_oscar_session_url(od)); |
264 purple_connection_error_reason(gc, | 264 purple_connection_error(gc, |
265 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | 265 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
266 g_free(msg); | 266 g_free(msg); |
267 xmlnode_free(response_node); | 267 xmlnode_free(response_node); |
268 return FALSE; | 268 return FALSE; |
269 } | 269 } |
275 } else { | 275 } else { |
276 if (strcmp(encryption_type, OSCAR_OPPORTUNISTIC_ENCRYPTION) == 0) { | 276 if (strcmp(encryption_type, OSCAR_OPPORTUNISTIC_ENCRYPTION) == 0) { |
277 purple_debug_warning("oscar", "We haven't received a tlsCertName to use. We will not do SSL to BOS.\n"); | 277 purple_debug_warning("oscar", "We haven't received a tlsCertName to use. We will not do SSL to BOS.\n"); |
278 } else { | 278 } else { |
279 purple_debug_error("oscar", "startOSCARSession was missing tlsCertName: %s\n", response); | 279 purple_debug_error("oscar", "startOSCARSession was missing tlsCertName: %s\n", response); |
280 purple_connection_error_reason( | 280 purple_connection_error( |
281 gc, | 281 gc, |
282 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, | 282 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, |
283 _("You required encryption in your account settings, but one of the servers doesn't support it.")); | 283 _("You required encryption in your account settings, but one of the servers doesn't support it.")); |
284 xmlnode_free(response_node); | 284 xmlnode_free(response_node); |
285 return FALSE; | 285 return FALSE; |
297 char *msg; | 297 char *msg; |
298 purple_debug_error("oscar", "startOSCARSession response was missing " | 298 purple_debug_error("oscar", "startOSCARSession response was missing " |
299 "something: %s\n", response); | 299 "something: %s\n", response); |
300 msg = generate_error_message(response_node, | 300 msg = generate_error_message(response_node, |
301 get_start_oscar_session_url(od)); | 301 get_start_oscar_session_url(od)); |
302 purple_connection_error_reason(gc, | 302 purple_connection_error(gc, |
303 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | 303 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
304 g_free(msg); | 304 g_free(msg); |
305 g_free(*host); | 305 g_free(*host); |
306 g_free(tmp); | 306 g_free(tmp); |
307 g_free(*cookie); | 307 g_free(*cookie); |
335 /* Note to translators: The first %s is a URL, the second is an | 335 /* Note to translators: The first %s is a URL, the second is an |
336 error message. */ | 336 error message. */ |
337 tmp = g_strdup_printf(_("Error requesting %s: %s"), | 337 tmp = g_strdup_printf(_("Error requesting %s: %s"), |
338 get_start_oscar_session_url(od), error_message ? | 338 get_start_oscar_session_url(od), error_message ? |
339 error_message : _("The server returned an empty response")); | 339 error_message : _("The server returned an empty response")); |
340 purple_connection_error_reason(gc, | 340 purple_connection_error(gc, |
341 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); | 341 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
342 g_free(tmp); | 342 g_free(tmp); |
343 return; | 343 return; |
344 } | 344 } |
345 | 345 |
382 query_string, signature); | 382 query_string, signature); |
383 g_free(query_string); | 383 g_free(query_string); |
384 g_free(signature); | 384 g_free(signature); |
385 | 385 |
386 /* Make the request */ | 386 /* Make the request */ |
387 od->url_data = purple_util_fetch_url_request_len_with_account(account, | 387 od->url_data = purple_util_fetch_url_request(account, |
388 url, TRUE, NULL, FALSE, NULL, FALSE, -1, | 388 url, TRUE, NULL, FALSE, NULL, FALSE, -1, |
389 start_oscar_session_cb, od); | 389 start_oscar_session_cb, od); |
390 g_free(url); | 390 g_free(url); |
391 } | 391 } |
392 | 392 |
393 /** | 393 /** |
394 * This function parses the given response from a clientLogin request | 394 * This function parses the given response from a clientLogin request |
395 * and extracts the useful information. | 395 * and extracts the useful information. |
396 * | 396 * |
397 * @param gc The PurpleConnection. If the response data does | 397 * @param gc The PurpleConnection. If the response data does |
398 * not indicate then purple_connection_error_reason() | 398 * not indicate then purple_connection_error() |
399 * will be called to close this connection. | 399 * will be called to close this connection. |
400 * @param response The response data from the clientLogin request. | 400 * @param response The response data from the clientLogin request. |
401 * @param response_len The length of the above response, or -1 if | 401 * @param response_len The length of the above response, or -1 if |
402 * @response is NUL terminated. | 402 * @response is NUL terminated. |
403 * @param token If parsing was successful then this will be set to | 403 * @param token If parsing was successful then this will be set to |
429 char *msg; | 429 char *msg; |
430 purple_debug_error("oscar", "clientLogin could not parse " | 430 purple_debug_error("oscar", "clientLogin could not parse " |
431 "response as XML: %s\n", response); | 431 "response as XML: %s\n", response); |
432 msg = generate_error_message(response_node, | 432 msg = generate_error_message(response_node, |
433 get_client_login_url(od)); | 433 get_client_login_url(od)); |
434 purple_connection_error_reason(gc, | 434 purple_connection_error(gc, |
435 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | 435 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
436 g_free(msg); | 436 g_free(msg); |
437 return FALSE; | 437 return FALSE; |
438 } | 438 } |
439 | 439 |
453 char *msg; | 453 char *msg; |
454 purple_debug_error("oscar", "clientLogin response was " | 454 purple_debug_error("oscar", "clientLogin response was " |
455 "missing statusCode: %s\n", response); | 455 "missing statusCode: %s\n", response); |
456 msg = generate_error_message(response_node, | 456 msg = generate_error_message(response_node, |
457 get_client_login_url(od)); | 457 get_client_login_url(od)); |
458 purple_connection_error_reason(gc, | 458 purple_connection_error(gc, |
459 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | 459 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
460 g_free(msg); | 460 g_free(msg); |
461 xmlnode_free(response_node); | 461 xmlnode_free(response_node); |
462 return FALSE; | 462 return FALSE; |
463 } | 463 } |
480 | 480 |
481 if (status_code == 330 && status_detail_code == 3011) { | 481 if (status_code == 330 && status_detail_code == 3011) { |
482 PurpleAccount *account = purple_connection_get_account(gc); | 482 PurpleAccount *account = purple_connection_get_account(gc); |
483 if (!purple_account_get_remember_password(account)) | 483 if (!purple_account_get_remember_password(account)) |
484 purple_account_set_password(account, NULL); | 484 purple_account_set_password(account, NULL); |
485 purple_connection_error_reason(gc, | 485 purple_connection_error(gc, |
486 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, | 486 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
487 _("Incorrect password")); | 487 _("Incorrect password")); |
488 } else if (status_code == 330 && status_detail_code == 3015) { | 488 } else if (status_code == 330 && status_detail_code == 3015) { |
489 purple_connection_error_reason(gc, | 489 purple_connection_error(gc, |
490 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, | 490 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
491 _("Server requested that you fill out a CAPTCHA in order to " | 491 _("Server requested that you fill out a CAPTCHA in order to " |
492 "sign in, but this client does not currently support CAPTCHAs.")); | 492 "sign in, but this client does not currently support CAPTCHAs.")); |
493 } else if (status_code == 401 && status_detail_code == 3019) { | 493 } else if (status_code == 401 && status_detail_code == 3019) { |
494 purple_connection_error_reason(gc, | 494 purple_connection_error(gc, |
495 PURPLE_CONNECTION_ERROR_OTHER_ERROR, | 495 PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
496 _("AOL does not allow your screen name to authenticate here")); | 496 _("AOL does not allow your screen name to authenticate here")); |
497 } else { | 497 } else { |
498 char *msg; | 498 char *msg; |
499 msg = generate_error_message(response_node, | 499 msg = generate_error_message(response_node, |
500 get_client_login_url(od)); | 500 get_client_login_url(od)); |
501 purple_connection_error_reason(gc, | 501 purple_connection_error(gc, |
502 PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg); | 502 PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg); |
503 g_free(msg); | 503 g_free(msg); |
504 } | 504 } |
505 | 505 |
506 xmlnode_free(response_node); | 506 xmlnode_free(response_node); |
515 char *msg; | 515 char *msg; |
516 purple_debug_error("oscar", "clientLogin response was missing " | 516 purple_debug_error("oscar", "clientLogin response was missing " |
517 "something: %s\n", response); | 517 "something: %s\n", response); |
518 msg = generate_error_message(response_node, | 518 msg = generate_error_message(response_node, |
519 get_client_login_url(od)); | 519 get_client_login_url(od)); |
520 purple_connection_error_reason(gc, | 520 purple_connection_error(gc, |
521 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | 521 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
522 g_free(msg); | 522 g_free(msg); |
523 xmlnode_free(response_node); | 523 xmlnode_free(response_node); |
524 return FALSE; | 524 return FALSE; |
525 } | 525 } |
533 char *msg; | 533 char *msg; |
534 purple_debug_error("oscar", "clientLogin response was missing " | 534 purple_debug_error("oscar", "clientLogin response was missing " |
535 "something: %s\n", response); | 535 "something: %s\n", response); |
536 msg = generate_error_message(response_node, | 536 msg = generate_error_message(response_node, |
537 get_client_login_url(od)); | 537 get_client_login_url(od)); |
538 purple_connection_error_reason(gc, | 538 purple_connection_error(gc, |
539 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); | 539 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg); |
540 g_free(msg); | 540 g_free(msg); |
541 g_free(*token); | 541 g_free(*token); |
542 g_free(*secret); | 542 g_free(*secret); |
543 g_free(tmp); | 543 g_free(tmp); |
570 if (error_message != NULL || len == 0) { | 570 if (error_message != NULL || len == 0) { |
571 gchar *tmp; | 571 gchar *tmp; |
572 tmp = g_strdup_printf(_("Error requesting %s: %s"), | 572 tmp = g_strdup_printf(_("Error requesting %s: %s"), |
573 get_client_login_url(od), error_message ? | 573 get_client_login_url(od), error_message ? |
574 error_message : _("The server returned an empty response")); | 574 error_message : _("The server returned an empty response")); |
575 purple_connection_error_reason(gc, | 575 purple_connection_error(gc, |
576 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); | 576 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
577 g_free(tmp); | 577 g_free(tmp); |
578 return; | 578 return; |
579 } | 579 } |
580 | 580 |
644 g_string_append_printf(request, "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n", body->len); | 644 g_string_append_printf(request, "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n", body->len); |
645 g_string_append_len(request, body->str, body->len); | 645 g_string_append_len(request, body->str, body->len); |
646 g_string_free(body, TRUE); | 646 g_string_free(body, TRUE); |
647 | 647 |
648 /* Send the POST request */ | 648 /* Send the POST request */ |
649 od->url_data = purple_util_fetch_url_request_len_with_account( | 649 od->url_data = purple_util_fetch_url_request( |
650 purple_connection_get_account(gc), get_client_login_url(od), | 650 purple_connection_get_account(gc), get_client_login_url(od), |
651 TRUE, NULL, FALSE, request->str, FALSE, -1, | 651 TRUE, NULL, FALSE, request->str, FALSE, -1, |
652 client_login_cb, od); | 652 client_login_cb, od); |
653 g_string_free(request, TRUE); | 653 g_string_free(request, TRUE); |
654 } | 654 } |