comparison libpurple/proxy.c @ 32802:fa666e7f747e

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 55372aac7eca74e2a3121931b867702d2fdfe299) to branch 'im.pidgin.pidgin' (head 1f233991b11d30d7bd9d1e058e19fe162a9600f3)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 25 May 2012 19:41:04 +0000
parents 0c2efa69492b 5ae7e1f36b43
children 2c6510167895
comparison
equal deleted inserted replaced
32782:90ae6701eaf2 32802:fa666e7f747e
67 * This contains alternating length/char* values. The char* 67 * This contains alternating length/char* values. The char*
68 * values need to be freed when removed from the linked list. 68 * values need to be freed when removed from the linked list.
69 */ 69 */
70 GSList *hosts; 70 GSList *hosts;
71 71
72 PurpleProxyConnectData *child;
73
72 /* 74 /*
73 * All of the following variables are used when establishing a 75 * All of the following variables are used when establishing a
74 * connection through a proxy. 76 * connection through a proxy.
75 */ 77 */
76 guchar *write_buffer; 78 guchar *write_buffer;
567 * connection was successful then pass in null. 569 * connection was successful then pass in null.
568 */ 570 */
569 static void 571 static void
570 purple_proxy_connect_data_disconnect(PurpleProxyConnectData *connect_data, const gchar *error_message) 572 purple_proxy_connect_data_disconnect(PurpleProxyConnectData *connect_data, const gchar *error_message)
571 { 573 {
574 if (connect_data->child != NULL)
575 {
576 purple_proxy_connect_cancel(connect_data->child);
577 connect_data->child = NULL;
578 }
579
572 if (connect_data->inpa > 0) 580 if (connect_data->inpa > 0)
573 { 581 {
574 purple_input_remove(connect_data->inpa); 582 purple_input_remove(connect_data->inpa);
575 connect_data->inpa = 0; 583 connect_data->inpa = 0;
576 } 584 }
2413 static void socks5_connected_to_proxy(gpointer data, gint source, 2421 static void socks5_connected_to_proxy(gpointer data, gint source,
2414 const gchar *error_message) { 2422 const gchar *error_message) {
2415 /* This is the PurpleProxyConnectData for the overall SOCKS5 connection */ 2423 /* This is the PurpleProxyConnectData for the overall SOCKS5 connection */
2416 PurpleProxyConnectData *connect_data = data; 2424 PurpleProxyConnectData *connect_data = data;
2417 2425
2426 purple_debug_error("proxy", "Connect Data is %p\n", connect_data);
2427
2418 /* Check that the overall SOCKS5 connection wasn't cancelled while we were 2428 /* Check that the overall SOCKS5 connection wasn't cancelled while we were
2419 * connecting to it (we don't have a way of associating the process of 2429 * connecting to it (we don't have a way of associating the process of
2420 * connecting to the SOCKS5 server to the overall PurpleProxyConnectData) 2430 * connecting to the SOCKS5 server to the overall PurpleProxyConnectData)
2421 */ 2431 */
2422 if (!PURPLE_PROXY_CONNECT_DATA_IS_VALID(connect_data)) 2432 if (!PURPLE_PROXY_CONNECT_DATA_IS_VALID(connect_data)) {
2423 return; 2433 purple_debug_error("proxy", "Data had gone out of scope :(\n");
2434 return;
2435 }
2436
2437 /* Break the link between the two PurpleProxyConnectDatas */
2438 connect_data->child = NULL;
2424 2439
2425 if (error_message != NULL) { 2440 if (error_message != NULL) {
2426 purple_debug_error("proxy", "Unable to connect to SOCKS5 host.\n"); 2441 purple_debug_error("proxy", "Unable to connect to SOCKS5 host.\n");
2427 connect_data->connect_cb(connect_data->data, source, error_message); 2442 connect_data->connect_cb(connect_data->data, source, error_message);
2428 return; 2443 return;
2482 purple_debug_error("proxy", "Unable to initiate connection to account proxy.\n"); 2497 purple_debug_error("proxy", "Unable to initiate connection to account proxy.\n");
2483 purple_proxy_connect_data_destroy(connect_data); 2498 purple_proxy_connect_data_destroy(connect_data);
2484 return NULL; 2499 return NULL;
2485 } 2500 }
2486 2501
2487 /* The API doesn't really provide us with a way to cancel the specific 2502 connect_data->child = account_proxy_conn_data;
2488 * proxy connection attempt (account_proxy_conn_data) when the overall
2489 * SOCKS5 connection (connect_data) attempt is cancelled :(
2490 */
2491 2503
2492 handles = g_slist_prepend(handles, connect_data); 2504 handles = g_slist_prepend(handles, connect_data);
2493 2505
2494 return connect_data; 2506 return connect_data;
2495 } 2507 }
2496 2508
2497 void 2509 void
2498 purple_proxy_connect_cancel(PurpleProxyConnectData *connect_data) 2510 purple_proxy_connect_cancel(PurpleProxyConnectData *connect_data)
2499 { 2511 {
2512 g_return_if_fail(connect_data != NULL);
2513
2500 purple_proxy_connect_data_disconnect(connect_data, NULL); 2514 purple_proxy_connect_data_disconnect(connect_data, NULL);
2501 purple_proxy_connect_data_destroy(connect_data); 2515 purple_proxy_connect_data_destroy(connect_data);
2502 } 2516 }
2503 2517
2504 void 2518 void