comparison libpurple/protocols/yahoo/yahoo_filexfer.c @ 27201:d078048fb03a

Pass the gc as the handle in a bunch of calls to purple_proxy_connect This causes the connection attempt to be canceled/destroyed if the gc is destroyed
author Mark Doliner <mark@kingant.net>
date Thu, 18 Jun 2009 23:36:55 +0000
parents 510f07e1f5c1
children f8428553f11c 462a509fb2ad
comparison
equal deleted inserted replaced
27200:a9899d234dfa 27201:d078048fb03a
318 yd = gc->proto_data; 318 yd = gc->proto_data;
319 account = purple_connection_get_account(gc); 319 account = purple_connection_get_account(gc);
320 320
321 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { 321 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
322 if (yd->jp) { 322 if (yd->jp) {
323 if (purple_proxy_connect(NULL, account, purple_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), 323 if (purple_proxy_connect(gc, account, purple_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST),
324 purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), 324 purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
325 yahoo_sendfile_connected, xfer) == NULL) 325 yahoo_sendfile_connected, xfer) == NULL)
326 { 326 {
327 purple_notify_error(gc, NULL, _("File Transfer Failed"), 327 purple_notify_error(gc, NULL, _("File Transfer Failed"),
328 _("Unable to establish file descriptor.")); 328 _("Unable to establish file descriptor."));
329 purple_xfer_cancel_remote(xfer); 329 purple_xfer_cancel_remote(xfer);
330 } 330 }
331 } else { 331 } else {
332 if (purple_proxy_connect(NULL, account, purple_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), 332 if (purple_proxy_connect(gc, account, purple_account_get_string(account, "xfer_host", YAHOO_XFER_HOST),
333 purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), 333 purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
334 yahoo_sendfile_connected, xfer) == NULL) 334 yahoo_sendfile_connected, xfer) == NULL)
335 { 335 {
336 purple_notify_error(gc, NULL, _("File Transfer Failed"), 336 purple_notify_error(gc, NULL, _("File Transfer Failed"),
337 _("Unable to establish file descriptor.")); 337 _("Unable to establish file descriptor."));
338 purple_xfer_cancel_remote(xfer); 338 purple_xfer_cancel_remote(xfer);
339 } 339 }
340 } 340 }
341 } else { 341 } else {
342 xfer->fd = -1; 342 xfer->fd = -1;
343 if (purple_proxy_connect(NULL, account, xfer_data->host, xfer_data->port, 343 if (purple_proxy_connect(gc, account, xfer_data->host, xfer_data->port,
344 yahoo_receivefile_connected, xfer) == NULL) { 344 yahoo_receivefile_connected, xfer) == NULL) {
345 purple_notify_error(gc, NULL, _("File Transfer Failed"), 345 purple_notify_error(gc, NULL, _("File Transfer Failed"),
346 _("Unable to establish file descriptor.")); 346 _("Unable to establish file descriptor."));
347 purple_xfer_cancel_remote(xfer); 347 purple_xfer_cancel_remote(xfer);
348 } 348 }
1118 xd->txbuf = g_strconcat(t,buf,NULL); 1118 xd->txbuf = g_strconcat(t,buf,NULL);
1119 g_free(t); 1119 g_free(t);
1120 } 1120 }
1121 g_free(buf); 1121 g_free(buf);
1122 1122
1123 if (did < 0 && errno == EAGAIN) return; 1123 if (did < 0 && errno == EAGAIN)
1124 return;
1124 else if (did < 0) { 1125 else if (did < 0) {
1125 purple_debug_error("yahoo", "Unable to write in order to start ft errno = %d\n", errno); 1126 purple_debug_error("yahoo", "Unable to write in order to start ft errno = %d\n", errno);
1126 purple_xfer_cancel_remote(xfer); 1127 purple_xfer_cancel_remote(xfer);
1127 return; 1128 return;
1128 } 1129 }
1134 if(xd->status_15 == HEAD_REQUESTED) { 1135 if(xd->status_15 == HEAD_REQUESTED) {
1135 xd->status_15 = HEAD_REPLY_RECEIVED; 1136 xd->status_15 = HEAD_REPLY_RECEIVED;
1136 close(source);/* Is this required? */ 1137 close(source);/* Is this required? */
1137 g_free(xd->txbuf); 1138 g_free(xd->txbuf);
1138 xd->txbuf = NULL; 1139 xd->txbuf = NULL;
1139 if (purple_proxy_connect(NULL, account, xd->host, xd->port, yahoo_xfer_connected_15, xfer) == NULL) 1140 if (purple_proxy_connect(gc, account, xd->host, xd->port, yahoo_xfer_connected_15, xfer) == NULL)
1140 { 1141 {
1141 purple_notify_error(gc, NULL, _("File Transfer Failed"), 1142 purple_notify_error(gc, NULL, _("File Transfer Failed"),
1142 _("Unable to establish file descriptor.")); 1143 _("Unable to establish file descriptor."));
1143 purple_xfer_cancel_remote(xfer); 1144 purple_xfer_cancel_remote(xfer);
1144 } 1145 }
1839 251, xfer_data->xfer_idstring_for_relay, 1840 251, xfer_data->xfer_idstring_for_relay,
1840 222, 3); 1841 222, 3);
1841 1842
1842 yahoo_packet_send_and_free(pkt_to_send, yd); 1843 yahoo_packet_send_and_free(pkt_to_send, yd);
1843 1844
1844 if (purple_proxy_connect(NULL, account, xfer_data->host, xfer_data->port, 1845 if (purple_proxy_connect(gc, account, xfer_data->host, xfer_data->port,
1845 yahoo_xfer_connected_15, xfer) == NULL) { 1846 yahoo_xfer_connected_15, xfer) == NULL) {
1846 purple_notify_error(gc, NULL, _("File Transfer Failed"), 1847 purple_notify_error(gc, NULL, _("File Transfer Failed"),
1847 _("Unable to establish file descriptor.")); 1848 _("Unable to establish file descriptor."));
1848 purple_xfer_cancel_remote(xfer); 1849 purple_xfer_cancel_remote(xfer);
1849 } 1850 }
1919 1920
1920 xfer_data->xfer_idstring_for_relay = g_strdup(xfer_idstring_for_relay); 1921 xfer_data->xfer_idstring_for_relay = g_strdup(xfer_idstring_for_relay);
1921 xfer_data->status_15 = ACCEPTED; 1922 xfer_data->status_15 = ACCEPTED;
1922 account = purple_connection_get_account(gc); 1923 account = purple_connection_get_account(gc);
1923 1924
1924 if (purple_proxy_connect(NULL, account, xfer_data->host, xfer_data->port, 1925 if (purple_proxy_connect(gc, account, xfer_data->host, xfer_data->port,
1925 yahoo_xfer_connected_15, xfer) == NULL) 1926 yahoo_xfer_connected_15, xfer) == NULL)
1926 { 1927 {
1927 purple_notify_error(gc, NULL, _("File Transfer Failed"),_("Unable to connect")); 1928 purple_notify_error(gc, NULL, _("File Transfer Failed"),_("Unable to connect"));
1928 purple_xfer_cancel_remote(xfer); 1929 purple_xfer_cancel_remote(xfer);
1929 } 1930 }