comparison src/protocols/yahoo/yahoo.c @ 14089:10e8eb6a4910

[gaim-migrate @ 16712] Pretty large commit here. Basically I got sick of having to verify that gc is still valid on all the callback functions for gaim_proxy_connect(). The fix for this for gaim_proxy_connect() to return something that allows the connection attempt to be canceled. It's not quite there yet, but this is a good first step. I changed gaim_proxy_connect() to return a reference to a new GaimProxyConnectInfo (this used to be called PHB). Eventually this can be passed to a function that'll cancel the connection attempt. I also decided to add an error_cb instead of using connect_cb and passing a file descriptor of -1. And proxy.c will also pass an error message to callers which should explain the reason that the connection attempt failed. Oh, and proxy.c now never calls gaim_connection_error() committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 12 Aug 2006 10:12:43 +0000
parents b7e4180af1db
children 7a205b430d19
comparison
equal deleted inserted replaced
14088:223570831b0b 14089:10e8eb6a4910
2237 2237
2238 yahoo_packet_free(pkt); 2238 yahoo_packet_free(pkt);
2239 } 2239 }
2240 } 2240 }
2241 2241
2242 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) 2242 static void yahoo_got_connected(gpointer data, gint source)
2243 { 2243 {
2244 GaimConnection *gc = data; 2244 GaimConnection *gc = data;
2245 struct yahoo_data *yd; 2245 struct yahoo_data *yd;
2246 struct yahoo_packet *pkt; 2246 struct yahoo_packet *pkt;
2247 2247
2264 yahoo_packet_send_and_free(pkt, yd); 2264 yahoo_packet_send_and_free(pkt, yd);
2265 2265
2266 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); 2266 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc);
2267 } 2267 }
2268 2268
2269 static void yahoo_got_web_connected(gpointer data, gint source, GaimInputCondition cond) 2269 static void yahoo_got_web_connected(gpointer data, gint source)
2270 { 2270 {
2271 GaimConnection *gc = data; 2271 GaimConnection *gc = data;
2272 struct yahoo_data *yd; 2272 struct yahoo_data *yd;
2273 struct yahoo_packet *pkt; 2273 struct yahoo_packet *pkt;
2274 2274
2346 yd->rxqueue = NULL; 2346 yd->rxqueue = NULL;
2347 yd->rxlen = 0; 2347 yd->rxlen = 0;
2348 /* Now we have our cookies to login with. I'll go get the milk. */ 2348 /* Now we have our cookies to login with. I'll go get the milk. */
2349 if (gaim_proxy_connect(account, "wcs2.msg.dcn.yahoo.com", 2349 if (gaim_proxy_connect(account, "wcs2.msg.dcn.yahoo.com",
2350 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), 2350 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT),
2351 yahoo_got_web_connected, gc) != 0) { 2351 yahoo_got_web_connected, NULL, gc) == NULL) {
2352 gaim_connection_error(gc, _("Connection problem")); 2352 gaim_connection_error(gc, _("Connection problem"));
2353 return; 2353 return;
2354 } 2354 }
2355 } 2355 }
2356 2356
2388 yd->auth_written = 0; 2388 yd->auth_written = 0;
2389 gaim_input_remove(gc->inpa); 2389 gaim_input_remove(gc->inpa);
2390 gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc); 2390 gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc);
2391 } 2391 }
2392 2392
2393 static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) 2393 static void yahoo_got_cookies(gpointer data, gint source)
2394 { 2394 {
2395 GaimConnection *gc = data; 2395 GaimConnection *gc = data;
2396 2396
2397 if (source < 0) { 2397 if (source < 0) {
2398 gaim_connection_error(gc, _("Unable to connect.")); 2398 gaim_connection_error(gc, _("Unable to connect."));
2514 2514
2515 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n" 2515 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n"
2516 "Host: login.yahoo.com\r\n\r\n"); 2516 "Host: login.yahoo.com\r\n\r\n");
2517 g_hash_table_destroy(hash); 2517 g_hash_table_destroy(hash);
2518 yd->auth = g_string_free(url, FALSE); 2518 yd->auth = g_string_free(url, FALSE);
2519 if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) != 0) { 2519 if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, NULL, gc) == NULL) {
2520 gaim_connection_error(gc, _("Connection problem")); 2520 gaim_connection_error(gc, _("Connection problem"));
2521 return; 2521 return;
2522 } 2522 }
2523 2523
2524 gaim_cipher_context_destroy(context); 2524 gaim_cipher_context_destroy(context);
2616 if (gaim_account_get_bool(account, "yahoojp", FALSE)) { 2616 if (gaim_account_get_bool(account, "yahoojp", FALSE)) {
2617 yd->jp = TRUE; 2617 yd->jp = TRUE;
2618 if (gaim_proxy_connect(account, 2618 if (gaim_proxy_connect(account,
2619 gaim_account_get_string(account, "serverjp", YAHOOJP_PAGER_HOST), 2619 gaim_account_get_string(account, "serverjp", YAHOOJP_PAGER_HOST),
2620 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), 2620 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT),
2621 yahoo_got_connected, gc) != 0) 2621 yahoo_got_connected, NULL, gc) == NULL)
2622 { 2622 {
2623 gaim_connection_error(gc, _("Connection problem")); 2623 gaim_connection_error(gc, _("Connection problem"));
2624 return; 2624 return;
2625 } 2625 }
2626 } else { 2626 } else {
2627 yd->jp = FALSE; 2627 yd->jp = FALSE;
2628 if (gaim_proxy_connect(account, 2628 if (gaim_proxy_connect(account,
2629 gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), 2629 gaim_account_get_string(account, "server", YAHOO_PAGER_HOST),
2630 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), 2630 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT),
2631 yahoo_got_connected, gc) != 0) 2631 yahoo_got_connected, NULL, gc) == NULL)
2632 { 2632 {
2633 gaim_connection_error(gc, _("Connection problem")); 2633 gaim_connection_error(gc, _("Connection problem"));
2634 return; 2634 return;
2635 } 2635 }
2636 } 2636 }