Mercurial > pidgin.yaz
changeset 14837:118fd0dc5b6e
[gaim-migrate @ 17606]
Add a "handle" parameter to gaim_proxy_connect(). It seemed like
people thought this was a good idea. You can still cancel
each gaim_proxy_connect() individually, if needed. I passed in
NULL for the handle in most places. It might be better to pass
in the gc in more places, but these changes do no harm, and they
should help some Yahoo! things, and I wanted to get the API change in.
committer: Tailor Script <tailor@pidgin.im>
line wrap: on
line diff
--- a/ChangeLog.API Sat Oct 28 19:52:30 2006 +0000 +++ b/ChangeLog.API Sat Oct 28 20:04:03 2006 +0000 @@ -118,7 +118,9 @@ gaim_proxy_connect() and gaim_network_listen*(). * gaim_proxy_connect(): changed to return NULL on error and a pointer to a GaimProxyConnectInfo object which can be used to cancel - connection attempts using gaim_proxy_connect_cancel(). + connection attempts using gaim_proxy_connect_cancel(). Also added + a 'handle' parameter that can be used to cancel to cancel the + connection attempt using gaim_proxy_connect_cancel_with_handle(). * gaim_gethostbyname_async(): Renamed to gaim_dnsquery_a() and changed to return a pointer to a data structure that can be used to cancel the pending DNS query using gaim_dnsquery_destroy() @@ -321,6 +323,8 @@ call to gaim_network_listen() or gaim_network_listen_range() * gaim_proxy_connect_cancel(): Can be used to cancel a pending gaim_proxy_connect() request + * gaim_proxy_connect_cancel_with_handle(): Can be used to cancel + a previous gaim_proxy_connect() request using a specified handle * gaim_dnsquery_destroy(): Can be used to cancel a pending DNS query. * gaim_util_fetch_url_cancel(): Can be used to cancel a pending
--- a/libgaim/ft.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/ft.c Sat Oct 28 20:04:03 2006 +0000 @@ -945,7 +945,7 @@ xfer->remote_port = port; /* Establish a file descriptor. */ - gaim_proxy_connect(xfer->account, xfer->remote_ip, + gaim_proxy_connect(NULL, xfer->account, xfer->remote_ip, xfer->remote_port, connect_cb, xfer); return;
--- a/libgaim/protocols/irc/irc.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/irc/irc.c Sat Oct 28 20:04:03 2006 +0000 @@ -341,11 +341,10 @@ if (!irc->gsc) { - irc->connect_data = gaim_proxy_connect(account, irc->server, + if (gaim_proxy_connect(gc, account, irc->server, gaim_account_get_int(account, "port", IRC_DEFAULT_PORT), - irc_login_cb, gc); - - if (!irc->connect_data || !gaim_account_get_connection(account)) { + irc_login_cb, gc) == NULL) + { gaim_connection_error(gc, _("Couldn't create socket")); return; } @@ -409,8 +408,6 @@ GaimConnection *gc = data; struct irc_conn *irc = gc->proto_data; - irc->connect_data = NULL; - if (source < 0) { gaim_connection_error(gc, _("Couldn't connect to host")); return; @@ -452,9 +449,6 @@ if (irc->gsc || (irc->fd >= 0)) irc_cmd_quit(irc, "quit", NULL, NULL); - if (irc->connect_data) - gaim_proxy_connect_cancel(irc->connect_data); - if (gc->inpa) gaim_input_remove(gc->inpa);
--- a/libgaim/protocols/irc/irc.h Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/irc/irc.h Sat Oct 28 20:04:03 2006 +0000 @@ -54,8 +54,6 @@ guint timer; GHashTable *buddies; - GaimProxyConnectData *connect_data; - char *inbuf; int inbuflen; int inbufused;
--- a/libgaim/protocols/jabber/jabber.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/jabber/jabber.c Sat Oct 28 20:04:03 2006 +0000 @@ -445,8 +445,6 @@ GaimConnection *gc = data; JabberStream *js = gc->proto_data; - js->connect_data = NULL; - if (source < 0) { gaim_connection_error(gc, _("Couldn't connect to host")); return; @@ -490,10 +488,8 @@ static void jabber_login_connect(JabberStream *js, const char *server, int port) { - js->connect_data = gaim_proxy_connect(js->gc->account, server, - port, jabber_login_callback, js->gc); - - if (js->connect_data == NULL) + if (gaim_proxy_connect(js->gc, js->gc->account, server, + port, jabber_login_callback, js->gc) == NULL) gaim_connection_error(js->gc, _("Unable to create socket")); } @@ -922,11 +918,9 @@ } if(!js->gsc) { - js->connect_data = gaim_proxy_connect(account, server, + if (gaim_proxy_connect(gc, account, server, gaim_account_get_int(account, "port", 5222), - jabber_login_callback, gc); - - if (js->connect_data == NULL) + jabber_login_callback, gc) == NULL) gaim_connection_error(gc, _("Unable to create socket")); } } @@ -945,9 +939,6 @@ if (js->srv_query_data) gaim_srv_cancel(js->srv_query_data); - if (js->connect_data) - gaim_proxy_connect_cancel(js->connect_data); - if(js->gsc) { #ifdef HAVE_OPENSSL if (!gc->disconnect_timeout)
--- a/libgaim/protocols/jabber/jabber.h Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/jabber/jabber.h Sat Oct 28 20:04:03 2006 +0000 @@ -67,7 +67,6 @@ int fd; GaimSrvQueryData *srv_query_data; - GaimProxyConnectData *connect_data; xmlParserCtxt *context; xmlnode *current;
--- a/libgaim/protocols/jabber/si.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/jabber/si.c Sat Oct 28 20:04:03 2006 +0000 @@ -177,7 +177,8 @@ for(i=0; i<20; i++, p+=2) snprintf(p, 3, "%02x", hashval[i]); - jsx->connect_data = gaim_proxy_connect_socks5(jsx->gpi, dstaddr, 0, + jsx->connect_data = gaim_proxy_connect_socks5(NULL, jsx->gpi, + dstaddr, 0, jabber_si_bytestreams_connect_cb, xfer); g_free(dstaddr);
--- a/libgaim/protocols/msn/directconn.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/msn/directconn.c Sat Oct 28 20:04:03 2006 +0000 @@ -423,8 +423,8 @@ } #endif - directconn->connect_data = gaim_proxy_connect(session->account, host, port, - connect_cb, directconn); + directconn->connect_data = gaim_proxy_connect(NULL, session->account, + host, port, connect_cb, directconn); if (directconn->connect_data != NULL) {
--- a/libgaim/protocols/msn/httpconn.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/msn/httpconn.c Sat Oct 28 20:04:03 2006 +0000 @@ -727,7 +727,7 @@ if (httpconn->connected) msn_httpconn_disconnect(httpconn); - httpconn->connect_data = gaim_proxy_connect(httpconn->session->account, + httpconn->connect_data = gaim_proxy_connect(NULL, httpconn->session->account, "gateway.messenger.hotmail.com", 80, connect_cb, httpconn); if (httpconn->connect_data != NULL)
--- a/libgaim/protocols/msn/servconn.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/msn/servconn.c Sat Oct 28 20:04:03 2006 +0000 @@ -213,9 +213,7 @@ if (servconn->connected) msn_servconn_disconnect(servconn); - if (servconn->host != NULL) - g_free(servconn->host); - + g_free(servconn->host); servconn->host = g_strdup(host); if (session->http_method) @@ -235,8 +233,8 @@ return TRUE; } - servconn->connect_data = gaim_proxy_connect(session->account, host, port, - connect_cb, servconn); + servconn->connect_data = gaim_proxy_connect(NULL, session->account, + host, port, connect_cb, servconn); if (servconn->connect_data != NULL) {
--- a/libgaim/protocols/oscar/oscar.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/oscar/oscar.c Sat Oct 28 20:04:03 2006 +0000 @@ -1211,7 +1211,7 @@ gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); newconn = flap_connection_new(od, SNAC_FAMILY_AUTH); - newconn->connect_data = gaim_proxy_connect(account, + newconn->connect_data = gaim_proxy_connect(NULL, account, gaim_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER), gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT), connection_established_cb, newconn); @@ -1333,7 +1333,7 @@ newconn = flap_connection_new(od, SNAC_FAMILY_LOCATE); newconn->cookielen = info->cookielen; newconn->cookie = g_memdup(info->cookie, info->cookielen); - newconn->connect_data = gaim_proxy_connect(account, host, port, + newconn->connect_data = gaim_proxy_connect(NULL, account, host, port, connection_established_cb, newconn); g_free(host); if (newconn->connect_data == NULL) @@ -1546,7 +1546,7 @@ pos->modname = g_strdup(modname); /* TODO: Keep track of this return value. */ - if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, + if (gaim_proxy_connect(NULL, pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) == NULL) { char buf[256]; @@ -1632,13 +1632,13 @@ gaim_debug_info("oscar", "Connecting to chat room %s exchange %hu\n", cc->name, cc->exchange); } - newconn->connect_data = gaim_proxy_connect(account, host, port, + newconn->connect_data = gaim_proxy_connect(NULL, account, host, port, connection_established_cb, newconn); if (newconn->connect_data == NULL) { flap_connection_schedule_destroy(newconn, OSCAR_DISCONNECT_COULD_NOT_CONNECT, - _("gaim_proxy_connect() failed")); + _("Unable to initialize connection")); gaim_debug_error("oscar", "Unable to connect to FLAP server " "of type 0x%04hx\n", redir->group); }
--- a/libgaim/protocols/oscar/peer.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/oscar/peer.c Sat Oct 28 20:04:03 2006 +0000 @@ -708,7 +708,7 @@ g_free(tmp); } - conn->connect_data = gaim_proxy_connect(account, + conn->connect_data = gaim_proxy_connect(NULL, account, conn->verifiedip, conn->port, peer_connection_established_cb, conn); if (conn->connect_data != NULL) @@ -743,7 +743,7 @@ g_free(tmp); } - conn->connect_data = gaim_proxy_connect(account, + conn->connect_data = gaim_proxy_connect(NULL, account, conn->clientip, conn->port, peer_connection_established_cb, conn); if (conn->connect_data != NULL) @@ -807,7 +807,7 @@ g_free(tmp); } - conn->connect_data = gaim_proxy_connect(account, + conn->connect_data = gaim_proxy_connect(NULL, account, (conn->proxyip != NULL) ? conn->proxyip : PEER_PROXY_SERVER, PEER_PROXY_PORT, peer_proxy_connection_established_cb, conn);
--- a/libgaim/protocols/qq/qq_proxy.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/qq/qq_proxy.c Sat Oct 28 20:04:03 2006 +0000 @@ -420,7 +420,7 @@ qd->server_port = port; if(use_tcp) - return (gaim_proxy_connect(account, host, port, func, data) == NULL); + return (gaim_proxy_connect(NULL, account, host, port, func, data) == NULL); else return _qq_udp_proxy_connect(account, host, port, func, data); }
--- a/libgaim/protocols/sametime/sametime.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/sametime/sametime.c Sat Oct 28 20:04:03 2006 +0000 @@ -225,7 +225,6 @@ /** socket fd */ int socket; gint outpa; /* like inpa, but the other way */ - GaimProxyConnectData *connect_data; /** circular buffer for outgoing data */ GaimCircBuffer *sock_buf; @@ -1409,7 +1408,7 @@ port = gaim_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); if(gaim_account_get_bool(account, MW_KEY_FORCE, FALSE) || - (gaim_proxy_connect(account, host, port, connect_cb, pd) == NULL)) { + (gaim_proxy_connect(NULL, account, host, port, connect_cb, pd) == NULL)) { mwSession_forceLogin(session); } @@ -1674,8 +1673,6 @@ struct mwGaimPluginData *pd = data; GaimConnection *gc = pd->gc; - pd->connect_data = NULL; - if(source < 0) { /* connection failed */ @@ -3680,8 +3677,7 @@ gaim_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); - pd->connect_data = gaim_proxy_connect(account, host, port, connect_cb, pd); - if(pd->connect_data == NULL) { + if (gaim_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL) { gaim_connection_error(gc, _("Unable to connect to host")); } } @@ -3714,11 +3710,6 @@ gc->inpa = 0; } - if(pd->connect_data != NULL) { - gaim_proxy_connect_cancel(pd->connect_data); - pd->connect_data = NULL; - } - /* clean up the rest */ mwGaimPluginData_free(pd); }
--- a/libgaim/protocols/silc/silc.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/silc/silc.c Sat Oct 28 20:04:03 2006 +0000 @@ -154,7 +154,6 @@ g_return_if_fail(gc != NULL); sg = gc->proto_data; - sg->connect_data = NULL; if (source < 0) { gaim_connection_error(gc, _("Connection failed")); @@ -357,12 +356,11 @@ gc->proto_data = sg; /* Connect to the SILC server */ - sg->connect_data = gaim_proxy_connect(account, + if (gaim_proxy_connect(gc, account, gaim_account_get_string(account, "server", "silc.silcnet.org"), gaim_account_get_int(account, "port", 706), - silcgaim_login_connected, gc); - if (sg->connect_data == NULL) + silcgaim_login_connected, gc) == NULL) { gaim_connection_error(gc, _("Unable to create connection")); return; @@ -382,8 +380,6 @@ SilcGaim sg = (SilcGaim)context; silc_client_stop(sg->client); silc_client_free(sg->client); - if (sg->connect_data != NULL) - gaim_proxy_connect_cancel(sg->connect_data); #ifdef HAVE_SILCMIME_H if (sg->mimeass) silc_mime_assembler_free(sg->mimeass);
--- a/libgaim/protocols/silc/silcgaim.h Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/silc/silcgaim.h Sat Oct 28 20:04:03 2006 +0000 @@ -67,7 +67,6 @@ SilcClient client; SilcClientConnection conn; - GaimProxyConnectData *connect_data; guint scheduler; GaimConnection *gc; GaimAccount *account;
--- a/libgaim/protocols/simple/simple.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/simple/simple.c Sat Oct 28 20:04:03 2006 +0000 @@ -457,12 +457,10 @@ static void sendlater(GaimConnection *gc, const char *buf) { struct simple_account_data *sip = gc->proto_data; - GaimProxyConnectData *connect_data; if(!sip->connecting) { gaim_debug_info("simple", "connecting to %s port %d\n", sip->realhostname ? sip->realhostname : "{NULL}", sip->realport); - connect_data = gaim_proxy_connect(sip->account, sip->realhostname, sip->realport, send_later_cb, gc); - if(connect_data == NULL) { + if (gaim_proxy_connect(gc, sip->account, sip->realhostname, sip->realport, send_later_cb, gc) == NULL) { gaim_connection_error(gc, _("Couldn't create socket")); } sip->connecting = TRUE; @@ -1565,7 +1563,6 @@ static void simple_tcp_connect_listen_cb(int listenfd, gpointer data) { struct simple_account_data *sip = (struct simple_account_data*) data; - GaimProxyConnectData *connect_data; sip->listen_data = NULL; @@ -1582,9 +1579,8 @@ gaim_debug_info("simple", "connecting to %s port %d\n", sip->realhostname, sip->realport); /* open tcp connection to the server */ - connect_data = gaim_proxy_connect(sip->account, sip->realhostname, - sip->realport, login_cb, sip->gc); - if(connect_data == NULL) { + if (gaim_proxy_connect(sip->gc, sip->account, sip->realhostname, + sip->realport, login_cb, sip->gc) == NULL) { gaim_connection_error(sip->gc, _("Couldn't create socket")); } }
--- a/libgaim/protocols/toc/toc.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/toc/toc.c Sat Oct 28 20:04:03 2006 +0000 @@ -141,7 +141,7 @@ gaim_connection_update_progress(gc, buf, 0, TOC_CONNECT_STEPS); gaim_debug(GAIM_DEBUG_INFO, "toc", "Client connects to TOC\n"); - if (gaim_proxy_connect(account, + if (gaim_proxy_connect(gc, account, gaim_account_get_string(account, "server", TOC_HOST), gaim_account_get_int(account, "port", TOC_PORT), toc_login_callback, gc) != 0 || !account->gc) { @@ -1933,7 +1933,7 @@ g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); sflap_send(ft->gc, buf, -1, TYPE_DATA); - if (gaim_proxy_connect(account, ft->ip, ft->port, toc_send_file_connect, ft) != 0) { + if (gaim_proxy_connect(ft->gc, account, ft->ip, ft->port, toc_send_file_connect, ft) != 0) { gaim_notify_error(ft->gc, NULL, _("Could not connect for transfer."), NULL); g_free(ft->filename); @@ -2145,7 +2145,7 @@ g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); sflap_send(ft->gc, buf2, -1, TYPE_DATA); - if (gaim_proxy_connect(account, ft->ip, ft->port, toc_get_file_connect, ft) < 0) { + if (gaim_proxy_connect(ft->gc, account, ft->ip, ft->port, toc_get_file_connect, ft) < 0) { gaim_notify_error(ft->gc, NULL, _("Could not connect for transfer."), NULL); fclose(ft->file);
--- a/libgaim/protocols/yahoo/yahoo.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/yahoo/yahoo.c Sat Oct 28 20:04:03 2006 +0000 @@ -2459,7 +2459,7 @@ yd->rxqueue = NULL; yd->rxlen = 0; /* Now we have our cookies to login with. I'll go get the milk. */ - if (gaim_proxy_connect(account, "wcs2.msg.dcn.yahoo.com", + if (gaim_proxy_connect(gc, account, "wcs2.msg.dcn.yahoo.com", gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), yahoo_got_web_connected, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); @@ -2633,7 +2633,7 @@ "Host: login.yahoo.com\r\n\r\n"); g_hash_table_destroy(hash); yd->auth = g_string_free(url, FALSE); - if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) { + if (gaim_proxy_connect(gc, account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; } @@ -2732,7 +2732,7 @@ if (gaim_account_get_bool(account, "yahoojp", FALSE)) { yd->jp = TRUE; - if (gaim_proxy_connect(account, + if (gaim_proxy_connect(gc, account, gaim_account_get_string(account, "serverjp", YAHOOJP_PAGER_HOST), gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), yahoo_got_connected, gc) == NULL) @@ -2742,7 +2742,7 @@ } } else { yd->jp = FALSE; - if (gaim_proxy_connect(account, + if (gaim_proxy_connect(gc, account, gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), yahoo_got_connected, gc) == NULL)
--- a/libgaim/protocols/yahoo/yahoo_filexfer.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/yahoo/yahoo_filexfer.c Sat Oct 28 20:04:03 2006 +0000 @@ -261,7 +261,7 @@ if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { if (yd->jp) { - if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), + if (gaim_proxy_connect(NULL, account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), yahoo_sendfile_connected, xfer) == NULL) { @@ -270,7 +270,7 @@ gaim_xfer_cancel_remote(xfer); } } else { - if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), + if (gaim_proxy_connect(NULL, account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), yahoo_sendfile_connected, xfer) == NULL) { @@ -281,7 +281,7 @@ } } else { /* TODO: Using xfer->fd like this is probably a bad thing... */ - if (gaim_proxy_connect(account, xfer_data->host, xfer_data->port, + if (gaim_proxy_connect(NULL, account, xfer_data->host, xfer_data->port, yahoo_receivefile_connected, xfer) == NULL) xfer->fd = -1; else
--- a/libgaim/protocols/yahoo/yahoo_picture.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/yahoo/yahoo_picture.c Sat Oct 28 20:04:03 2006 +0000 @@ -511,7 +511,7 @@ } if (yd->jp) { - if ((connect_data = gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), + if ((connect_data = gaim_proxy_connect(NULL, account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), yahoo_buddy_icon_upload_connected, d)) == NULL) { @@ -519,7 +519,7 @@ yahoo_buddy_icon_upload_data_free(d); } } else { - if ((connect_data = gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), + if ((connect_data = gaim_proxy_connect(NULL, account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), yahoo_buddy_icon_upload_connected, d)) == NULL) {
--- a/libgaim/protocols/yahoo/yahoochat.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/yahoo/yahoochat.c Sat Oct 28 20:04:03 2006 +0000 @@ -1449,7 +1449,7 @@ gaim_roomlist_set_fields(rl, fields); - if (gaim_proxy_connect(gaim_connection_get_account(gc), yrl->host, 80, + if (gaim_proxy_connect(NULL, gaim_connection_get_account(gc), yrl->host, 80, yahoo_roomlist_got_connected, yrl) == NULL) { gaim_notify_error(gc, NULL, _("Connection problem"), _("Unable to fetch room list.")); @@ -1518,7 +1518,7 @@ yrl->ucat = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_CATEGORY, _("User Rooms"), yrl->cat); gaim_roomlist_room_add(list, yrl->ucat); - if (gaim_proxy_connect(list->account, yrl->host, 80, + if (gaim_proxy_connect(NULL, list->account, yrl->host, 80, yahoo_roomlist_got_connected, yrl) == NULL) { gaim_notify_error(gaim_account_get_connection(list->account),
--- a/libgaim/protocols/yahoo/ycht.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/protocols/yahoo/ycht.c Sat Oct 28 20:04:03 2006 +0000 @@ -577,7 +577,7 @@ yd->ycht = ycht; - if (gaim_proxy_connect(account, + if (gaim_proxy_connect(NULL, account, gaim_account_get_string(account, "ycht-server", YAHOO_YCHT_HOST), gaim_account_get_int(account, "ycht-port", YAHOO_YCHT_PORT), ycht_got_connected, ycht) == NULL)
--- a/libgaim/proxy.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/proxy.c Sat Oct 28 20:04:03 2006 +0000 @@ -40,6 +40,7 @@ #include "util.h" struct _GaimProxyConnectData { + void *handle; GaimProxyConnectFunction connect_cb; gpointer data; gchar *host; @@ -82,12 +83,7 @@ static GaimProxyInfo *global_proxy_info = NULL; -/* - * TODO: Once all callers of gaim_proxy_connect() are keeping track - * of the return value from that function this linked list - * will no longer be needed. - */ -static GSList *connect_datas = NULL; +static GSList *handles = NULL; static void try_connect(GaimProxyConnectData *connect_data); @@ -281,7 +277,7 @@ static void gaim_proxy_connect_data_destroy(GaimProxyConnectData *connect_data) { - connect_datas = g_slist_remove(connect_datas, connect_data); + handles = g_slist_remove(handles, connect_data); if (connect_data->query_data != NULL) gaim_dnsquery_destroy(connect_data->query_data); @@ -1750,7 +1746,8 @@ } GaimProxyConnectData * -gaim_proxy_connect(GaimAccount *account, const char *host, int port, +gaim_proxy_connect(void *handle, GaimAccount *account, + const char *host, int port, GaimProxyConnectFunction connect_cb, gpointer data) { const char *connecthost = host; @@ -1763,6 +1760,7 @@ connect_data = g_new0(GaimProxyConnectData, 1); connect_data->fd = -1; + connect_data->handle = handle; connect_data->connect_cb = connect_cb; connect_data->data = data; connect_data->host = g_strdup(host); @@ -1804,7 +1802,7 @@ return NULL; } - connect_datas = g_slist_prepend(connect_datas, connect_data); + handles = g_slist_prepend(handles, connect_data); return connect_data; } @@ -1813,8 +1811,10 @@ * Combine some of this code with gaim_proxy_connect() */ GaimProxyConnectData * -gaim_proxy_connect_socks5(GaimProxyInfo *gpi, const char *host, int port, - GaimProxyConnectFunction connect_cb, gpointer data) +gaim_proxy_connect_socks5(void *handle, GaimProxyInfo *gpi, + const char *host, int port, + GaimProxyConnectFunction connect_cb, + gpointer data) { GaimProxyConnectData *connect_data; @@ -1824,6 +1824,7 @@ connect_data = g_new0(GaimProxyConnectData, 1); connect_data->fd = -1; + connect_data->handle = handle; connect_data->connect_cb = connect_cb; connect_data->data = data; connect_data->host = g_strdup(host); @@ -1840,7 +1841,7 @@ return NULL; } - connect_datas = g_slist_prepend(connect_datas, connect_data); + handles = g_slist_prepend(handles, connect_data); return connect_data; } @@ -1852,6 +1853,21 @@ gaim_proxy_connect_data_destroy(connect_data); } +void +gaim_proxy_connect_cancel_with_handle(void *handle) +{ + GSList *l, *l_next; + + for (l = handles; l != NULL; l = l_next) { + GaimProxyConnectData *connect_data = l->data; + + l_next = l->next; + + if (connect_data->handle == handle) + gaim_proxy_connect_cancel(connect_data); + } +} + static void proxy_pref_cb(const char *name, GaimPrefType type, gconstpointer value, gpointer data) @@ -1927,9 +1943,9 @@ void gaim_proxy_uninit(void) { - while (connect_datas != NULL) + while (handles != NULL) { - gaim_proxy_connect_data_disconnect(connect_datas->data, NULL); - gaim_proxy_connect_data_destroy(connect_datas->data); + gaim_proxy_connect_data_disconnect(handles->data, NULL); + gaim_proxy_connect_data_destroy(handles->data); } }
--- a/libgaim/proxy.h Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/proxy.h Sat Oct 28 20:04:03 2006 +0000 @@ -237,7 +237,8 @@ * structure that can be used to cancel the pending * connection, if needed. */ -GaimProxyConnectData *gaim_proxy_connect(GaimAccount *account, +GaimProxyConnectData *gaim_proxy_connect(void *handle, + GaimAccount *account, const char *host, int port, GaimProxyConnectFunction connect_cb, gpointer data); @@ -257,7 +258,8 @@ * structure that can be used to cancel the pending * connection, if needed. */ -GaimProxyConnectData *gaim_proxy_connect_socks5(GaimProxyInfo *gpi, +GaimProxyConnectData *gaim_proxy_connect_socks5(void *handle, + GaimProxyInfo *gpi, const char *host, int port, GaimProxyConnectFunction connect_cb, gpointer data); @@ -272,6 +274,13 @@ */ void gaim_proxy_connect_cancel(GaimProxyConnectData *connect_data); +/* + * Closes all proxy connections registered with the specified handle. + * + * @param handle The handle. + */ +void gaim_proxy_connect_cancel_with_handle(void *handle); + /*@}*/ #ifdef __cplusplus
--- a/libgaim/sslconn.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/sslconn.c Sat Oct 28 20:04:03 2006 +0000 @@ -117,7 +117,7 @@ gsc->connect_cb = func; gsc->error_cb = error_func; - gsc->connect_data = gaim_proxy_connect(account, host, port, gaim_ssl_connect_cb, gsc); + gsc->connect_data = gaim_proxy_connect(NULL, account, host, port, gaim_ssl_connect_cb, gsc); if (gsc->connect_data == NULL) {
--- a/libgaim/upnp.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/upnp.c Sat Oct 28 20:04:03 2006 +0000 @@ -215,14 +215,14 @@ /* make sure we have a valid http response */ if(g_strstr_len(httpResponse, len, HTTP_OK) == NULL) { gaim_debug_error("upnp", - "parse_description_response(): Failed In HTTP_OK\n\n"); + "parse_description_response(): Failed In HTTP_OK\n"); return NULL; } /* find the root of the xml document */ if((xmlRoot = g_strstr_len(httpResponse, len, "<root")) == NULL) { gaim_debug_error("upnp", - "parse_description_response(): Failed finding root\n\n"); + "parse_description_response(): Failed finding root\n"); return NULL; } @@ -230,7 +230,7 @@ if((xmlRootNode = xmlnode_from_str(xmlRoot, len - (xmlRoot - httpResponse))) == NULL) { gaim_debug_error("upnp", - "parse_description_response(): Could not parse xml root node\n\n"); + "parse_description_response(): Could not parse xml root node\n"); return NULL; } @@ -252,7 +252,7 @@ } if(serviceTypeNode == NULL) { gaim_debug_error("upnp", - "parse_description_response(): could not get serviceTypeNode 1\n\n"); + "parse_description_response(): could not get serviceTypeNode 1\n"); g_free(baseURL); xmlnode_free(xmlRootNode); return NULL; @@ -260,7 +260,7 @@ serviceTypeNode = xmlnode_get_child(serviceTypeNode, "deviceList"); if(serviceTypeNode == NULL) { gaim_debug_error("upnp", - "parse_description_response(): could not get serviceTypeNode 2\n\n"); + "parse_description_response(): could not get serviceTypeNode 2\n"); g_free(baseURL); xmlnode_free(xmlRootNode); return NULL; @@ -275,7 +275,7 @@ } if(serviceTypeNode == NULL) { gaim_debug_error("upnp", - "parse_description_response(): could not get serviceTypeNode 3\n\n"); + "parse_description_response(): could not get serviceTypeNode 3\n"); g_free(baseURL); xmlnode_free(xmlRootNode); return NULL; @@ -283,7 +283,7 @@ serviceTypeNode = xmlnode_get_child(serviceTypeNode, "deviceList"); if(serviceTypeNode == NULL) { gaim_debug_error("upnp", - "parse_description_response(): could not get serviceTypeNode 4\n\n"); + "parse_description_response(): could not get serviceTypeNode 4\n"); g_free(baseURL); xmlnode_free(xmlRootNode); return NULL; @@ -297,7 +297,7 @@ } if(serviceTypeNode == NULL) { gaim_debug_error("upnp", - "parse_description_response(): could not get serviceTypeNode 5\n\n"); + "parse_description_response(): could not get serviceTypeNode 5\n"); g_free(baseURL); xmlnode_free(xmlRootNode); return NULL; @@ -305,7 +305,7 @@ serviceTypeNode = xmlnode_get_child(serviceTypeNode, "serviceList"); if(serviceTypeNode == NULL) { gaim_debug_error("upnp", - "parse_description_response(): could not get serviceTypeNode 6\n\n"); + "parse_description_response(): could not get serviceTypeNode 6\n"); g_free(baseURL); xmlnode_free(xmlRootNode); return NULL; @@ -322,7 +322,7 @@ g_free(service); if(serviceTypeNode == NULL) { gaim_debug_error("upnp", - "parse_description_response(): could not get serviceTypeNode 7\n\n"); + "parse_description_response(): could not get serviceTypeNode 7\n"); g_free(baseURL); xmlnode_free(xmlRootNode); return NULL; @@ -332,7 +332,7 @@ if((controlURLNode = xmlnode_get_child(serviceTypeNode, "controlURL")) == NULL) { gaim_debug_error("upnp", - "parse_description_response(): Could not find controlURL\n\n"); + "parse_description_response(): Could not find controlURL\n"); g_free(baseURL); xmlnode_free(xmlRootNode); return NULL; @@ -367,7 +367,7 @@ if(control_url == NULL) { gaim_debug_error("upnp", - "gaim_upnp_parse_description(): control URL is NULL\n\n"); + "gaim_upnp_parse_description(): control URL is NULL\n"); } control_info.status = control_url ? GAIM_UPNP_STATUS_DISCOVERED @@ -444,13 +444,13 @@ if(g_strstr_len(buf, buf_len, HTTP_OK) == NULL) { gaim_debug_error("upnp", - "parse_discover_response(): Failed In HTTP_OK\n\n"); + "parse_discover_response(): Failed In HTTP_OK\n"); return; } if((startDescURL = g_strstr_len(buf, buf_len, "http://")) == NULL) { gaim_debug_error("upnp", - "parse_discover_response(): Failed In finding http://\n\n"); + "parse_discover_response(): Failed In finding http://\n"); return; } @@ -461,7 +461,7 @@ buf_len - (startDescURL - buf), "\n"); if(endDescURL == NULL) { gaim_debug_error("upnp", - "parse_discover_response(): Failed In endDescURL\n\n"); + "parse_discover_response(): Failed In endDescURL\n"); return; } } @@ -469,7 +469,7 @@ /* XXX: I'm not sure how this could ever happen */ if(endDescURL == startDescURL) { gaim_debug_error("upnp", - "parse_discover_response(): endDescURL == startDescURL\n\n"); + "parse_discover_response(): endDescURL == startDescURL\n"); return; } @@ -492,6 +492,7 @@ dd->tima = 0; if (dd->retry_count < NUM_UDP_ATTEMPTS) { + /* TODO: We probably shouldn't be incrementing retry_count in two places */ dd->retry_count++; gaim_upnp_discover_send_broadcast(dd); } else { @@ -625,7 +626,7 @@ sock = socket(AF_INET, SOCK_DGRAM, 0); if(sock == -1) { gaim_debug_error("upnp", - "gaim_upnp_discover(): Failed In sock creation\n\n"); + "gaim_upnp_discover(): Failed In sock creation\n"); /* Short circuit the retry attempts */ dd->retry_count = NUM_UDP_ATTEMPTS; gaim_timeout_add(10, gaim_upnp_discover_timeout, dd); @@ -634,10 +635,10 @@ dd->fd = sock; - /* This shouldn't block */ + /* TODO: Non-blocking! */ if((hp = gethostbyname(HTTPMU_HOST_ADDRESS)) == NULL) { gaim_debug_error("upnp", - "gaim_upnp_discover(): Failed In gethostbyname\n\n"); + "gaim_upnp_discover(): Failed In gethostbyname\n"); /* Short circuit the retry attempts */ dd->retry_count = NUM_UDP_ATTEMPTS; gaim_timeout_add(10, gaim_upnp_discover_timeout, dd); @@ -670,7 +671,7 @@ if(!gaim_url_parse(control_info.control_url, &addressOfControl, &port, &pathOfControl, NULL, NULL)) { gaim_debug_error("upnp", - "generate_action_message_and_send(): Failed In Parse URL\n\n"); + "generate_action_message_and_send(): Failed In Parse URL\n"); /* XXX: This should probably be async */ if(cb) cb(NULL, cb_data, NULL, 0, NULL); @@ -728,17 +729,17 @@ if((temp = g_strstr_len(httpResponse, len, "<NewExternalIPAddress")) == NULL) { gaim_debug_error("upnp", - "looked_up_public_ip_cb(): Failed Finding <NewExternalIPAddress\n\n"); + "looked_up_public_ip_cb(): Failed Finding <NewExternalIPAddress\n"); return; } if(!(temp = g_strstr_len(temp, len - (temp - httpResponse), ">"))) { gaim_debug_error("upnp", - "looked_up_public_ip_cb(): Failed In Finding >\n\n"); + "looked_up_public_ip_cb(): Failed In Finding >\n"); return; } if(!(temp2 = g_strstr_len(temp, len - (temp - httpResponse), "<"))) { gaim_debug_error("upnp", - "looked_up_public_ip_cb(): Failed In Finding <\n\n"); + "looked_up_public_ip_cb(): Failed In Finding <\n"); return; } *temp2 = '\0'; @@ -798,14 +799,14 @@ if(!gaim_url_parse(control_info.control_url, &addressOfControl, &port, NULL, NULL, NULL)) { gaim_debug_error("upnp", - "lookup_internal_ip(): Failed In Parse URL\n\n"); + "lookup_internal_ip(): Failed In Parse URL\n"); return; } if(port == 0 || port == -1) { port = DEFAULT_HTTP_PORT; } - if(gaim_proxy_connect(NULL, addressOfControl, port, + if(gaim_proxy_connect(NULL, NULL, addressOfControl, port, looked_up_internal_ip_cb, NULL) == NULL) { gaim_debug_error("upnp", "Get Local IP Connect Failed: Address: %s @@@ Port %d\n", @@ -828,7 +829,7 @@ (g_strstr_len(httpResponse, len, HTTP_OK) == NULL)) { gaim_debug_error("upnp", - "gaim_upnp_set_port_mapping(): Failed HTTP_OK\n\n%s\n\n", + "gaim_upnp_set_port_mapping(): Failed HTTP_OK\n%s\n", httpResponse ? httpResponse : "(null)"); success = FALSE; } else @@ -852,7 +853,7 @@ /* get the internal IP */ if(!(internal_ip = gaim_upnp_get_internal_ip())) { gaim_debug_error("upnp", - "gaim_upnp_set_port_mapping(): couldn't get local ip\n\n"); + "gaim_upnp_set_port_mapping(): couldn't get local ip\n"); /* UGLY */ if (ar->cb) ar->cb(FALSE, ar->cb_data);
--- a/libgaim/util.c Sat Oct 28 19:52:30 2006 +0000 +++ b/libgaim/util.c Sat Oct 28 20:04:03 2006 +0000 @@ -3152,7 +3152,7 @@ gaim_url_parse(new_url, &gfud->website.address, &gfud->website.port, &gfud->website.page, &gfud->website.user, &gfud->website.passwd); - gfud->connect_data = gaim_proxy_connect(NULL, + gfud->connect_data = gaim_proxy_connect(NULL, NULL, gfud->website.address, gfud->website.port, url_fetch_connect_cb, gfud); @@ -3451,7 +3451,7 @@ gaim_url_parse(url, &gfud->website.address, &gfud->website.port, &gfud->website.page, &gfud->website.user, &gfud->website.passwd); - gfud->connect_data = gaim_proxy_connect(NULL, + gfud->connect_data = gaim_proxy_connect(NULL, NULL, gfud->website.address, gfud->website.port, url_fetch_connect_cb, gfud);